@sailfish-ai/sf-veritas 0.2.7 → 0.2.9

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 (40) hide show
  1. package/dist/contextManager-CEPhVu9T.js +197 -0
  2. package/dist/contextManager-CGINtRN5.cjs +1 -0
  3. package/dist/funcSpanTransformer-B9WWl-g1.cjs +1 -0
  4. package/dist/funcSpanTransformer-CWNEWRxq.js +225 -0
  5. package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
  6. package/dist/plugins/funcspanEsbuildPlugin.mjs +17 -11
  7. package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
  8. package/dist/plugins/funcspanRollupPlugin.mjs +13 -8
  9. package/dist/plugins/funcspanTscPlugin.cjs +1 -1
  10. package/dist/plugins/funcspanTscPlugin.mjs +19 -14
  11. package/dist/plugins/funcspanVitePlugin.cjs +1 -1
  12. package/dist/plugins/funcspanVitePlugin.mjs +15 -10
  13. package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
  14. package/dist/plugins/funcspanWebpackLoader.mjs +1 -1
  15. package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
  16. package/dist/plugins/funcspanWebpackPlugin.mjs +22 -17
  17. package/dist/runtime/funcspanRegister.cjs +276 -0
  18. package/dist/runtimeConfig-CpQ27dZD.cjs +8 -0
  19. package/dist/runtimeConfig-emBNO3lJ.js +350 -0
  20. package/dist/sf-veritas.cjs +18 -18
  21. package/dist/sf-veritas.mjs +417 -619
  22. package/dist/source-map-Cr6YkjTd.js +631 -0
  23. package/dist/source-map-rHHEdpre.cjs +1 -0
  24. package/dist/types/dataTransmitter.d.ts +1 -0
  25. package/dist/types/funcSpanConfigLoader.d.ts +10 -0
  26. package/dist/types/index.d.ts +3 -1
  27. package/dist/types/logHandler.d.ts +5 -0
  28. package/dist/types/plugins/funcSpanTransformer.d.ts +13 -0
  29. package/dist/types/runtime/instrumentationDetector.d.ts +33 -0
  30. package/dist/types/runtime/runtimeConfig.d.ts +48 -0
  31. package/dist/types/sourceLocation.d.ts +30 -0
  32. package/dist/worker-pool-capture.cjs +1 -1
  33. package/dist/worker-pool-capture.mjs +1 -1
  34. package/dist/workerPoolSpanCapture-B5KN-q4b.js +528 -0
  35. package/dist/workerPoolSpanCapture-Dg_WGjmO.cjs +86 -0
  36. package/package.json +5 -2
  37. package/dist/funcSpanTransformer-BLhIRZqX.js +0 -765
  38. package/dist/funcSpanTransformer-BpWuHXKT.cjs +0 -1
  39. package/dist/workerPoolSpanCapture-D0-0Z0Jw.js +0 -718
  40. package/dist/workerPoolSpanCapture-DEwlTq0a.cjs +0 -86
@@ -0,0 +1,197 @@
1
+ var L = Object.defineProperty;
2
+ var _ = (n, e, t) => e in n ? L(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var r = (n, e, t) => _(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { AsyncLocalStorage as T } from "async_hooks";
5
+ const a = [];
6
+ for (let n = 0; n < 256; ++n) a.push((n + 256).toString(16).slice(1));
7
+ let C;
8
+ const U = new Uint8Array(16), f = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
9
+ function l(n, e, t) {
10
+ if (f.randomUUID && !n) return f.randomUUID();
11
+ const o = (n = n || {}).random ?? n.rng?.() ?? (function() {
12
+ if (!C) {
13
+ if (typeof crypto > "u" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
14
+ C = crypto.getRandomValues.bind(crypto);
15
+ }
16
+ return C(U);
17
+ })();
18
+ if (o.length < 16) throw new Error("Random bytes length must be >= 16");
19
+ return o[6] = 15 & o[6] | 64, o[8] = 63 & o[8] | 128, (function(i, s = 0) {
20
+ return (a[i[s + 0]] + a[i[s + 1]] + a[i[s + 2]] + a[i[s + 3]] + "-" + a[i[s + 4]] + a[i[s + 5]] + "-" + a[i[s + 6]] + a[i[s + 7]] + "-" + a[i[s + 8]] + a[i[s + 9]] + "-" + a[i[s + 10]] + a[i[s + 11]] + a[i[s + 12]] + a[i[s + 13]] + a[i[s + 14]] + a[i[s + 15]]).toLowerCase();
21
+ })(o);
22
+ }
23
+ class b {
24
+ constructor(e) {
25
+ r(this, "apiKey");
26
+ r(this, "apiGraphqlEndpoint");
27
+ r(this, "sfDebug");
28
+ r(this, "serviceIdentifier");
29
+ r(this, "serviceVersion");
30
+ r(this, "serviceUUID");
31
+ r(this, "serviceAdditionalMetadata");
32
+ r(this, "profilingModeEnabled");
33
+ r(this, "profilingMaxDepth");
34
+ r(this, "profilingMaxVariableSizeKb");
35
+ r(this, "domainsToNotPropagateHeadersTo");
36
+ r(this, "nodeModulesToCollectLocalVariablesOn");
37
+ r(this, "printConfigurationStatuses");
38
+ r(this, "logLevel");
39
+ r(this, "stackDepthLocals");
40
+ r(this, "stackDepthCodeTraceDepth");
41
+ r(this, "packageLibraryType");
42
+ r(this, "version");
43
+ r(this, "gitSha");
44
+ r(this, "_serviceIdentificationReceived", !1);
45
+ this.apiKey = e.apiKey, this.apiGraphqlEndpoint = e?.apiGraphqlEndpoint || process.env.SAILFISH_GRAPHQL_ENDPOINT || "https://api-service.sailfishqa.com/graphql/", this.sfDebug = e?.debug === !0 || process.env.SF_DEBUG === "true", this.serviceIdentifier = e?.serviceIdentifier || process.env.SERVICE_IDENTIFIER, this.serviceUUID = l(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.gitSha = e?.gitSha || process.env.GIT_SHA || process.env.VERCEL_GIT_COMMIT_SHA, this.serviceAdditionalMetadata = e?.serviceAdditionalMetadata || {}, this.profilingModeEnabled = e?.profilingModeEnabled ?? !1, this.profilingMaxDepth = e?.profilingMaxDepth ?? 5, this.profilingMaxVariableSizeKb = e?.profilingMaxVariableSizeKb ?? 25, this.domainsToNotPropagateHeadersTo = e?.domainsToNotPropagateHeadersTo || [], this.nodeModulesToCollectLocalVariablesOn = e?.nodeModulesToCollectLocalVariablesOn || ["_all_"], this.printConfigurationStatuses = process.env.PRINT_CONFIGURATION_STATUSES || "true", this.logLevel = process.env.LOG_LEVEL || "INFO", this.stackDepthLocals = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS, 10) : 5, isNaN(this.stackDepthLocals) && (this.stackDepthLocals = -1), this.stackDepthCodeTraceDepth = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH, 10) : -1, isNaN(this.stackDepthCodeTraceDepth) && (this.stackDepthCodeTraceDepth = -1), this.packageLibraryType = "JS/TS BACKEND", this.version = this.getPackageVersion();
46
+ }
47
+ getPackageVersion() {
48
+ return "0.1.15";
49
+ }
50
+ get serviceIdentificationReceived() {
51
+ return this._serviceIdentificationReceived;
52
+ }
53
+ setServiceIdentificationReceived(e) {
54
+ this._serviceIdentificationReceived = e;
55
+ }
56
+ }
57
+ const x = Symbol.for("sailfish.sf_config");
58
+ function m() {
59
+ return globalThis[x];
60
+ }
61
+ function P(n) {
62
+ const e = m();
63
+ if (e) return { config: e };
64
+ const t = new b(n);
65
+ return (function(o) {
66
+ globalThis[x] = o;
67
+ })(t), t.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", t), { config: t };
68
+ }
69
+ function I() {
70
+ const n = m();
71
+ if (!n) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
72
+ return n;
73
+ }
74
+ const D = Symbol.for("sf.ctx.storeAls"), c = globalThis, S = c[D] ?? (c[D] = new T()), y = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], E = Symbol.for("sf.ctx.als"), p = c[E] ?? (c[E] = new T()), v = Symbol.for("sf.ctx.sessionRegistry"), u = c[v] ?? (c[v] = /* @__PURE__ */ new Map()), g = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(y), supportedDomains: /* @__PURE__ */ new Set() }, d = class d {
75
+ constructor() {
76
+ }
77
+ current() {
78
+ return S.getStore();
79
+ }
80
+ ensureStore() {
81
+ const e = this.current();
82
+ if (e) return e;
83
+ const t = /* @__PURE__ */ new Map();
84
+ return S.enterWith(t), t;
85
+ }
86
+ runWith(e, t) {
87
+ const o = this.current() ?? /* @__PURE__ */ new Map(), i = new Map(o);
88
+ for (const [s, A] of Object.entries(e)) i.set(s, A);
89
+ return S.run(i, t);
90
+ }
91
+ static getInstance() {
92
+ return c[d.GLOBAL_MANAGER_SYMBOL] || (c[d.GLOBAL_MANAGER_SYMBOL] = new d()), c[d.GLOBAL_MANAGER_SYMBOL];
93
+ }
94
+ getCurrentContext() {
95
+ return p.getStore() || g;
96
+ }
97
+ setCurrentContext(e) {
98
+ const t = p.getStore() || g;
99
+ p.enterWith({ ...t, ...e });
100
+ }
101
+ ensureSession(e) {
102
+ let t = u.get(e);
103
+ return t || (t = { ...g }, u.set(e, t)), t;
104
+ }
105
+ getContextFor(e) {
106
+ return u.get(e) ?? g;
107
+ }
108
+ updateContextFor(e, t) {
109
+ const o = this.ensureSession(e);
110
+ u.set(e, { ...o, ...t });
111
+ }
112
+ runWithSession(e, t) {
113
+ const o = { ...this.ensureSession(e) };
114
+ return p.run(o, t);
115
+ }
116
+ deleteSession(e) {
117
+ u.delete(e);
118
+ }
119
+ getTraceId() {
120
+ return this.getCurrentContext().traceId;
121
+ }
122
+ getPageVisitUUID() {
123
+ return this.getCurrentContext().pageVisitUUID;
124
+ }
125
+ setTraceId(e) {
126
+ this.setCurrentContext({ traceId: e });
127
+ }
128
+ setPageVisitUUID(e) {
129
+ this.setCurrentContext({ pageVisitUUID: e });
130
+ }
131
+ getCurrentFunctionSpanId() {
132
+ return this.getCurrentContext().currentFunctionSpanId;
133
+ }
134
+ setCurrentFunctionSpanId(e) {
135
+ this.setCurrentContext({ currentFunctionSpanId: e });
136
+ }
137
+ clearCurrentFunctionSpanId() {
138
+ this.setCurrentContext({ currentFunctionSpanId: void 0 });
139
+ }
140
+ getOrSetSfTraceId(e, t = !1) {
141
+ let o = this.getTraceId();
142
+ return o || (o = e || (t ? l() : `nonsession-applogs-v3/${I().apiKey}/${l()}`), this.setTraceId(o), I().sfDebug && console.log(" Created new trace ID:", o), o);
143
+ }
144
+ getOrSetPageVisitUUID() {
145
+ let e = this.getPageVisitUUID();
146
+ return e || (e = l(), this.setPageVisitUUID(e), I().sfDebug && console.log(" Created new page visit UUID:", e), e);
147
+ }
148
+ getHandledExceptions() {
149
+ return this.getCurrentContext().handledExceptions;
150
+ }
151
+ markExceptionHandled(e) {
152
+ const t = this.getHandledExceptions();
153
+ t.add(e), this.setCurrentContext({ handledExceptions: t });
154
+ }
155
+ hasHandledException(e) {
156
+ return this.getHandledExceptions().has(e);
157
+ }
158
+ resetHandledExceptions() {
159
+ this.setCurrentContext({ handledExceptions: /* @__PURE__ */ new Set() });
160
+ }
161
+ getExcludedDomains() {
162
+ return this.getCurrentContext().excludedDomains;
163
+ }
164
+ getSupportedDomains() {
165
+ return this.getCurrentContext().supportedDomains;
166
+ }
167
+ addSupportedDomains(e) {
168
+ this.getCurrentContext().supportedDomains.add(e.toLowerCase().trim());
169
+ }
170
+ setTraceIdFor(e, t) {
171
+ this.updateContextFor(e, { traceId: t });
172
+ }
173
+ setPageVisitUUIDFor(e, t) {
174
+ this.updateContextFor(e, { pageVisitUUID: t });
175
+ }
176
+ };
177
+ r(d, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
178
+ let h = d;
179
+ function V(n) {
180
+ const e = { ...h.getInstance().getCurrentContext() };
181
+ p.run(e, () => {
182
+ n();
183
+ });
184
+ }
185
+ function w() {
186
+ return h.getInstance().getCurrentFunctionSpanId();
187
+ }
188
+ export {
189
+ h as C,
190
+ y as D,
191
+ m as a,
192
+ w as b,
193
+ P as c,
194
+ I as g,
195
+ V as r,
196
+ l as v
197
+ };
@@ -0,0 +1 @@
1
+ "use strict";var m=Object.defineProperty;var U=(n,e,t)=>e in n?m(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>U(n,typeof e!="symbol"?e+"":e,t);const x=require("async_hooks"),a=[];for(let n=0;n<256;++n)a.push((n+256).toString(16).slice(1));let I;const b=new Uint8Array(16),D={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function g(n,e,t){if(D.randomUUID&&!n)return D.randomUUID();const i=(n=n||{}).random??n.rng?.()??(function(){if(!I){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");I=crypto.getRandomValues.bind(crypto)}return I(b)})();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,(function(o,s=0){return(a[o[s+0]]+a[o[s+1]]+a[o[s+2]]+a[o[s+3]]+"-"+a[o[s+4]]+a[o[s+5]]+"-"+a[o[s+6]]+a[o[s+7]]+"-"+a[o[s+8]]+a[o[s+9]]+"-"+a[o[s+10]]+a[o[s+11]]+a[o[s+12]]+a[o[s+13]]+a[o[s+14]]+a[o[s+15]]).toLowerCase()})(i)}class y{constructor(e){r(this,"apiKey");r(this,"apiGraphqlEndpoint");r(this,"sfDebug");r(this,"serviceIdentifier");r(this,"serviceVersion");r(this,"serviceUUID");r(this,"serviceAdditionalMetadata");r(this,"profilingModeEnabled");r(this,"profilingMaxDepth");r(this,"profilingMaxVariableSizeKb");r(this,"domainsToNotPropagateHeadersTo");r(this,"nodeModulesToCollectLocalVariablesOn");r(this,"printConfigurationStatuses");r(this,"logLevel");r(this,"stackDepthLocals");r(this,"stackDepthCodeTraceDepth");r(this,"packageLibraryType");r(this,"version");r(this,"gitSha");r(this,"_serviceIdentificationReceived",!1);this.apiKey=e.apiKey,this.apiGraphqlEndpoint=e?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=e?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=e?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=g(),this.serviceVersion=e?.serviceVersion||process.env.SERVICE_VERSION,this.gitSha=e?.gitSha||process.env.GIT_SHA||process.env.VERCEL_GIT_COMMIT_SHA,this.serviceAdditionalMetadata=e?.serviceAdditionalMetadata||{},this.profilingModeEnabled=e?.profilingModeEnabled??!1,this.profilingMaxDepth=e?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=e?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=e?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=e?.nodeModulesToCollectLocalVariablesOn||["_all_"],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="JS/TS BACKEND",this.version=this.getPackageVersion()}getPackageVersion(){return"0.1.15"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(e){this._serviceIdentificationReceived=e}}const A=Symbol.for("sailfish.sf_config");function f(){return globalThis[A]}function C(){const n=f();if(!n)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return n}const E=Symbol.for("sf.ctx.storeAls"),c=globalThis,S=c[E]??(c[E]=new x.AsyncLocalStorage),L=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],v=Symbol.for("sf.ctx.als"),p=c[v]??(c[v]=new x.AsyncLocalStorage),T=Symbol.for("sf.ctx.sessionRegistry"),u=c[T]??(c[T]=new Map),h={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(L),supportedDomains:new Set},d=class d{constructor(){}current(){return S.getStore()}ensureStore(){const e=this.current();if(e)return e;const t=new Map;return S.enterWith(t),t}runWith(e,t){const i=this.current()??new Map,o=new Map(i);for(const[s,_]of Object.entries(e))o.set(s,_);return S.run(o,t)}static getInstance(){return c[d.GLOBAL_MANAGER_SYMBOL]||(c[d.GLOBAL_MANAGER_SYMBOL]=new d),c[d.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return p.getStore()||h}setCurrentContext(e){const t=p.getStore()||h;p.enterWith({...t,...e})}ensureSession(e){let t=u.get(e);return t||(t={...h},u.set(e,t)),t}getContextFor(e){return u.get(e)??h}updateContextFor(e,t){const i=this.ensureSession(e);u.set(e,{...i,...t})}runWithSession(e,t){const i={...this.ensureSession(e)};return p.run(i,t)}deleteSession(e){u.delete(e)}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(e){this.setCurrentContext({traceId:e})}setPageVisitUUID(e){this.setCurrentContext({pageVisitUUID:e})}getCurrentFunctionSpanId(){return this.getCurrentContext().currentFunctionSpanId}setCurrentFunctionSpanId(e){this.setCurrentContext({currentFunctionSpanId:e})}clearCurrentFunctionSpanId(){this.setCurrentContext({currentFunctionSpanId:void 0})}getOrSetSfTraceId(e,t=!1){let i=this.getTraceId();return i||(i=e||(t?g():`nonsession-applogs-v3/${C().apiKey}/${g()}`),this.setTraceId(i),C().sfDebug&&console.log(" Created new trace ID:",i),i)}getOrSetPageVisitUUID(){let e=this.getPageVisitUUID();return e||(e=g(),this.setPageVisitUUID(e),C().sfDebug&&console.log(" Created new page visit UUID:",e),e)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(e){const t=this.getHandledExceptions();t.add(e),this.setCurrentContext({handledExceptions:t})}hasHandledException(e){return this.getHandledExceptions().has(e)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}getExcludedDomains(){return this.getCurrentContext().excludedDomains}getSupportedDomains(){return this.getCurrentContext().supportedDomains}addSupportedDomains(e){this.getCurrentContext().supportedDomains.add(e.toLowerCase().trim())}setTraceIdFor(e,t){this.updateContextFor(e,{traceId:t})}setPageVisitUUIDFor(e,t){this.updateContextFor(e,{pageVisitUUID:t})}};r(d,"GLOBAL_MANAGER_SYMBOL",Symbol.for("sf.ctx.manager"));let l=d;exports.ContextManager=l,exports.DEFAULT_DOMAINS_TO_EXCLUDE=L,exports.getConfig=C,exports.getCurrentFunctionSpanId=function(){return l.getInstance().getCurrentFunctionSpanId()},exports.getGlobalConfigUnsafe=f,exports.getOrCreateConfig=function(n){const e=f();if(e)return{config:e};const t=new y(n);return(function(i){globalThis[A]=i})(t),t.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",t),{config:t}},exports.runWithContext=function(n){const e={...l.getInstance().getCurrentContext()};p.run(e,()=>{n()})},exports.v4=g;
@@ -0,0 +1 @@
1
+ "use strict";const O=require("@babel/parser"),w=require("@babel/traverse"),C=require("@babel/generator"),K=require("@babel/types"),F=require("path"),R=require("fs"),z=require("./source-map-rHHEdpre.cjs");function V(d){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(d){for(const o in d)if(o!=="default"){const L=Object.getOwnPropertyDescriptor(d,o);Object.defineProperty(t,o,L.get?L:{enumerable:!0,get:()=>d[o]})}}return t.default=d,Object.freeze(t)}const e=V(K),W=new Set(["register","setupInterceptors","initializeConfigLoader","initializeWorkerPoolPatching"]),M=[/instrumentation\.(ts|js|tsx|jsx)$/,/unifiedInterceptor\.(ts|js)$/];let D=!1;const _=w.default||w,q=C.default||C;function $(d){const t=[];for(const o of d)e.isIdentifier(o)?t.push(o.name):e.isRestElement(o)&&e.isIdentifier(o.argument)?t.push(`...${o.argument.name}`):e.isAssignmentPattern(o)&&e.isIdentifier(o.left)?t.push(o.left.name):e.isObjectPattern(o)?t.push("{}"):e.isArrayPattern(o)?t.push("[]"):t.push("_");return t}function A(d){let t=!1;return _(d,{ImportDeclaration(o){e.isStringLiteral(o.node.source)&&o.node.source.value==="@sailfish-ai/sf-veritas"&&o.node.specifiers.some(L=>e.isImportSpecifier(L)&&e.isIdentifier(L.imported)&&L.imported.name==="captureFunctionSpan")&&(t=!0,o.stop())},VariableDeclarator(o){if(e.isObjectPattern(o.node.id)&&e.isCallExpression(o.node.init)&&e.isIdentifier(o.node.init.callee)&&o.node.init.callee.name==="require"){const L=o.node.init.arguments;L.length>0&&e.isStringLiteral(L[0])&&L[0].value==="@sailfish-ai/sf-veritas"&&o.node.id.properties.some(I=>e.isObjectProperty(I)&&e.isIdentifier(I.key)&&I.key.name==="captureFunctionSpan")&&(t=!0,o.stop())}}}),t}function G(d){let t=!1;return _(d,{CallExpression(o){e.isIdentifier(o.node.callee)&&o.node.callee.name==="require"&&(t=!0,o.stop())},MemberExpression(o){!e.isIdentifier(o.node.object)||o.node.object.name!=="module"&&o.node.object.name!=="exports"||(t=!0,o.stop())}}),t}exports.setSkipTypeScriptPlugin=function(d){D=d},exports.transformFunctionSpans=async function(d,t,o={}){const{projectRoot:L=process.cwd(),includeNodeModules:I=[],debug:u=!1}=o;if(t.includes("node_modules")&&!I.some(n=>t.includes(`node_modules/${n}`)))return{code:d,modified:!1,functionsWrapped:0};if(M.some(n=>n.test(t)))return u&&console.log(`[FuncSpan Transform] SKIPPING instrumentation entry point file: ${t}`),{code:d,modified:!1,functionsWrapped:0};const k=F.relative(L,t).replace(/\\/g,"/");let h;u&&console.log(`[FuncSpan Transform] Processing: ${k}`);try{h=O.parse(d,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy","classProperties","objectRestSpread","asyncGenerators","dynamicImport","optionalCatchBinding","optionalChaining","nullishCoalescingOperator"]})}catch(n){return u&&console.error(`[FuncSpan Transform] Parse error in ${k}:`,n),{code:d,modified:!1,functionsWrapped:0}}let v=null,T=null;try{const n=R.readFileSync(`${t}.map`,"utf-8");v=await new z.sourceMapExports.SourceMapConsumer(JSON.parse(n))}catch{}const E=(n,r)=>{if(v){const i=v.originalPositionFor({line:n,column:r});if(i.line!==null&&i.column!==null)return!T&&i.source&&(T=i.source),{line:i.line,column:i.column,source:i.source||void 0}}return{line:n,column:r}};let x=!1,S=0;const g=new Set;if(_(h,{FunctionDeclaration(n){const r=n.node.id?.name;if(!r)return;if(W.has(r))return void(u&&console.log(`[FuncSpan Transform] SKIPPING entry point function: ${r}`));const i=`decl_${r}`;if(g.has(i))return;u&&console.log(`[FuncSpan Transform] Wrapping function declaration: ${r}`);const s=n.node.loc?.start.line??0,a=n.node.loc?.start.column??0,l=E(s,a),{line:m,column:c}=l;let p=t;l.source&&(p=F.resolve(F.dirname(t),l.source)),!u||m===s&&c===a||console.log(`[FuncSpan Transform] Mapped ${s}:${a} → ${m}:${c} in ${p}`);const y=$(n.node.params),f=e.callExpression(e.identifier("captureFunctionSpan"),[e.identifier(r),e.stringLiteral(r),e.stringLiteral(p),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(m)),e.objectProperty(e.identifier("column"),e.numericLiteral(c)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(y.map(j=>e.stringLiteral(j))))])]),b=e.expressionStatement(e.assignmentExpression("=",e.identifier(r),f));n.insertAfter(b),x=!0,S++,g.add(i)},VariableDeclarator(n){const r=n.node.id,i=n.node.init;if(!e.isIdentifier(r)||!i||!e.isFunctionExpression(i)&&!e.isArrowFunctionExpression(i))return;const s=r.name;if(W.has(s))return void(u&&console.log(`[FuncSpan Transform] SKIPPING entry point function: ${s}`));const a=`var_${s}`;if(g.has(a))return;u&&console.log(`[FuncSpan Transform] Wrapping variable function: ${s}`);const l=i.loc?.start.line??0,m=i.loc?.start.column??0,c=E(l,m),{line:p,column:y}=c;let f=t;c.source&&(f=F.resolve(F.dirname(t),c.source)),!u||p===l&&y===m||console.log(`[FuncSpan Transform] Mapped ${l}:${m} → ${p}:${y} in ${f}`);const b=$(i.params),j=e.callExpression(e.identifier("captureFunctionSpan"),[i,e.stringLiteral(s),e.stringLiteral(f),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(p)),e.objectProperty(e.identifier("column"),e.numericLiteral(y)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(b.map(P=>e.stringLiteral(P))))])]);n.node.init=j,x=!0,S++,g.add(a)},ClassMethod(n){if(n.node.kind==="constructor"||n.node.kind==="get"||n.node.kind==="set")return;const r=e.isIdentifier(n.node.key)?n.node.key.name:"anonymous",i=`method_${r}_${n.node.start}`;if(g.has(i))return;u&&console.log(`[FuncSpan Transform] Wrapping class method: ${r}`);const s=n.node.loc?.start.line??0,a=n.node.loc?.start.column??0,l=E(s,a),{line:m,column:c}=l,p=t,y=$(n.node.params),f=n.node.body,b=e.functionExpression(null,n.node.params,f,n.node.generator,n.node.async),j=e.callExpression(e.identifier("captureFunctionSpan"),[b,e.stringLiteral(r),e.stringLiteral(p),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(m)),e.objectProperty(e.identifier("column"),e.numericLiteral(c)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(y.map(N=>e.stringLiteral(N))))])]),P=e.blockStatement([e.returnStatement(e.callExpression(e.memberExpression(j,e.identifier("call")),[e.thisExpression(),e.spreadElement(e.identifier("arguments"))]))]);n.node.body=P,x=!0,S++,g.add(i)},ObjectMethod(n){if(n.node.kind==="get"||n.node.kind==="set")return;const r=e.isIdentifier(n.node.key)?n.node.key.name:e.isStringLiteral(n.node.key)?n.node.key.value:"anonymous",i=`objmethod_${r}_${n.node.start}`;if(g.has(i))return;u&&console.log(`[FuncSpan Transform] Wrapping object method: ${r}`);const s=n.node.loc?.start.line??0,a=n.node.loc?.start.column??0,l=E(s,a),{line:m,column:c}=l;let p=t;l.source&&(p=F.resolve(F.dirname(t),l.source));const y=$(n.node.params),f=e.functionExpression(e.identifier(r),n.node.params,n.node.body,n.node.generator,n.node.async),b=e.callExpression(e.identifier("captureFunctionSpan"),[f,e.stringLiteral(r),e.stringLiteral(p),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(m)),e.objectProperty(e.identifier("column"),e.numericLiteral(c)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(y.map(P=>e.stringLiteral(P))))])]),j=e.objectProperty(n.node.key,b,n.node.computed,!1);n.replaceWith(j),x=!0,S++,g.add(i)},ClassProperty(n){const r=n.node.key,i=n.node.value;if(!e.isIdentifier(r)||!i||!e.isFunctionExpression(i)&&!e.isArrowFunctionExpression(i))return;const s=r.name,a=`classprop_${s}_${n.node.start}`;if(g.has(a))return;u&&console.log(`[FuncSpan Transform] Wrapping class property function: ${s}`);const l=i.loc?.start.line??0,m=i.loc?.start.column??0,c=E(l,m),{line:p,column:y}=c;let f=t;c.source&&(f=F.resolve(F.dirname(t),c.source));const b=$(i.params),j=e.callExpression(e.identifier("captureFunctionSpan"),[i,e.stringLiteral(s),e.stringLiteral(f),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(p)),e.objectProperty(e.identifier("column"),e.numericLiteral(y)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(b.map(P=>e.stringLiteral(P))))])]);n.node.value=j,x=!0,S++,g.add(a)},ObjectProperty(n){const r=n.node.key,i=n.node.value;if(!e.isIdentifier(r)&&!e.isStringLiteral(r)||!i||!e.isFunctionExpression(i)&&!e.isArrowFunctionExpression(i))return;const s=e.isIdentifier(r)?r.name:r.value,a=`objprop_${s}_${n.node.start}`;if(g.has(a))return;u&&console.log(`[FuncSpan Transform] Wrapping object property function: ${s}`);const l=i.loc?.start.line??0,m=i.loc?.start.column??0,c=E(l,m),{line:p,column:y}=c;let f=t;c.source&&(f=F.resolve(F.dirname(t),c.source));const b=$(i.params),j=e.callExpression(e.identifier("captureFunctionSpan"),[i,e.stringLiteral(s),e.stringLiteral(f),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(p)),e.objectProperty(e.identifier("column"),e.numericLiteral(y)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(b.map(P=>e.stringLiteral(P))))])]);n.node.value=j,x=!0,S++,g.add(a)}}),x&&!A(h))if(G(h)){const n=e.variableDeclaration("const",[e.variableDeclarator(e.objectPattern([e.objectProperty(e.identifier("captureFunctionSpan"),e.identifier("captureFunctionSpan"),!1,!0)]),e.callExpression(e.identifier("require"),[e.stringLiteral("@sailfish-ai/sf-veritas")]))]);h.program.body.unshift(n)}else{const n=e.importDeclaration([e.importSpecifier(e.identifier("captureFunctionSpan"),e.identifier("captureFunctionSpan"))],e.stringLiteral("@sailfish-ai/sf-veritas"));h.program.body.unshift(n)}if(S>0){const n=q(h,{retainLines:!0,compact:!1,sourceMaps:!0,sourceFileName:t},d);return u&&console.log(`[FuncSpan Transform] ✅ Wrapped ${S} functions in ${k}`),{code:n.code,map:n.map,modified:!0,functionsWrapped:S}}return{code:d,modified:!1,functionsWrapped:0}},exports.transformFunctionSpansSync=function(d,t,o={}){const{projectRoot:L=process.cwd(),includeNodeModules:I=[],debug:u=!1,parseAsJavaScript:k=!1}=o;if(t.includes("node_modules")&&!I.some(n=>t.includes(`node_modules/${n}`)))return{code:d,modified:!1,functionsWrapped:0};if(M.some(n=>n.test(t)))return u&&console.log(`[FuncSpan Transform] SKIPPING instrumentation entry point file: ${t}`),{code:d,modified:!1,functionsWrapped:0};const h=F.relative(L,t).replace(/\\/g,"/");let v;u&&console.log(`[FuncSpan Transform] Processing: ${h}`);const T=["jsx","decorators-legacy","classProperties","objectRestSpread","asyncGenerators","dynamicImport","optionalCatchBinding","optionalChaining","nullishCoalescingOperator"];D||k||T.unshift("typescript");try{v=O.parse(d,{sourceType:"module",plugins:T})}catch(n){return u&&console.error(`[FuncSpan Transform] Parse error in ${h}:`,n),{code:d,modified:!1,functionsWrapped:0}}const E=(n,r)=>({line:n,column:r});let x=!1,S=0;const g=new Set;if(_(v,{FunctionDeclaration(n){const r=n.node.id?.name;if(!r)return;if(W.has(r))return void(u&&console.log(`[FuncSpan Transform] SKIPPING entry point function: ${r}`));const i=`decl_${r}`;if(g.has(i))return;u&&console.log(`[FuncSpan Transform] Wrapping function declaration: ${r}`);const s=n.node.loc?.start.line??0,a=n.node.loc?.start.column??0,l=E(s,a),{line:m,column:c}=l,p=t,y=$(n.node.params),f=e.callExpression(e.identifier("captureFunctionSpan"),[e.identifier(r),e.stringLiteral(r),e.stringLiteral(p),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(m)),e.objectProperty(e.identifier("column"),e.numericLiteral(c)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(y.map(j=>e.stringLiteral(j))))])]),b=e.expressionStatement(e.assignmentExpression("=",e.identifier(r),f));n.insertAfter(b),x=!0,S++,g.add(i)},VariableDeclarator(n){const r=n.node.id,i=n.node.init;if(!e.isIdentifier(r)||!i||!e.isFunctionExpression(i)&&!e.isArrowFunctionExpression(i))return;const s=r.name;if(W.has(s))return void(u&&console.log(`[FuncSpan Transform] SKIPPING entry point function: ${s}`));const a=`var_${s}`;if(g.has(a))return;u&&console.log(`[FuncSpan Transform] Wrapping variable function: ${s}`);const l=i.loc?.start.line??0,m=i.loc?.start.column??0,c=E(l,m),{line:p,column:y}=c,f=t,b=$(i.params),j=e.callExpression(e.identifier("captureFunctionSpan"),[i,e.stringLiteral(s),e.stringLiteral(f),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(p)),e.objectProperty(e.identifier("column"),e.numericLiteral(y)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(b.map(P=>e.stringLiteral(P))))])]);n.node.init=j,x=!0,S++,g.add(a)},ClassMethod(n){if(n.node.kind==="constructor"||n.node.kind==="get"||n.node.kind==="set")return;const r=e.isIdentifier(n.node.key)?n.node.key.name:"anonymous",i=`method_${r}_${n.node.start}`;if(g.has(i))return;u&&console.log(`[FuncSpan Transform] Wrapping class method: ${r}`);const s=n.node.loc?.start.line??0,a=n.node.loc?.start.column??0,l=E(s,a),{line:m,column:c}=l,p=t,y=$(n.node.params),f=n.node.body,b=e.functionExpression(null,n.node.params,f,n.node.generator,n.node.async),j=e.callExpression(e.identifier("captureFunctionSpan"),[b,e.stringLiteral(r),e.stringLiteral(p),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(m)),e.objectProperty(e.identifier("column"),e.numericLiteral(c)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(y.map(N=>e.stringLiteral(N))))])]),P=e.blockStatement([e.returnStatement(e.callExpression(e.memberExpression(j,e.identifier("call")),[e.thisExpression(),e.spreadElement(e.identifier("arguments"))]))]);n.node.body=P,x=!0,S++,g.add(i)},ObjectMethod(n){if(n.node.kind==="get"||n.node.kind==="set")return;const r=e.isIdentifier(n.node.key)?n.node.key.name:e.isStringLiteral(n.node.key)?n.node.key.value:"anonymous",i=`objmethod_${r}_${n.node.start}`;if(g.has(i))return;u&&console.log(`[FuncSpan Transform] Wrapping object method: ${r}`);const s=n.node.loc?.start.line??0,a=n.node.loc?.start.column??0,l=E(s,a),{line:m,column:c}=l,p=t,y=$(n.node.params),f=e.functionExpression(e.identifier(r),n.node.params,n.node.body,n.node.generator,n.node.async),b=e.callExpression(e.identifier("captureFunctionSpan"),[f,e.stringLiteral(r),e.stringLiteral(p),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(m)),e.objectProperty(e.identifier("column"),e.numericLiteral(c)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(y.map(P=>e.stringLiteral(P))))])]),j=e.objectProperty(n.node.key,b,n.node.computed,!1);n.replaceWith(j),x=!0,S++,g.add(i)},ClassProperty(n){const r=n.node.key,i=n.node.value;if(!e.isIdentifier(r)||!i||!e.isFunctionExpression(i)&&!e.isArrowFunctionExpression(i))return;const s=r.name,a=`classprop_${s}_${n.node.start}`;if(g.has(a))return;u&&console.log(`[FuncSpan Transform] Wrapping class property function: ${s}`);const l=i.loc?.start.line??0,m=i.loc?.start.column??0,c=E(l,m),{line:p,column:y}=c,f=t,b=$(i.params),j=e.callExpression(e.identifier("captureFunctionSpan"),[i,e.stringLiteral(s),e.stringLiteral(f),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(p)),e.objectProperty(e.identifier("column"),e.numericLiteral(y)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(b.map(P=>e.stringLiteral(P))))])]);n.node.value=j,x=!0,S++,g.add(a)},ObjectProperty(n){const r=n.node.key,i=n.node.value;if(!e.isIdentifier(r)&&!e.isStringLiteral(r)||!i||!e.isFunctionExpression(i)&&!e.isArrowFunctionExpression(i))return;const s=e.isIdentifier(r)?r.name:r.value,a=`objprop_${s}_${n.node.start}`;if(g.has(a))return;u&&console.log(`[FuncSpan Transform] Wrapping object property function: ${s}`);const l=i.loc?.start.line??0,m=i.loc?.start.column??0,c=E(l,m),{line:p,column:y}=c,f=t,b=$(i.params),j=e.callExpression(e.identifier("captureFunctionSpan"),[i,e.stringLiteral(s),e.stringLiteral(f),e.objectExpression([e.objectProperty(e.identifier("line"),e.numericLiteral(p)),e.objectProperty(e.identifier("column"),e.numericLiteral(y)),e.objectProperty(e.identifier("paramNames"),e.arrayExpression(b.map(P=>e.stringLiteral(P))))])]);n.node.value=j,x=!0,S++,g.add(a)}}),x&&!A(v))if(G(v)){const n=e.variableDeclaration("const",[e.variableDeclarator(e.objectPattern([e.objectProperty(e.identifier("captureFunctionSpan"),e.identifier("captureFunctionSpan"),!1,!0)]),e.callExpression(e.identifier("require"),[e.stringLiteral("@sailfish-ai/sf-veritas")]))]);v.program.body.unshift(n)}else{const n=e.importDeclaration([e.importSpecifier(e.identifier("captureFunctionSpan"),e.identifier("captureFunctionSpan"))],e.stringLiteral("@sailfish-ai/sf-veritas"));v.program.body.unshift(n)}if(S>0){const n=q(v,{retainLines:!0,compact:!1,sourceMaps:!0,sourceFileName:t},d);return u&&console.log(`[FuncSpan Transform] ✅ Wrapped ${S} functions in ${h}`),{code:n.code,map:n.map,modified:!0,functionsWrapped:S}}return{code:d,modified:!1,functionsWrapped:0}};
@@ -0,0 +1,225 @@
1
+ import { parse as M } from "@babel/parser";
2
+ import w from "@babel/traverse";
3
+ import D from "@babel/generator";
4
+ import * as e from "@babel/types";
5
+ import { relative as A, resolve as T, dirname as W } from "path";
6
+ import { readFileSync as V } from "fs";
7
+ import { s as z } from "./source-map-Cr6YkjTd.js";
8
+ const _ = /* @__PURE__ */ new Set(["register", "setupInterceptors", "initializeConfigLoader", "initializeWorkerPoolPatching"]), O = [/instrumentation\.(ts|js|tsx|jsx)$/, /unifiedInterceptor\.(ts|js)$/];
9
+ let G = !1;
10
+ function Y(j) {
11
+ G = j;
12
+ }
13
+ const N = w.default || w, K = D.default || D;
14
+ async function Z(j, t, s = {}) {
15
+ const { projectRoot: F = process.cwd(), includeNodeModules: I = [], debug: d = !1 } = s;
16
+ if (t.includes("node_modules") && !I.some((n) => t.includes(`node_modules/${n}`))) return { code: j, modified: !1, functionsWrapped: 0 };
17
+ if (O.some((n) => n.test(t))) return d && console.log(`[FuncSpan Transform] SKIPPING instrumentation entry point file: ${t}`), { code: j, modified: !1, functionsWrapped: 0 };
18
+ const v = A(F, t).replace(/\\/g, "/");
19
+ let $;
20
+ d && console.log(`[FuncSpan Transform] Processing: ${v}`);
21
+ try {
22
+ $ = M(j, { sourceType: "module", plugins: ["typescript", "jsx", "decorators-legacy", "classProperties", "objectRestSpread", "asyncGenerators", "dynamicImport", "optionalCatchBinding", "optionalChaining", "nullishCoalescingOperator"] });
23
+ } catch (n) {
24
+ return d && console.error(`[FuncSpan Transform] Parse error in ${v}:`, n), { code: j, modified: !1, functionsWrapped: 0 };
25
+ }
26
+ let h = null, k = null;
27
+ try {
28
+ const n = V(`${t}.map`, "utf-8");
29
+ h = await new z.SourceMapConsumer(JSON.parse(n));
30
+ } catch {
31
+ }
32
+ const P = (n, r) => {
33
+ if (h) {
34
+ const i = h.originalPositionFor({ line: n, column: r });
35
+ if (i.line !== null && i.column !== null) return !k && i.source && (k = i.source), { line: i.line, column: i.column, source: i.source || void 0 };
36
+ }
37
+ return { line: n, column: r };
38
+ };
39
+ let L = !1, S = 0;
40
+ const f = /* @__PURE__ */ new Set();
41
+ if (N($, { FunctionDeclaration(n) {
42
+ const r = n.node.id?.name;
43
+ if (!r) return;
44
+ if (_.has(r)) return void (d && console.log(`[FuncSpan Transform] SKIPPING entry point function: ${r}`));
45
+ const i = `decl_${r}`;
46
+ if (f.has(i)) return;
47
+ d && console.log(`[FuncSpan Transform] Wrapping function declaration: ${r}`);
48
+ const o = n.node.loc?.start.line ?? 0, a = n.node.loc?.start.column ?? 0, l = P(o, a), { line: u, column: c } = l;
49
+ let p = t;
50
+ l.source && (p = T(W(t), l.source)), !d || u === o && c === a || console.log(`[FuncSpan Transform] Mapped ${o}:${a} → ${u}:${c} in ${p}`);
51
+ const g = E(n.node.params), m = e.callExpression(e.identifier("captureFunctionSpan"), [e.identifier(r), e.stringLiteral(r), e.stringLiteral(p), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(u)), e.objectProperty(e.identifier("column"), e.numericLiteral(c)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(g.map((b) => e.stringLiteral(b))))])]), y = e.expressionStatement(e.assignmentExpression("=", e.identifier(r), m));
52
+ n.insertAfter(y), L = !0, S++, f.add(i);
53
+ }, VariableDeclarator(n) {
54
+ const r = n.node.id, i = n.node.init;
55
+ if (!e.isIdentifier(r) || !i || !e.isFunctionExpression(i) && !e.isArrowFunctionExpression(i)) return;
56
+ const o = r.name;
57
+ if (_.has(o)) return void (d && console.log(`[FuncSpan Transform] SKIPPING entry point function: ${o}`));
58
+ const a = `var_${o}`;
59
+ if (f.has(a)) return;
60
+ d && console.log(`[FuncSpan Transform] Wrapping variable function: ${o}`);
61
+ const l = i.loc?.start.line ?? 0, u = i.loc?.start.column ?? 0, c = P(l, u), { line: p, column: g } = c;
62
+ let m = t;
63
+ c.source && (m = T(W(t), c.source)), !d || p === l && g === u || console.log(`[FuncSpan Transform] Mapped ${l}:${u} → ${p}:${g} in ${m}`);
64
+ const y = E(i.params), b = e.callExpression(e.identifier("captureFunctionSpan"), [i, e.stringLiteral(o), e.stringLiteral(m), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(p)), e.objectProperty(e.identifier("column"), e.numericLiteral(g)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(y.map((x) => e.stringLiteral(x))))])]);
65
+ n.node.init = b, L = !0, S++, f.add(a);
66
+ }, ClassMethod(n) {
67
+ if (n.node.kind === "constructor" || n.node.kind === "get" || n.node.kind === "set") return;
68
+ const r = e.isIdentifier(n.node.key) ? n.node.key.name : "anonymous", i = `method_${r}_${n.node.start}`;
69
+ if (f.has(i)) return;
70
+ d && console.log(`[FuncSpan Transform] Wrapping class method: ${r}`);
71
+ const o = n.node.loc?.start.line ?? 0, a = n.node.loc?.start.column ?? 0, l = P(o, a), { line: u, column: c } = l, p = t, g = E(n.node.params), m = n.node.body, y = e.functionExpression(null, n.node.params, m, n.node.generator, n.node.async), b = e.callExpression(e.identifier("captureFunctionSpan"), [y, e.stringLiteral(r), e.stringLiteral(p), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(u)), e.objectProperty(e.identifier("column"), e.numericLiteral(c)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(g.map((C) => e.stringLiteral(C))))])]), x = e.blockStatement([e.returnStatement(e.callExpression(e.memberExpression(b, e.identifier("call")), [e.thisExpression(), e.spreadElement(e.identifier("arguments"))]))]);
72
+ n.node.body = x, L = !0, S++, f.add(i);
73
+ }, ObjectMethod(n) {
74
+ if (n.node.kind === "get" || n.node.kind === "set") return;
75
+ const r = e.isIdentifier(n.node.key) ? n.node.key.name : e.isStringLiteral(n.node.key) ? n.node.key.value : "anonymous", i = `objmethod_${r}_${n.node.start}`;
76
+ if (f.has(i)) return;
77
+ d && console.log(`[FuncSpan Transform] Wrapping object method: ${r}`);
78
+ const o = n.node.loc?.start.line ?? 0, a = n.node.loc?.start.column ?? 0, l = P(o, a), { line: u, column: c } = l;
79
+ let p = t;
80
+ l.source && (p = T(W(t), l.source));
81
+ const g = E(n.node.params), m = e.functionExpression(e.identifier(r), n.node.params, n.node.body, n.node.generator, n.node.async), y = e.callExpression(e.identifier("captureFunctionSpan"), [m, e.stringLiteral(r), e.stringLiteral(p), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(u)), e.objectProperty(e.identifier("column"), e.numericLiteral(c)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(g.map((x) => e.stringLiteral(x))))])]), b = e.objectProperty(n.node.key, y, n.node.computed, !1);
82
+ n.replaceWith(b), L = !0, S++, f.add(i);
83
+ }, ClassProperty(n) {
84
+ const r = n.node.key, i = n.node.value;
85
+ if (!e.isIdentifier(r) || !i || !e.isFunctionExpression(i) && !e.isArrowFunctionExpression(i)) return;
86
+ const o = r.name, a = `classprop_${o}_${n.node.start}`;
87
+ if (f.has(a)) return;
88
+ d && console.log(`[FuncSpan Transform] Wrapping class property function: ${o}`);
89
+ const l = i.loc?.start.line ?? 0, u = i.loc?.start.column ?? 0, c = P(l, u), { line: p, column: g } = c;
90
+ let m = t;
91
+ c.source && (m = T(W(t), c.source));
92
+ const y = E(i.params), b = e.callExpression(e.identifier("captureFunctionSpan"), [i, e.stringLiteral(o), e.stringLiteral(m), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(p)), e.objectProperty(e.identifier("column"), e.numericLiteral(g)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(y.map((x) => e.stringLiteral(x))))])]);
93
+ n.node.value = b, L = !0, S++, f.add(a);
94
+ }, ObjectProperty(n) {
95
+ const r = n.node.key, i = n.node.value;
96
+ if (!e.isIdentifier(r) && !e.isStringLiteral(r) || !i || !e.isFunctionExpression(i) && !e.isArrowFunctionExpression(i)) return;
97
+ const o = e.isIdentifier(r) ? r.name : r.value, a = `objprop_${o}_${n.node.start}`;
98
+ if (f.has(a)) return;
99
+ d && console.log(`[FuncSpan Transform] Wrapping object property function: ${o}`);
100
+ const l = i.loc?.start.line ?? 0, u = i.loc?.start.column ?? 0, c = P(l, u), { line: p, column: g } = c;
101
+ let m = t;
102
+ c.source && (m = T(W(t), c.source));
103
+ const y = E(i.params), b = e.callExpression(e.identifier("captureFunctionSpan"), [i, e.stringLiteral(o), e.stringLiteral(m), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(p)), e.objectProperty(e.identifier("column"), e.numericLiteral(g)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(y.map((x) => e.stringLiteral(x))))])]);
104
+ n.node.value = b, L = !0, S++, f.add(a);
105
+ } }), L && !R($)) if (q($)) {
106
+ const n = e.variableDeclaration("const", [e.variableDeclarator(e.objectPattern([e.objectProperty(e.identifier("captureFunctionSpan"), e.identifier("captureFunctionSpan"), !1, !0)]), e.callExpression(e.identifier("require"), [e.stringLiteral("@sailfish-ai/sf-veritas")]))]);
107
+ $.program.body.unshift(n);
108
+ } else {
109
+ const n = e.importDeclaration([e.importSpecifier(e.identifier("captureFunctionSpan"), e.identifier("captureFunctionSpan"))], e.stringLiteral("@sailfish-ai/sf-veritas"));
110
+ $.program.body.unshift(n);
111
+ }
112
+ if (S > 0) {
113
+ const n = K($, { retainLines: !0, compact: !1, sourceMaps: !0, sourceFileName: t }, j);
114
+ return d && console.log(`[FuncSpan Transform] ✅ Wrapped ${S} functions in ${v}`), { code: n.code, map: n.map, modified: !0, functionsWrapped: S };
115
+ }
116
+ return { code: j, modified: !1, functionsWrapped: 0 };
117
+ }
118
+ function ee(j, t, s = {}) {
119
+ const { projectRoot: F = process.cwd(), includeNodeModules: I = [], debug: d = !1, parseAsJavaScript: v = !1 } = s;
120
+ if (t.includes("node_modules") && !I.some((n) => t.includes(`node_modules/${n}`))) return { code: j, modified: !1, functionsWrapped: 0 };
121
+ if (O.some((n) => n.test(t))) return d && console.log(`[FuncSpan Transform] SKIPPING instrumentation entry point file: ${t}`), { code: j, modified: !1, functionsWrapped: 0 };
122
+ const $ = A(F, t).replace(/\\/g, "/");
123
+ let h;
124
+ d && console.log(`[FuncSpan Transform] Processing: ${$}`);
125
+ const k = ["jsx", "decorators-legacy", "classProperties", "objectRestSpread", "asyncGenerators", "dynamicImport", "optionalCatchBinding", "optionalChaining", "nullishCoalescingOperator"];
126
+ G || v || k.unshift("typescript");
127
+ try {
128
+ h = M(j, { sourceType: "module", plugins: k });
129
+ } catch (n) {
130
+ return d && console.error(`[FuncSpan Transform] Parse error in ${$}:`, n), { code: j, modified: !1, functionsWrapped: 0 };
131
+ }
132
+ const P = (n, r) => ({ line: n, column: r });
133
+ let L = !1, S = 0;
134
+ const f = /* @__PURE__ */ new Set();
135
+ if (N(h, { FunctionDeclaration(n) {
136
+ const r = n.node.id?.name;
137
+ if (!r) return;
138
+ if (_.has(r)) return void (d && console.log(`[FuncSpan Transform] SKIPPING entry point function: ${r}`));
139
+ const i = `decl_${r}`;
140
+ if (f.has(i)) return;
141
+ d && console.log(`[FuncSpan Transform] Wrapping function declaration: ${r}`);
142
+ const o = n.node.loc?.start.line ?? 0, a = n.node.loc?.start.column ?? 0, l = P(o, a), { line: u, column: c } = l, p = t, g = E(n.node.params), m = e.callExpression(e.identifier("captureFunctionSpan"), [e.identifier(r), e.stringLiteral(r), e.stringLiteral(p), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(u)), e.objectProperty(e.identifier("column"), e.numericLiteral(c)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(g.map((b) => e.stringLiteral(b))))])]), y = e.expressionStatement(e.assignmentExpression("=", e.identifier(r), m));
143
+ n.insertAfter(y), L = !0, S++, f.add(i);
144
+ }, VariableDeclarator(n) {
145
+ const r = n.node.id, i = n.node.init;
146
+ if (!e.isIdentifier(r) || !i || !e.isFunctionExpression(i) && !e.isArrowFunctionExpression(i)) return;
147
+ const o = r.name;
148
+ if (_.has(o)) return void (d && console.log(`[FuncSpan Transform] SKIPPING entry point function: ${o}`));
149
+ const a = `var_${o}`;
150
+ if (f.has(a)) return;
151
+ d && console.log(`[FuncSpan Transform] Wrapping variable function: ${o}`);
152
+ const l = i.loc?.start.line ?? 0, u = i.loc?.start.column ?? 0, c = P(l, u), { line: p, column: g } = c, m = t, y = E(i.params), b = e.callExpression(e.identifier("captureFunctionSpan"), [i, e.stringLiteral(o), e.stringLiteral(m), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(p)), e.objectProperty(e.identifier("column"), e.numericLiteral(g)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(y.map((x) => e.stringLiteral(x))))])]);
153
+ n.node.init = b, L = !0, S++, f.add(a);
154
+ }, ClassMethod(n) {
155
+ if (n.node.kind === "constructor" || n.node.kind === "get" || n.node.kind === "set") return;
156
+ const r = e.isIdentifier(n.node.key) ? n.node.key.name : "anonymous", i = `method_${r}_${n.node.start}`;
157
+ if (f.has(i)) return;
158
+ d && console.log(`[FuncSpan Transform] Wrapping class method: ${r}`);
159
+ const o = n.node.loc?.start.line ?? 0, a = n.node.loc?.start.column ?? 0, l = P(o, a), { line: u, column: c } = l, p = t, g = E(n.node.params), m = n.node.body, y = e.functionExpression(null, n.node.params, m, n.node.generator, n.node.async), b = e.callExpression(e.identifier("captureFunctionSpan"), [y, e.stringLiteral(r), e.stringLiteral(p), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(u)), e.objectProperty(e.identifier("column"), e.numericLiteral(c)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(g.map((C) => e.stringLiteral(C))))])]), x = e.blockStatement([e.returnStatement(e.callExpression(e.memberExpression(b, e.identifier("call")), [e.thisExpression(), e.spreadElement(e.identifier("arguments"))]))]);
160
+ n.node.body = x, L = !0, S++, f.add(i);
161
+ }, ObjectMethod(n) {
162
+ if (n.node.kind === "get" || n.node.kind === "set") return;
163
+ const r = e.isIdentifier(n.node.key) ? n.node.key.name : e.isStringLiteral(n.node.key) ? n.node.key.value : "anonymous", i = `objmethod_${r}_${n.node.start}`;
164
+ if (f.has(i)) return;
165
+ d && console.log(`[FuncSpan Transform] Wrapping object method: ${r}`);
166
+ const o = n.node.loc?.start.line ?? 0, a = n.node.loc?.start.column ?? 0, l = P(o, a), { line: u, column: c } = l, p = t, g = E(n.node.params), m = e.functionExpression(e.identifier(r), n.node.params, n.node.body, n.node.generator, n.node.async), y = e.callExpression(e.identifier("captureFunctionSpan"), [m, e.stringLiteral(r), e.stringLiteral(p), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(u)), e.objectProperty(e.identifier("column"), e.numericLiteral(c)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(g.map((x) => e.stringLiteral(x))))])]), b = e.objectProperty(n.node.key, y, n.node.computed, !1);
167
+ n.replaceWith(b), L = !0, S++, f.add(i);
168
+ }, ClassProperty(n) {
169
+ const r = n.node.key, i = n.node.value;
170
+ if (!e.isIdentifier(r) || !i || !e.isFunctionExpression(i) && !e.isArrowFunctionExpression(i)) return;
171
+ const o = r.name, a = `classprop_${o}_${n.node.start}`;
172
+ if (f.has(a)) return;
173
+ d && console.log(`[FuncSpan Transform] Wrapping class property function: ${o}`);
174
+ const l = i.loc?.start.line ?? 0, u = i.loc?.start.column ?? 0, c = P(l, u), { line: p, column: g } = c, m = t, y = E(i.params), b = e.callExpression(e.identifier("captureFunctionSpan"), [i, e.stringLiteral(o), e.stringLiteral(m), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(p)), e.objectProperty(e.identifier("column"), e.numericLiteral(g)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(y.map((x) => e.stringLiteral(x))))])]);
175
+ n.node.value = b, L = !0, S++, f.add(a);
176
+ }, ObjectProperty(n) {
177
+ const r = n.node.key, i = n.node.value;
178
+ if (!e.isIdentifier(r) && !e.isStringLiteral(r) || !i || !e.isFunctionExpression(i) && !e.isArrowFunctionExpression(i)) return;
179
+ const o = e.isIdentifier(r) ? r.name : r.value, a = `objprop_${o}_${n.node.start}`;
180
+ if (f.has(a)) return;
181
+ d && console.log(`[FuncSpan Transform] Wrapping object property function: ${o}`);
182
+ const l = i.loc?.start.line ?? 0, u = i.loc?.start.column ?? 0, c = P(l, u), { line: p, column: g } = c, m = t, y = E(i.params), b = e.callExpression(e.identifier("captureFunctionSpan"), [i, e.stringLiteral(o), e.stringLiteral(m), e.objectExpression([e.objectProperty(e.identifier("line"), e.numericLiteral(p)), e.objectProperty(e.identifier("column"), e.numericLiteral(g)), e.objectProperty(e.identifier("paramNames"), e.arrayExpression(y.map((x) => e.stringLiteral(x))))])]);
183
+ n.node.value = b, L = !0, S++, f.add(a);
184
+ } }), L && !R(h)) if (q(h)) {
185
+ const n = e.variableDeclaration("const", [e.variableDeclarator(e.objectPattern([e.objectProperty(e.identifier("captureFunctionSpan"), e.identifier("captureFunctionSpan"), !1, !0)]), e.callExpression(e.identifier("require"), [e.stringLiteral("@sailfish-ai/sf-veritas")]))]);
186
+ h.program.body.unshift(n);
187
+ } else {
188
+ const n = e.importDeclaration([e.importSpecifier(e.identifier("captureFunctionSpan"), e.identifier("captureFunctionSpan"))], e.stringLiteral("@sailfish-ai/sf-veritas"));
189
+ h.program.body.unshift(n);
190
+ }
191
+ if (S > 0) {
192
+ const n = K(h, { retainLines: !0, compact: !1, sourceMaps: !0, sourceFileName: t }, j);
193
+ return d && console.log(`[FuncSpan Transform] ✅ Wrapped ${S} functions in ${$}`), { code: n.code, map: n.map, modified: !0, functionsWrapped: S };
194
+ }
195
+ return { code: j, modified: !1, functionsWrapped: 0 };
196
+ }
197
+ function E(j) {
198
+ const t = [];
199
+ for (const s of j) e.isIdentifier(s) ? t.push(s.name) : e.isRestElement(s) && e.isIdentifier(s.argument) ? t.push(`...${s.argument.name}`) : e.isAssignmentPattern(s) && e.isIdentifier(s.left) ? t.push(s.left.name) : e.isObjectPattern(s) ? t.push("{}") : e.isArrayPattern(s) ? t.push("[]") : t.push("_");
200
+ return t;
201
+ }
202
+ function R(j) {
203
+ let t = !1;
204
+ return N(j, { ImportDeclaration(s) {
205
+ e.isStringLiteral(s.node.source) && s.node.source.value === "@sailfish-ai/sf-veritas" && s.node.specifiers.some((F) => e.isImportSpecifier(F) && e.isIdentifier(F.imported) && F.imported.name === "captureFunctionSpan") && (t = !0, s.stop());
206
+ }, VariableDeclarator(s) {
207
+ if (e.isObjectPattern(s.node.id) && e.isCallExpression(s.node.init) && e.isIdentifier(s.node.init.callee) && s.node.init.callee.name === "require") {
208
+ const F = s.node.init.arguments;
209
+ F.length > 0 && e.isStringLiteral(F[0]) && F[0].value === "@sailfish-ai/sf-veritas" && s.node.id.properties.some((I) => e.isObjectProperty(I) && e.isIdentifier(I.key) && I.key.name === "captureFunctionSpan") && (t = !0, s.stop());
210
+ }
211
+ } }), t;
212
+ }
213
+ function q(j) {
214
+ let t = !1;
215
+ return N(j, { CallExpression(s) {
216
+ e.isIdentifier(s.node.callee) && s.node.callee.name === "require" && (t = !0, s.stop());
217
+ }, MemberExpression(s) {
218
+ !e.isIdentifier(s.node.object) || s.node.object.name !== "module" && s.node.object.name !== "exports" || (t = !0, s.stop());
219
+ } }), t;
220
+ }
221
+ export {
222
+ ee as a,
223
+ Y as s,
224
+ Z as t
225
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("fs"),r=require("../funcSpanTransformer-BpWuHXKT.cjs");function u(o={}){const{enabled:l=!0,includeNodeModules:n=[],debug:t=!1}=o;return{name:"sailfish-funcspan-esbuild",setup(d){l&&(d.onLoad({filter:/\.(js|ts|jsx|tsx)$/},async e=>{if(e.path.includes("node_modules")&&!n.some(s=>e.path.includes(`node_modules/${s}`))||e.path.includes("@sailfish-ai/sf-veritas")||e.path.includes("jsts-backend/dist"))return null;try{const s=a.readFileSync(e.path,"utf-8"),i=await r.transformFunctionSpans(s,e.path,{projectRoot:process.cwd(),includeNodeModules:n,debug:t});if(i.modified)return{contents:i.code,loader:e.path.endsWith(".ts")||e.path.endsWith(".tsx")?"ts":"js"}}catch(s){t&&console.error(`[FuncSpan Esbuild] Error transforming ${e.path}:`,s)}return null}),t&&console.log("[FuncSpan Esbuild] Plugin initialized"))}}}exports.default=u,exports.funcspanEsbuildPlugin=u;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("fs"),r=require("../funcSpanTransformer-B9WWl-g1.cjs"),c=require("../runtimeConfig-CpQ27dZD.cjs");function l(o={}){try{if(c.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Esbuild Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-esbuild-disabled",setup(){}}}catch{}const{enabled:a=!0,includeNodeModules:i=[],debug:t=!1}=o;return{name:"sailfish-funcspan-esbuild",setup(u){a&&(u.onLoad({filter:/\.(js|ts|jsx|tsx)$/},async e=>{if(e.path.includes("node_modules")&&!i.some(n=>e.path.includes(`node_modules/${n}`))||e.path.includes("@sailfish-ai/sf-veritas")||e.path.includes("jsts-backend/dist"))return null;try{const n=d.readFileSync(e.path,"utf-8"),s=await r.transformFunctionSpans(n,e.path,{projectRoot:process.cwd(),includeNodeModules:i,debug:t});if(s.modified)return{contents:s.code,loader:e.path.endsWith(".ts")||e.path.endsWith(".tsx")?"ts":"js"}}catch(n){t&&console.error(`[FuncSpan Esbuild] Error transforming ${e.path}:`,n)}return null}),t&&console.log("[FuncSpan Esbuild] Plugin initialized"))}}}exports.default=l,exports.funcspanEsbuildPlugin=l;
@@ -1,21 +1,27 @@
1
- import { readFileSync as u } from "fs";
2
- import { t as l } from "../funcSpanTransformer-BLhIRZqX.js";
3
- function p(o = {}) {
1
+ import { readFileSync as l } from "fs";
2
+ import { t as d } from "../funcSpanTransformer-CWNEWRxq.js";
3
+ import { s as r } from "../runtimeConfig-emBNO3lJ.js";
4
+ function h(o = {}) {
5
+ try {
6
+ if (r()) return console.warn("[FuncSpan Esbuild Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-esbuild-disabled", setup() {
7
+ } };
8
+ } catch {
9
+ }
4
10
  const { enabled: a = !0, includeNodeModules: i = [], debug: t = !1 } = o;
5
- return { name: "sailfish-funcspan-esbuild", setup(d) {
6
- a && (d.onLoad({ filter: /\.(js|ts|jsx|tsx)$/ }, async (s) => {
7
- if (s.path.includes("node_modules") && !i.some((e) => s.path.includes(`node_modules/${e}`)) || s.path.includes("@sailfish-ai/sf-veritas") || s.path.includes("jsts-backend/dist")) return null;
11
+ return { name: "sailfish-funcspan-esbuild", setup(s) {
12
+ a && (s.onLoad({ filter: /\.(js|ts|jsx|tsx)$/ }, async (n) => {
13
+ if (n.path.includes("node_modules") && !i.some((e) => n.path.includes(`node_modules/${e}`)) || n.path.includes("@sailfish-ai/sf-veritas") || n.path.includes("jsts-backend/dist")) return null;
8
14
  try {
9
- const e = u(s.path, "utf-8"), n = await l(e, s.path, { projectRoot: process.cwd(), includeNodeModules: i, debug: t });
10
- if (n.modified) return { contents: n.code, loader: s.path.endsWith(".ts") || s.path.endsWith(".tsx") ? "ts" : "js" };
15
+ const e = l(n.path, "utf-8"), u = await d(e, n.path, { projectRoot: process.cwd(), includeNodeModules: i, debug: t });
16
+ if (u.modified) return { contents: u.code, loader: n.path.endsWith(".ts") || n.path.endsWith(".tsx") ? "ts" : "js" };
11
17
  } catch (e) {
12
- t && console.error(`[FuncSpan Esbuild] Error transforming ${s.path}:`, e);
18
+ t && console.error(`[FuncSpan Esbuild] Error transforming ${n.path}:`, e);
13
19
  }
14
20
  return null;
15
21
  }), t && console.log("[FuncSpan Esbuild] Plugin initialized"));
16
22
  } };
17
23
  }
18
24
  export {
19
- p as default,
20
- p as funcspanEsbuildPlugin
25
+ h as default,
26
+ h as funcspanEsbuildPlugin
21
27
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../funcSpanTransformer-BpWuHXKT.cjs");function l(r={}){const{enabled:t=!0,includeNodeModules:u=[],debug:s=!1}=r;return{name:"sailfish-funcspan-rollup",async transform(i,e){if(!t||!e.match(/\.(js|ts|jsx|tsx)$/)||e.includes("node_modules")&&!u.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await o.transformFunctionSpans(i,e,{projectRoot:process.cwd(),includeNodeModules:u,debug:s});if(n.modified)return{code:n.code,map:n.map||null}}catch(n){s&&console.error(`[FuncSpan Rollup] Error transforming ${e}:`,n)}return null}}}exports.default=l,exports.funcspanRollupPlugin=l;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../funcSpanTransformer-B9WWl-g1.cjs"),a=require("../runtimeConfig-CpQ27dZD.cjs");function s(o={}){try{if(a.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-rollup-disabled"}}catch{}const{enabled:t=!0,includeNodeModules:l=[],debug:u=!1}=o;return{name:"sailfish-funcspan-rollup",async transform(r,e){if(!t||!e.match(/\.(js|ts|jsx|tsx)$/)||e.includes("node_modules")&&!l.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await i.transformFunctionSpans(r,e,{projectRoot:process.cwd(),includeNodeModules:l,debug:u});if(n.modified)return{code:n.code,map:n.map||null}}catch(n){u&&console.error(`[FuncSpan Rollup] Error transforming ${e}:`,n)}return null}}}exports.default=s,exports.funcspanRollupPlugin=s;
@@ -1,10 +1,15 @@
1
- import { t } from "../funcSpanTransformer-BLhIRZqX.js";
2
- function i(r = {}) {
3
- const { enabled: o = !0, includeNodeModules: s = [], debug: u = !1 } = r;
4
- return { name: "sailfish-funcspan-rollup", async transform(l, n) {
5
- if (!o || !n.match(/\.(js|ts|jsx|tsx)$/) || n.includes("node_modules") && !s.some((e) => n.includes(`node_modules/${e}`)) || n.includes("@sailfish-ai/sf-veritas") || n.includes("jsts-backend/dist")) return null;
1
+ import { t as i } from "../funcSpanTransformer-CWNEWRxq.js";
2
+ import { s as r } from "../runtimeConfig-emBNO3lJ.js";
3
+ function c(o = {}) {
4
+ try {
5
+ if (r()) return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-rollup-disabled" };
6
+ } catch {
7
+ }
8
+ const { enabled: t = !0, includeNodeModules: l = [], debug: u = !1 } = o;
9
+ return { name: "sailfish-funcspan-rollup", async transform(s, n) {
10
+ if (!t || !n.match(/\.(js|ts|jsx|tsx)$/) || n.includes("node_modules") && !l.some((e) => n.includes(`node_modules/${e}`)) || n.includes("@sailfish-ai/sf-veritas") || n.includes("jsts-backend/dist")) return null;
6
11
  try {
7
- const e = await t(l, n, { projectRoot: process.cwd(), includeNodeModules: s, debug: u });
12
+ const e = await i(s, n, { projectRoot: process.cwd(), includeNodeModules: l, debug: u });
8
13
  if (e.modified) return { code: e.code, map: e.map || null };
9
14
  } catch (e) {
10
15
  u && console.error(`[FuncSpan Rollup] Error transforming ${n}:`, e);
@@ -13,6 +18,6 @@ function i(r = {}) {
13
18
  } };
14
19
  }
15
20
  export {
16
- i as default,
17
- i as funcspanRollupPlugin
21
+ c as default,
22
+ c as funcspanRollupPlugin
18
23
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs"),C=require("glob"),N=require("path"),T=require("../funcSpanTransformer-BpWuHXKT.cjs");async function d(n={}){const{outDir:f="dist",include:F=["**/*.js"],exclude:g=["**/*.test.js","**/*.spec.js","**/__tests__/**"],projectRoot:s=process.cwd(),includeNodeModules:_=[],debug:t=!1}=n,u=N.resolve(s,f);console.log("[FuncSpan TSC] Starting post-build function instrumentation..."),console.log(`[FuncSpan TSC] Output directory: ${u}`),console.log(`[FuncSpan TSC] Project root: ${s}`);const r=[];for(const o of F){const c=C.sync(o,{cwd:u,absolute:!0,ignore:g});r.push(...c)}console.log(`[FuncSpan TSC] Found ${r.length} JavaScript files to process`);let l=0,p=0;for(const o of r)try{const c=i.readFileSync(o,"utf-8"),e=await T.transformFunctionSpans(c,o,{projectRoot:s,includeNodeModules:_,debug:t});if(e.modified){if(i.writeFileSync(o,e.code,"utf-8"),e.map){const a=`${o}.map`;i.writeFileSync(a,JSON.stringify(e.map),"utf-8"),t&&console.log(`[FuncSpan TSC] Generated source map: ${a}`)}l++,p+=e.functionsWrapped,t&&console.log(`[FuncSpan TSC] Modified: ${o} (${e.functionsWrapped} functions)`)}}catch(c){console.error(`[FuncSpan TSC] Error processing ${o}:`,c)}console.log(`[FuncSpan TSC] ✅ Completed: Modified ${l} files, wrapped ${p} functions`)}async function S(){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 d(n)}require.main===module&&S().catch(n=>{console.error("[FuncSpan TSC] Fatal error:",n),process.exit(1)}),exports.cli=S,exports.processTscFiles=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs"),_=require("glob"),N=require("path"),m=require("../funcSpanTransformer-B9WWl-g1.cjs"),T=require("../runtimeConfig-CpQ27dZD.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;