trickle-observe 0.2.103 → 0.2.105
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/observe-register.js +3 -0
- package/dist/type-inference.js +18 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/observe-register.ts +4 -0
- package/src/type-inference.ts +19 -1
- package/src/types.ts +1 -1
package/dist/observe-register.js
CHANGED
|
@@ -40,6 +40,7 @@ const wrap_1 = require("./wrap");
|
|
|
40
40
|
const fetch_observer_1 = require("./fetch-observer");
|
|
41
41
|
const express_1 = require("./express");
|
|
42
42
|
const trace_var_1 = require("./trace-var");
|
|
43
|
+
const call_trace_1 = require("./call-trace");
|
|
43
44
|
const vite_plugin_1 = require("./vite-plugin");
|
|
44
45
|
// ── Source map support ──
|
|
45
46
|
// Lightweight VLQ decoder for mapping compiled JS lines back to original TS lines
|
|
@@ -1016,6 +1017,8 @@ if (enabled) {
|
|
|
1016
1017
|
if (process.env.TRICKLE_TRACE_VARS !== '0') {
|
|
1017
1018
|
(0, trace_var_1.initVarTracer)({ debug });
|
|
1018
1019
|
}
|
|
1020
|
+
// ── Hook 0b2: Initialize call trace ──
|
|
1021
|
+
(0, call_trace_1.initCallTrace)();
|
|
1019
1022
|
// ── Hook 0c: Capture environment snapshot ──
|
|
1020
1023
|
try {
|
|
1021
1024
|
const envDir = process.env.TRICKLE_LOCAL_DIR || path_1.default.join(process.cwd(), '.trickle');
|
package/dist/type-inference.js
CHANGED
|
@@ -153,6 +153,23 @@ function inferObject(obj, depth, seen) {
|
|
|
153
153
|
},
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
+
// Known complex framework objects — use class name instead of deep introspection.
|
|
157
|
+
// These types have dozens of internal properties that generate unusably verbose stubs.
|
|
158
|
+
const className = obj.constructor?.name;
|
|
159
|
+
const OPAQUE_CLASSES = new Set([
|
|
160
|
+
// Node.js HTTP internals
|
|
161
|
+
'IncomingMessage', 'ServerResponse', 'Socket', 'Server',
|
|
162
|
+
'ReadableState', 'WritableState',
|
|
163
|
+
// Express
|
|
164
|
+
'IncomingMessage', // Express req extends this
|
|
165
|
+
// Streams
|
|
166
|
+
'Readable', 'Writable', 'Duplex', 'Transform', 'PassThrough',
|
|
167
|
+
// EventEmitter
|
|
168
|
+
'EventEmitter',
|
|
169
|
+
]);
|
|
170
|
+
if (className && OPAQUE_CLASSES.has(className)) {
|
|
171
|
+
return { kind: 'object', properties: {}, class_name: className };
|
|
172
|
+
}
|
|
156
173
|
// Plain objects
|
|
157
174
|
return inferPlainObject(obj, depth, seen);
|
|
158
175
|
}
|
|
@@ -167,7 +184,7 @@ function inferArray(arr, depth, seen) {
|
|
|
167
184
|
}
|
|
168
185
|
return { kind: 'array', element: unifyTypes(elementTypes) };
|
|
169
186
|
}
|
|
170
|
-
const MAX_PROPERTIES =
|
|
187
|
+
const MAX_PROPERTIES = 12;
|
|
171
188
|
function inferPlainObject(obj, depth, seen) {
|
|
172
189
|
const properties = {};
|
|
173
190
|
const keys = Object.keys(obj);
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
package/src/observe-register.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { WrapOptions } from './types';
|
|
|
37
37
|
import { patchFetch } from './fetch-observer';
|
|
38
38
|
import { instrumentExpress, trickleMiddleware } from './express';
|
|
39
39
|
import { initVarTracer, traceVar } from './trace-var';
|
|
40
|
+
import { initCallTrace } from './call-trace';
|
|
40
41
|
import {
|
|
41
42
|
findReassignments,
|
|
42
43
|
findForLoopVars,
|
|
@@ -1004,6 +1005,9 @@ if (enabled) {
|
|
|
1004
1005
|
initVarTracer({ debug });
|
|
1005
1006
|
}
|
|
1006
1007
|
|
|
1008
|
+
// ── Hook 0b2: Initialize call trace ──
|
|
1009
|
+
initCallTrace();
|
|
1010
|
+
|
|
1007
1011
|
// ── Hook 0c: Capture environment snapshot ──
|
|
1008
1012
|
try {
|
|
1009
1013
|
const envDir = process.env.TRICKLE_LOCAL_DIR || path.join(process.cwd(), '.trickle');
|
package/src/type-inference.ts
CHANGED
|
@@ -168,6 +168,24 @@ function inferObject(obj: object, depth: number, seen: WeakSet<object>): TypeNod
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
// Known complex framework objects — use class name instead of deep introspection.
|
|
172
|
+
// These types have dozens of internal properties that generate unusably verbose stubs.
|
|
173
|
+
const className = obj.constructor?.name;
|
|
174
|
+
const OPAQUE_CLASSES = new Set([
|
|
175
|
+
// Node.js HTTP internals
|
|
176
|
+
'IncomingMessage', 'ServerResponse', 'Socket', 'Server',
|
|
177
|
+
'ReadableState', 'WritableState',
|
|
178
|
+
// Express
|
|
179
|
+
'IncomingMessage', // Express req extends this
|
|
180
|
+
// Streams
|
|
181
|
+
'Readable', 'Writable', 'Duplex', 'Transform', 'PassThrough',
|
|
182
|
+
// EventEmitter
|
|
183
|
+
'EventEmitter',
|
|
184
|
+
]);
|
|
185
|
+
if (className && OPAQUE_CLASSES.has(className)) {
|
|
186
|
+
return { kind: 'object', properties: {}, class_name: className };
|
|
187
|
+
}
|
|
188
|
+
|
|
171
189
|
// Plain objects
|
|
172
190
|
return inferPlainObject(obj, depth, seen);
|
|
173
191
|
}
|
|
@@ -187,7 +205,7 @@ function inferArray(arr: unknown[], depth: number, seen: WeakSet<object>): TypeN
|
|
|
187
205
|
return { kind: 'array', element: unifyTypes(elementTypes) };
|
|
188
206
|
}
|
|
189
207
|
|
|
190
|
-
const MAX_PROPERTIES =
|
|
208
|
+
const MAX_PROPERTIES = 12;
|
|
191
209
|
|
|
192
210
|
function inferPlainObject(obj: object, depth: number, seen: WeakSet<object>): TypeNode {
|
|
193
211
|
const properties: Record<string, TypeNode> = {};
|
package/src/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type TypeNode =
|
|
2
2
|
| { kind: "primitive"; name: "string" | "number" | "boolean" | "null" | "undefined" | "bigint" | "symbol" }
|
|
3
3
|
| { kind: "array"; element: TypeNode }
|
|
4
|
-
| { kind: "object"; properties: Record<string, TypeNode
|
|
4
|
+
| { kind: "object"; properties: Record<string, TypeNode>; class_name?: string }
|
|
5
5
|
| { kind: "union"; members: TypeNode[] }
|
|
6
6
|
| { kind: "function"; params: TypeNode[]; returnType: TypeNode }
|
|
7
7
|
| { kind: "promise"; resolved: TypeNode }
|