@sailfish-ai/sf-veritas 0.2.21 → 0.3.1

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.
Files changed (41) hide show
  1. package/README.md +53 -0
  2. package/dist/consoleLocationTransformer-BSSB5msZ.cjs +1 -0
  3. package/dist/consoleLocationTransformer-DZu_9MDA.js +51 -0
  4. package/dist/contextManager-BsolAr_q.cjs +1 -0
  5. package/dist/{contextManager-RxrMXs5c.js → contextManager-D2ijKL-E.js} +105 -102
  6. package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
  7. package/dist/plugins/funcspanEsbuildPlugin.mjs +20 -16
  8. package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
  9. package/dist/plugins/funcspanRollupPlugin.mjs +17 -13
  10. package/dist/plugins/funcspanTscPlugin.cjs +1 -1
  11. package/dist/plugins/funcspanTscPlugin.mjs +34 -30
  12. package/dist/plugins/funcspanVitePlugin.cjs +1 -1
  13. package/dist/plugins/funcspanVitePlugin.mjs +16 -12
  14. package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
  15. package/dist/plugins/funcspanWebpackLoader.mjs +55 -50
  16. package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
  17. package/dist/plugins/funcspanWebpackPlugin.mjs +1 -1
  18. package/dist/runtimeConfig-C4mv7SVM.js +484 -0
  19. package/dist/runtimeConfig-XIm4yAFB.cjs +6 -0
  20. package/dist/sf-veritas.cjs +13 -13
  21. package/dist/sf-veritas.mjs +532 -388
  22. package/dist/telemetryWorker.cjs +1 -0
  23. package/dist/types/dataTransmitter.d.ts +6 -5
  24. package/dist/types/exceptionTransmitter.d.ts +2 -1
  25. package/dist/types/networkHopTransmitter.d.ts +2 -1
  26. package/dist/types/networkRequestTransmitter.d.ts +2 -1
  27. package/dist/types/plugins/consoleLocationTransformer.d.ts +37 -0
  28. package/dist/types/requestTransmitter.d.ts +45 -0
  29. package/dist/types/requestUtils.d.ts +17 -6
  30. package/dist/types/setupConfig.d.ts +21 -0
  31. package/dist/types/sourceLocation.d.ts +19 -19
  32. package/dist/types/telemetryWorker.d.ts +1 -0
  33. package/dist/worker-pool-capture.cjs +1 -1
  34. package/dist/worker-pool-capture.mjs +1 -1
  35. package/dist/workerPoolSpanCapture-DzCJnMDA.cjs +83 -0
  36. package/dist/{workerPoolSpanCapture-DVYmzgbN.js → workerPoolSpanCapture-hyxgVqUF.js} +222 -168
  37. package/package.json +17 -1
  38. package/dist/contextManager-0D8uHQ1_.cjs +0 -1
  39. package/dist/runtimeConfig-CB57auSb.js +0 -444
  40. package/dist/runtimeConfig-sm_7bnKx.cjs +0 -9
  41. package/dist/workerPoolSpanCapture-DFnbcpkU.cjs +0 -83
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs"),_=require("glob"),N=require("path"),m=require("../funcSpanTransformer-D0W2t41q.cjs"),T=require("../runtimeConfig-sm_7bnKx.cjs");async function S(n={}){try{if(T.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{outDir:f="dist",include:F=["**/*.js"],exclude:g=["**/*.test.js","**/*.spec.js","**/__tests__/**"],projectRoot:c=process.cwd(),includeNodeModules:C=[],debug:s=!1}=n,u=N.resolve(c,f);console.log("[FuncSpan TSC] Starting post-build function instrumentation..."),console.log(`[FuncSpan TSC] Output directory: ${u}`),console.log(`[FuncSpan TSC] Project root: ${c}`);const r=[];for(const e of F){const t=_.sync(e,{cwd:u,absolute:!0,ignore:g});r.push(...t)}console.log(`[FuncSpan TSC] Found ${r.length} JavaScript files to process`);let l=0,a=0;for(const e of r)try{const t=i.readFileSync(e,"utf-8"),o=await m.transformFunctionSpans(t,e,{projectRoot:c,includeNodeModules:C,debug:s});if(o.modified){if(i.writeFileSync(e,o.code,"utf-8"),o.map){const p=`${e}.map`;i.writeFileSync(p,JSON.stringify(o.map),"utf-8"),s&&console.log(`[FuncSpan TSC] Generated source map: ${p}`)}l++,a+=o.functionsWrapped,s&&console.log(`[FuncSpan TSC] Modified: ${e} (${o.functionsWrapped} functions)`)}}catch(t){console.error(`[FuncSpan TSC] Error processing ${e}:`,t)}console.log(`[FuncSpan TSC] ✅ Completed: Modified ${l} files, wrapped ${a} functions`)}async function d(){const n={outDir:process.env.SF_FUNCSPAN_OUT_DIR||"dist",debug:process.env.SF_FUNCSPAN_DEBUG==="true",includeNodeModules:process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES?process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES.split(","):[]};await S(n)}require.main===module&&d().catch(n=>{console.error("[FuncSpan TSC] Fatal error:",n),process.exit(1)}),exports.cli=d,exports.processTscFiles=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("fs"),T=require("glob"),y=require("path"),D=require("../funcSpanTransformer-D0W2t41q.cjs"),b=require("../consoleLocationTransformer-BSSB5msZ.cjs"),v=require("../runtimeConfig-XIm4yAFB.cjs");async function C(n={}){try{if(v.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{outDir:N="dist",include:_=["**/*.js"],exclude:m=["**/*.test.js","**/*.spec.js","**/__tests__/**"],projectRoot:c=process.cwd(),includeNodeModules:d=[],debug:s=!1}=n,p=y.resolve(c,N);console.log("[FuncSpan TSC] Starting post-build function instrumentation..."),console.log(`[FuncSpan TSC] Output directory: ${p}`),console.log(`[FuncSpan TSC] Project root: ${c}`);const i=[];for(const o of _){const e=T.sync(o,{cwd:p,absolute:!0,ignore:m});i.push(...e)}console.log(`[FuncSpan TSC] Found ${i.length} JavaScript files to process`);let S=0,f=0;for(const o of i)try{let e=a.readFileSync(o,"utf-8"),r=null,u=!1;const t=await D.transformFunctionSpans(e,o,{projectRoot:c,includeNodeModules:d,debug:s});t.modified&&(e=t.code,r=t.map,u=!0);const l=await b.transformConsoleLocations(e,o,{projectRoot:c,includeNodeModules:d,debug:s});if(l.modified&&(e=l.code,r=l.map,u=!0),u){if(a.writeFileSync(o,e,"utf-8"),r){const F=`${o}.map`;a.writeFileSync(F,JSON.stringify(r),"utf-8"),s&&console.log(`[FuncSpan TSC] Generated source map: ${F}`)}S++,f+=t.functionsWrapped,s&&console.log(`[FuncSpan TSC] Modified: ${o} (${t.functionsWrapped} functions)`)}}catch(e){console.error(`[FuncSpan TSC] Error processing ${o}:`,e)}console.log(`[FuncSpan TSC] ✅ Completed: Modified ${S} files, wrapped ${f} functions`)}async function g(){const n={outDir:process.env.SF_FUNCSPAN_OUT_DIR||"dist",debug:process.env.SF_FUNCSPAN_DEBUG==="true",includeNodeModules:process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES?process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES.split(","):[]};await C(n)}require.main===module&&g().catch(n=>{console.error("[FuncSpan TSC] Fatal error:",n),process.exit(1)}),exports.cli=g,exports.processTscFiles=C;
@@ -1,44 +1,48 @@
1
- import { readFileSync as m, writeFileSync as l } from "fs";
2
- import { sync as g } from "glob";
3
- import { resolve as C } from "path";
4
- import { t as _ } from "../funcSpanTransformer-S_WeAt_m.js";
5
- import { s as N } from "../runtimeConfig-CB57auSb.js";
6
- async function D(n = {}) {
1
+ import { readFileSync as N, writeFileSync as m } from "fs";
2
+ import { sync as _ } from "glob";
3
+ import { resolve as D } from "path";
4
+ import { t as T } from "../funcSpanTransformer-S_WeAt_m.js";
5
+ import { t as U } from "../consoleLocationTransformer-DZu_9MDA.js";
6
+ import { s as $ } from "../runtimeConfig-C4mv7SVM.js";
7
+ async function v(n = {}) {
7
8
  try {
8
- if (N()) return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation");
9
+ if ($()) return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation");
9
10
  } catch {
10
11
  }
11
- const { outDir: d = "dist", include: S = ["**/*.js"], exclude: f = ["**/*.test.js", "**/*.spec.js", "**/__tests__/**"], projectRoot: t = process.cwd(), includeNodeModules: F = [], debug: c = !1 } = n, i = C(t, d);
12
- console.log("[FuncSpan TSC] Starting post-build function instrumentation..."), console.log(`[FuncSpan TSC] Output directory: ${i}`), console.log(`[FuncSpan TSC] Project root: ${t}`);
13
- const r = [];
14
- for (const o of S) {
15
- const s = g(o, { cwd: i, absolute: !0, ignore: f });
16
- r.push(...s);
12
+ const { outDir: F = "dist", include: g = ["**/*.js"], exclude: C = ["**/*.test.js", "**/*.spec.js", "**/__tests__/**"], projectRoot: s = process.cwd(), includeNodeModules: l = [], debug: c = !1 } = n, p = D(s, F);
13
+ console.log("[FuncSpan TSC] Starting post-build function instrumentation..."), console.log(`[FuncSpan TSC] Output directory: ${p}`), console.log(`[FuncSpan TSC] Project root: ${s}`);
14
+ const i = [];
15
+ for (const o of g) {
16
+ const e = _(o, { cwd: p, absolute: !0, ignore: C });
17
+ i.push(...e);
17
18
  }
18
- console.log(`[FuncSpan TSC] Found ${r.length} JavaScript files to process`);
19
- let u = 0, a = 0;
20
- for (const o of r) try {
21
- const s = m(o, "utf-8"), e = await _(s, o, { projectRoot: t, includeNodeModules: F, debug: c });
22
- if (e.modified) {
23
- if (l(o, e.code, "utf-8"), e.map) {
24
- const p = `${o}.map`;
25
- l(p, JSON.stringify(e.map), "utf-8"), c && console.log(`[FuncSpan TSC] Generated source map: ${p}`);
19
+ console.log(`[FuncSpan TSC] Found ${i.length} JavaScript files to process`);
20
+ let d = 0, S = 0;
21
+ for (const o of i) try {
22
+ let e = N(o, "utf-8"), r = null, u = !1;
23
+ const t = await T(e, o, { projectRoot: s, includeNodeModules: l, debug: c });
24
+ t.modified && (e = t.code, r = t.map, u = !0);
25
+ const a = await U(e, o, { projectRoot: s, includeNodeModules: l, debug: c });
26
+ if (a.modified && (e = a.code, r = a.map, u = !0), u) {
27
+ if (m(o, e, "utf-8"), r) {
28
+ const f = `${o}.map`;
29
+ m(f, JSON.stringify(r), "utf-8"), c && console.log(`[FuncSpan TSC] Generated source map: ${f}`);
26
30
  }
27
- u++, a += e.functionsWrapped, c && console.log(`[FuncSpan TSC] Modified: ${o} (${e.functionsWrapped} functions)`);
31
+ d++, S += t.functionsWrapped, c && console.log(`[FuncSpan TSC] Modified: ${o} (${t.functionsWrapped} functions)`);
28
32
  }
29
- } catch (s) {
30
- console.error(`[FuncSpan TSC] Error processing ${o}:`, s);
33
+ } catch (e) {
34
+ console.error(`[FuncSpan TSC] Error processing ${o}:`, e);
31
35
  }
32
- console.log(`[FuncSpan TSC] ✅ Completed: Modified ${u} files, wrapped ${a} functions`);
36
+ console.log(`[FuncSpan TSC] ✅ Completed: Modified ${d} files, wrapped ${S} functions`);
33
37
  }
34
- async function T() {
38
+ async function y() {
35
39
  const n = { outDir: process.env.SF_FUNCSPAN_OUT_DIR || "dist", debug: process.env.SF_FUNCSPAN_DEBUG === "true", includeNodeModules: process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES ? process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES.split(",") : [] };
36
- await D(n);
40
+ await v(n);
37
41
  }
38
- require.main === module && T().catch((n) => {
42
+ require.main === module && y().catch((n) => {
39
43
  console.error("[FuncSpan TSC] Fatal error:", n), process.exit(1);
40
44
  });
41
45
  export {
42
- T as cli,
43
- D as processTscFiles
46
+ y as cli,
47
+ v as processTscFiles
44
48
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../funcSpanTransformer-D0W2t41q.cjs"),l=require("../runtimeConfig-sm_7bnKx.cjs");exports.funcspanVitePlugin=function(s={}){try{if(l.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Vite Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-vite-disabled"}}catch{}const{enabled:o=!0,includeNodeModules:t=[],debug:i=!1}=s;return{name:"sailfish-funcspan-vite",enforce:"pre",async transform(u,e){if(!o||!e.match(/\.(js|ts|jsx|tsx)$/)||e.startsWith("\0")||e.includes("node_modules")&&!t.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await r.transformFunctionSpans(u,e,{projectRoot:process.cwd(),includeNodeModules:t,debug:i});if(n.modified)return{code:n.code,map:null}}catch(n){i&&console.error(`[FuncSpan Vite] Error transforming ${e}:`,n)}return null}}};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../funcSpanTransformer-D0W2t41q.cjs"),a=require("../consoleLocationTransformer-BSSB5msZ.cjs"),f=require("../runtimeConfig-XIm4yAFB.cjs");exports.funcspanVitePlugin=function(l={}){try{if(f.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Vite Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-vite-disabled"}}catch{}const{enabled:c=!0,includeNodeModules:t=[],debug:o=!1}=l;return{name:"sailfish-funcspan-vite",enforce:"pre",async transform(s,e){if(!c||!e.match(/\.(js|ts|jsx|tsx)$/)||e.startsWith("\0")||e.includes("node_modules")&&!t.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{let n=s,i=!1;const u=await d.transformFunctionSpans(n,e,{projectRoot:process.cwd(),includeNodeModules:t,debug:o});u.modified&&(n=u.code,i=!0);const r=await a.transformConsoleLocations(n,e,{projectRoot:process.cwd(),includeNodeModules:t,debug:o});if(r.modified&&(n=r.code,i=!0),i)return{code:n,map:null}}catch(n){o&&console.error(`[FuncSpan Vite] Error transforming ${e}:`,n)}return null}}};
@@ -1,22 +1,26 @@
1
- import { t as o } from "../funcSpanTransformer-S_WeAt_m.js";
2
- import { s as l } from "../runtimeConfig-CB57auSb.js";
3
- function d(u = {}) {
1
+ import { t as d } from "../funcSpanTransformer-S_WeAt_m.js";
2
+ import { t as a } from "../consoleLocationTransformer-DZu_9MDA.js";
3
+ import { s as f } from "../runtimeConfig-C4mv7SVM.js";
4
+ function g(l = {}) {
4
5
  try {
5
- if (l()) return console.warn("[FuncSpan Vite Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-vite-disabled" };
6
+ if (f()) return console.warn("[FuncSpan Vite Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-vite-disabled" };
6
7
  } catch {
7
8
  }
8
- const { enabled: r = !0, includeNodeModules: t = [], debug: i = !1 } = u;
9
- return { name: "sailfish-funcspan-vite", enforce: "pre", async transform(s, n) {
10
- if (!r || !n.match(/\.(js|ts|jsx|tsx)$/) || n.startsWith("\0") || n.includes("node_modules") && !t.some((e) => n.includes(`node_modules/${e}`)) || n.includes("@sailfish-ai/sf-veritas") || n.includes("jsts-backend/dist")) return null;
9
+ const { enabled: c = !0, includeNodeModules: t = [], debug: i = !1 } = l;
10
+ return { name: "sailfish-funcspan-vite", enforce: "pre", async transform(o, e) {
11
+ if (!c || !e.match(/\.(js|ts|jsx|tsx)$/) || e.startsWith("\0") || e.includes("node_modules") && !t.some((n) => e.includes(`node_modules/${n}`)) || e.includes("@sailfish-ai/sf-veritas") || e.includes("jsts-backend/dist")) return null;
11
12
  try {
12
- const e = await o(s, n, { projectRoot: process.cwd(), includeNodeModules: t, debug: i });
13
- if (e.modified) return { code: e.code, map: null };
14
- } catch (e) {
15
- i && console.error(`[FuncSpan Vite] Error transforming ${n}:`, e);
13
+ let n = o, s = !1;
14
+ const u = await d(n, e, { projectRoot: process.cwd(), includeNodeModules: t, debug: i });
15
+ u.modified && (n = u.code, s = !0);
16
+ const r = await a(n, e, { projectRoot: process.cwd(), includeNodeModules: t, debug: i });
17
+ if (r.modified && (n = r.code, s = !0), s) return { code: n, map: null };
18
+ } catch (n) {
19
+ i && console.error(`[FuncSpan Vite] Error transforming ${e}:`, n);
16
20
  }
17
21
  return null;
18
22
  } };
19
23
  }
20
24
  export {
21
- d as funcspanVitePlugin
25
+ g as funcspanVitePlugin
22
26
  };
@@ -1 +1 @@
1
- "use strict";const I=require("../funcSpanTransformer-D0W2t41q.cjs"),M=require("@babel/parser"),x=require("@babel/traverse"),O=require("@babel/generator"),R=require("@babel/types"),z=require("path");function L(n){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const r in n)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(p,r,l.get?l:{enumerable:!0,get:()=>n[r]})}}return p.default=n,Object.freeze(p)}const e=L(R),C=x.default||x,N=O.default||O,Z=["lookup","lookupService","resolve","resolve4","resolve6","resolveAny","resolveCname","resolveMx","resolveNs","resolvePtr","resolveSoa","resolveSrv","resolveTxt","reverse","setServers","getServers"],A=["readFile","writeFile","appendFile","readdir","stat","lstat","mkdir","rmdir","unlink","rename","copyFile","open","close","read","write","access"],B=["pbkdf2","randomBytes","randomFill","scrypt"],G=["deflate","deflateRaw","gzip","gunzip","inflate","inflateRaw","unzip","brotliCompress","brotliDecompress"];module.exports=function(n){const p=this.async(),r=this.getOptions();(async()=>{try{let l=await I.transformFunctionSpans(n,this.resourcePath,{projectRoot:r.projectRoot||process.cwd(),includeNodeModules:r.includeNodeModules||[],debug:r.debug||!1}),m=l.modified?l.code:n,v=l.map;if(r.enableWorkerPoolTracking){const k=await(async function(g,W,D={}){const{projectRoot:q=process.cwd(),trackDns:h=!1,trackFs:w=!1,trackCrypto:j=!1,trackZlib:T=!1,debug:d=!1}=D;if(!(h||w||j||T))return{code:g,modified:!1,callsWrapped:0};const b=z.relative(q,W).replace(/\\/g,"/");let u;d&&console.log(`[WorkerPool Transform] Processing: ${b}`);try{u=M.parse(g,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy","classProperties","objectRestSpread","asyncGenerators","dynamicImport","optionalCatchBinding","optionalChaining","nullishCoalescingOperator"]})}catch(t){return d&&console.error(`[WorkerPool Transform] Parse error in ${b}:`,t),{code:g,modified:!1,callsWrapped:0}}let F=!1,y=0,S=!1;const P=new Map,c=new Map;if(h&&c.set("dns",Z),w&&c.set("fs",A),j&&c.set("crypto",B),T&&c.set("zlib",G),C(u,{VariableDeclarator(t){const o=t.node.init,i=t.node.id;if(o&&e.isCallExpression(o)&&e.isIdentifier(o.callee,{name:"require"})&&o.arguments.length===1&&e.isStringLiteral(o.arguments[0])){const s=o.arguments[0].value;for(const[a]of c)s!==a&&s!==`node:${a}`||e.isIdentifier(i)&&(P.set(i.name,a),d&&console.log(`[WorkerPool Transform] Found ${a} binding: ${i.name}`))}},ImportDeclaration(t){const o=t.node.source.value;for(const[i]of c)if(o===i||o===`node:${i}`){for(const s of t.node.specifiers)if(e.isImportDefaultSpecifier(s)||e.isImportNamespaceSpecifier(s)){const a=s.local.name;P.set(a,i),d&&console.log(`[WorkerPool Transform] Found ${i} import: ${a}`)}}}}),C(u,{CallExpression(t){const o=t.node.callee;if(e.isMemberExpression(o)&&e.isIdentifier(o.object)){const i=o.object.name,s=P.get(i);if(s&&c.has(s)){const a=c.get(s),f=e.isIdentifier(o.property)?o.property.name:null;if(f&&a.includes(f)){d&&console.log(`[WorkerPool Transform] Wrapping ${s}.${f}()`);const E=e.callExpression(e.identifier("captureWorkerPoolOperation"),[e.stringLiteral(s),e.stringLiteral(f),e.memberExpression(e.identifier(i),e.identifier(f)),e.arrayExpression(t.node.arguments),e.identifier(i)]);t.replaceWith(E),S=!0,y++,F=!0}}}}}),S){const t=e.variableDeclaration("const",[e.variableDeclarator(e.objectPattern([e.objectProperty(e.identifier("captureWorkerPoolOperation"),e.identifier("captureWorkerPoolOperation"),!1,!0)]),e.callExpression(e.identifier("require"),[e.stringLiteral("@sailfish-ai/sf-veritas/worker-pool-capture")]))]);u.program.body.length>0&&u.program.body.unshift(t),d&&console.log("[WorkerPool Transform] Added captureWorkerPoolOperation import")}if(!F)return{code:g,modified:!1,callsWrapped:0};const $=N(u,{sourceMaps:!0,sourceFileName:W});return d&&console.log(`[WorkerPool Transform] Wrapped ${y} calls in ${b}`),{code:$.code,map:$.map,modified:!0,callsWrapped:y}})(m,this.resourcePath,{projectRoot:r.projectRoot||process.cwd(),trackDns:r.workerPoolTrackDns||!1,trackFs:r.workerPoolTrackFs||!1,trackCrypto:r.workerPoolTrackCrypto||!1,trackZlib:r.workerPoolTrackZlib||!1,debug:r.debug||!1});k.modified&&(m=k.code,v=k.map)}m!==n?p(null,m,v):p(null,n)}catch(l){r.debug&&console.error(`[FuncSpan Webpack Loader] Error transforming ${this.resourcePath}:`,l),p(null,n)}})()};
1
+ "use strict";const q=require("../funcSpanTransformer-D0W2t41q.cjs"),E=require("@babel/parser"),C=require("@babel/traverse"),x=require("@babel/generator"),I=require("@babel/types"),L=require("path"),N=require("../consoleLocationTransformer-BSSB5msZ.cjs");function z(n){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const r in n)if(r!=="default"){const c=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(d,r,c.get?c:{enumerable:!0,get:()=>n[r]})}}return d.default=n,Object.freeze(d)}const e=z(I),O=C.default||C,Z=x.default||x,A=["lookup","lookupService","resolve","resolve4","resolve6","resolveAny","resolveCname","resolveMx","resolveNs","resolvePtr","resolveSoa","resolveSrv","resolveTxt","reverse","setServers","getServers"],B=["readFile","writeFile","appendFile","readdir","stat","lstat","mkdir","rmdir","unlink","rename","copyFile","open","close","read","write","access"],G=["pbkdf2","randomBytes","randomFill","scrypt"],V=["deflate","deflateRaw","gzip","gunzip","inflate","inflateRaw","unzip","brotliCompress","brotliDecompress"];module.exports=function(n){const d=this.async(),r=this.getOptions();(async()=>{try{let c=await q.transformFunctionSpans(n,this.resourcePath,{projectRoot:r.projectRoot||process.cwd(),includeNodeModules:r.includeNodeModules||[],debug:r.debug||!1}),f=c.modified?c.code:n,k=c.map;if(r.enableWorkerPoolTracking){const p=await(async function(b,h,D={}){const{projectRoot:M=process.cwd(),trackDns:W=!1,trackFs:w=!1,trackCrypto:j=!1,trackZlib:T=!1,debug:u=!1}=D;if(!(W||w||j||T))return{code:b,modified:!1,callsWrapped:0};const P=L.relative(M,h).replace(/\\/g,"/");let m;u&&console.log(`[WorkerPool Transform] Processing: ${P}`);try{m=E.parse(b,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy","classProperties","objectRestSpread","asyncGenerators","dynamicImport","optionalCatchBinding","optionalChaining","nullishCoalescingOperator"]})}catch(t){return u&&console.error(`[WorkerPool Transform] Parse error in ${P}:`,t),{code:b,modified:!1,callsWrapped:0}}let F=!1,y=0,S=!1;const v=new Map,l=new Map;if(W&&l.set("dns",A),w&&l.set("fs",B),j&&l.set("crypto",G),T&&l.set("zlib",V),O(m,{VariableDeclarator(t){const o=t.node.init,i=t.node.id;if(o&&e.isCallExpression(o)&&e.isIdentifier(o.callee,{name:"require"})&&o.arguments.length===1&&e.isStringLiteral(o.arguments[0])){const s=o.arguments[0].value;for(const[a]of l)s!==a&&s!==`node:${a}`||e.isIdentifier(i)&&(v.set(i.name,a),u&&console.log(`[WorkerPool Transform] Found ${a} binding: ${i.name}`))}},ImportDeclaration(t){const o=t.node.source.value;for(const[i]of l)if(o===i||o===`node:${i}`){for(const s of t.node.specifiers)if(e.isImportDefaultSpecifier(s)||e.isImportNamespaceSpecifier(s)){const a=s.local.name;v.set(a,i),u&&console.log(`[WorkerPool Transform] Found ${i} import: ${a}`)}}}}),O(m,{CallExpression(t){const o=t.node.callee;if(e.isMemberExpression(o)&&e.isIdentifier(o.object)){const i=o.object.name,s=v.get(i);if(s&&l.has(s)){const a=l.get(s),g=e.isIdentifier(o.property)?o.property.name:null;if(g&&a.includes(g)){u&&console.log(`[WorkerPool Transform] Wrapping ${s}.${g}()`);const R=e.callExpression(e.identifier("captureWorkerPoolOperation"),[e.stringLiteral(s),e.stringLiteral(g),e.memberExpression(e.identifier(i),e.identifier(g)),e.arrayExpression(t.node.arguments),e.identifier(i)]);t.replaceWith(R),S=!0,y++,F=!0}}}}}),S){const t=e.variableDeclaration("const",[e.variableDeclarator(e.objectPattern([e.objectProperty(e.identifier("captureWorkerPoolOperation"),e.identifier("captureWorkerPoolOperation"),!1,!0)]),e.callExpression(e.identifier("require"),[e.stringLiteral("@sailfish-ai/sf-veritas/worker-pool-capture")]))]);m.program.body.length>0&&m.program.body.unshift(t),u&&console.log("[WorkerPool Transform] Added captureWorkerPoolOperation import")}if(!F)return{code:b,modified:!1,callsWrapped:0};const $=Z(m,{sourceMaps:!0,sourceFileName:h});return u&&console.log(`[WorkerPool Transform] Wrapped ${y} calls in ${P}`),{code:$.code,map:$.map,modified:!0,callsWrapped:y}})(f,this.resourcePath,{projectRoot:r.projectRoot||process.cwd(),trackDns:r.workerPoolTrackDns||!1,trackFs:r.workerPoolTrackFs||!1,trackCrypto:r.workerPoolTrackCrypto||!1,trackZlib:r.workerPoolTrackZlib||!1,debug:r.debug||!1});p.modified&&(f=p.code,k=p.map)}if(r.enableConsoleLocationTracking!==!1){const p=await N.transformConsoleLocations(f,this.resourcePath,{projectRoot:r.projectRoot||process.cwd(),includeNodeModules:r.includeNodeModules||[],debug:r.debug||!1});p.modified&&(f=p.code,k=p.map)}f!==n?d(null,f,k):d(null,n)}catch(c){r.debug&&console.error(`[FuncSpan Webpack Loader] Error transforming ${this.resourcePath}:`,c),d(null,n)}})()};
@@ -1,72 +1,77 @@
1
- import { t as M } from "../funcSpanTransformer-S_WeAt_m.js";
2
- import { parse as O } from "@babel/parser";
1
+ import { t as I } from "../funcSpanTransformer-S_WeAt_m.js";
2
+ import { parse as N } from "@babel/parser";
3
3
  import C from "@babel/traverse";
4
- import S from "@babel/generator";
4
+ import R from "@babel/generator";
5
5
  import * as e from "@babel/types";
6
6
  import { relative as L } from "path";
7
- const D = C.default || C, N = S.default || S, z = ["lookup", "lookupService", "resolve", "resolve4", "resolve6", "resolveAny", "resolveCname", "resolveMx", "resolveNs", "resolvePtr", "resolveSoa", "resolveSrv", "resolveTxt", "reverse", "setServers", "getServers"], Z = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "mkdir", "rmdir", "unlink", "rename", "copyFile", "open", "close", "read", "write", "access"], q = ["pbkdf2", "randomBytes", "randomFill", "scrypt"], A = ["deflate", "deflateRaw", "gzip", "gunzip", "inflate", "inflateRaw", "unzip", "brotliCompress", "brotliDecompress"];
8
- function K(p) {
9
- const g = this.async(), s = this.getOptions();
7
+ import { t as O } from "../consoleLocationTransformer-DZu_9MDA.js";
8
+ const S = C.default || C, z = R.default || R, Z = ["lookup", "lookupService", "resolve", "resolve4", "resolve6", "resolveAny", "resolveCname", "resolveMx", "resolveNs", "resolvePtr", "resolveSoa", "resolveSrv", "resolveTxt", "reverse", "setServers", "getServers"], q = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "mkdir", "rmdir", "unlink", "rename", "copyFile", "open", "close", "read", "write", "access"], A = ["pbkdf2", "randomBytes", "randomFill", "scrypt"], B = ["deflate", "deflateRaw", "gzip", "gunzip", "inflate", "inflateRaw", "unzip", "brotliCompress", "brotliDecompress"];
9
+ function U(m) {
10
+ const k = this.async(), o = this.getOptions();
10
11
  (async () => {
11
12
  try {
12
- let d = await M(p, this.resourcePath, { projectRoot: s.projectRoot || process.cwd(), includeNodeModules: s.includeNodeModules || [], debug: s.debug || !1 }), m = d.modified ? d.code : p, v = d.map;
13
- if (s.enableWorkerPoolTracking) {
14
- const k = await (async function(u, W, E = {}) {
15
- const { projectRoot: I = process.cwd(), trackDns: h = !1, trackFs: w = !1, trackCrypto: T = !1, trackZlib: $ = !1, debug: l = !1 } = E;
16
- if (!(h || w || T || $)) return { code: u, modified: !1, callsWrapped: 0 };
17
- const b = L(I, W).replace(/\\/g, "/");
18
- let c;
19
- l && console.log(`[WorkerPool Transform] Processing: ${b}`);
13
+ let f = await I(m, this.resourcePath, { projectRoot: o.projectRoot || process.cwd(), includeNodeModules: o.includeNodeModules || [], debug: o.debug || !1 }), p = f.modified ? f.code : m, b = f.map;
14
+ if (o.enableWorkerPoolTracking) {
15
+ const l = await (async function(g, h, D = {}) {
16
+ const { projectRoot: M = process.cwd(), trackDns: W = !1, trackFs: w = !1, trackCrypto: T = !1, trackZlib: j = !1, debug: c = !1 } = D;
17
+ if (!(W || w || T || j)) return { code: g, modified: !1, callsWrapped: 0 };
18
+ const P = L(M, h).replace(/\\/g, "/");
19
+ let d;
20
+ c && console.log(`[WorkerPool Transform] Processing: ${P}`);
20
21
  try {
21
- c = O(u, { sourceType: "module", plugins: ["typescript", "jsx", "decorators-legacy", "classProperties", "objectRestSpread", "asyncGenerators", "dynamicImport", "optionalCatchBinding", "optionalChaining", "nullishCoalescingOperator"] });
22
- } catch (o) {
23
- return l && console.error(`[WorkerPool Transform] Parse error in ${b}:`, o), { code: u, modified: !1, callsWrapped: 0 };
22
+ d = N(g, { sourceType: "module", plugins: ["typescript", "jsx", "decorators-legacy", "classProperties", "objectRestSpread", "asyncGenerators", "dynamicImport", "optionalCatchBinding", "optionalChaining", "nullishCoalescingOperator"] });
23
+ } catch (t) {
24
+ return c && console.error(`[WorkerPool Transform] Parse error in ${P}:`, t), { code: g, modified: !1, callsWrapped: 0 };
24
25
  }
25
- let F = !1, P = 0, j = !1;
26
- const y = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
27
- if (h && n.set("dns", z), w && n.set("fs", Z), T && n.set("crypto", q), $ && n.set("zlib", A), D(c, { VariableDeclarator(o) {
28
- const r = o.node.init, t = o.node.id;
26
+ let $ = !1, y = 0, F = !1;
27
+ const v = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
28
+ if (W && n.set("dns", Z), w && n.set("fs", q), T && n.set("crypto", A), j && n.set("zlib", B), S(d, { VariableDeclarator(t) {
29
+ const r = t.node.init, i = t.node.id;
29
30
  if (r && e.isCallExpression(r) && e.isIdentifier(r.callee, { name: "require" }) && r.arguments.length === 1 && e.isStringLiteral(r.arguments[0])) {
30
- const i = r.arguments[0].value;
31
- for (const [a] of n) i !== a && i !== `node:${a}` || e.isIdentifier(t) && (y.set(t.name, a), l && console.log(`[WorkerPool Transform] Found ${a} binding: ${t.name}`));
31
+ const s = r.arguments[0].value;
32
+ for (const [a] of n) s !== a && s !== `node:${a}` || e.isIdentifier(i) && (v.set(i.name, a), c && console.log(`[WorkerPool Transform] Found ${a} binding: ${i.name}`));
32
33
  }
33
- }, ImportDeclaration(o) {
34
- const r = o.node.source.value;
35
- for (const [t] of n) if (r === t || r === `node:${t}`) {
36
- for (const i of o.node.specifiers) if (e.isImportDefaultSpecifier(i) || e.isImportNamespaceSpecifier(i)) {
37
- const a = i.local.name;
38
- y.set(a, t), l && console.log(`[WorkerPool Transform] Found ${t} import: ${a}`);
34
+ }, ImportDeclaration(t) {
35
+ const r = t.node.source.value;
36
+ for (const [i] of n) if (r === i || r === `node:${i}`) {
37
+ for (const s of t.node.specifiers) if (e.isImportDefaultSpecifier(s) || e.isImportNamespaceSpecifier(s)) {
38
+ const a = s.local.name;
39
+ v.set(a, i), c && console.log(`[WorkerPool Transform] Found ${i} import: ${a}`);
39
40
  }
40
41
  }
41
- } }), D(c, { CallExpression(o) {
42
- const r = o.node.callee;
42
+ } }), S(d, { CallExpression(t) {
43
+ const r = t.node.callee;
43
44
  if (e.isMemberExpression(r) && e.isIdentifier(r.object)) {
44
- const t = r.object.name, i = y.get(t);
45
- if (i && n.has(i)) {
46
- const a = n.get(i), f = e.isIdentifier(r.property) ? r.property.name : null;
47
- if (f && a.includes(f)) {
48
- l && console.log(`[WorkerPool Transform] Wrapping ${i}.${f}()`);
49
- const R = e.callExpression(e.identifier("captureWorkerPoolOperation"), [e.stringLiteral(i), e.stringLiteral(f), e.memberExpression(e.identifier(t), e.identifier(f)), e.arrayExpression(o.node.arguments), e.identifier(t)]);
50
- o.replaceWith(R), j = !0, P++, F = !0;
45
+ const i = r.object.name, s = v.get(i);
46
+ if (s && n.has(s)) {
47
+ const a = n.get(s), u = e.isIdentifier(r.property) ? r.property.name : null;
48
+ if (u && a.includes(u)) {
49
+ c && console.log(`[WorkerPool Transform] Wrapping ${s}.${u}()`);
50
+ const E = e.callExpression(e.identifier("captureWorkerPoolOperation"), [e.stringLiteral(s), e.stringLiteral(u), e.memberExpression(e.identifier(i), e.identifier(u)), e.arrayExpression(t.node.arguments), e.identifier(i)]);
51
+ t.replaceWith(E), F = !0, y++, $ = !0;
51
52
  }
52
53
  }
53
54
  }
54
- } }), j) {
55
- const o = e.variableDeclaration("const", [e.variableDeclarator(e.objectPattern([e.objectProperty(e.identifier("captureWorkerPoolOperation"), e.identifier("captureWorkerPoolOperation"), !1, !0)]), e.callExpression(e.identifier("require"), [e.stringLiteral("@sailfish-ai/sf-veritas/worker-pool-capture")]))]);
56
- c.program.body.length > 0 && c.program.body.unshift(o), l && console.log("[WorkerPool Transform] Added captureWorkerPoolOperation import");
55
+ } }), F) {
56
+ const t = e.variableDeclaration("const", [e.variableDeclarator(e.objectPattern([e.objectProperty(e.identifier("captureWorkerPoolOperation"), e.identifier("captureWorkerPoolOperation"), !1, !0)]), e.callExpression(e.identifier("require"), [e.stringLiteral("@sailfish-ai/sf-veritas/worker-pool-capture")]))]);
57
+ d.program.body.length > 0 && d.program.body.unshift(t), c && console.log("[WorkerPool Transform] Added captureWorkerPoolOperation import");
57
58
  }
58
- if (!F) return { code: u, modified: !1, callsWrapped: 0 };
59
- const x = N(c, { sourceMaps: !0, sourceFileName: W });
60
- return l && console.log(`[WorkerPool Transform] Wrapped ${P} calls in ${b}`), { code: x.code, map: x.map, modified: !0, callsWrapped: P };
61
- })(m, this.resourcePath, { projectRoot: s.projectRoot || process.cwd(), trackDns: s.workerPoolTrackDns || !1, trackFs: s.workerPoolTrackFs || !1, trackCrypto: s.workerPoolTrackCrypto || !1, trackZlib: s.workerPoolTrackZlib || !1, debug: s.debug || !1 });
62
- k.modified && (m = k.code, v = k.map);
59
+ if (!$) return { code: g, modified: !1, callsWrapped: 0 };
60
+ const x = z(d, { sourceMaps: !0, sourceFileName: h });
61
+ return c && console.log(`[WorkerPool Transform] Wrapped ${y} calls in ${P}`), { code: x.code, map: x.map, modified: !0, callsWrapped: y };
62
+ })(p, this.resourcePath, { projectRoot: o.projectRoot || process.cwd(), trackDns: o.workerPoolTrackDns || !1, trackFs: o.workerPoolTrackFs || !1, trackCrypto: o.workerPoolTrackCrypto || !1, trackZlib: o.workerPoolTrackZlib || !1, debug: o.debug || !1 });
63
+ l.modified && (p = l.code, b = l.map);
63
64
  }
64
- m !== p ? g(null, m, v) : g(null, p);
65
- } catch (d) {
66
- s.debug && console.error(`[FuncSpan Webpack Loader] Error transforming ${this.resourcePath}:`, d), g(null, p);
65
+ if (o.enableConsoleLocationTracking !== !1) {
66
+ const l = await O(p, this.resourcePath, { projectRoot: o.projectRoot || process.cwd(), includeNodeModules: o.includeNodeModules || [], debug: o.debug || !1 });
67
+ l.modified && (p = l.code, b = l.map);
68
+ }
69
+ p !== m ? k(null, p, b) : k(null, m);
70
+ } catch (f) {
71
+ o.debug && console.error(`[FuncSpan Webpack Loader] Error transforming ${this.resourcePath}:`, f), k(null, m);
67
72
  }
68
73
  })();
69
74
  }
70
75
  export {
71
- K as default
76
+ U as default
72
77
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("../runtimeConfig-sm_7bnKx.cjs"),a=require("path"),P=require("url");function m(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(o,n,t.get?t:{enumerable:!0,get:()=>r[n]})}}return o.default=r,Object.freeze(o)}const f=m(a);class u{options;constructor(o={}){this.options={enabled:!0,includeNodeModules:[],debug:!1,enableWorkerPoolTracking:!1,workerPoolTrackDns:!1,workerPoolTrackFs:!1,workerPoolTrackCrypto:!1,workerPoolTrackZlib:!1,...o}}apply(o){try{if(b.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan Webpack Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{enabled:n,includeNodeModules:t,debug:c}=this.options;if(!n)return;const l="FuncspanWebpackPlugin";o.hooks.compilation.tap(l,s=>{s.hooks.buildModule.tap(l,i=>{i.resource&&i.resource.match(/\.(js|ts|jsx|tsx)$/)&&(!i.resource.includes("node_modules")||t?.some(e=>i.resource.includes(`node_modules/${e}`)))}),o.webpack.NormalModule.getCompilationHooks(s).loader.tap(l,(i,e)=>{if(!e.resource||!e.resource.match(/\.(js|ts|jsx|tsx)$/)||e.resource.includes("node_modules")&&!t?.some(p=>e.resource.includes(`node_modules/${p}`)))return;const d=typeof __dirname<"u"?__dirname:a.dirname(P.fileURLToPath(require("node:url").pathToFileURL(__filename).href)),k=f.join(d,"funcspanWebpackLoader.cjs");e.loaders.push({loader:k,options:{projectRoot:o.context,includeNodeModules:t,debug:c,enableWorkerPoolTracking:this.options.enableWorkerPoolTracking,workerPoolTrackDns:this.options.workerPoolTrackDns,workerPoolTrackFs:this.options.workerPoolTrackFs,workerPoolTrackCrypto:this.options.workerPoolTrackCrypto,workerPoolTrackZlib:this.options.workerPoolTrackZlib}})})}),c&&console.log("[FuncSpan Webpack] Plugin initialized")}}exports.FuncspanWebpackPlugin=u,exports.default=u;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("../runtimeConfig-XIm4yAFB.cjs"),a=require("path"),P=require("url");function m(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(o,n,t.get?t:{enumerable:!0,get:()=>r[n]})}}return o.default=r,Object.freeze(o)}const f=m(a);class u{options;constructor(o={}){this.options={enabled:!0,includeNodeModules:[],debug:!1,enableWorkerPoolTracking:!1,workerPoolTrackDns:!1,workerPoolTrackFs:!1,workerPoolTrackCrypto:!1,workerPoolTrackZlib:!1,...o}}apply(o){try{if(b.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan Webpack Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{enabled:n,includeNodeModules:t,debug:c}=this.options;if(!n)return;const l="FuncspanWebpackPlugin";o.hooks.compilation.tap(l,s=>{s.hooks.buildModule.tap(l,i=>{i.resource&&i.resource.match(/\.(js|ts|jsx|tsx)$/)&&(!i.resource.includes("node_modules")||t?.some(e=>i.resource.includes(`node_modules/${e}`)))}),o.webpack.NormalModule.getCompilationHooks(s).loader.tap(l,(i,e)=>{if(!e.resource||!e.resource.match(/\.(js|ts|jsx|tsx)$/)||e.resource.includes("node_modules")&&!t?.some(p=>e.resource.includes(`node_modules/${p}`)))return;const d=typeof __dirname<"u"?__dirname:a.dirname(P.fileURLToPath(require("node:url").pathToFileURL(__filename).href)),k=f.join(d,"funcspanWebpackLoader.cjs");e.loaders.push({loader:k,options:{projectRoot:o.context,includeNodeModules:t,debug:c,enableWorkerPoolTracking:this.options.enableWorkerPoolTracking,workerPoolTrackDns:this.options.workerPoolTrackDns,workerPoolTrackFs:this.options.workerPoolTrackFs,workerPoolTrackCrypto:this.options.workerPoolTrackCrypto,workerPoolTrackZlib:this.options.workerPoolTrackZlib}})})}),c&&console.log("[FuncSpan Webpack] Plugin initialized")}}exports.FuncspanWebpackPlugin=u,exports.default=u;
@@ -1,7 +1,7 @@
1
1
  var k = Object.defineProperty;
2
2
  var m = (r, o, s) => o in r ? k(r, o, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[o] = s;
3
3
  var c = (r, o, s) => m(r, typeof o != "symbol" ? o + "" : o, s);
4
- import { s as b } from "../runtimeConfig-CB57auSb.js";
4
+ import { s as b } from "../runtimeConfig-C4mv7SVM.js";
5
5
  import * as P from "path";
6
6
  import { dirname as T } from "path";
7
7
  import { fileURLToPath as f } from "url";