trickle-observe 0.2.110 → 0.2.111

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/express.js CHANGED
@@ -181,11 +181,6 @@ function wrapExpressHandler(handler, routeName, opts) {
181
181
  return next(err);
182
182
  }
183
183
  };
184
- const debug = process.env.TRICKLE_DEBUG === '1';
185
- if (debug) {
186
- const hs = handler.toString().substring(0, 200);
187
- process.stderr.write(`[trickle/express-wrap] Calling handler: ${hs.replace(/\n/g, '\\n')}\n`);
188
- }
189
184
  try {
190
185
  const result = handler.call(this, req, res, wrappedNext);
191
186
  // Handle async handlers that return a promise
@@ -1080,10 +1080,7 @@ function transformCjsSource(source, filename, moduleName, env, sourceMap) {
1080
1080
  lineNo: remapLine(ins.lineNo),
1081
1081
  }));
1082
1082
  if (debug && funcParamInsertions.length > 0) {
1083
- console.log(`[trickle/observe] Found ${funcParamInsertions.length} function param insertions in ${moduleName}`);
1084
- for (const ins of funcParamInsertions) {
1085
- console.log(` Line ${ins.lineNo}: params=[${ins.paramNames.join(', ')}]`);
1086
- }
1083
+ console.log(`[trickle/observe] Tracing ${funcParamInsertions.length} function param sites in ${moduleName}`);
1087
1084
  }
1088
1085
  }
1089
1086
  if (insertions.length === 0 && varInsertions.length === 0 && destructInsertions.length === 0 && reassignInsertions.length === 0 && forLoopInsertions.length === 0 && catchInsertions.length === 0 && classInsertions.length === 0 && funcParamInsertions.length === 0)
@@ -1120,7 +1117,7 @@ function transformCjsSource(source, filename, moduleName, env, sourceMap) {
1120
1117
  const traceModuleName = sourceMap
1121
1118
  ? path_1.default.basename(sourceMap.originalFile).replace(/\.[jt]sx?$/, '')
1122
1119
  : moduleName;
1123
- prefixLines.push(`var __trickle_tv_mod = require(${JSON.stringify(traceVarPath)});`, `var __trickle_tv = function(v, n, l, m, f) { try { __trickle_tv_mod.traceVar(v, n, l, m || ${JSON.stringify(traceModuleName)}, f || ${JSON.stringify(traceFilePath)}); } catch(e){ if (process.env.TRICKLE_DEBUG === '1') console.error('[trickle/tv] Error tracing', n, ':', e && e.message); } };`);
1120
+ prefixLines.push(`var __trickle_tv_mod = require(${JSON.stringify(traceVarPath)});`, `var __trickle_tv = function(v, n, l, m, f) { try { __trickle_tv_mod.traceVar(v, n, l, m || ${JSON.stringify(traceModuleName)}, f || ${JSON.stringify(traceFilePath)}); } catch(e){} };`);
1124
1121
  }
1125
1122
  prefixLines.push('');
1126
1123
  const prefix = prefixLines.join('\n');
@@ -1184,7 +1181,7 @@ function transformCjsSource(source, filename, moduleName, env, sourceMap) {
1184
1181
  const calls = paramNames.map(n => `__trickle_tv(${n},${JSON.stringify(n)},${lineNo}${sf})`).join(';');
1185
1182
  allInsertions.push({
1186
1183
  position: bodyStart,
1187
- code: `\nprocess.stderr.write("[trickle/params] Entering L${lineNo}\\n");try{${calls}}catch(__e3){process.stderr.write('[trickle/params] Error:'+(__e3&&__e3.message)+'\\n')}\n`,
1184
+ code: `\ntry{${calls}}catch(__e3){}\n`,
1188
1185
  });
1189
1186
  }
1190
1187
  // Add class method wrappings
@@ -1197,14 +1194,6 @@ function transformCjsSource(source, filename, moduleName, env, sourceMap) {
1197
1194
  for (const { position, code } of allInsertions) {
1198
1195
  result = result.slice(0, position) + code + result.slice(position);
1199
1196
  }
1200
- // Debug: dump transformed source
1201
- if (debug && funcParamInsertions.length > 0) {
1202
- try {
1203
- const debugDir = process.env.TRICKLE_LOCAL_DIR || path_1.default.join(process.cwd(), '.trickle');
1204
- fs_1.default.writeFileSync(path_1.default.join(debugDir, 'transformed-' + moduleName + '.js'), prefix + result);
1205
- }
1206
- catch { }
1207
- }
1208
1197
  return prefix + result;
1209
1198
  }
1210
1199
  /**
package/dist/trace-var.js CHANGED
@@ -145,9 +145,6 @@ function traceVar(value, varName, line, moduleName, filePath) {
145
145
  return;
146
146
  }
147
147
  try {
148
- if (debugMode) {
149
- console.log(`[trickle/vars] traceVar called: ${varName} at ${filePath}:${line} (typeof=${typeof value})`);
150
- }
151
148
  const type = (0, type_inference_1.inferType)(value, 3);
152
149
  // Create a stable hash for dedup
153
150
  const dummyArgs = { kind: 'tuple', elements: [] };
@@ -193,11 +190,8 @@ function traceVar(value, varName, line, moduleName, filePath) {
193
190
  }
194
191
  }
195
192
  }
196
- catch (err) {
193
+ catch {
197
194
  // Never crash user's app
198
- if (debugMode) {
199
- console.error(`[trickle/vars] Error tracing ${varName}: ${err instanceof Error ? err.message : String(err)}`);
200
- }
201
195
  }
202
196
  }
203
197
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trickle-observe",
3
- "version": "0.2.110",
3
+ "version": "0.2.111",
4
4
  "description": "Runtime type observability for JavaScript applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/express.ts CHANGED
@@ -205,11 +205,6 @@ function wrapExpressHandler(
205
205
  }
206
206
  };
207
207
 
208
- const debug = process.env.TRICKLE_DEBUG === '1';
209
- if (debug) {
210
- const hs = handler.toString().substring(0, 200);
211
- process.stderr.write(`[trickle/express-wrap] Calling handler: ${hs.replace(/\n/g, '\\n')}\n`);
212
- }
213
208
  try {
214
209
  const result = handler.call(this, req, res, wrappedNext);
215
210
 
@@ -1041,10 +1041,7 @@ function transformCjsSource(source: string, filename: string, moduleName: string
1041
1041
  lineNo: remapLine(ins.lineNo),
1042
1042
  }));
1043
1043
  if (debug && funcParamInsertions.length > 0) {
1044
- console.log(`[trickle/observe] Found ${funcParamInsertions.length} function param insertions in ${moduleName}`);
1045
- for (const ins of funcParamInsertions) {
1046
- console.log(` Line ${ins.lineNo}: params=[${ins.paramNames.join(', ')}]`);
1047
- }
1044
+ console.log(`[trickle/observe] Tracing ${funcParamInsertions.length} function param sites in ${moduleName}`);
1048
1045
  }
1049
1046
  }
1050
1047
 
@@ -1088,7 +1085,7 @@ function transformCjsSource(source: string, filename: string, moduleName: string
1088
1085
 
1089
1086
  prefixLines.push(
1090
1087
  `var __trickle_tv_mod = require(${JSON.stringify(traceVarPath)});`,
1091
- `var __trickle_tv = function(v, n, l, m, f) { try { __trickle_tv_mod.traceVar(v, n, l, m || ${JSON.stringify(traceModuleName)}, f || ${JSON.stringify(traceFilePath)}); } catch(e){ if (process.env.TRICKLE_DEBUG === '1') console.error('[trickle/tv] Error tracing', n, ':', e && e.message); } };`,
1088
+ `var __trickle_tv = function(v, n, l, m, f) { try { __trickle_tv_mod.traceVar(v, n, l, m || ${JSON.stringify(traceModuleName)}, f || ${JSON.stringify(traceFilePath)}); } catch(e){} };`,
1092
1089
  );
1093
1090
  }
1094
1091
 
@@ -1164,7 +1161,7 @@ function transformCjsSource(source: string, filename: string, moduleName: string
1164
1161
  const calls = paramNames.map(n => `__trickle_tv(${n},${JSON.stringify(n)},${lineNo}${sf})`).join(';');
1165
1162
  allInsertions.push({
1166
1163
  position: bodyStart,
1167
- code: `\nprocess.stderr.write("[trickle/params] Entering L${lineNo}\\n");try{${calls}}catch(__e3){process.stderr.write('[trickle/params] Error:'+(__e3&&__e3.message)+'\\n')}\n`,
1164
+ code: `\ntry{${calls}}catch(__e3){}\n`,
1168
1165
  });
1169
1166
  }
1170
1167
 
@@ -1181,14 +1178,6 @@ function transformCjsSource(source: string, filename: string, moduleName: string
1181
1178
  result = result.slice(0, position) + code + result.slice(position);
1182
1179
  }
1183
1180
 
1184
- // Debug: dump transformed source
1185
- if (debug && funcParamInsertions.length > 0) {
1186
- try {
1187
- const debugDir = process.env.TRICKLE_LOCAL_DIR || path.join(process.cwd(), '.trickle');
1188
- fs.writeFileSync(path.join(debugDir, 'transformed-' + moduleName + '.js'), prefix + result);
1189
- } catch {}
1190
- }
1191
-
1192
1181
  return prefix + result;
1193
1182
  }
1194
1183
 
package/src/trace-var.ts CHANGED
@@ -130,9 +130,6 @@ export function traceVar(
130
130
  }
131
131
 
132
132
  try {
133
- if (debugMode) {
134
- console.log(`[trickle/vars] traceVar called: ${varName} at ${filePath}:${line} (typeof=${typeof value})`);
135
- }
136
133
  const type = inferType(value, 3);
137
134
 
138
135
  // Create a stable hash for dedup
@@ -181,11 +178,8 @@ export function traceVar(
181
178
  flushTimer.unref();
182
179
  }
183
180
  }
184
- } catch (err: unknown) {
181
+ } catch {
185
182
  // Never crash user's app
186
- if (debugMode) {
187
- console.error(`[trickle/vars] Error tracing ${varName}: ${err instanceof Error ? err.message : String(err)}`);
188
- }
189
183
  }
190
184
  }
191
185