@sailfish-ai/sf-veritas 0.2.13 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contextManager-Cx03mw7l.js +258 -0
- package/dist/contextManager-CxQqBCEA.cjs +1 -0
- package/dist/funcSpanTransformer-Byqzu4B1.js +231 -0
- package/dist/funcSpanTransformer-CDh0o-AP.cjs +1 -0
- package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
- package/dist/plugins/funcspanEsbuildPlugin.mjs +2 -2
- package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.mjs +2 -2
- package/dist/plugins/funcspanTscPlugin.cjs +1 -1
- package/dist/plugins/funcspanTscPlugin.mjs +2 -2
- package/dist/plugins/funcspanVitePlugin.cjs +1 -1
- package/dist/plugins/funcspanVitePlugin.mjs +2 -2
- package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
- package/dist/plugins/funcspanWebpackLoader.mjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.mjs +1 -1
- package/dist/{runtimeConfig-CgLfwL3X.js → runtimeConfig-DndXTWki.js} +130 -127
- package/dist/{runtimeConfig-DIsq-KCn.cjs → runtimeConfig-TWzqPe1S.cjs} +7 -7
- package/dist/sf-veritas.cjs +37 -12
- package/dist/sf-veritas.mjs +546 -489
- package/dist/types/networkRequestTransmitter.d.ts +4 -0
- package/dist/types/setupConfig.d.ts +35 -0
- package/dist/worker-pool-capture.cjs +1 -1
- package/dist/worker-pool-capture.mjs +1 -1
- package/dist/{workerPoolSpanCapture-BYaf3NOr.js → workerPoolSpanCapture-DWS_V0Mn.js} +1 -1
- package/dist/{workerPoolSpanCapture-D85i6nhQ.cjs → workerPoolSpanCapture-Danyb3Qa.cjs} +1 -1
- package/package.json +2 -1
- package/dist/contextManager-BkETRITg.cjs +0 -1
- package/dist/contextManager-CEPhVu9T.js +0 -197
- package/dist/funcSpanTransformer-B9WWl-g1.cjs +0 -1
- package/dist/funcSpanTransformer-CWNEWRxq.js +0 -225
|
@@ -1,225 +0,0 @@
|
|
|
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
|
-
};
|