@rasputin-ai/node 0.13.0 → 0.14.0
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/auto-instrumentation/bun-plugin.d.ts.map +1 -1
- package/dist/auto-instrumentation/instrument-compiled-esm.d.ts.map +1 -1
- package/dist/auto-instrumentation/instrumentation-manifest-registry.d.ts.map +1 -1
- package/dist/auto-instrumentation/node-hooks.d.ts.map +1 -1
- package/dist/auto-instrumentation/transform-disk-cache.d.ts.map +1 -1
- package/dist/execution-metrics/bind-execution-metrics.d.ts +20 -0
- package/dist/execution-metrics/bind-execution-metrics.d.ts.map +1 -0
- package/dist/execution-metrics/encode-execution-metrics-upload.d.ts +14 -0
- package/dist/execution-metrics/encode-execution-metrics-upload.d.ts.map +1 -0
- package/dist/execution-metrics/execution-metrics-batches.d.ts +34 -0
- package/dist/execution-metrics/execution-metrics-batches.d.ts.map +1 -0
- package/dist/execution-metrics/execution-metrics-collector.d.ts +44 -0
- package/dist/execution-metrics/execution-metrics-collector.d.ts.map +1 -0
- package/dist/execution-metrics/execution-metrics-exporter.d.ts +23 -0
- package/dist/execution-metrics/execution-metrics-exporter.d.ts.map +1 -0
- package/dist/execution-recorder/adaptive-recording-options.d.ts +0 -2
- package/dist/execution-recorder/adaptive-recording-options.d.ts.map +1 -1
- package/dist/execution-recorder/bind-adaptive-recorder.d.ts +8 -2
- package/dist/execution-recorder/bind-adaptive-recorder.d.ts.map +1 -1
- package/dist/execution-recorder/execution-identity.d.ts +6 -0
- package/dist/execution-recorder/execution-identity.d.ts.map +1 -1
- package/dist/execution-recorder/execution-journal.d.ts +1 -0
- package/dist/execution-recorder/execution-journal.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recorder-hooks.d.ts +9 -0
- package/dist/execution-recorder/execution-recorder-hooks.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recorder-types.d.ts +1 -12
- package/dist/execution-recorder/execution-recorder-types.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recorder.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recording-sync.d.ts +2 -2
- package/dist/execution-recorder/execution-recording-sync.d.ts.map +1 -1
- package/dist/execution-recorder/function-plan.d.ts +3 -1
- package/dist/execution-recorder/function-plan.d.ts.map +1 -1
- package/dist/function-metrics/bind-function-metrics.d.ts +20 -0
- package/dist/function-metrics/bind-function-metrics.d.ts.map +1 -0
- package/dist/function-metrics/create-metrics-only-runtime.d.ts +10 -0
- package/dist/function-metrics/create-metrics-only-runtime.d.ts.map +1 -0
- package/dist/function-metrics/encode-function-metrics-upload.d.ts +14 -0
- package/dist/function-metrics/encode-function-metrics-upload.d.ts.map +1 -0
- package/dist/function-metrics/function-metric-declaration-registry.d.ts +9 -0
- package/dist/function-metrics/function-metric-declaration-registry.d.ts.map +1 -0
- package/dist/function-metrics/function-metrics-batches.d.ts +36 -0
- package/dist/function-metrics/function-metrics-batches.d.ts.map +1 -0
- package/dist/function-metrics/function-metrics-collector.d.ts +60 -0
- package/dist/function-metrics/function-metrics-collector.d.ts.map +1 -0
- package/dist/function-metrics/function-metrics-exporter.d.ts +23 -0
- package/dist/function-metrics/function-metrics-exporter.d.ts.map +1 -0
- package/dist/function-metrics/install-function-metric-declaration-sink.d.ts +2 -0
- package/dist/function-metrics/install-function-metric-declaration-sink.d.ts.map +1 -0
- package/dist/function-metrics/intern-prepared-metrics.d.ts +6 -0
- package/dist/function-metrics/intern-prepared-metrics.d.ts.map +1 -0
- package/dist/function-metrics/send-function-metrics-batch.d.ts +25 -0
- package/dist/function-metrics/send-function-metrics-batch.d.ts.map +1 -0
- package/dist/function-metrics/settle-function-metrics.d.ts +8 -0
- package/dist/function-metrics/settle-function-metrics.d.ts.map +1 -0
- package/dist/index.js +3530 -671
- package/dist/instrument/build.js +450 -140
- package/dist/instrument/bun.js +454 -132
- package/dist/instrument/node.js +452 -132
- package/dist/internal.d.ts +5 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +3836 -1009
- package/dist/rasputin-init.d.ts +37 -4
- package/dist/rasputin-init.d.ts.map +1 -1
- package/dist/runtime-timing/call-duration.d.ts +13 -0
- package/dist/runtime-timing/call-duration.d.ts.map +1 -0
- package/dist/{execution-recorder → runtime-timing}/dynamic-duration-sampling.d.ts +6 -4
- package/dist/runtime-timing/dynamic-duration-sampling.d.ts.map +1 -0
- package/dist/runtime-timing/execution-duration.d.ts +5 -0
- package/dist/runtime-timing/execution-duration.d.ts.map +1 -0
- package/dist/sdk-meta.d.ts +1 -1
- package/package.json +2 -2
- package/dist/execution-recorder/dynamic-duration-sampling.d.ts.map +0 -1
package/dist/instrument/node.js
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
import * as nodeModule from "node:module";
|
|
3
3
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4
4
|
|
|
5
|
+
// src/function-metrics/function-metric-declaration-registry.ts
|
|
6
|
+
var REGISTRY_SYMBOL = Symbol.for("rasputin.functionMetrics.declarations.v1");
|
|
7
|
+
var getRegistry = () => {
|
|
8
|
+
const existing = Reflect.get(globalThis, REGISTRY_SYMBOL);
|
|
9
|
+
if (typeof existing === "object" && existing !== null) {
|
|
10
|
+
const byRuntimeId = Reflect.get(existing, "byRuntimeId");
|
|
11
|
+
if (byRuntimeId instanceof Map) return { byRuntimeId };
|
|
12
|
+
}
|
|
13
|
+
const registry = {
|
|
14
|
+
byRuntimeId: /* @__PURE__ */ new Map()
|
|
15
|
+
};
|
|
16
|
+
Reflect.set(globalThis, REGISTRY_SYMBOL, registry);
|
|
17
|
+
return registry;
|
|
18
|
+
};
|
|
19
|
+
var registerFunctionMetricDeclarations = (declarations) => {
|
|
20
|
+
const { byRuntimeId } = getRegistry();
|
|
21
|
+
for (const declaration of declarations) {
|
|
22
|
+
if (byRuntimeId.has(declaration.runtime_id)) continue;
|
|
23
|
+
byRuntimeId.set(declaration.runtime_id, declaration);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
5
27
|
// src/auto-instrumentation/instrumentation-manifest-registry.ts
|
|
6
28
|
import { resolve } from "node:path";
|
|
7
29
|
import {
|
|
@@ -48,7 +70,7 @@ var AUTOMATIC_RUNTIME_SYMBOL = "rasputin.execution.runtime.v3";
|
|
|
48
70
|
// src/auto-instrumentation/instrumentation-manifest-registry.ts
|
|
49
71
|
var INSTRUMENTATION_MANIFEST_SYMBOL = "rasputin.instrumentation.manifest.v3";
|
|
50
72
|
var registrySymbol = Symbol.for(INSTRUMENTATION_MANIFEST_SYMBOL);
|
|
51
|
-
var
|
|
73
|
+
var getRegistry2 = () => {
|
|
52
74
|
const existing = Reflect.get(globalThis, registrySymbol);
|
|
53
75
|
if (existing?.__rasputinManifestRegistry && existing.files instanceof Map && typeof existing.generation === "number" && typeof existing.uploadedGeneration === "number") {
|
|
54
76
|
const registry2 = existing;
|
|
@@ -66,7 +88,7 @@ var getRegistry = () => {
|
|
|
66
88
|
return registry;
|
|
67
89
|
};
|
|
68
90
|
var recordInstrumentationManifestDelta = (filePath, delta) => {
|
|
69
|
-
const registry =
|
|
91
|
+
const registry = getRegistry2();
|
|
70
92
|
if (delta.alreadyInstrumented) {
|
|
71
93
|
registry.alreadyInstrumented += 1;
|
|
72
94
|
return;
|
|
@@ -184,6 +206,7 @@ import {
|
|
|
184
206
|
} from "node:fs";
|
|
185
207
|
import { homedir } from "node:os";
|
|
186
208
|
import { dirname as dirname2, join as join2 } from "node:path";
|
|
209
|
+
import { sourceLocatorFromFile as sourceLocatorFromFile4 } from "@rasputin-ai/core";
|
|
187
210
|
|
|
188
211
|
// ../instrumentation/src/classify-function.ts
|
|
189
212
|
import ts3 from "typescript";
|
|
@@ -792,7 +815,7 @@ var attachInlineSourceMap = (original, generated, filePath, edits, basenameOf) =
|
|
|
792
815
|
|
|
793
816
|
// ../instrumentation/src/browser-function-edits.ts
|
|
794
817
|
import { propertyNameIsSensitive } from "@rasputin-ai/core";
|
|
795
|
-
import
|
|
818
|
+
import ts10 from "typescript";
|
|
796
819
|
|
|
797
820
|
// ../instrumentation/src/suspension-whitelist.ts
|
|
798
821
|
import ts4 from "typescript";
|
|
@@ -923,34 +946,286 @@ var decideAsyncInstrumentation = (node, sourceFile) => {
|
|
|
923
946
|
|
|
924
947
|
// ../instrumentation/src/transform-source.ts
|
|
925
948
|
import { basename, resolve as resolve4 } from "node:path";
|
|
926
|
-
import
|
|
949
|
+
import ts9 from "typescript";
|
|
927
950
|
|
|
928
|
-
// ../instrumentation/src/
|
|
951
|
+
// ../instrumentation/src/function-metric-declarations.ts
|
|
952
|
+
import {
|
|
953
|
+
canonicalizeFunctionIdentityPath,
|
|
954
|
+
FUNCTION_IDENTITY_VERSION,
|
|
955
|
+
functionIdentityKey,
|
|
956
|
+
sha256Hex,
|
|
957
|
+
sourceLocatorFromFile as sourceLocatorFromFile3
|
|
958
|
+
} from "@rasputin-ai/core";
|
|
929
959
|
import ts5 from "typescript";
|
|
960
|
+
var printer = ts5.createPrinter({ removeComments: true, newLine: ts5.NewLineKind.LineFeed });
|
|
961
|
+
var propertyText = (name) => {
|
|
962
|
+
if (!name) return void 0;
|
|
963
|
+
if (ts5.isIdentifier(name) || ts5.isStringLiteral(name) || ts5.isNumericLiteral(name)) {
|
|
964
|
+
return name.text;
|
|
965
|
+
}
|
|
966
|
+
if (ts5.isNoSubstitutionTemplateLiteral(name)) return name.text;
|
|
967
|
+
return void 0;
|
|
968
|
+
};
|
|
969
|
+
var hasStaticModifier = (node) => {
|
|
970
|
+
if (!ts5.canHaveModifiers(node)) return false;
|
|
971
|
+
const modifiers = ts5.getModifiers(node);
|
|
972
|
+
if (!modifiers) return false;
|
|
973
|
+
return modifiers.some((modifier) => modifier.kind === ts5.SyntaxKind.StaticKeyword);
|
|
974
|
+
};
|
|
975
|
+
var memberIsStatic = (node) => {
|
|
976
|
+
if (hasStaticModifier(node)) return true;
|
|
977
|
+
const parent = node.parent;
|
|
978
|
+
const isPropertyValue = ts5.isArrowFunction(node) || ts5.isFunctionExpression(node);
|
|
979
|
+
if (!isPropertyValue || !ts5.isPropertyDeclaration(parent)) return false;
|
|
980
|
+
return hasStaticModifier(parent);
|
|
981
|
+
};
|
|
982
|
+
var kindOf = (node) => {
|
|
983
|
+
if (ts5.isConstructorDeclaration(node)) return "constructor";
|
|
984
|
+
if (ts5.isGetAccessor(node)) return "getter";
|
|
985
|
+
if (ts5.isSetAccessor(node)) return "setter";
|
|
986
|
+
if (ts5.isMethodDeclaration(node)) return "method";
|
|
987
|
+
if (ts5.isArrowFunction(node)) return "arrow";
|
|
988
|
+
return "function";
|
|
989
|
+
};
|
|
990
|
+
var bindingOf = (node) => {
|
|
991
|
+
if (ts5.isConstructorDeclaration(node)) return "constructor";
|
|
992
|
+
const ownName = propertyText(node.name);
|
|
993
|
+
if (ownName) return ownName;
|
|
994
|
+
const parent = node.parent;
|
|
995
|
+
if (ts5.isVariableDeclaration(parent) && ts5.isIdentifier(parent.name)) {
|
|
996
|
+
return parent.name.text;
|
|
997
|
+
}
|
|
998
|
+
if (ts5.isPropertyAssignment(parent) || ts5.isPropertyDeclaration(parent)) {
|
|
999
|
+
return propertyText(parent.name);
|
|
1000
|
+
}
|
|
1001
|
+
return void 0;
|
|
1002
|
+
};
|
|
1003
|
+
var calleeText = (expression) => {
|
|
1004
|
+
if (ts5.isIdentifier(expression)) return expression.text;
|
|
1005
|
+
if (!ts5.isPropertyAccessExpression(expression) || !ts5.isIdentifier(expression.name)) {
|
|
1006
|
+
return void 0;
|
|
1007
|
+
}
|
|
1008
|
+
const object = calleeText(expression.expression);
|
|
1009
|
+
if (!object) return void 0;
|
|
1010
|
+
return `${object}.${expression.name.text}`;
|
|
1011
|
+
};
|
|
1012
|
+
var soleCallbackCallee = (node) => {
|
|
1013
|
+
const parent = node.parent;
|
|
1014
|
+
if (ts5.isCallExpression(parent)) {
|
|
1015
|
+
if (parent.arguments.length !== 1 || parent.arguments[0] !== node) return void 0;
|
|
1016
|
+
return parent.expression;
|
|
1017
|
+
}
|
|
1018
|
+
if (!ts5.isNewExpression(parent) || !parent.arguments) return void 0;
|
|
1019
|
+
if (parent.arguments.length !== 1 || parent.arguments[0] !== node) return void 0;
|
|
1020
|
+
return parent.expression;
|
|
1021
|
+
};
|
|
1022
|
+
var withScope = (scopes, kind, name) => {
|
|
1023
|
+
if (!name) return scopes;
|
|
1024
|
+
return [...scopes, { kind, name }];
|
|
1025
|
+
};
|
|
1026
|
+
var fingerprintOf = (node, sourceFile) => {
|
|
1027
|
+
const printed = printer.printNode(ts5.EmitHint.Unspecified, node, sourceFile);
|
|
1028
|
+
const normalized = printed.replace(/\s+/g, "");
|
|
1029
|
+
return `fp1_${sha256Hex(normalized)}`;
|
|
1030
|
+
};
|
|
1031
|
+
var sourceRange = (node, sourceFile, filePath, mapLocation) => {
|
|
1032
|
+
const start = mappedLocation(sourceFile, node.getStart(sourceFile), filePath, mapLocation);
|
|
1033
|
+
const end = mappedLocation(sourceFile, node.end, filePath, mapLocation);
|
|
1034
|
+
if (!start || !end) return null;
|
|
1035
|
+
return {
|
|
1036
|
+
start_line: start.line,
|
|
1037
|
+
start_column: start.column,
|
|
1038
|
+
end_line: end.line,
|
|
1039
|
+
end_column: end.column
|
|
1040
|
+
};
|
|
1041
|
+
};
|
|
1042
|
+
var isFunctionNode = (node) => {
|
|
1043
|
+
const isFunction = ts5.isFunctionDeclaration(node) || ts5.isFunctionExpression(node) || ts5.isArrowFunction(node) || ts5.isMethodDeclaration(node) || ts5.isGetAccessor(node) || ts5.isSetAccessor(node) || ts5.isConstructorDeclaration(node);
|
|
1044
|
+
return isFunction && Boolean(node.body);
|
|
1045
|
+
};
|
|
1046
|
+
var anchoredName = (candidate, anchorCount) => {
|
|
1047
|
+
if (candidate.binding || !candidate.anchor) return void 0;
|
|
1048
|
+
if (anchorCount.get(candidate.anchor) !== 1) return void 0;
|
|
1049
|
+
const binding = candidate.anchor.split(".").at(-1) ?? candidate.anchor;
|
|
1050
|
+
return {
|
|
1051
|
+
binding,
|
|
1052
|
+
scopes: withScope(candidate.scopes, "property", candidate.anchor)
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
var stableDescriptor = (candidate, packagePath, packageName, anchorCount) => {
|
|
1056
|
+
const anchored = anchoredName(candidate, anchorCount);
|
|
1057
|
+
const binding = candidate.binding ?? anchored?.binding;
|
|
1058
|
+
const scopes = anchored?.scopes ?? candidate.scopes;
|
|
1059
|
+
if (candidate.ancestorAmbiguous || !binding || !packagePath || !packageName) return void 0;
|
|
1060
|
+
return {
|
|
1061
|
+
identity_version: FUNCTION_IDENTITY_VERSION,
|
|
1062
|
+
identity_kind: "stable",
|
|
1063
|
+
source_basis: "package",
|
|
1064
|
+
package_name: packageName,
|
|
1065
|
+
path: packagePath,
|
|
1066
|
+
scopes,
|
|
1067
|
+
declaration_kind: candidate.kind,
|
|
1068
|
+
binding_name: binding,
|
|
1069
|
+
is_static: candidate.isStatic
|
|
1070
|
+
};
|
|
1071
|
+
};
|
|
1072
|
+
var walkCandidates = (sourceFile, runtimeIdByNode) => {
|
|
1073
|
+
const candidates = [];
|
|
1074
|
+
const visit = (node, scopes, ancestorAmbiguous, parent) => {
|
|
1075
|
+
if (isFunctionNode(node)) {
|
|
1076
|
+
const binding = bindingOf(node);
|
|
1077
|
+
const index = candidates.length;
|
|
1078
|
+
const callee = binding ? void 0 : soleCallbackCallee(node);
|
|
1079
|
+
candidates.push({
|
|
1080
|
+
node,
|
|
1081
|
+
scopes,
|
|
1082
|
+
ancestorAmbiguous,
|
|
1083
|
+
binding,
|
|
1084
|
+
kind: kindOf(node),
|
|
1085
|
+
isStatic: memberIsStatic(node),
|
|
1086
|
+
anchor: callee ? calleeText(callee) : void 0,
|
|
1087
|
+
parent,
|
|
1088
|
+
runtimeId: runtimeIdByNode.get(node)
|
|
1089
|
+
});
|
|
1090
|
+
const nextScopes = binding && !ancestorAmbiguous ? withScope(scopes, "function", binding) : scopes;
|
|
1091
|
+
const childAmbiguous = ancestorAmbiguous || !binding;
|
|
1092
|
+
ts5.forEachChild(node, (child) => visit(child, nextScopes, childAmbiguous, index));
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
if ((ts5.isClassDeclaration(node) || ts5.isClassExpression(node)) && node.name) {
|
|
1096
|
+
const next = withScope(scopes, "class", node.name.text);
|
|
1097
|
+
ts5.forEachChild(node, (child) => visit(child, next, ancestorAmbiguous, parent));
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
if (ts5.isModuleDeclaration(node) && ts5.isIdentifier(node.name)) {
|
|
1101
|
+
const next = withScope(scopes, "namespace", node.name.text);
|
|
1102
|
+
ts5.forEachChild(node, (child) => visit(child, next, ancestorAmbiguous, parent));
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
if (ts5.isVariableDeclaration(node) && ts5.isIdentifier(node.name) && node.initializer && ts5.isObjectLiteralExpression(node.initializer)) {
|
|
1106
|
+
visit(
|
|
1107
|
+
node.initializer,
|
|
1108
|
+
withScope(scopes, "object", node.name.text),
|
|
1109
|
+
ancestorAmbiguous,
|
|
1110
|
+
parent
|
|
1111
|
+
);
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
if (ts5.isPropertyAssignment(node) && node.initializer && ts5.isObjectLiteralExpression(node.initializer)) {
|
|
1115
|
+
const name = propertyText(node.name);
|
|
1116
|
+
visit(node.initializer, withScope(scopes, "property", name), ancestorAmbiguous, parent);
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
ts5.forEachChild(node, (child) => visit(child, scopes, ancestorAmbiguous, parent));
|
|
1120
|
+
};
|
|
1121
|
+
visit(sourceFile, [], false, void 0);
|
|
1122
|
+
return candidates;
|
|
1123
|
+
};
|
|
1124
|
+
var blockDescendants = (candidates, blocked, index) => {
|
|
1125
|
+
if (blocked.has(index)) return;
|
|
1126
|
+
blocked.add(index);
|
|
1127
|
+
for (let child = 0; child < candidates.length; child += 1) {
|
|
1128
|
+
const candidate = candidates[child];
|
|
1129
|
+
if (candidate?.parent === index) blockDescendants(candidates, blocked, child);
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
var releaseScopedDescriptor = (runtimeId) => ({
|
|
1133
|
+
identity_version: FUNCTION_IDENTITY_VERSION,
|
|
1134
|
+
identity_kind: "release_scoped",
|
|
1135
|
+
declaration_id: runtimeId
|
|
1136
|
+
});
|
|
1137
|
+
var collectFunctionMetricDeclarations = (input) => {
|
|
1138
|
+
const runtimeIdByNode = new Map(input.functions.map((item) => [item.node, item.runtimeId]));
|
|
1139
|
+
const candidates = walkCandidates(input.sourceFile, runtimeIdByNode);
|
|
1140
|
+
const anchorCount = /* @__PURE__ */ new Map();
|
|
1141
|
+
for (const candidate of candidates) {
|
|
1142
|
+
if (!candidate.anchor) continue;
|
|
1143
|
+
anchorCount.set(candidate.anchor, (anchorCount.get(candidate.anchor) ?? 0) + 1);
|
|
1144
|
+
}
|
|
1145
|
+
const locator = input.originalAst ? sourceLocatorFromFile3(input.filePath) : void 0;
|
|
1146
|
+
const packageName = locator?.packageName;
|
|
1147
|
+
const packagePath = locator && packageName ? canonicalizeFunctionIdentityPath(locator.packageRelativePath) : void 0;
|
|
1148
|
+
const rows = candidates.map((candidate) => ({
|
|
1149
|
+
candidate,
|
|
1150
|
+
descriptor: stableDescriptor(candidate, packagePath, packageName, anchorCount)
|
|
1151
|
+
}));
|
|
1152
|
+
const keyCount = /* @__PURE__ */ new Map();
|
|
1153
|
+
for (const row of rows) {
|
|
1154
|
+
if (!row.descriptor) continue;
|
|
1155
|
+
const key = functionIdentityKey(row.descriptor);
|
|
1156
|
+
keyCount.set(key, (keyCount.get(key) ?? 0) + 1);
|
|
1157
|
+
}
|
|
1158
|
+
const blocked = /* @__PURE__ */ new Set();
|
|
1159
|
+
for (const [index, row] of rows.entries()) {
|
|
1160
|
+
if (!row.descriptor) {
|
|
1161
|
+
blockDescendants(candidates, blocked, index);
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
const key = functionIdentityKey(row.descriptor);
|
|
1165
|
+
if ((keyCount.get(key) ?? 0) > 1) blockDescendants(candidates, blocked, index);
|
|
1166
|
+
}
|
|
1167
|
+
const declarations = [];
|
|
1168
|
+
for (const [index, row] of rows.entries()) {
|
|
1169
|
+
const runtimeId = row.candidate.runtimeId;
|
|
1170
|
+
if (!runtimeId) continue;
|
|
1171
|
+
const range = sourceRange(
|
|
1172
|
+
row.candidate.node,
|
|
1173
|
+
input.sourceFile,
|
|
1174
|
+
input.filePath,
|
|
1175
|
+
input.mapLocation
|
|
1176
|
+
);
|
|
1177
|
+
const fingerprint = input.originalAst ? fingerprintOf(row.candidate.node, input.sourceFile) : null;
|
|
1178
|
+
const stable = blocked.has(index) ? void 0 : row.descriptor;
|
|
1179
|
+
if (stable) {
|
|
1180
|
+
declarations.push({
|
|
1181
|
+
runtime_id: runtimeId,
|
|
1182
|
+
logical_key: functionIdentityKey(stable),
|
|
1183
|
+
identity_kind: "stable",
|
|
1184
|
+
descriptor: stable,
|
|
1185
|
+
source_range: range,
|
|
1186
|
+
implementation_fingerprint: fingerprint
|
|
1187
|
+
});
|
|
1188
|
+
continue;
|
|
1189
|
+
}
|
|
1190
|
+
const descriptor = releaseScopedDescriptor(runtimeId);
|
|
1191
|
+
declarations.push({
|
|
1192
|
+
runtime_id: runtimeId,
|
|
1193
|
+
logical_key: functionIdentityKey(descriptor),
|
|
1194
|
+
identity_kind: "release_scoped",
|
|
1195
|
+
descriptor,
|
|
1196
|
+
source_range: range,
|
|
1197
|
+
implementation_fingerprint: fingerprint
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
return declarations;
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
// ../instrumentation/src/parameter-initializer-may-run-code.ts
|
|
1204
|
+
import ts6 from "typescript";
|
|
930
1205
|
var unwrap = (expression) => {
|
|
931
1206
|
let current = expression;
|
|
932
|
-
while (
|
|
1207
|
+
while (ts6.isParenthesizedExpression(current) || ts6.isNonNullExpression(current)) {
|
|
933
1208
|
current = current.expression;
|
|
934
1209
|
}
|
|
935
1210
|
return current;
|
|
936
1211
|
};
|
|
937
1212
|
var isSafeLiteralInitializer = (expression) => {
|
|
938
1213
|
const current = unwrap(expression);
|
|
939
|
-
if (
|
|
1214
|
+
if (ts6.isNumericLiteral(current) || ts6.isStringLiteral(current) || ts6.isNoSubstitutionTemplateLiteral(current) || ts6.isBigIntLiteral(current)) {
|
|
940
1215
|
return true;
|
|
941
1216
|
}
|
|
942
|
-
if (current.kind ===
|
|
1217
|
+
if (current.kind === ts6.SyntaxKind.TrueKeyword || current.kind === ts6.SyntaxKind.FalseKeyword || current.kind === ts6.SyntaxKind.NullKeyword) {
|
|
943
1218
|
return true;
|
|
944
1219
|
}
|
|
945
|
-
if (
|
|
946
|
-
if (
|
|
947
|
-
return
|
|
1220
|
+
if (ts6.isIdentifier(current) && current.text === "undefined") return true;
|
|
1221
|
+
if (ts6.isPrefixUnaryExpression(current) && (current.operator === ts6.SyntaxKind.PlusToken || current.operator === ts6.SyntaxKind.MinusToken)) {
|
|
1222
|
+
return ts6.isNumericLiteral(unwrap(current.operand));
|
|
948
1223
|
}
|
|
949
1224
|
return false;
|
|
950
1225
|
};
|
|
951
1226
|
var functionHasPreBodyParameterEvaluation = (node) => {
|
|
952
1227
|
for (const parameter of node.parameters) {
|
|
953
|
-
if (
|
|
1228
|
+
if (ts6.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
|
|
954
1229
|
if (!parameter.initializer) continue;
|
|
955
1230
|
if (!isSafeLiteralInitializer(parameter.initializer)) return true;
|
|
956
1231
|
}
|
|
@@ -958,24 +1233,24 @@ var functionHasPreBodyParameterEvaluation = (node) => {
|
|
|
958
1233
|
};
|
|
959
1234
|
|
|
960
1235
|
// ../instrumentation/src/verify-instrumentation-isomorphism.ts
|
|
961
|
-
import
|
|
1236
|
+
import ts7 from "typescript";
|
|
962
1237
|
var RASPUTIN_IDENT = /^__rasputin/;
|
|
963
1238
|
var scriptKindFor = (filePath) => {
|
|
964
|
-
if (/\.tsx$/i.test(filePath)) return
|
|
965
|
-
if (/\.jsx$/i.test(filePath)) return
|
|
966
|
-
if (/\.[cm]?ts$/i.test(filePath)) return
|
|
967
|
-
return
|
|
1239
|
+
if (/\.tsx$/i.test(filePath)) return ts7.ScriptKind.TSX;
|
|
1240
|
+
if (/\.jsx$/i.test(filePath)) return ts7.ScriptKind.JSX;
|
|
1241
|
+
if (/\.[cm]?ts$/i.test(filePath)) return ts7.ScriptKind.TS;
|
|
1242
|
+
return ts7.ScriptKind.JS;
|
|
968
1243
|
};
|
|
969
|
-
var parse = (filePath, source) =>
|
|
1244
|
+
var parse = (filePath, source) => ts7.createSourceFile(filePath, source, ts7.ScriptTarget.Latest, true, scriptKindFor(filePath));
|
|
970
1245
|
var isRasputinName = (name) => RASPUTIN_IDENT.test(name);
|
|
971
1246
|
var identText = (node) => {
|
|
972
|
-
if (
|
|
973
|
-
if (
|
|
1247
|
+
if (ts7.isIdentifier(node)) return node.text;
|
|
1248
|
+
if (ts7.isPrivateIdentifier(node)) return node.text;
|
|
974
1249
|
return void 0;
|
|
975
1250
|
};
|
|
976
1251
|
var calleeName = (expression) => {
|
|
977
|
-
if (
|
|
978
|
-
if (
|
|
1252
|
+
if (ts7.isIdentifier(expression)) return expression.text;
|
|
1253
|
+
if (ts7.isPropertyAccessExpression(expression)) {
|
|
979
1254
|
const object = identText(expression.expression);
|
|
980
1255
|
const property = identText(expression.name);
|
|
981
1256
|
if (object && isRasputinName(object) && property) return `${object}.${property}`;
|
|
@@ -983,7 +1258,7 @@ var calleeName = (expression) => {
|
|
|
983
1258
|
return void 0;
|
|
984
1259
|
};
|
|
985
1260
|
var isRasputinCall = (node, methods) => {
|
|
986
|
-
if (!
|
|
1261
|
+
if (!ts7.isCallExpression(node)) return false;
|
|
987
1262
|
const name = calleeName(node.expression);
|
|
988
1263
|
if (!name) return false;
|
|
989
1264
|
if (isRasputinName(name)) return !methods || methods.has(name.split(".")[1] ?? "");
|
|
@@ -993,20 +1268,20 @@ var unwrapCall = (node) => {
|
|
|
993
1268
|
let current = node;
|
|
994
1269
|
while (isRasputinCall(current) && current.arguments.length === 1 && current.arguments[0]) {
|
|
995
1270
|
current = current.arguments[0];
|
|
996
|
-
if (
|
|
1271
|
+
if (ts7.isParenthesizedExpression(current)) current = current.expression;
|
|
997
1272
|
}
|
|
998
|
-
if (
|
|
1273
|
+
if (ts7.isParenthesizedExpression(current)) return current.expression;
|
|
999
1274
|
return current;
|
|
1000
1275
|
};
|
|
1001
1276
|
var isRasputinStatement = (node) => {
|
|
1002
|
-
if (
|
|
1003
|
-
if (
|
|
1277
|
+
if (ts7.isEmptyStatement(node)) return true;
|
|
1278
|
+
if (ts7.isVariableStatement(node)) {
|
|
1004
1279
|
return node.declarationList.declarations.every((declaration) => {
|
|
1005
1280
|
const name = identText(declaration.name);
|
|
1006
1281
|
return Boolean(name && isRasputinName(name));
|
|
1007
1282
|
});
|
|
1008
1283
|
}
|
|
1009
|
-
if (
|
|
1284
|
+
if (ts7.isExpressionStatement(node)) {
|
|
1010
1285
|
if (!isRasputinCall(node.expression)) return false;
|
|
1011
1286
|
const unwrapped = unwrapCall(node.expression);
|
|
1012
1287
|
return unwrapped === node.expression;
|
|
@@ -1020,7 +1295,7 @@ var isRasputinTryWrapper = (node) => {
|
|
|
1020
1295
|
(statement) => !isRasputinStatement(statement)
|
|
1021
1296
|
);
|
|
1022
1297
|
const leftover = catchCalls[0];
|
|
1023
|
-
const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 &&
|
|
1298
|
+
const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts7.isThrowStatement(leftover) && ts7.isIdentifier(leftover.expression) && isRasputinName(leftover.expression.text);
|
|
1024
1299
|
if (!leftoverThrow && catchCalls.length > 0) return false;
|
|
1025
1300
|
return node.finallyBlock.statements.every((statement) => isRasputinStatement(statement));
|
|
1026
1301
|
};
|
|
@@ -1028,7 +1303,7 @@ var flattenStatements = (statements) => {
|
|
|
1028
1303
|
const flattened = [];
|
|
1029
1304
|
for (const statement of statements) {
|
|
1030
1305
|
if (isRasputinStatement(statement)) continue;
|
|
1031
|
-
if (
|
|
1306
|
+
if (ts7.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
|
|
1032
1307
|
flattened.push(...flattenStatements(statement.tryBlock.statements));
|
|
1033
1308
|
continue;
|
|
1034
1309
|
}
|
|
@@ -1037,38 +1312,38 @@ var flattenStatements = (statements) => {
|
|
|
1037
1312
|
return flattened;
|
|
1038
1313
|
};
|
|
1039
1314
|
var extra = (node) => {
|
|
1040
|
-
if (
|
|
1315
|
+
if (ts7.isIdentifier(node) || ts7.isPrivateIdentifier(node)) {
|
|
1041
1316
|
return isRasputinName(node.text) ? "" : node.text;
|
|
1042
1317
|
}
|
|
1043
|
-
if (
|
|
1318
|
+
if (ts7.isStringLiteral(node) || ts7.isNumericLiteral(node) || ts7.isNoSubstitutionTemplateLiteral(node)) {
|
|
1044
1319
|
return node.text;
|
|
1045
1320
|
}
|
|
1046
|
-
if (
|
|
1321
|
+
if (ts7.isToken(node) && !ts7.isIdentifier(node)) return ts7.SyntaxKind[node.kind] ?? "";
|
|
1047
1322
|
return "";
|
|
1048
1323
|
};
|
|
1049
1324
|
var signatureOf = (node) => {
|
|
1050
1325
|
const unwrapped = unwrapCall(node);
|
|
1051
1326
|
if (unwrapped !== node) return signatureOf(unwrapped);
|
|
1052
|
-
if (
|
|
1053
|
-
if (
|
|
1327
|
+
if (ts7.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
|
|
1328
|
+
if (ts7.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
|
|
1054
1329
|
return flattenStatements(unwrapped.tryBlock.statements).map(signatureOf).filter(Boolean).join("");
|
|
1055
1330
|
}
|
|
1056
|
-
if (
|
|
1331
|
+
if (ts7.isBlock(unwrapped)) {
|
|
1057
1332
|
const statements = flattenStatements(unwrapped.statements);
|
|
1058
1333
|
return `Block[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
|
|
1059
1334
|
}
|
|
1060
|
-
if (
|
|
1335
|
+
if (ts7.isCatchClause(unwrapped)) {
|
|
1061
1336
|
const statements = flattenStatements(unwrapped.block.statements);
|
|
1062
1337
|
const variable = unwrapped.variableDeclaration ? signatureOf(unwrapped.variableDeclaration) : "";
|
|
1063
1338
|
return `Catch${variable}[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
|
|
1064
1339
|
}
|
|
1065
|
-
if (
|
|
1340
|
+
if (ts7.isArrowFunction(unwrapped) && ts7.isBlock(unwrapped.body)) {
|
|
1066
1341
|
const statements = flattenStatements(unwrapped.body.statements);
|
|
1067
1342
|
const only = statements[0];
|
|
1068
|
-
if (statements.length === 1 && only &&
|
|
1343
|
+
if (statements.length === 1 && only && ts7.isReturnStatement(only) && only.expression) {
|
|
1069
1344
|
const expression = only.expression;
|
|
1070
1345
|
const parts2 = [];
|
|
1071
|
-
|
|
1346
|
+
ts7.forEachChild(unwrapped, (child) => {
|
|
1072
1347
|
if (child === unwrapped.body) {
|
|
1073
1348
|
const part2 = signatureOf(expression);
|
|
1074
1349
|
if (part2) parts2.push(part2);
|
|
@@ -1081,11 +1356,11 @@ var signatureOf = (node) => {
|
|
|
1081
1356
|
}
|
|
1082
1357
|
}
|
|
1083
1358
|
const parts = [];
|
|
1084
|
-
|
|
1359
|
+
ts7.forEachChild(unwrapped, (child) => {
|
|
1085
1360
|
const part = signatureOf(child);
|
|
1086
1361
|
if (part) parts.push(part);
|
|
1087
1362
|
});
|
|
1088
|
-
const kind =
|
|
1363
|
+
const kind = ts7.SyntaxKind[unwrapped.kind] ?? "Node";
|
|
1089
1364
|
const label = extra(unwrapped);
|
|
1090
1365
|
return `${kind}${label}[${parts.join(",")}]`;
|
|
1091
1366
|
};
|
|
@@ -1094,14 +1369,14 @@ var instrumentationTreesAreIsomorphic = (filePath, original, transformed) => {
|
|
|
1094
1369
|
};
|
|
1095
1370
|
|
|
1096
1371
|
// ../instrumentation/src/verify-transformed-source.ts
|
|
1097
|
-
import
|
|
1098
|
-
var transpileForVerification = (filePath, code) =>
|
|
1372
|
+
import ts8 from "typescript";
|
|
1373
|
+
var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
|
|
1099
1374
|
compilerOptions: {
|
|
1100
1375
|
// ES2020 downlevel keeps native @decorators out of `new Function`.
|
|
1101
|
-
target:
|
|
1102
|
-
module:
|
|
1376
|
+
target: ts8.ScriptTarget.ES2020,
|
|
1377
|
+
module: ts8.ModuleKind.ESNext,
|
|
1103
1378
|
allowJs: true,
|
|
1104
|
-
jsx:
|
|
1379
|
+
jsx: ts8.JsxEmit.React,
|
|
1105
1380
|
experimentalDecorators: true
|
|
1106
1381
|
},
|
|
1107
1382
|
reportDiagnostics: true,
|
|
@@ -1109,7 +1384,7 @@ var transpileForVerification = (filePath, code) => ts7.transpileModule(code, {
|
|
|
1109
1384
|
});
|
|
1110
1385
|
var hasScanOrParseError = (diagnostics) => Boolean(
|
|
1111
1386
|
diagnostics?.some(
|
|
1112
|
-
(diagnostic) => diagnostic.category ===
|
|
1387
|
+
(diagnostic) => diagnostic.category === ts8.DiagnosticCategory.Error && diagnostic.code < 2e3
|
|
1113
1388
|
)
|
|
1114
1389
|
);
|
|
1115
1390
|
var scriptBodyForEngine = (emitted) => (
|
|
@@ -1118,39 +1393,39 @@ var scriptBodyForEngine = (emitted) => (
|
|
|
1118
1393
|
);
|
|
1119
1394
|
var looksTyped = (filePath) => /\.[cm]?tsx?$/i.test(filePath);
|
|
1120
1395
|
var scriptKindFor2 = (filePath) => {
|
|
1121
|
-
if (/\.tsx$/i.test(filePath)) return
|
|
1122
|
-
if (/\.jsx$/i.test(filePath)) return
|
|
1123
|
-
if (/\.[cm]?ts$/i.test(filePath)) return
|
|
1124
|
-
return
|
|
1396
|
+
if (/\.tsx$/i.test(filePath)) return ts8.ScriptKind.TSX;
|
|
1397
|
+
if (/\.jsx$/i.test(filePath)) return ts8.ScriptKind.JSX;
|
|
1398
|
+
if (/\.[cm]?ts$/i.test(filePath)) return ts8.ScriptKind.TS;
|
|
1399
|
+
return ts8.ScriptKind.JS;
|
|
1125
1400
|
};
|
|
1126
|
-
var isIterationStatement = (node) =>
|
|
1401
|
+
var isIterationStatement = (node) => ts8.isForStatement(node) || ts8.isForOfStatement(node) || ts8.isForInStatement(node) || ts8.isWhileStatement(node) || ts8.isDoStatement(node);
|
|
1127
1402
|
var unwrapLabeled = (node) => {
|
|
1128
1403
|
let current = node;
|
|
1129
|
-
while (
|
|
1404
|
+
while (ts8.isLabeledStatement(current)) current = current.statement;
|
|
1130
1405
|
return current;
|
|
1131
1406
|
};
|
|
1132
1407
|
var hasInvalidLabelJump = (sourceFile) => {
|
|
1133
1408
|
const visit = (node, labels) => {
|
|
1134
|
-
if (
|
|
1409
|
+
if (ts8.isFunctionLike(node)) {
|
|
1135
1410
|
let nestedInvalid = false;
|
|
1136
|
-
|
|
1411
|
+
ts8.forEachChild(node, (child) => {
|
|
1137
1412
|
if (visit(child, /* @__PURE__ */ new Map())) nestedInvalid = true;
|
|
1138
1413
|
});
|
|
1139
1414
|
return nestedInvalid;
|
|
1140
1415
|
}
|
|
1141
|
-
if (
|
|
1416
|
+
if (ts8.isLabeledStatement(node)) {
|
|
1142
1417
|
const next = new Map(labels);
|
|
1143
1418
|
next.set(node.label.text, isIterationStatement(unwrapLabeled(node.statement)));
|
|
1144
1419
|
return visit(node.statement, next);
|
|
1145
1420
|
}
|
|
1146
|
-
if (
|
|
1421
|
+
if (ts8.isContinueStatement(node) && node.label) {
|
|
1147
1422
|
if (labels.get(node.label.text) !== true) return true;
|
|
1148
1423
|
}
|
|
1149
|
-
if (
|
|
1424
|
+
if (ts8.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
|
|
1150
1425
|
return true;
|
|
1151
1426
|
}
|
|
1152
1427
|
let invalid = false;
|
|
1153
|
-
|
|
1428
|
+
ts8.forEachChild(node, (child) => {
|
|
1154
1429
|
if (visit(child, labels)) invalid = true;
|
|
1155
1430
|
});
|
|
1156
1431
|
return invalid;
|
|
@@ -1193,10 +1468,10 @@ var UNTERMINATED_BARE_LEAVE = /\breturn\s+__rasputin\w*\.leave\(\)(?!\s*;|\()/;
|
|
|
1193
1468
|
var transformedSourceIsInvalid = (filePath, code) => {
|
|
1194
1469
|
if (GLUED_INSTRUMENTATION.test(code)) return true;
|
|
1195
1470
|
if (UNTERMINATED_BARE_LEAVE.test(code)) return true;
|
|
1196
|
-
const sourceFile =
|
|
1471
|
+
const sourceFile = ts8.createSourceFile(
|
|
1197
1472
|
filePath,
|
|
1198
1473
|
code,
|
|
1199
|
-
|
|
1474
|
+
ts8.ScriptTarget.Latest,
|
|
1200
1475
|
true,
|
|
1201
1476
|
scriptKindFor2(filePath)
|
|
1202
1477
|
);
|
|
@@ -1217,25 +1492,25 @@ var alreadyInstrumentedResult = (source) => ({
|
|
|
1217
1492
|
delta: { functions: [], callSites: [], destructures: [], alreadyInstrumented: true }
|
|
1218
1493
|
});
|
|
1219
1494
|
var scriptKindFor3 = (filePath) => {
|
|
1220
|
-
if (/\.tsx$/i.test(filePath)) return
|
|
1221
|
-
if (/\.jsx$/i.test(filePath)) return
|
|
1222
|
-
if (/\.[cm]?ts$/i.test(filePath)) return
|
|
1223
|
-
return
|
|
1495
|
+
if (/\.tsx$/i.test(filePath)) return ts9.ScriptKind.TSX;
|
|
1496
|
+
if (/\.jsx$/i.test(filePath)) return ts9.ScriptKind.JSX;
|
|
1497
|
+
if (/\.[cm]?ts$/i.test(filePath)) return ts9.ScriptKind.TS;
|
|
1498
|
+
return ts9.ScriptKind.JS;
|
|
1224
1499
|
};
|
|
1225
1500
|
var functionName = (node, sourceFile) => {
|
|
1226
|
-
if (
|
|
1501
|
+
if (ts9.isConstructorDeclaration(node)) return "constructor";
|
|
1227
1502
|
if (node.name) return node.name.getText(sourceFile).replace(/^['"]|['"]$/g, "");
|
|
1228
1503
|
const parent = node.parent;
|
|
1229
|
-
if (
|
|
1230
|
-
if (
|
|
1231
|
-
if (
|
|
1504
|
+
if (ts9.isVariableDeclaration(parent) && ts9.isIdentifier(parent.name)) return parent.name.text;
|
|
1505
|
+
if (ts9.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
|
|
1506
|
+
if (ts9.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
|
|
1232
1507
|
const location = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
1233
1508
|
return `anonymous@${location.line + 1}:${location.character + 1}`;
|
|
1234
1509
|
};
|
|
1235
1510
|
var functionLocationPosition = (node, sourceFile) => {
|
|
1236
1511
|
if (node.name) return node.name.getStart(sourceFile);
|
|
1237
1512
|
const parent = node.parent;
|
|
1238
|
-
if ((
|
|
1513
|
+
if ((ts9.isVariableDeclaration(parent) || ts9.isPropertyAssignment(parent)) && parent.name) {
|
|
1239
1514
|
return parent.name.getStart(sourceFile);
|
|
1240
1515
|
}
|
|
1241
1516
|
return node.getStart(sourceFile);
|
|
@@ -1248,12 +1523,12 @@ var functionBodyPrologueEnd = (body, sourceFile) => {
|
|
|
1248
1523
|
}
|
|
1249
1524
|
return end;
|
|
1250
1525
|
};
|
|
1251
|
-
var isStaticPropertyName = (name) =>
|
|
1526
|
+
var isStaticPropertyName = (name) => ts9.isIdentifier(name) || ts9.isStringLiteral(name) || ts9.isNoSubstitutionTemplateLiteral(name) || ts9.isNumericLiteral(name);
|
|
1252
1527
|
var canReconstructBinding = (name) => {
|
|
1253
|
-
if (
|
|
1254
|
-
if (
|
|
1528
|
+
if (ts9.isIdentifier(name)) return true;
|
|
1529
|
+
if (ts9.isArrayBindingPattern(name)) {
|
|
1255
1530
|
return name.elements.every(
|
|
1256
|
-
(element) =>
|
|
1531
|
+
(element) => ts9.isOmittedExpression(element) || canReconstructBinding(element.name)
|
|
1257
1532
|
);
|
|
1258
1533
|
}
|
|
1259
1534
|
return name.elements.every((element) => {
|
|
@@ -1262,10 +1537,10 @@ var canReconstructBinding = (name) => {
|
|
|
1262
1537
|
});
|
|
1263
1538
|
};
|
|
1264
1539
|
var bindingValue = (name, sourceFile) => {
|
|
1265
|
-
if (
|
|
1266
|
-
if (
|
|
1540
|
+
if (ts9.isIdentifier(name)) return name.text;
|
|
1541
|
+
if (ts9.isArrayBindingPattern(name)) {
|
|
1267
1542
|
const values = name.elements.map((element) => {
|
|
1268
|
-
if (
|
|
1543
|
+
if (ts9.isOmittedExpression(element)) return "";
|
|
1269
1544
|
const value = bindingValue(element.name, sourceFile);
|
|
1270
1545
|
return element.dotDotDotToken ? `...${value}` : value;
|
|
1271
1546
|
});
|
|
@@ -1275,7 +1550,7 @@ var bindingValue = (name, sourceFile) => {
|
|
|
1275
1550
|
const value = bindingValue(element.name, sourceFile);
|
|
1276
1551
|
if (element.dotDotDotToken) return `...${value}`;
|
|
1277
1552
|
if (!element.propertyName) return value;
|
|
1278
|
-
const key =
|
|
1553
|
+
const key = ts9.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
|
|
1279
1554
|
return `${key}:${value}`;
|
|
1280
1555
|
});
|
|
1281
1556
|
return `{${properties.join(",")}}`;
|
|
@@ -1283,7 +1558,7 @@ var bindingValue = (name, sourceFile) => {
|
|
|
1283
1558
|
var arrowArgsCapture = (node) => {
|
|
1284
1559
|
const sourceFile = node.getSourceFile();
|
|
1285
1560
|
const params = node.parameters.filter(
|
|
1286
|
-
(parameter) => !(
|
|
1561
|
+
(parameter) => !(ts9.isIdentifier(parameter.name) && parameter.name.text === "this")
|
|
1287
1562
|
);
|
|
1288
1563
|
if (!params.every((parameter) => canReconstructBinding(parameter.name))) {
|
|
1289
1564
|
return {
|
|
@@ -1298,13 +1573,13 @@ var arrowArgsCapture = (node) => {
|
|
|
1298
1573
|
return { args: `[${values.join(",")}]`, omitValues: false };
|
|
1299
1574
|
};
|
|
1300
1575
|
var isSupportedFunction = (node) => {
|
|
1301
|
-
if (!
|
|
1576
|
+
if (!ts9.isFunctionDeclaration(node) && !ts9.isFunctionExpression(node) && !ts9.isArrowFunction(node) && !ts9.isMethodDeclaration(node) && !ts9.isGetAccessorDeclaration(node) && !ts9.isSetAccessorDeclaration(node)) {
|
|
1302
1577
|
return false;
|
|
1303
1578
|
}
|
|
1304
1579
|
if (!node.body || "asteriskToken" in node && node.asteriskToken) return false;
|
|
1305
1580
|
return true;
|
|
1306
1581
|
};
|
|
1307
|
-
var isDirectivePrologue = (statement) =>
|
|
1582
|
+
var isDirectivePrologue = (statement) => ts9.isExpressionStatement(statement) && ts9.isStringLiteral(statement.expression);
|
|
1308
1583
|
var insertPositionAfterPrologue = (source, sourceFile) => {
|
|
1309
1584
|
const shebangEnd = source.startsWith("#!") ? source.indexOf("\n") + 1 : 0;
|
|
1310
1585
|
let end = shebangEnd;
|
|
@@ -1355,7 +1630,7 @@ var insertAfterSuperOrPrologue = (body, sourceFile) => {
|
|
|
1355
1630
|
const end = functionBodyPrologueEnd(body, sourceFile);
|
|
1356
1631
|
for (const statement of body.statements) {
|
|
1357
1632
|
if (isDirectivePrologue(statement)) continue;
|
|
1358
|
-
if (
|
|
1633
|
+
if (ts9.isExpressionStatement(statement) && ts9.isCallExpression(statement.expression) && statement.expression.expression.kind === ts9.SyntaxKind.SuperKeyword) {
|
|
1359
1634
|
return statement.end;
|
|
1360
1635
|
}
|
|
1361
1636
|
break;
|
|
@@ -1366,15 +1641,15 @@ var failEpilogue = (handleName, errorName, args, restoreOnCatch) => `}catch(${er
|
|
|
1366
1641
|
var walkOwnBody = (node, visitNode) => {
|
|
1367
1642
|
if (!node.body) return;
|
|
1368
1643
|
const visit = (candidate) => {
|
|
1369
|
-
if (candidate !== node &&
|
|
1644
|
+
if (candidate !== node && ts9.isFunctionLike(candidate)) return;
|
|
1370
1645
|
visitNode(candidate);
|
|
1371
|
-
|
|
1646
|
+
ts9.forEachChild(candidate, visit);
|
|
1372
1647
|
};
|
|
1373
1648
|
visit(node.body);
|
|
1374
1649
|
};
|
|
1375
1650
|
var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
|
|
1376
1651
|
walkOwnBody(node, (candidate) => {
|
|
1377
|
-
if (!
|
|
1652
|
+
if (!ts9.isAwaitExpression(candidate)) return;
|
|
1378
1653
|
wrap(
|
|
1379
1654
|
edits,
|
|
1380
1655
|
candidate.expression.getStart(sourceFile),
|
|
@@ -1395,7 +1670,7 @@ var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
|
|
|
1395
1670
|
};
|
|
1396
1671
|
var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) => {
|
|
1397
1672
|
walkOwnBody(node, (candidate) => {
|
|
1398
|
-
if (!
|
|
1673
|
+
if (!ts9.isTryStatement(candidate)) return;
|
|
1399
1674
|
const blocks = [candidate.catchClause?.block, candidate.finallyBlock];
|
|
1400
1675
|
for (const block of blocks) {
|
|
1401
1676
|
if (!block) continue;
|
|
@@ -1411,10 +1686,10 @@ var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) =>
|
|
|
1411
1686
|
});
|
|
1412
1687
|
};
|
|
1413
1688
|
var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
|
|
1414
|
-
if (!node.body || !
|
|
1689
|
+
if (!node.body || !ts9.isBlock(node.body)) return;
|
|
1415
1690
|
const visit = (candidate, at) => {
|
|
1416
|
-
if (candidate !== node &&
|
|
1417
|
-
if (
|
|
1691
|
+
if (candidate !== node && ts9.isFunctionLike(candidate)) return;
|
|
1692
|
+
if (ts9.isReturnStatement(candidate) && candidate.expression) {
|
|
1418
1693
|
const expression = candidate.expression;
|
|
1419
1694
|
wrap(
|
|
1420
1695
|
edits,
|
|
@@ -1426,17 +1701,17 @@ var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
|
|
|
1426
1701
|
);
|
|
1427
1702
|
return;
|
|
1428
1703
|
}
|
|
1429
|
-
|
|
1704
|
+
ts9.forEachChild(candidate, (child) => visit(child, at + 1));
|
|
1430
1705
|
};
|
|
1431
1706
|
visit(node.body, depth + 1);
|
|
1432
1707
|
};
|
|
1433
1708
|
var transformSource = (source, options) => {
|
|
1434
1709
|
if (source.includes("@rasputin-ignore-file")) return void 0;
|
|
1435
1710
|
if (sourceIsRasputinInstrumented(source)) return alreadyInstrumentedResult(source);
|
|
1436
|
-
const sourceFile =
|
|
1711
|
+
const sourceFile = ts9.createSourceFile(
|
|
1437
1712
|
options.filePath,
|
|
1438
1713
|
source,
|
|
1439
|
-
|
|
1714
|
+
ts9.ScriptTarget.Latest,
|
|
1440
1715
|
true,
|
|
1441
1716
|
scriptKindFor3(options.filePath)
|
|
1442
1717
|
);
|
|
@@ -1457,10 +1732,31 @@ var transformSource = (source, options) => {
|
|
|
1457
1732
|
absolutePath
|
|
1458
1733
|
};
|
|
1459
1734
|
const pending = [];
|
|
1460
|
-
const
|
|
1735
|
+
const identityNodes = [];
|
|
1736
|
+
const rememberIdentity = (node, collected) => {
|
|
1737
|
+
identityNodes.push({ node, runtimeId: collected.functionId });
|
|
1738
|
+
};
|
|
1739
|
+
const withDeclarations = (result) => {
|
|
1740
|
+
if (!options.functionMetrics) return result;
|
|
1741
|
+
if (identityNodes.length === 0) return { ...result, declarations: [] };
|
|
1742
|
+
const declarations = collectFunctionMetricDeclarations({
|
|
1743
|
+
sourceFile,
|
|
1744
|
+
filePath: options.filePath,
|
|
1745
|
+
functions: identityNodes,
|
|
1746
|
+
originalAst: !options.mapLocation,
|
|
1747
|
+
mapLocation: options.mapLocation
|
|
1748
|
+
});
|
|
1749
|
+
const byId = new Map(declarations.map((declaration) => [declaration.runtime_id, declaration]));
|
|
1750
|
+
for (const fn of result.delta.functions) {
|
|
1751
|
+
fn.metricsDeclaration = byId.get(fn.functionId);
|
|
1752
|
+
}
|
|
1753
|
+
return { ...result, declarations };
|
|
1754
|
+
};
|
|
1755
|
+
const skipFunction = (node, collected, reason) => {
|
|
1461
1756
|
collected.instrumented = false;
|
|
1462
1757
|
collected.skipReason = reason;
|
|
1463
1758
|
delta.functions.push(collected);
|
|
1759
|
+
rememberIdentity(node, collected);
|
|
1464
1760
|
if (process.env.RASPUTIN_DEBUG === "1") {
|
|
1465
1761
|
console.info(
|
|
1466
1762
|
`[rasputin] skipped instrumentation for ${collected.name} in ${options.filePath}: ${reason}`
|
|
@@ -1477,9 +1773,9 @@ var transformSource = (source, options) => {
|
|
|
1477
1773
|
);
|
|
1478
1774
|
if (collected) {
|
|
1479
1775
|
collected.asyncFunction = true;
|
|
1480
|
-
skipFunction(collected, "unsupported_async_generator");
|
|
1776
|
+
skipFunction(node, collected, "unsupported_async_generator");
|
|
1481
1777
|
}
|
|
1482
|
-
|
|
1778
|
+
ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
|
|
1483
1779
|
return;
|
|
1484
1780
|
}
|
|
1485
1781
|
if (isSyncGeneratorLike(node) && node.body) {
|
|
@@ -1489,25 +1785,27 @@ var transformSource = (source, options) => {
|
|
|
1489
1785
|
absolutePath,
|
|
1490
1786
|
options.mapLocation
|
|
1491
1787
|
);
|
|
1492
|
-
if (collected)
|
|
1493
|
-
|
|
1788
|
+
if (collected)
|
|
1789
|
+
skipFunction(node, collected, "unsupported_sync_generator");
|
|
1790
|
+
ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
|
|
1494
1791
|
return;
|
|
1495
1792
|
}
|
|
1496
|
-
if (
|
|
1793
|
+
if (ts9.isConstructorDeclaration(node) && node.body) {
|
|
1497
1794
|
const collected = collectWrappedFunction(
|
|
1498
1795
|
node,
|
|
1499
1796
|
sourceFile,
|
|
1500
1797
|
absolutePath,
|
|
1501
1798
|
options.mapLocation
|
|
1502
1799
|
);
|
|
1503
|
-
if (collected)
|
|
1504
|
-
|
|
1800
|
+
if (collected)
|
|
1801
|
+
skipFunction(node, collected, "unsupported_constructor");
|
|
1802
|
+
ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
|
|
1505
1803
|
return;
|
|
1506
1804
|
}
|
|
1507
1805
|
if (isSupportedFunction(node)) {
|
|
1508
1806
|
const collected = collectWrappedFunction(node, sourceFile, absolutePath, options.mapLocation);
|
|
1509
1807
|
if (!collected) {
|
|
1510
|
-
|
|
1808
|
+
ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
|
|
1511
1809
|
return;
|
|
1512
1810
|
}
|
|
1513
1811
|
if (options.decideFunction?.({
|
|
@@ -1516,15 +1814,15 @@ var transformSource = (source, options) => {
|
|
|
1516
1814
|
filePath: options.filePath,
|
|
1517
1815
|
name: collected.name
|
|
1518
1816
|
}) === "skip") {
|
|
1519
|
-
|
|
1817
|
+
ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
|
|
1520
1818
|
return;
|
|
1521
1819
|
}
|
|
1522
1820
|
const asyncFunction = isAsyncFunctionLike(node);
|
|
1523
1821
|
collected.asyncFunction = asyncFunction;
|
|
1524
1822
|
const decision = asyncFunction ? decideAsyncInstrumentation(node, sourceFile) : { action: "inline" };
|
|
1525
1823
|
if (decision.action === "skip") {
|
|
1526
|
-
skipFunction(collected, decision.reason);
|
|
1527
|
-
|
|
1824
|
+
skipFunction(node, collected, decision.reason);
|
|
1825
|
+
ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
|
|
1528
1826
|
return;
|
|
1529
1827
|
}
|
|
1530
1828
|
if (functionHasPreBodyParameterEvaluation(node)) {
|
|
@@ -1537,29 +1835,30 @@ var transformSource = (source, options) => {
|
|
|
1537
1835
|
suspendResume: decision.action === "suspend_resume"
|
|
1538
1836
|
});
|
|
1539
1837
|
delta.functions.push(collected);
|
|
1540
|
-
|
|
1838
|
+
rememberIdentity(node, collected);
|
|
1839
|
+
ts9.forEachChild(node, (child) => visit(child, collected, depth + 1));
|
|
1541
1840
|
return;
|
|
1542
1841
|
}
|
|
1543
|
-
if (caller && (
|
|
1842
|
+
if (caller && (ts9.isCallExpression(node) || ts9.isNewExpression(node))) {
|
|
1544
1843
|
const site = collectCallSite(node, caller, collectContext);
|
|
1545
1844
|
if (site) delta.callSites.push(site);
|
|
1546
1845
|
}
|
|
1547
|
-
if (caller &&
|
|
1846
|
+
if (caller && ts9.isVariableDeclaration(node)) {
|
|
1548
1847
|
const destructure = collectParamDestructure(node, caller, collectContext);
|
|
1549
1848
|
if (destructure) delta.destructures.push(destructure);
|
|
1550
1849
|
}
|
|
1551
|
-
|
|
1850
|
+
ts9.forEachChild(node, (child) => visit(child, caller, depth + 1));
|
|
1552
1851
|
};
|
|
1553
1852
|
visit(sourceFile, void 0, 0);
|
|
1554
1853
|
if (pending.length === 0) {
|
|
1555
|
-
return delta.functions.length > 0 ? { code: source, delta } : void 0;
|
|
1854
|
+
return delta.functions.length > 0 ? withDeclarations({ code: source, delta }) : void 0;
|
|
1556
1855
|
}
|
|
1557
1856
|
for (const [planIndex, entry] of pending.entries()) {
|
|
1558
|
-
const captured =
|
|
1857
|
+
const captured = ts9.isArrowFunction(entry.node) ? arrowArgsCapture(entry.node) : { args: "arguments", omitValues: false };
|
|
1559
1858
|
const omitArg = captured.omitValues ? ",true" : "";
|
|
1560
1859
|
const enterCall = `${runName}.enter(${planIndex},${captured.args}${omitArg})`;
|
|
1561
1860
|
const epilogue = failEpilogue(handleName, errorName, captured.args, entry.suspendResume);
|
|
1562
|
-
if (
|
|
1861
|
+
if (ts9.isBlock(entry.node.body)) {
|
|
1563
1862
|
const prologueAt = insertAfterSuperOrPrologue(entry.node.body, sourceFile);
|
|
1564
1863
|
const closeAt = entry.node.body.end - 1;
|
|
1565
1864
|
wrap(
|
|
@@ -1625,7 +1924,7 @@ var transformSource = (source, options) => {
|
|
|
1625
1924
|
`[rasputin] skipped instrumentation for ${options.filePath}: verification_failed`
|
|
1626
1925
|
);
|
|
1627
1926
|
}
|
|
1628
|
-
return { code: source, delta };
|
|
1927
|
+
return withDeclarations({ code: source, delta });
|
|
1629
1928
|
};
|
|
1630
1929
|
if (verify && transformedSourceIsInvalid(options.filePath, transformed)) {
|
|
1631
1930
|
if (transformedSourceIsInvalid(options.filePath, source)) {
|
|
@@ -1641,34 +1940,34 @@ var transformSource = (source, options) => {
|
|
|
1641
1940
|
if (verify && !instrumentationTreesAreIsomorphic(options.filePath, source, transformed)) {
|
|
1642
1941
|
return refuseTransformed();
|
|
1643
1942
|
}
|
|
1644
|
-
return {
|
|
1943
|
+
return withDeclarations({
|
|
1645
1944
|
code: attachInlineSourceMap(source, transformed, options.filePath, edits, basename),
|
|
1646
1945
|
delta,
|
|
1647
1946
|
map: exactTransformMap(source, transformed, basename(options.filePath), edits)
|
|
1648
|
-
};
|
|
1947
|
+
});
|
|
1649
1948
|
};
|
|
1650
1949
|
|
|
1651
1950
|
// ../instrumentation/src/json-producer-sites.ts
|
|
1652
|
-
import
|
|
1951
|
+
import ts11 from "typescript";
|
|
1653
1952
|
|
|
1654
1953
|
// ../instrumentation/src/literal-sites.ts
|
|
1655
|
-
import
|
|
1954
|
+
import ts12 from "typescript";
|
|
1656
1955
|
|
|
1657
1956
|
// ../instrumentation/src/observe-sites.ts
|
|
1658
1957
|
import { propertyNameIsSensitive as propertyNameIsSensitive2 } from "@rasputin-ai/core";
|
|
1659
|
-
import
|
|
1958
|
+
import ts13 from "typescript";
|
|
1660
1959
|
|
|
1661
1960
|
// ../instrumentation/src/verify-browser-source.ts
|
|
1662
|
-
import
|
|
1961
|
+
import ts14 from "typescript";
|
|
1663
1962
|
|
|
1664
1963
|
// ../instrumentation/src/provenance-function-edits.ts
|
|
1665
|
-
import
|
|
1964
|
+
import ts15 from "typescript";
|
|
1666
1965
|
|
|
1667
1966
|
// ../instrumentation/src/source-map-location.ts
|
|
1668
1967
|
import { originalPositionFor as originalPositionFor3, TraceMap as TraceMap4 } from "@jridgewell/trace-mapping";
|
|
1669
1968
|
|
|
1670
1969
|
// src/sdk-meta.ts
|
|
1671
|
-
var SDK_VERSION = "0.
|
|
1970
|
+
var SDK_VERSION = "0.14.0";
|
|
1672
1971
|
|
|
1673
1972
|
// src/auto-instrumentation/transform-disk-cache.ts
|
|
1674
1973
|
var projectCacheDir = () => {
|
|
@@ -1728,7 +2027,12 @@ var ensureTrustedCacheDir = (directory, explicit) => {
|
|
|
1728
2027
|
return false;
|
|
1729
2028
|
}
|
|
1730
2029
|
};
|
|
1731
|
-
var
|
|
2030
|
+
var identityCacheToken = (filePath, metricsRequested) => {
|
|
2031
|
+
if (!metricsRequested) return "no-metrics";
|
|
2032
|
+
const locator = sourceLocatorFromFile4(filePath);
|
|
2033
|
+
return `metrics-manifest-v1\0${locator?.packageName ?? ""}\0${locator?.packageRelativePath ?? ""}`;
|
|
2034
|
+
};
|
|
2035
|
+
var cacheKey = (source, filePath, verifyTransform, metricsRequested) => createHash("sha256").update(SDK_VERSION).update("\0").update(filePath).update("\0").update(source).update("\0").update(sourceMapPayloadForCache(filePath, source)).update("\0").update(verifyTransform ? "1" : "0").update("\0").update(identityCacheToken(filePath, metricsRequested)).digest("hex");
|
|
1732
2036
|
var revive = (cached) => ({
|
|
1733
2037
|
code: cached.code,
|
|
1734
2038
|
delta: {
|
|
@@ -1739,9 +2043,10 @@ var revive = (cached) => ({
|
|
|
1739
2043
|
})),
|
|
1740
2044
|
callSites: cached.delta.callSites,
|
|
1741
2045
|
destructures: cached.delta.destructures
|
|
1742
|
-
}
|
|
2046
|
+
},
|
|
2047
|
+
...cached.declarations ? { declarations: cached.declarations } : {}
|
|
1743
2048
|
});
|
|
1744
|
-
var persistable = (result) => ({
|
|
2049
|
+
var persistable = (result, metricsRequested) => ({
|
|
1745
2050
|
code: result.code,
|
|
1746
2051
|
delta: {
|
|
1747
2052
|
functions: result.delta.functions.map((fn) => ({
|
|
@@ -1750,7 +2055,8 @@ var persistable = (result) => ({
|
|
|
1750
2055
|
})),
|
|
1751
2056
|
callSites: result.delta.callSites,
|
|
1752
2057
|
destructures: result.delta.destructures
|
|
1753
|
-
}
|
|
2058
|
+
},
|
|
2059
|
+
...metricsRequested || result.declarations ? { declarations: result.declarations ?? [] } : {}
|
|
1754
2060
|
});
|
|
1755
2061
|
var evictOldest = (directory, keep) => {
|
|
1756
2062
|
const entries = readdirSync(directory).map((name) => {
|
|
@@ -1781,10 +2087,10 @@ var readCache = (directory, key) => {
|
|
|
1781
2087
|
return void 0;
|
|
1782
2088
|
}
|
|
1783
2089
|
};
|
|
1784
|
-
var writeCache = (directory, key, result, limit) => {
|
|
2090
|
+
var writeCache = (directory, key, result, limit, metricsRequested) => {
|
|
1785
2091
|
try {
|
|
1786
2092
|
const path = join2(directory, `${key}.json`);
|
|
1787
|
-
writeFileSync(path, JSON.stringify(persistable(result)), { mode: 384 });
|
|
2093
|
+
writeFileSync(path, JSON.stringify(persistable(result, metricsRequested)), { mode: 384 });
|
|
1788
2094
|
try {
|
|
1789
2095
|
chmodSync(path, 384);
|
|
1790
2096
|
} catch {
|
|
@@ -1801,12 +2107,22 @@ var transformSourceCached = (source, options, cache = {}) => {
|
|
|
1801
2107
|
if (!cacheEnabled()) return transformSource(source, transformOptions);
|
|
1802
2108
|
const explicit = cache.directory !== void 0;
|
|
1803
2109
|
const directory = cache.directory ?? resolveTransformCacheDir();
|
|
1804
|
-
if (!ensureTrustedCacheDir(directory, explicit))
|
|
1805
|
-
|
|
2110
|
+
if (!ensureTrustedCacheDir(directory, explicit)) {
|
|
2111
|
+
return transformSource(source, transformOptions);
|
|
2112
|
+
}
|
|
2113
|
+
const metricsRequested = transformOptions.functionMetrics === true;
|
|
2114
|
+
const key = cacheKey(
|
|
2115
|
+
source,
|
|
2116
|
+
options.filePath,
|
|
2117
|
+
transformOptions.verifyTransform === true,
|
|
2118
|
+
metricsRequested
|
|
2119
|
+
);
|
|
1806
2120
|
const hit = readCache(directory, key);
|
|
1807
|
-
if (hit) return hit;
|
|
2121
|
+
if (hit && !(metricsRequested && hit.declarations === void 0)) return hit;
|
|
1808
2122
|
const result = transformSource(source, transformOptions);
|
|
1809
|
-
if (result)
|
|
2123
|
+
if (result) {
|
|
2124
|
+
writeCache(directory, key, result, cache.limit ?? defaultCacheLimit(), metricsRequested);
|
|
2125
|
+
}
|
|
1810
2126
|
return result;
|
|
1811
2127
|
};
|
|
1812
2128
|
|
|
@@ -1850,9 +2166,13 @@ var registerRasputinNodeHooks = (options = {}) => {
|
|
|
1850
2166
|
try {
|
|
1851
2167
|
const transformed = transformSourceCached(source, {
|
|
1852
2168
|
filePath,
|
|
1853
|
-
mapLocation: createSourceMapLocationMapper(filePath, source)
|
|
2169
|
+
mapLocation: createSourceMapLocationMapper(filePath, source),
|
|
2170
|
+
functionMetrics: true
|
|
1854
2171
|
});
|
|
1855
2172
|
if (!transformed) return result;
|
|
2173
|
+
if (transformed.declarations) {
|
|
2174
|
+
registerFunctionMetricDeclarations(transformed.declarations);
|
|
2175
|
+
}
|
|
1856
2176
|
recordInstrumentationManifestDelta(filePath, transformed.delta);
|
|
1857
2177
|
if (debug) {
|
|
1858
2178
|
console.info(
|