@sailfish-ai/sf-veritas 0.2.5 → 0.2.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.
@@ -1 +1 @@
1
- "use strict";const s=require("../funcSpanTransformer-TjdooSrw.cjs");module.exports=function(t){const r=this.async(),e=this.getOptions();(async()=>{try{const o=await s.transformFunctionSpans(t,this.resourcePath,{projectRoot:e.projectRoot||process.cwd(),includeNodeModules:e.includeNodeModules||[],debug:e.debug||!1});o.modified?r(null,o.code,o.map):r(null,t)}catch(o){e.debug&&console.error(`[FuncSpan Webpack Loader] Error transforming ${this.resourcePath}:`,o),r(null,t)}})()};
1
+ "use strict";const I=require("../funcSpanTransformer-TjdooSrw.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,15 +1,72 @@
1
- import { t as s } from "../funcSpanTransformer-sqmZLAcs.js";
2
- function n(t) {
3
- const r = this.async(), e = this.getOptions();
1
+ import { t as M } from "../funcSpanTransformer-sqmZLAcs.js";
2
+ import { parse as O } from "@babel/parser";
3
+ import C from "@babel/traverse";
4
+ import S from "@babel/generator";
5
+ import * as e from "@babel/types";
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();
4
10
  (async () => {
5
11
  try {
6
- const o = await s(t, this.resourcePath, { projectRoot: e.projectRoot || process.cwd(), includeNodeModules: e.includeNodeModules || [], debug: e.debug || !1 });
7
- o.modified ? r(null, o.code, o.map) : r(null, t);
8
- } catch (o) {
9
- e.debug && console.error(`[FuncSpan Webpack Loader] Error transforming ${this.resourcePath}:`, o), r(null, t);
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}`);
20
+ 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 };
24
+ }
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;
29
+ 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}`));
32
+ }
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}`);
39
+ }
40
+ }
41
+ } }), D(c, { CallExpression(o) {
42
+ const r = o.node.callee;
43
+ 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;
51
+ }
52
+ }
53
+ }
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");
57
+ }
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);
63
+ }
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);
10
67
  }
11
68
  })();
12
69
  }
13
70
  export {
14
- n as default
71
+ K as default
15
72
  };
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var j=(o,e,n)=>e in o?g(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n;var i=(o,e,n)=>j(o,typeof e!="symbol"?e+"":e,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),_=require("url");var c=typeof document<"u"?document.currentScript:null;function h(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const n in o)if(n!=="default"){const u=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(e,n,u.get?u:{enumerable:!0,get:()=>o[n]})}}return e.default=o,Object.freeze(e)}const k=h(p);class a{constructor(e={}){i(this,"options");this.options={enabled:!0,includeNodeModules:[],debug:!1,...e}}apply(e){const{enabled:n,includeNodeModules:u,debug:d}=this.options;if(!n)return;const s="FuncspanWebpackPlugin";e.hooks.compilation.tap(s,l=>{l.hooks.buildModule.tap(s,r=>{r.resource&&r.resource.match(/\.(js|ts|jsx|tsx)$/)&&(!r.resource.includes("node_modules")||u?.some(t=>r.resource.includes(`node_modules/${t}`)))}),e.webpack.NormalModule.getCompilationHooks(l).loader.tap(s,(r,t)=>{if(!t.resource||!t.resource.match(/\.(js|ts|jsx|tsx)$/)||t.resource.includes("node_modules")&&!u?.some(b=>t.resource.includes(`node_modules/${b}`)))return;const f=typeof __dirname<"u"?__dirname:p.dirname(_.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:c&&c.tagName.toUpperCase()==="SCRIPT"&&c.src||new URL("plugins/funcspanWebpackPlugin.cjs",document.baseURI).href)),m=k.join(f,"funcspanWebpackLoader.cjs");t.loaders.push({loader:m,options:{projectRoot:e.context,includeNodeModules:u,debug:d}})})}),d&&console.log("[FuncSpan Webpack] Plugin initialized")}}exports.FuncspanWebpackPlugin=a,exports.default=a;
1
+ "use strict";var P=Object.defineProperty;var m=(o,e,r)=>e in o?P(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var a=(o,e,r)=>m(o,typeof e!="symbol"?e+"":e,r);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("path"),g=require("url");var l=typeof document<"u"?document.currentScript:null;function T(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const t=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(e,r,t.get?t:{enumerable:!0,get:()=>o[r]})}}return e.default=o,Object.freeze(e)}const h=T(p);class d{constructor(e={}){a(this,"options");this.options={enabled:!0,includeNodeModules:[],debug:!1,enableWorkerPoolTracking:!1,workerPoolTrackDns:!1,workerPoolTrackFs:!1,workerPoolTrackCrypto:!1,workerPoolTrackZlib:!1,...e}}apply(e){const{enabled:r,includeNodeModules:t,debug:u}=this.options;if(!r)return;const c="FuncspanWebpackPlugin";e.hooks.compilation.tap(c,i=>{i.hooks.buildModule.tap(c,s=>{s.resource&&s.resource.match(/\.(js|ts|jsx|tsx)$/)&&(!s.resource.includes("node_modules")||t?.some(n=>s.resource.includes(`node_modules/${n}`)))}),e.webpack.NormalModule.getCompilationHooks(i).loader.tap(c,(s,n)=>{if(!n.resource||!n.resource.match(/\.(js|ts|jsx|tsx)$/)||n.resource.includes("node_modules")&&!t?.some(f=>n.resource.includes(`node_modules/${f}`)))return;const k=typeof __dirname<"u"?__dirname:p.dirname(g.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:l&&l.tagName.toUpperCase()==="SCRIPT"&&l.src||new URL("plugins/funcspanWebpackPlugin.cjs",document.baseURI).href)),b=h.join(k,"funcspanWebpackLoader.cjs");n.loaders.push({loader:b,options:{projectRoot:e.context,includeNodeModules:t,debug:u,enableWorkerPoolTracking:this.options.enableWorkerPoolTracking,workerPoolTrackDns:this.options.workerPoolTrackDns,workerPoolTrackFs:this.options.workerPoolTrackFs,workerPoolTrackCrypto:this.options.workerPoolTrackCrypto,workerPoolTrackZlib:this.options.workerPoolTrackZlib}})})}),u&&console.log("[FuncSpan Webpack] Plugin initialized")}}exports.FuncspanWebpackPlugin=d,exports.default=d;
@@ -1,30 +1,30 @@
1
- var m = Object.defineProperty;
2
- var f = (s, e, n) => e in s ? m(s, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : s[e] = n;
3
- var a = (s, e, n) => f(s, typeof e != "symbol" ? e + "" : e, n);
4
- import * as b from "path";
5
- import { dirname as g } from "path";
6
- import { fileURLToPath as h } from "url";
7
- class x {
8
- constructor(e = {}) {
9
- a(this, "options");
10
- this.options = { enabled: !0, includeNodeModules: [], debug: !1, ...e };
1
+ var p = Object.defineProperty;
2
+ var m = (r, o, s) => o in r ? p(r, o, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[o] = s;
3
+ var i = (r, o, s) => m(r, typeof o != "symbol" ? o + "" : o, s);
4
+ import * as P from "path";
5
+ import { dirname as b } from "path";
6
+ import { fileURLToPath as T } from "url";
7
+ class g {
8
+ constructor(o = {}) {
9
+ i(this, "options");
10
+ this.options = { enabled: !0, includeNodeModules: [], debug: !1, enableWorkerPoolTracking: !1, workerPoolTrackDns: !1, workerPoolTrackFs: !1, workerPoolTrackCrypto: !1, workerPoolTrackZlib: !1, ...o };
11
11
  }
12
- apply(e) {
13
- const { enabled: n, includeNodeModules: r, debug: i } = this.options;
14
- if (!n) return;
15
- const t = "FuncspanWebpackPlugin";
16
- e.hooks.compilation.tap(t, (c) => {
17
- c.hooks.buildModule.tap(t, (u) => {
18
- u.resource && u.resource.match(/\.(js|ts|jsx|tsx)$/) && (!u.resource.includes("node_modules") || r?.some((o) => u.resource.includes(`node_modules/${o}`)));
19
- }), e.webpack.NormalModule.getCompilationHooks(c).loader.tap(t, (u, o) => {
20
- if (!o.resource || !o.resource.match(/\.(js|ts|jsx|tsx)$/) || o.resource.includes("node_modules") && !r?.some((p) => o.resource.includes(`node_modules/${p}`))) return;
21
- const d = typeof __dirname < "u" ? __dirname : g(h(import.meta.url)), l = b.join(d, "funcspanWebpackLoader.cjs");
22
- o.loaders.push({ loader: l, options: { projectRoot: e.context, includeNodeModules: r, debug: i } });
12
+ apply(o) {
13
+ const { enabled: s, includeNodeModules: l, debug: t } = this.options;
14
+ if (!s) return;
15
+ const a = "FuncspanWebpackPlugin";
16
+ o.hooks.compilation.tap(a, (c) => {
17
+ c.hooks.buildModule.tap(a, (n) => {
18
+ n.resource && n.resource.match(/\.(js|ts|jsx|tsx)$/) && (!n.resource.includes("node_modules") || l?.some((e) => n.resource.includes(`node_modules/${e}`)));
19
+ }), o.webpack.NormalModule.getCompilationHooks(c).loader.tap(a, (n, e) => {
20
+ if (!e.resource || !e.resource.match(/\.(js|ts|jsx|tsx)$/) || e.resource.includes("node_modules") && !l?.some((k) => e.resource.includes(`node_modules/${k}`))) return;
21
+ const u = typeof __dirname < "u" ? __dirname : b(T(import.meta.url)), d = P.join(u, "funcspanWebpackLoader.cjs");
22
+ e.loaders.push({ loader: d, options: { projectRoot: o.context, includeNodeModules: l, debug: t, enableWorkerPoolTracking: this.options.enableWorkerPoolTracking, workerPoolTrackDns: this.options.workerPoolTrackDns, workerPoolTrackFs: this.options.workerPoolTrackFs, workerPoolTrackCrypto: this.options.workerPoolTrackCrypto, workerPoolTrackZlib: this.options.workerPoolTrackZlib } });
23
23
  });
24
- }), i && console.log("[FuncSpan Webpack] Plugin initialized");
24
+ }), t && console.log("[FuncSpan Webpack] Plugin initialized");
25
25
  }
26
26
  }
27
27
  export {
28
- x as FuncspanWebpackPlugin,
29
- x as default
28
+ g as FuncspanWebpackPlugin,
29
+ g as default
30
30
  };