@routier/core 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capabilities/Capability.d.ts +21 -0
- package/dist/capabilities/PerformanceCapability.d.ts +15 -0
- package/dist/capabilities/TracingCapability.d.ts +14 -0
- package/dist/capabilities/index.d.ts +4 -0
- package/dist/capabilities/index.js +707 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/performance/PerformanceTracker.d.ts +11 -0
- package/dist/capabilities/tracing/CallTraceManager.d.ts +12 -0
- package/dist/capabilities/types.d.ts +26 -0
- package/dist/codegen/index.js +621 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +724 -522
- package/dist/index.js.map +1 -1
- package/dist/pipeline/TrampolinePipeline.d.ts +0 -1
- package/dist/pipeline/WorkPipeline.test.d.ts +1 -0
- package/dist/pipeline/index.js +47 -71
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/EphemeralDataPlugin.test.d.ts +1 -0
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.js +128 -550
- package/dist/plugins/index.js.map +1 -1
- package/dist/schema/index.js +4 -3
- package/dist/schema/index.js.map +1 -1
- package/package.json +5 -1
- package/dist/plugins/capabilities/DbPluginCapability.d.ts +0 -23
- package/dist/plugins/capabilities/index.d.ts +0 -2
- package/dist/plugins/capabilities/logging/DbPluginLoggingCapability.d.ts +0 -28
- package/dist/plugins/capabilities/logging/index.d.ts +0 -1
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
var __webpack_modules__ = ({
|
|
2
|
+
"./src/capabilities/Capability.ts":
|
|
3
|
+
/*!****************************************!*\
|
|
4
|
+
!*** ./src/capabilities/Capability.ts ***!
|
|
5
|
+
\****************************************/
|
|
6
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
Capability: () => (Capability)
|
|
10
|
+
});
|
|
11
|
+
class Capability {
|
|
12
|
+
isValidObject(obj) {
|
|
13
|
+
return typeof obj === "object" && obj !== null;
|
|
14
|
+
}
|
|
15
|
+
getObjectName(obj) {
|
|
16
|
+
return obj?.constructor?.name || 'root';
|
|
17
|
+
}
|
|
18
|
+
exploreObjectMethods(obj, callback, options = {}) {
|
|
19
|
+
if (!this.isValidObject(obj)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const { maxDepth = 10, includeNonEnumerable = false, filter = () => true } = options;
|
|
23
|
+
const rootName = this.getObjectName(obj);
|
|
24
|
+
const visited = new Set();
|
|
25
|
+
// Explore root methods
|
|
26
|
+
this.exploreRootMethods(obj, callback, filter);
|
|
27
|
+
// Explore nested methods
|
|
28
|
+
this.exploreNestedMethods(obj, callback, filter, [rootName], visited, maxDepth, includeNonEnumerable);
|
|
29
|
+
}
|
|
30
|
+
exploreRootMethods(obj, callback, filter) {
|
|
31
|
+
const methodNames = this.extractMethodNames(obj);
|
|
32
|
+
for (const methodName of methodNames) {
|
|
33
|
+
const methodInfo = {
|
|
34
|
+
methodName,
|
|
35
|
+
instance: obj,
|
|
36
|
+
methodPath: [String(methodName)],
|
|
37
|
+
parent: null
|
|
38
|
+
};
|
|
39
|
+
if (filter(methodInfo)) {
|
|
40
|
+
callback(methodInfo);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
extractMethodNames(obj) {
|
|
45
|
+
const methodNames = new Set();
|
|
46
|
+
let prototype = obj;
|
|
47
|
+
while (prototype && prototype !== Object.prototype) {
|
|
48
|
+
const allKeys = [
|
|
49
|
+
...Object.getOwnPropertyNames(prototype),
|
|
50
|
+
...Object.getOwnPropertySymbols(prototype),
|
|
51
|
+
];
|
|
52
|
+
for (const key of allKeys) {
|
|
53
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, key);
|
|
54
|
+
if (this.isCallableMethod(descriptor, key)) {
|
|
55
|
+
methodNames.add(key);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
59
|
+
}
|
|
60
|
+
return Array.from(methodNames);
|
|
61
|
+
}
|
|
62
|
+
isCallableMethod(descriptor, key) {
|
|
63
|
+
return (descriptor?.value &&
|
|
64
|
+
typeof descriptor.value === 'function' &&
|
|
65
|
+
key !== 'constructor' &&
|
|
66
|
+
key !== 'undefined');
|
|
67
|
+
}
|
|
68
|
+
isCustomClassInstance(value) {
|
|
69
|
+
if (value === null || (typeof value !== "object" && typeof value !== "function")) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const objectTag = Object.prototype.toString.call(value);
|
|
73
|
+
// Most built-ins have distinct tags; user classes default to "[object Object]"
|
|
74
|
+
// Caveat: Symbol.toStringTag can spoof this.
|
|
75
|
+
return objectTag === "[object Object]";
|
|
76
|
+
}
|
|
77
|
+
shouldProcessProperty(property) {
|
|
78
|
+
return (this.isCustomClassInstance(property) &&
|
|
79
|
+
property?.constructor.name !== "Object");
|
|
80
|
+
}
|
|
81
|
+
exploreNestedMethods(obj, callback, filter, initialPath, visited, maxDepth, includeNonEnumerable) {
|
|
82
|
+
if (visited.has(obj) || initialPath.length > maxDepth) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
visited.add(obj);
|
|
86
|
+
if (!this.isValidObject(obj)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const properties = includeNonEnumerable
|
|
90
|
+
? Object.getOwnPropertyNames(obj)
|
|
91
|
+
: Object.keys(obj);
|
|
92
|
+
for (const propertyName of properties) {
|
|
93
|
+
const property = obj[propertyName];
|
|
94
|
+
if (!this.shouldProcessProperty(property)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const newPath = [...initialPath, propertyName];
|
|
98
|
+
// Explore methods on this property
|
|
99
|
+
this.explorePropertyMethods(property, callback, filter, newPath, obj);
|
|
100
|
+
// Recursively explore nested objects
|
|
101
|
+
this.exploreNestedMethods(property, callback, filter, newPath, visited, maxDepth, includeNonEnumerable);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
explorePropertyMethods(property, callback, filter, methodPath, parent) {
|
|
105
|
+
const methodNames = this.extractMethodNames(property);
|
|
106
|
+
for (const methodName of methodNames) {
|
|
107
|
+
const fullMethodPath = [...methodPath, String(methodName)];
|
|
108
|
+
const methodInfo = {
|
|
109
|
+
methodName,
|
|
110
|
+
instance: property,
|
|
111
|
+
methodPath: fullMethodPath,
|
|
112
|
+
parent
|
|
113
|
+
};
|
|
114
|
+
if (filter(methodInfo)) {
|
|
115
|
+
callback(methodInfo);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
stringifyValue(value, maxDepth = 3, currentDepth = 0) {
|
|
120
|
+
if (value === null)
|
|
121
|
+
return 'null';
|
|
122
|
+
if (value === undefined)
|
|
123
|
+
return 'undefined';
|
|
124
|
+
const type = typeof value;
|
|
125
|
+
switch (type) {
|
|
126
|
+
case 'string':
|
|
127
|
+
return `"${value}"`;
|
|
128
|
+
case 'number':
|
|
129
|
+
case 'boolean':
|
|
130
|
+
return String(value);
|
|
131
|
+
case 'function':
|
|
132
|
+
return `[Function: ${this.getFunctionName(value)}]`;
|
|
133
|
+
case 'object':
|
|
134
|
+
if (currentDepth >= maxDepth) {
|
|
135
|
+
return '[Max Depth Reached]';
|
|
136
|
+
}
|
|
137
|
+
return this.stringifyObject(value, maxDepth, currentDepth);
|
|
138
|
+
default:
|
|
139
|
+
return `[${type}]`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
getFunctionName(fn) {
|
|
143
|
+
const name = fn.name;
|
|
144
|
+
return name || 'anonymous';
|
|
145
|
+
}
|
|
146
|
+
stringifyObject(obj, maxDepth, currentDepth) {
|
|
147
|
+
if (obj === null)
|
|
148
|
+
return 'null';
|
|
149
|
+
// Handle special object types
|
|
150
|
+
if (obj instanceof Date) {
|
|
151
|
+
return `Date(${obj.toISOString()})`;
|
|
152
|
+
}
|
|
153
|
+
if (obj instanceof Error) {
|
|
154
|
+
return `Error(${obj.message})`;
|
|
155
|
+
}
|
|
156
|
+
if (obj instanceof RegExp) {
|
|
157
|
+
return obj.toString();
|
|
158
|
+
}
|
|
159
|
+
if (Array.isArray(obj)) {
|
|
160
|
+
return this.stringifyArray(obj, maxDepth, currentDepth);
|
|
161
|
+
}
|
|
162
|
+
if (obj.constructor && obj.constructor.name !== 'Object') {
|
|
163
|
+
return this.stringifyClassInstance(obj, maxDepth, currentDepth);
|
|
164
|
+
}
|
|
165
|
+
return this.stringifyPlainObject(obj, maxDepth, currentDepth);
|
|
166
|
+
}
|
|
167
|
+
stringifyArray(arr, maxDepth, currentDepth) {
|
|
168
|
+
if (arr.length === 0)
|
|
169
|
+
return '[]';
|
|
170
|
+
const items = arr.slice(0, 5).map(item => this.stringifyValue(item, maxDepth, currentDepth + 1));
|
|
171
|
+
const suffix = arr.length > 5 ? `... (+${arr.length - 5} more)` : '';
|
|
172
|
+
return `[${items.join(', ')}${suffix}]`;
|
|
173
|
+
}
|
|
174
|
+
stringifyClassInstance(obj, maxDepth, currentDepth) {
|
|
175
|
+
const className = obj.constructor.name;
|
|
176
|
+
const properties = this.getObjectProperties(obj);
|
|
177
|
+
if (Object.keys(properties).length === 0) {
|
|
178
|
+
return `${className} {}`;
|
|
179
|
+
}
|
|
180
|
+
const props = Object.entries(properties)
|
|
181
|
+
.slice(0, 5)
|
|
182
|
+
.map(([key, value]) => {
|
|
183
|
+
// For primitive values, don't increase depth
|
|
184
|
+
const isPrimitive = value === null || value === undefined ||
|
|
185
|
+
(typeof value !== 'object' && typeof value !== 'function');
|
|
186
|
+
const depth = isPrimitive ? currentDepth : currentDepth + 1;
|
|
187
|
+
return `${key}: ${this.stringifyValue(value, maxDepth, depth)}`;
|
|
188
|
+
});
|
|
189
|
+
const suffix = Object.keys(properties).length > 5 ?
|
|
190
|
+
`... (+${Object.keys(properties).length - 5} more)` : '';
|
|
191
|
+
return `${className} { ${props.join(', ')}${suffix} }`;
|
|
192
|
+
}
|
|
193
|
+
stringifyPlainObject(obj, maxDepth, currentDepth) {
|
|
194
|
+
const properties = this.getObjectProperties(obj);
|
|
195
|
+
if (Object.keys(properties).length === 0) {
|
|
196
|
+
return '{}';
|
|
197
|
+
}
|
|
198
|
+
const props = Object.entries(properties)
|
|
199
|
+
.slice(0, 5)
|
|
200
|
+
.map(([key, value]) => {
|
|
201
|
+
// For primitive values, don't increase depth
|
|
202
|
+
const isPrimitive = value === null || value === undefined ||
|
|
203
|
+
(typeof value !== 'object' && typeof value !== 'function');
|
|
204
|
+
const depth = isPrimitive ? currentDepth : currentDepth + 1;
|
|
205
|
+
return `${key}: ${this.stringifyValue(value, maxDepth, depth)}`;
|
|
206
|
+
});
|
|
207
|
+
const suffix = Object.keys(properties).length > 5 ?
|
|
208
|
+
`... (+${Object.keys(properties).length - 5} more)` : '';
|
|
209
|
+
return `{ ${props.join(', ')}${suffix} }`;
|
|
210
|
+
}
|
|
211
|
+
getObjectProperties(obj) {
|
|
212
|
+
const properties = {};
|
|
213
|
+
// Get enumerable properties
|
|
214
|
+
for (const key in obj) {
|
|
215
|
+
if (obj.hasOwnProperty(key)) {
|
|
216
|
+
properties[key] = obj[key];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return properties;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
}),
|
|
225
|
+
"./src/capabilities/PerformanceCapability.ts":
|
|
226
|
+
/*!***************************************************!*\
|
|
227
|
+
!*** ./src/capabilities/PerformanceCapability.ts ***!
|
|
228
|
+
\***************************************************/
|
|
229
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
230
|
+
__webpack_require__.r(__webpack_exports__);
|
|
231
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
232
|
+
PerformanceCapability: () => (PerformanceCapability)
|
|
233
|
+
});
|
|
234
|
+
/* ESM import */var _Capability__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Capability */ "./src/capabilities/Capability.ts");
|
|
235
|
+
/* ESM import */var _performance_PerformanceTracker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./performance/PerformanceTracker */ "./src/capabilities/performance/PerformanceTracker.ts");
|
|
236
|
+
/* ESM import */var _tracing_CallTraceManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tracing/CallTraceManager */ "./src/capabilities/tracing/CallTraceManager.ts");
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class PerformanceCapability extends _Capability__WEBPACK_IMPORTED_MODULE_0__.Capability {
|
|
241
|
+
callTraceManager;
|
|
242
|
+
performanceTracker;
|
|
243
|
+
log;
|
|
244
|
+
shouldLog;
|
|
245
|
+
constructor(options) {
|
|
246
|
+
super();
|
|
247
|
+
this.log = options?.log ?? ((type, operationId, methodName, methodPath, performanceMetrics, isCompleted) => {
|
|
248
|
+
if (isCompleted) {
|
|
249
|
+
if (!performanceMetrics.duration)
|
|
250
|
+
return;
|
|
251
|
+
const deltaFromStart = this.performanceTracker.getDeltaFromOperationStart(operationId, performanceMetrics.endTime || performanceMetrics.startTime);
|
|
252
|
+
console.log(`[${type} ${operationId}] ${methodName} COMPLETED`, {
|
|
253
|
+
methodPath,
|
|
254
|
+
performance: {
|
|
255
|
+
deltaFromStart: this.performanceTracker.formatDuration(deltaFromStart),
|
|
256
|
+
executionTime: this.performanceTracker.formatDuration(performanceMetrics.duration),
|
|
257
|
+
timeToNextCall: performanceMetrics.timeToNextCall ?
|
|
258
|
+
this.performanceTracker.formatDuration(performanceMetrics.timeToNextCall) : 'N/A'
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const deltaFromStart = this.performanceTracker.getDeltaFromOperationStart(operationId, performanceMetrics.startTime);
|
|
264
|
+
console.log(`[${type} ${operationId}] ${methodName}`, {
|
|
265
|
+
methodPath,
|
|
266
|
+
performance: {
|
|
267
|
+
deltaFromStart: this.performanceTracker.formatDuration(deltaFromStart)
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
this.shouldLog = options?.shouldLog ?? (() => true);
|
|
272
|
+
this.callTraceManager = new _tracing_CallTraceManager__WEBPACK_IMPORTED_MODULE_1__.CallTraceManager();
|
|
273
|
+
this.performanceTracker = new _performance_PerformanceTracker__WEBPACK_IMPORTED_MODULE_2__.PerformanceTracker();
|
|
274
|
+
}
|
|
275
|
+
createPerformanceInterceptor(originalMethod, methodName, methodPath, instance) {
|
|
276
|
+
return (...args) => {
|
|
277
|
+
const isNewOperation = this.callTraceManager.isNewOperation();
|
|
278
|
+
let operationId;
|
|
279
|
+
if (isNewOperation) {
|
|
280
|
+
operationId = this.callTraceManager.startNewOperation();
|
|
281
|
+
const startTime = this.performanceTracker.startMethodTiming(operationId, methodPath);
|
|
282
|
+
this.log('ORIGIN', operationId, methodName, methodPath, { startTime }, false);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
operationId = this.callTraceManager.getActiveOperationId();
|
|
286
|
+
// Record that the previous method is about to call this one
|
|
287
|
+
const callTrace = this.callTraceManager.getCurrentTrace();
|
|
288
|
+
const previousMethodPath = callTrace[callTrace.length - 2];
|
|
289
|
+
if (previousMethodPath) {
|
|
290
|
+
this.performanceTracker.recordNextMethodStart(operationId, previousMethodPath);
|
|
291
|
+
}
|
|
292
|
+
const startTime = this.performanceTracker.startMethodTiming(operationId, methodPath);
|
|
293
|
+
this.log('CHILD', operationId, methodName, methodPath, { startTime }, false);
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
const result = originalMethod.apply(instance, args);
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
finally {
|
|
300
|
+
// End performance tracking
|
|
301
|
+
const performanceMetrics = this.performanceTracker.endMethodTiming(operationId, methodPath);
|
|
302
|
+
// Log completion with performance metrics
|
|
303
|
+
this.log(isNewOperation ? 'ORIGIN' : 'CHILD', operationId, methodName, methodPath, performanceMetrics, true);
|
|
304
|
+
if (isNewOperation) {
|
|
305
|
+
this.callTraceManager.endOperation();
|
|
306
|
+
this.performanceTracker.cleanupOperation(operationId);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
apply(instance) {
|
|
312
|
+
if (!this.isValidObject(instance)) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
// Create a performance wrapper
|
|
316
|
+
const wrapper = {
|
|
317
|
+
wrapMethod: (originalMethod, methodInfo) => {
|
|
318
|
+
return this.createPerformanceInterceptor(originalMethod, String(methodInfo.methodName), methodInfo.methodPath.join(' → '), methodInfo.instance);
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
// Use the generic interception utility
|
|
322
|
+
this.exploreObjectMethods(instance, (methodInfo) => {
|
|
323
|
+
const originalMethod = methodInfo.instance[methodInfo.methodName].bind(methodInfo.instance);
|
|
324
|
+
const wrappedMethod = wrapper.wrapMethod(originalMethod, methodInfo);
|
|
325
|
+
methodInfo.instance[methodInfo.methodName] = wrappedMethod;
|
|
326
|
+
}, {});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
}),
|
|
332
|
+
"./src/capabilities/TracingCapability.ts":
|
|
333
|
+
/*!***********************************************!*\
|
|
334
|
+
!*** ./src/capabilities/TracingCapability.ts ***!
|
|
335
|
+
\***********************************************/
|
|
336
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
337
|
+
__webpack_require__.r(__webpack_exports__);
|
|
338
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
339
|
+
TracingCapability: () => (TracingCapability)
|
|
340
|
+
});
|
|
341
|
+
/* ESM import */var _Capability__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Capability */ "./src/capabilities/Capability.ts");
|
|
342
|
+
/* ESM import */var _tracing_CallTraceManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tracing/CallTraceManager */ "./src/capabilities/tracing/CallTraceManager.ts");
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
class TracingCapability extends _Capability__WEBPACK_IMPORTED_MODULE_0__.Capability {
|
|
346
|
+
callTraceManager;
|
|
347
|
+
log;
|
|
348
|
+
shouldLogMethod;
|
|
349
|
+
constructor(options) {
|
|
350
|
+
super();
|
|
351
|
+
this.log = options?.log ?? ((type, operationId, methodName, methodPath, _callTrace, formattedCallTrace, args) => {
|
|
352
|
+
const stringifiedArgs = args.map(arg => this.stringifyValue(arg, 4));
|
|
353
|
+
const logData = {
|
|
354
|
+
methodPath,
|
|
355
|
+
callStack: formattedCallTrace,
|
|
356
|
+
args: stringifiedArgs
|
|
357
|
+
};
|
|
358
|
+
console.log(`[${type} ${operationId}] ${methodName}`, logData);
|
|
359
|
+
});
|
|
360
|
+
this.shouldLogMethod = options?.shouldLog ?? (() => true);
|
|
361
|
+
this.callTraceManager = new _tracing_CallTraceManager__WEBPACK_IMPORTED_MODULE_1__.CallTraceManager();
|
|
362
|
+
}
|
|
363
|
+
createTracingInterceptor(originalMethod, methodName, methodPath, instance) {
|
|
364
|
+
return (...args) => {
|
|
365
|
+
const isNewOperation = this.callTraceManager.isNewOperation();
|
|
366
|
+
let operationId;
|
|
367
|
+
let callTrace;
|
|
368
|
+
if (isNewOperation) {
|
|
369
|
+
operationId = this.callTraceManager.startNewOperation();
|
|
370
|
+
callTrace = this.callTraceManager.addMethodToTrace(methodPath);
|
|
371
|
+
const formattedCallTrace = this.callTraceManager.formatMethodPaths(callTrace);
|
|
372
|
+
this.log('ORIGIN', operationId, methodName, methodPath, callTrace, formattedCallTrace, args);
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
operationId = this.callTraceManager.getActiveOperationId();
|
|
376
|
+
callTrace = this.callTraceManager.addMethodToTrace(methodPath);
|
|
377
|
+
const formattedCallTrace = this.callTraceManager.formatMethodPaths(callTrace);
|
|
378
|
+
this.log('CHILD', operationId, methodName, methodPath, callTrace, formattedCallTrace, args);
|
|
379
|
+
}
|
|
380
|
+
try {
|
|
381
|
+
const result = originalMethod.apply(instance, args);
|
|
382
|
+
return result;
|
|
383
|
+
}
|
|
384
|
+
finally {
|
|
385
|
+
if (isNewOperation) {
|
|
386
|
+
this.callTraceManager.endOperation();
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
this.callTraceManager.removeMethodFromTrace();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
apply(instance) {
|
|
395
|
+
if (!this.isValidObject(instance)) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
const logMethodCall = (type, operationId, methodName, methodPath, callTrace, formattedCallTrace, args) => {
|
|
399
|
+
if (this.log) {
|
|
400
|
+
this.log(type, operationId, methodName, methodPath, callTrace, formattedCallTrace, args);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const stringifiedArgs = args.map(arg => this.stringifyValue(arg, 4));
|
|
404
|
+
const logData = {
|
|
405
|
+
methodPath,
|
|
406
|
+
callStack: formattedCallTrace,
|
|
407
|
+
args: stringifiedArgs
|
|
408
|
+
};
|
|
409
|
+
console.log(`[${type} ${operationId}] ${methodName}`, logData);
|
|
410
|
+
};
|
|
411
|
+
// Create a tracing wrapper
|
|
412
|
+
const wrapper = {
|
|
413
|
+
wrapMethod: (originalMethod, methodInfo) => {
|
|
414
|
+
const metadata = {
|
|
415
|
+
parent: methodInfo.parent,
|
|
416
|
+
instance: methodInfo.instance,
|
|
417
|
+
methodPath: methodInfo.methodPath
|
|
418
|
+
};
|
|
419
|
+
const shouldLog = this.shouldLogMethod(methodInfo.methodName, metadata);
|
|
420
|
+
if (!shouldLog) {
|
|
421
|
+
return originalMethod; // Return unwrapped method if not logging
|
|
422
|
+
}
|
|
423
|
+
return this.createTracingInterceptor(originalMethod, String(methodInfo.methodName), methodInfo.methodPath.join(' → '), methodInfo.instance);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
// Use the generic interception utility
|
|
427
|
+
this.exploreObjectMethods(instance, (methodInfo) => {
|
|
428
|
+
const originalMethod = methodInfo.instance[methodInfo.methodName].bind(methodInfo.instance);
|
|
429
|
+
const wrappedMethod = wrapper.wrapMethod(originalMethod, methodInfo);
|
|
430
|
+
methodInfo.instance[methodInfo.methodName] = wrappedMethod;
|
|
431
|
+
}, {});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
}),
|
|
437
|
+
"./src/capabilities/performance/PerformanceTracker.ts":
|
|
438
|
+
/*!************************************************************!*\
|
|
439
|
+
!*** ./src/capabilities/performance/PerformanceTracker.ts ***!
|
|
440
|
+
\************************************************************/
|
|
441
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
442
|
+
__webpack_require__.r(__webpack_exports__);
|
|
443
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
444
|
+
PerformanceTracker: () => (PerformanceTracker)
|
|
445
|
+
});
|
|
446
|
+
class PerformanceTracker {
|
|
447
|
+
methodTimings = new Map();
|
|
448
|
+
operationStartTimes = new Map();
|
|
449
|
+
startMethodTiming(operationId, methodPath) {
|
|
450
|
+
const startTime = performance.now();
|
|
451
|
+
const key = `${operationId}:${methodPath}`;
|
|
452
|
+
// Track operation start time for delta calculations
|
|
453
|
+
if (!this.operationStartTimes.has(operationId)) {
|
|
454
|
+
this.operationStartTimes.set(operationId, startTime);
|
|
455
|
+
}
|
|
456
|
+
this.methodTimings.set(key, { startTime });
|
|
457
|
+
return startTime;
|
|
458
|
+
}
|
|
459
|
+
recordNextMethodStart(operationId, methodPath) {
|
|
460
|
+
const key = `${operationId}:${methodPath}`;
|
|
461
|
+
const timing = this.methodTimings.get(key);
|
|
462
|
+
if (timing) {
|
|
463
|
+
timing.nextMethodStartTime = performance.now();
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
endMethodTiming(operationId, methodPath) {
|
|
467
|
+
const endTime = performance.now();
|
|
468
|
+
const key = `${operationId}:${methodPath}`;
|
|
469
|
+
const timing = this.methodTimings.get(key);
|
|
470
|
+
if (!timing) {
|
|
471
|
+
return { startTime: endTime };
|
|
472
|
+
}
|
|
473
|
+
const duration = endTime - timing.startTime;
|
|
474
|
+
const timeToNextCall = timing.nextMethodStartTime ?
|
|
475
|
+
timing.nextMethodStartTime - timing.startTime : undefined;
|
|
476
|
+
// Clean up
|
|
477
|
+
this.methodTimings.delete(key);
|
|
478
|
+
return {
|
|
479
|
+
startTime: timing.startTime,
|
|
480
|
+
endTime,
|
|
481
|
+
duration,
|
|
482
|
+
nextMethodStartTime: timing.nextMethodStartTime,
|
|
483
|
+
timeToNextCall
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
formatDuration(milliseconds) {
|
|
487
|
+
if (milliseconds < 1) {
|
|
488
|
+
return `${(milliseconds * 1000).toFixed(1)}μs`;
|
|
489
|
+
}
|
|
490
|
+
else if (milliseconds < 1000) {
|
|
491
|
+
return `${milliseconds.toFixed(2)}ms`;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
return `${(milliseconds / 1000).toFixed(2)}s`;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
getDeltaFromOperationStart(operationId, currentTime) {
|
|
498
|
+
const operationStartTime = this.operationStartTimes.get(operationId);
|
|
499
|
+
return operationStartTime ? currentTime - operationStartTime : 0;
|
|
500
|
+
}
|
|
501
|
+
cleanupOperation(operationId) {
|
|
502
|
+
this.operationStartTimes.delete(operationId);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
}),
|
|
508
|
+
"./src/capabilities/tracing/CallTraceManager.ts":
|
|
509
|
+
/*!******************************************************!*\
|
|
510
|
+
!*** ./src/capabilities/tracing/CallTraceManager.ts ***!
|
|
511
|
+
\******************************************************/
|
|
512
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
513
|
+
__webpack_require__.r(__webpack_exports__);
|
|
514
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
515
|
+
CallTraceManager: () => (CallTraceManager)
|
|
516
|
+
});
|
|
517
|
+
/* ESM import */var _utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utilities */ "./src/utilities/uuid.ts");
|
|
518
|
+
|
|
519
|
+
class CallTraceManager {
|
|
520
|
+
activeOperationId = null;
|
|
521
|
+
activeCallStack = [];
|
|
522
|
+
startNewOperation() {
|
|
523
|
+
const operationId = (0,_utilities__WEBPACK_IMPORTED_MODULE_0__.uuid)();
|
|
524
|
+
this.activeOperationId = operationId;
|
|
525
|
+
this.activeCallStack = [];
|
|
526
|
+
return operationId;
|
|
527
|
+
}
|
|
528
|
+
isNewOperation() {
|
|
529
|
+
return this.activeOperationId === null;
|
|
530
|
+
}
|
|
531
|
+
getActiveOperationId() {
|
|
532
|
+
if (!this.activeOperationId) {
|
|
533
|
+
throw new Error('No active operation context');
|
|
534
|
+
}
|
|
535
|
+
return this.activeOperationId;
|
|
536
|
+
}
|
|
537
|
+
addMethodToTrace(methodPath) {
|
|
538
|
+
if (this.isNewOperation()) {
|
|
539
|
+
this.activeCallStack = [methodPath];
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
this.activeCallStack.push(methodPath);
|
|
543
|
+
}
|
|
544
|
+
return [...this.activeCallStack];
|
|
545
|
+
}
|
|
546
|
+
removeMethodFromTrace() {
|
|
547
|
+
if (!this.isNewOperation()) {
|
|
548
|
+
this.activeCallStack.pop();
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
endOperation() {
|
|
552
|
+
this.activeOperationId = null;
|
|
553
|
+
this.activeCallStack = [];
|
|
554
|
+
}
|
|
555
|
+
formatMethodPaths(methodPaths) {
|
|
556
|
+
return methodPaths.map(path => path.replace(/ → /g, '.'));
|
|
557
|
+
}
|
|
558
|
+
getCurrentTrace() {
|
|
559
|
+
return [...this.activeCallStack];
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
}),
|
|
565
|
+
"./src/utilities/uuid.ts":
|
|
566
|
+
/*!*******************************!*\
|
|
567
|
+
!*** ./src/utilities/uuid.ts ***!
|
|
568
|
+
\*******************************/
|
|
569
|
+
(function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
570
|
+
__webpack_require__.r(__webpack_exports__);
|
|
571
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
572
|
+
uuid: () => (uuid),
|
|
573
|
+
uuidv4: () => (uuidv4)
|
|
574
|
+
});
|
|
575
|
+
const uuid = (length = 16) => {
|
|
576
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
577
|
+
const charLength = chars.length;
|
|
578
|
+
let result = '';
|
|
579
|
+
for (let i = 0; i < length; i++) {
|
|
580
|
+
result += chars[Math.random() * charLength | 0];
|
|
581
|
+
}
|
|
582
|
+
return result;
|
|
583
|
+
};
|
|
584
|
+
const HEX_CHARS = '0123456789abcdef';
|
|
585
|
+
const UUID_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
586
|
+
const hasCrypto = typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
|
|
587
|
+
const uuidv4 = () => {
|
|
588
|
+
let randomBytes = null;
|
|
589
|
+
if (hasCrypto) {
|
|
590
|
+
randomBytes = crypto.getRandomValues(new Uint8Array(16));
|
|
591
|
+
}
|
|
592
|
+
let byteIndex = 0;
|
|
593
|
+
let uuid = '';
|
|
594
|
+
for (let i = 0; i < UUID_TEMPLATE.length; i++) {
|
|
595
|
+
const c = UUID_TEMPLATE[i];
|
|
596
|
+
if (c === '-') {
|
|
597
|
+
uuid += '-';
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
let r;
|
|
601
|
+
if (hasCrypto && randomBytes) {
|
|
602
|
+
// Each byte gives two hex digits (nibbles)
|
|
603
|
+
r =
|
|
604
|
+
(i % 2 === 0
|
|
605
|
+
? randomBytes[byteIndex] >> 4
|
|
606
|
+
: randomBytes[byteIndex++] & 0x0f);
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
r = Math.floor(Math.random() * 16);
|
|
610
|
+
}
|
|
611
|
+
if (c === 'x') {
|
|
612
|
+
uuid += HEX_CHARS[r];
|
|
613
|
+
}
|
|
614
|
+
else if (c === 'y') {
|
|
615
|
+
// Variant bits: 8, 9, A, or B
|
|
616
|
+
uuid += HEX_CHARS[(r & 0x3) | 0x8];
|
|
617
|
+
}
|
|
618
|
+
else if (c === '4') {
|
|
619
|
+
uuid += '4';
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return uuid;
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
}),
|
|
627
|
+
|
|
628
|
+
});
|
|
629
|
+
/************************************************************************/
|
|
630
|
+
// The module cache
|
|
631
|
+
var __webpack_module_cache__ = {};
|
|
632
|
+
|
|
633
|
+
// The require function
|
|
634
|
+
function __webpack_require__(moduleId) {
|
|
635
|
+
|
|
636
|
+
// Check if module is in cache
|
|
637
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
638
|
+
if (cachedModule !== undefined) {
|
|
639
|
+
return cachedModule.exports;
|
|
640
|
+
}
|
|
641
|
+
// Create a new module (and put it into the cache)
|
|
642
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
643
|
+
exports: {}
|
|
644
|
+
});
|
|
645
|
+
// Execute the module function
|
|
646
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
647
|
+
|
|
648
|
+
// Return the exports of the module
|
|
649
|
+
return module.exports;
|
|
650
|
+
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/************************************************************************/
|
|
654
|
+
// webpack/runtime/define_property_getters
|
|
655
|
+
(() => {
|
|
656
|
+
__webpack_require__.d = (exports, definition) => {
|
|
657
|
+
for(var key in definition) {
|
|
658
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
659
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
})();
|
|
664
|
+
// webpack/runtime/has_own_property
|
|
665
|
+
(() => {
|
|
666
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
667
|
+
})();
|
|
668
|
+
// webpack/runtime/make_namespace_object
|
|
669
|
+
(() => {
|
|
670
|
+
// define __esModule on exports
|
|
671
|
+
__webpack_require__.r = (exports) => {
|
|
672
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
673
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
674
|
+
}
|
|
675
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
676
|
+
};
|
|
677
|
+
})();
|
|
678
|
+
/************************************************************************/
|
|
679
|
+
var __webpack_exports__ = {};
|
|
680
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
681
|
+
(() => {
|
|
682
|
+
|
|
683
|
+
/*!***********************************!*\
|
|
684
|
+
!*** ./src/capabilities/index.ts ***!
|
|
685
|
+
\***********************************/
|
|
686
|
+
__webpack_require__.r(__webpack_exports__);
|
|
687
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
688
|
+
Capability: () => (/* reexport safe */ _Capability__WEBPACK_IMPORTED_MODULE_0__.Capability),
|
|
689
|
+
PerformanceCapability: () => (/* reexport safe */ _PerformanceCapability__WEBPACK_IMPORTED_MODULE_1__.PerformanceCapability),
|
|
690
|
+
TracingCapability: () => (/* reexport safe */ _TracingCapability__WEBPACK_IMPORTED_MODULE_2__.TracingCapability)
|
|
691
|
+
});
|
|
692
|
+
/* ESM import */var _Capability__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Capability */ "./src/capabilities/Capability.ts");
|
|
693
|
+
/* ESM import */var _PerformanceCapability__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PerformanceCapability */ "./src/capabilities/PerformanceCapability.ts");
|
|
694
|
+
/* ESM import */var _TracingCapability__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./TracingCapability */ "./src/capabilities/TracingCapability.ts");
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
})();
|
|
701
|
+
|
|
702
|
+
var __webpack_exports__Capability = __webpack_exports__.Capability;
|
|
703
|
+
var __webpack_exports__PerformanceCapability = __webpack_exports__.PerformanceCapability;
|
|
704
|
+
var __webpack_exports__TracingCapability = __webpack_exports__.TracingCapability;
|
|
705
|
+
export { __webpack_exports__Capability as Capability, __webpack_exports__PerformanceCapability as PerformanceCapability, __webpack_exports__TracingCapability as TracingCapability };
|
|
706
|
+
|
|
707
|
+
//# sourceMappingURL=index.js.map
|