@rasputin-ai/browser 0.6.2 → 0.7.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.
@@ -81,7 +81,7 @@ var runtimeFunctionId = (definition) => {
81
81
  return `rf_${createHash("sha256").update(identity).digest("base64url").slice(0, 24)}`;
82
82
  };
83
83
 
84
- // ../node_modules/.bun/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
84
+ // ../../node_modules/.bun/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
85
85
  var comma = ",".charCodeAt(0);
86
86
  var semicolon = ";".charCodeAt(0);
87
87
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -252,7 +252,7 @@ function encode(decoded) {
252
252
  return writer.flush();
253
253
  }
254
254
 
255
- // ../node_modules/.bun/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
255
+ // ../../node_modules/.bun/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
256
256
  var schemeRegex = /^[\w+.-]+:\/\//;
257
257
  var urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
258
258
  var fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
@@ -421,7 +421,7 @@ function resolve2(input, base) {
421
421
  }
422
422
  }
423
423
 
424
- // ../node_modules/.bun/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
424
+ // ../../node_modules/.bun/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
425
425
  function stripFilename(path) {
426
426
  if (!path) return "";
427
427
  const index = path.lastIndexOf("/");
@@ -666,6 +666,11 @@ var DEFAULTS = {
666
666
  shutdownFlushMs: 2e3
667
667
  };
668
668
 
669
+ // ../core/src/create-client/error-observation.ts
670
+ var runtimeStateUnavailable = Symbol.for(
671
+ "rasputin.runtime-state.unavailable"
672
+ );
673
+
669
674
  // ../core/src/derivation/sensitive-property-name.ts
670
675
  var DEFAULT_SENSITIVE_PROPERTY_NAMES = [
671
676
  "password",
@@ -849,7 +854,7 @@ var encodeFunctionPlan = (source) => {
849
854
  var AUTOMATIC_RUNTIME_SYMBOL = "rasputin.execution.runtime.v3";
850
855
 
851
856
  // ../instrumentation/src/classify-function.ts
852
- import ts4 from "typescript";
857
+ import ts3 from "typescript";
853
858
 
854
859
  // ../instrumentation/src/collect-instrumentation-delta.ts
855
860
  import ts from "typescript";
@@ -1045,81 +1050,6 @@ var peel = (expression) => {
1045
1050
  return current;
1046
1051
  };
1047
1052
 
1048
- // ../instrumentation/src/svelte-generated.ts
1049
- import ts3 from "typescript";
1050
- var SVELTE_TEMPLATE_FACTORIES = /* @__PURE__ */ new Set(["from_html", "from_svg", "template"]);
1051
- var SVELTE_PROP_GETTERS = /* @__PURE__ */ new Set(["prop", "prop_source"]);
1052
- var isFunctionLike = (node) => ts3.isFunctionDeclaration(node) || ts3.isFunctionExpression(node) || ts3.isArrowFunction(node) || ts3.isMethodDeclaration(node) || ts3.isGetAccessorDeclaration(node) || ts3.isSetAccessorDeclaration(node);
1053
- var isDescendant = (root, node) => {
1054
- let current = node;
1055
- while (current) {
1056
- if (current === root) return true;
1057
- current = current.parent;
1058
- }
1059
- return false;
1060
- };
1061
- var svelteCallMethod = (call) => {
1062
- const callee = call.expression;
1063
- if (!ts3.isPropertyAccessExpression(callee) || !ts3.isIdentifier(callee.expression)) {
1064
- return void 0;
1065
- }
1066
- if (callee.expression.text !== "$" || !ts3.isIdentifier(callee.name)) return void 0;
1067
- return callee.name.text;
1068
- };
1069
- var svelteRuntimeMethod = (node) => {
1070
- const parent = node.parent;
1071
- if (!parent || !ts3.isCallExpression(parent)) return void 0;
1072
- if (!parent.arguments.some((argument) => argument === node)) return void 0;
1073
- return svelteCallMethod(parent);
1074
- };
1075
- var enclosingSvelteRuntimeMethod = (node) => {
1076
- const direct = svelteRuntimeMethod(node);
1077
- if (direct) return direct;
1078
- let current = node;
1079
- let parent = node.parent;
1080
- while (parent) {
1081
- if (isFunctionLike(parent) && parent.body) {
1082
- if (current === parent.body || isDescendant(parent.body, current)) return void 0;
1083
- }
1084
- if (ts3.isCallExpression(parent)) {
1085
- const method = svelteCallMethod(parent);
1086
- if (method && parent.arguments.some((argument) => argument === current || isDescendant(argument, current))) {
1087
- return method;
1088
- }
1089
- }
1090
- current = parent;
1091
- parent = parent.parent;
1092
- }
1093
- return void 0;
1094
- };
1095
- var svelteGeneratedIdentifierCallees = (sourceFile) => {
1096
- const names = /* @__PURE__ */ new Set();
1097
- const visit = (node) => {
1098
- if (ts3.isVariableDeclaration(node) && ts3.isIdentifier(node.name) && node.initializer && ts3.isCallExpression(node.initializer)) {
1099
- const method = svelteCallMethod(node.initializer);
1100
- if (method && (SVELTE_TEMPLATE_FACTORIES.has(method) || SVELTE_PROP_GETTERS.has(method))) {
1101
- names.add(node.name.text);
1102
- }
1103
- }
1104
- ts3.forEachChild(node, visit);
1105
- };
1106
- visit(sourceFile);
1107
- return names;
1108
- };
1109
- var isSvelteCompilerCall = (call, sourceFile, identifierCallees) => {
1110
- if (svelteCallMethod(call)) return true;
1111
- if (!ts3.isCallExpression(call) || !ts3.isIdentifier(call.expression)) return false;
1112
- if (call.expression.text.startsWith("$$")) return true;
1113
- const names = identifierCallees ?? svelteGeneratedIdentifierCallees(sourceFile);
1114
- return names.has(call.expression.text);
1115
- };
1116
-
1117
- // ../instrumentation/src/svelte-module-path.ts
1118
- var isSvelteCompiledPath = (idOrPath) => {
1119
- const path = idOrPath.split("?")[0]?.replaceAll("\\", "/") ?? "";
1120
- return path.endsWith(".svelte") || path.endsWith(".svelte.ts") || path.endsWith(".svelte.js");
1121
- };
1122
-
1123
1053
  // ../instrumentation/src/classify-function.ts
1124
1054
  var ALLOWED_STATIC_CALLS = /* @__PURE__ */ new Map([
1125
1055
  ["Array", /* @__PURE__ */ new Set(["isArray"])],
@@ -1128,54 +1058,54 @@ var ALLOWED_STATIC_CALLS = /* @__PURE__ */ new Map([
1128
1058
  ["Object", /* @__PURE__ */ new Set(["is"])]
1129
1059
  ]);
1130
1060
  var functionName = (node, sourceFile) => {
1131
- if (ts4.isConstructorDeclaration(node)) return "constructor";
1061
+ if (ts3.isConstructorDeclaration(node)) return "constructor";
1132
1062
  if (node.name) return node.name.getText(sourceFile).replace(/^['"]|['"]$/g, "");
1133
1063
  const parent = node.parent;
1134
- if (ts4.isVariableDeclaration(parent) && ts4.isIdentifier(parent.name)) return parent.name.text;
1135
- if (ts4.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
1136
- if (ts4.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
1064
+ if (ts3.isVariableDeclaration(parent) && ts3.isIdentifier(parent.name)) return parent.name.text;
1065
+ if (ts3.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
1066
+ if (ts3.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
1137
1067
  const location = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
1138
1068
  return `anonymous@${location.line + 1}:${location.character + 1}`;
1139
1069
  };
1140
1070
  var functionLocationPosition = (node, sourceFile) => {
1141
1071
  if (node.name) return node.name.getStart(sourceFile);
1142
1072
  const parent = node.parent;
1143
- if ((ts4.isVariableDeclaration(parent) || ts4.isPropertyAssignment(parent)) && parent.name) {
1073
+ if ((ts3.isVariableDeclaration(parent) || ts3.isPropertyAssignment(parent)) && parent.name) {
1144
1074
  return parent.name.getStart(sourceFile);
1145
1075
  }
1146
1076
  return node.getStart(sourceFile);
1147
1077
  };
1148
1078
  var isSupportedFunction = (node) => {
1149
- if (!ts4.isFunctionDeclaration(node) && !ts4.isFunctionExpression(node) && !ts4.isArrowFunction(node) && !ts4.isMethodDeclaration(node) && !ts4.isGetAccessorDeclaration(node) && !ts4.isSetAccessorDeclaration(node)) {
1079
+ if (!ts3.isFunctionDeclaration(node) && !ts3.isFunctionExpression(node) && !ts3.isArrowFunction(node) && !ts3.isMethodDeclaration(node) && !ts3.isGetAccessorDeclaration(node) && !ts3.isSetAccessorDeclaration(node)) {
1150
1080
  return false;
1151
1081
  }
1152
1082
  if (!node.body || "asteriskToken" in node && node.asteriskToken) return false;
1153
1083
  return true;
1154
1084
  };
1155
1085
  var singleReturnedExpression = (body) => {
1156
- if (!ts4.isBlock(body)) return body;
1086
+ if (!ts3.isBlock(body)) return body;
1157
1087
  if (body.statements.length === 0) return void 0;
1158
1088
  if (body.statements.length !== 1) return void 0;
1159
1089
  const statement = body.statements[0];
1160
- if (!statement || !ts4.isReturnStatement(statement)) return void 0;
1090
+ if (!statement || !ts3.isReturnStatement(statement)) return void 0;
1161
1091
  return statement.expression;
1162
1092
  };
1163
1093
  var isLiteralExpression = (expression) => {
1164
1094
  const node = peel(expression);
1165
- if (ts4.isStringLiteral(node) || ts4.isNoSubstitutionTemplateLiteral(node)) return true;
1166
- if (ts4.isNumericLiteral(node)) return true;
1167
- if (node.kind === ts4.SyntaxKind.TrueKeyword || node.kind === ts4.SyntaxKind.FalseKeyword || node.kind === ts4.SyntaxKind.NullKeyword) {
1095
+ if (ts3.isStringLiteral(node) || ts3.isNoSubstitutionTemplateLiteral(node)) return true;
1096
+ if (ts3.isNumericLiteral(node)) return true;
1097
+ if (node.kind === ts3.SyntaxKind.TrueKeyword || node.kind === ts3.SyntaxKind.FalseKeyword || node.kind === ts3.SyntaxKind.NullKeyword) {
1168
1098
  return true;
1169
1099
  }
1170
- if (ts4.isIdentifier(node) && (node.text === "undefined" || node.text === "NaN")) return true;
1100
+ if (ts3.isIdentifier(node) && (node.text === "undefined" || node.text === "NaN")) return true;
1171
1101
  return false;
1172
1102
  };
1173
1103
  var isLiteralOnlyBody = (body) => {
1174
- if (ts4.isBlock(body)) {
1104
+ if (ts3.isBlock(body)) {
1175
1105
  if (body.statements.length === 0) return true;
1176
1106
  if (body.statements.length !== 1) return false;
1177
1107
  const statement = body.statements[0];
1178
- if (!statement || !ts4.isReturnStatement(statement)) return false;
1108
+ if (!statement || !ts3.isReturnStatement(statement)) return false;
1179
1109
  return !statement.expression || isLiteralExpression(statement.expression);
1180
1110
  }
1181
1111
  return isLiteralExpression(body);
@@ -1183,8 +1113,8 @@ var isLiteralOnlyBody = (body) => {
1183
1113
  var identifierParams = (node) => {
1184
1114
  const names = [];
1185
1115
  for (const parameter of node.parameters) {
1186
- if (ts4.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
1187
- if (!ts4.isIdentifier(parameter.name) || parameter.dotDotDotToken) return [];
1116
+ if (ts3.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
1117
+ if (!ts3.isIdentifier(parameter.name) || parameter.dotDotDotToken) return [];
1188
1118
  names.push(parameter.name.text);
1189
1119
  }
1190
1120
  return names;
@@ -1195,42 +1125,42 @@ var isIdentityFunction = (node) => {
1195
1125
  const returned = singleReturnedExpression(node.body);
1196
1126
  if (!returned) return false;
1197
1127
  const value = peel(returned);
1198
- return ts4.isIdentifier(value) && value.text === params[0];
1128
+ return ts3.isIdentifier(value) && value.text === params[0];
1199
1129
  };
1200
1130
  var isAllowedTypeCall = (expression) => {
1201
1131
  const callee = peel(expression);
1202
- if (ts4.isIdentifier(callee)) {
1132
+ if (ts3.isIdentifier(callee)) {
1203
1133
  return callee.text === "Boolean";
1204
1134
  }
1205
- if (!ts4.isPropertyAccessExpression(callee) || !ts4.isIdentifier(callee.expression)) return false;
1135
+ if (!ts3.isPropertyAccessExpression(callee) || !ts3.isIdentifier(callee.expression)) return false;
1206
1136
  const allowed = ALLOWED_STATIC_CALLS.get(callee.expression.text);
1207
- return !!allowed && ts4.isIdentifier(callee.name) && allowed.has(callee.name.text);
1137
+ return !!allowed && ts3.isIdentifier(callee.name) && allowed.has(callee.name.text);
1208
1138
  };
1209
1139
  var isPredicateAtom = (expression) => {
1210
1140
  const node = peel(expression);
1211
- if (isLiteralExpression(node) || ts4.isIdentifier(node)) return true;
1212
- if (node.kind === ts4.SyntaxKind.ThisKeyword) return true;
1213
- if (ts4.isPropertyAccessExpression(node)) return isPredicateAtom(node.expression);
1214
- if (ts4.isElementAccessExpression(node)) {
1141
+ if (isLiteralExpression(node) || ts3.isIdentifier(node)) return true;
1142
+ if (node.kind === ts3.SyntaxKind.ThisKeyword) return true;
1143
+ if (ts3.isPropertyAccessExpression(node)) return isPredicateAtom(node.expression);
1144
+ if (ts3.isElementAccessExpression(node)) {
1215
1145
  return isPredicateAtom(node.expression) && isPredicateAtom(node.argumentExpression);
1216
1146
  }
1217
1147
  return false;
1218
1148
  };
1219
1149
  var isPredicateExpression = (expression) => {
1220
1150
  const node = peel(expression);
1221
- if (ts4.isTypeOfExpression(node)) return isPredicateAtom(node.expression);
1222
- if (ts4.isPrefixUnaryExpression(node) && node.operator === ts4.SyntaxKind.ExclamationToken) {
1151
+ if (ts3.isTypeOfExpression(node)) return isPredicateAtom(node.expression);
1152
+ if (ts3.isPrefixUnaryExpression(node) && node.operator === ts3.SyntaxKind.ExclamationToken) {
1223
1153
  return isPredicateExpression(node.operand) || isPredicateAtom(node.operand);
1224
1154
  }
1225
- if (ts4.isBinaryExpression(node)) {
1155
+ if (ts3.isBinaryExpression(node)) {
1226
1156
  const kind = node.operatorToken.kind;
1227
- if (kind === ts4.SyntaxKind.EqualsEqualsEqualsToken || kind === ts4.SyntaxKind.ExclamationEqualsEqualsToken || kind === ts4.SyntaxKind.EqualsEqualsToken || kind === ts4.SyntaxKind.ExclamationEqualsToken || kind === ts4.SyntaxKind.LessThanToken || kind === ts4.SyntaxKind.GreaterThanToken || kind === ts4.SyntaxKind.LessThanEqualsToken || kind === ts4.SyntaxKind.GreaterThanEqualsToken || kind === ts4.SyntaxKind.AmpersandAmpersandToken || kind === ts4.SyntaxKind.BarBarToken || kind === ts4.SyntaxKind.QuestionQuestionToken || kind === ts4.SyntaxKind.InstanceOfKeyword) {
1157
+ if (kind === ts3.SyntaxKind.EqualsEqualsEqualsToken || kind === ts3.SyntaxKind.ExclamationEqualsEqualsToken || kind === ts3.SyntaxKind.EqualsEqualsToken || kind === ts3.SyntaxKind.ExclamationEqualsToken || kind === ts3.SyntaxKind.LessThanToken || kind === ts3.SyntaxKind.GreaterThanToken || kind === ts3.SyntaxKind.LessThanEqualsToken || kind === ts3.SyntaxKind.GreaterThanEqualsToken || kind === ts3.SyntaxKind.AmpersandAmpersandToken || kind === ts3.SyntaxKind.BarBarToken || kind === ts3.SyntaxKind.QuestionQuestionToken || kind === ts3.SyntaxKind.InstanceOfKeyword) {
1228
1158
  const side = (value) => isPredicateExpression(value) || isPredicateAtom(value);
1229
1159
  return side(node.left) && side(node.right);
1230
1160
  }
1231
1161
  return false;
1232
1162
  }
1233
- if (ts4.isCallExpression(node)) {
1163
+ if (ts3.isCallExpression(node)) {
1234
1164
  return isAllowedTypeCall(node.expression) && node.arguments.every(
1235
1165
  (argument) => isPredicateExpression(argument) || isPredicateAtom(argument)
1236
1166
  );
@@ -1241,15 +1171,15 @@ var bodyHasDisallowedControl = (body) => {
1241
1171
  let found2 = false;
1242
1172
  const visit = (node) => {
1243
1173
  if (found2) return;
1244
- if (ts4.isAwaitExpression(node) || ts4.isYieldExpression(node) || ts4.isThrowStatement(node) || ts4.isTryStatement(node) || ts4.isNewExpression(node)) {
1174
+ if (ts3.isAwaitExpression(node) || ts3.isYieldExpression(node) || ts3.isThrowStatement(node) || ts3.isTryStatement(node) || ts3.isNewExpression(node)) {
1245
1175
  found2 = true;
1246
1176
  return;
1247
1177
  }
1248
- if (ts4.isBinaryExpression(node) && node.operatorToken.kind === ts4.SyntaxKind.EqualsToken) {
1178
+ if (ts3.isBinaryExpression(node) && node.operatorToken.kind === ts3.SyntaxKind.EqualsToken) {
1249
1179
  found2 = true;
1250
1180
  return;
1251
1181
  }
1252
- ts4.forEachChild(node, visit);
1182
+ ts3.forEachChild(node, visit);
1253
1183
  };
1254
1184
  visit(body);
1255
1185
  return found2;
@@ -1258,7 +1188,7 @@ var isObjectEntriesWrapper = (body) => {
1258
1188
  const returned = singleReturnedExpression(body);
1259
1189
  if (!returned) return false;
1260
1190
  let current = peel(returned);
1261
- while (ts4.isCallExpression(current) && ts4.isPropertyAccessExpression(current.expression)) {
1191
+ while (ts3.isCallExpression(current) && ts3.isPropertyAccessExpression(current.expression)) {
1262
1192
  const method = current.expression.name.getText();
1263
1193
  if (method === "filter" || method === "map" || method === "flatMap") {
1264
1194
  current = peel(current.expression.expression);
@@ -1266,116 +1196,50 @@ var isObjectEntriesWrapper = (body) => {
1266
1196
  }
1267
1197
  break;
1268
1198
  }
1269
- if (!ts4.isCallExpression(current) || !ts4.isPropertyAccessExpression(current.expression)) {
1199
+ if (!ts3.isCallExpression(current) || !ts3.isPropertyAccessExpression(current.expression)) {
1270
1200
  return false;
1271
1201
  }
1272
- return ts4.isIdentifier(current.expression.expression) && current.expression.expression.text === "Object" && ts4.isIdentifier(current.expression.name) && (current.expression.name.text === "entries" || current.expression.name.text === "keys" || current.expression.name.text === "values");
1273
- };
1274
- var SVELTE_REACTIVE_CALLBACKS = /* @__PURE__ */ new Map([
1275
- ["derived", { name: "$derived", reason: "svelte $derived callback", kind: "derived" }],
1276
- ["user_effect", { name: "$effect", reason: "svelte $effect callback", kind: "effect" }],
1277
- [
1278
- "user_pre_effect",
1279
- { name: "$effect.pre", reason: "svelte $effect.pre callback", kind: "effect.pre" }
1280
- ]
1281
- ]);
1282
- var SVELTE_EVENT_CALLBACKS = /* @__PURE__ */ new Set(["delegated", "event"]);
1283
- var parameterNames = (node) => {
1284
- const names = [];
1285
- for (const parameter of node.parameters) {
1286
- if (ts4.isIdentifier(parameter.name)) names.push(parameter.name.text);
1287
- }
1288
- return names;
1289
- };
1290
- var isSvelteComponentWrapper = (node) => {
1291
- const names = parameterNames(node);
1292
- return names.includes("$$anchor") && names.includes("$$props");
1293
- };
1294
- var isSvelteGeneratedBlock = (node) => {
1295
- const names = parameterNames(node);
1296
- if (names.includes("$$props")) return false;
1297
- return names.includes("$$anchor") || names.includes("$$render");
1298
- };
1299
- var isSvelteChildPropThunk = (node) => {
1300
- const parent = node.parent;
1301
- if (!parent || !ts4.isPropertyAssignment(parent)) return false;
1302
- const object = parent.parent;
1303
- if (!object || !ts4.isObjectLiteralExpression(object)) return false;
1304
- const call = object.parent;
1305
- if (!call || !ts4.isCallExpression(call)) return false;
1306
- return call.arguments.some((argument) => argument === object);
1202
+ return ts3.isIdentifier(current.expression.expression) && current.expression.expression.text === "Object" && ts3.isIdentifier(current.expression.name) && (current.expression.name.text === "entries" || current.expression.name.text === "keys" || current.expression.name.text === "values");
1307
1203
  };
1308
1204
  var isSimpleReadBody = (body) => {
1309
1205
  const returned = singleReturnedExpression(body);
1310
1206
  if (!returned || bodyHasDisallowedControl(body)) return false;
1311
1207
  const value = peel(returned);
1312
- if (ts4.isIdentifier(value)) return true;
1313
- if (ts4.isPropertyAccessExpression(value) && isPredicateAtom(value)) return true;
1314
- if (!ts4.isCallExpression(value) || value.arguments.length !== 1) return false;
1208
+ if (ts3.isIdentifier(value)) return true;
1209
+ if (ts3.isPropertyAccessExpression(value) && isPredicateAtom(value)) return true;
1210
+ if (!ts3.isCallExpression(value) || value.arguments.length !== 1) return false;
1315
1211
  const argument = value.arguments[0];
1316
1212
  if (!argument) return false;
1317
- if (!ts4.isPropertyAccessExpression(value.expression) || !ts4.isIdentifier(value.expression.expression)) {
1213
+ if (!ts3.isPropertyAccessExpression(value.expression) || !ts3.isIdentifier(value.expression.expression)) {
1318
1214
  return false;
1319
1215
  }
1320
- return value.expression.expression.text === "$" && ts4.isIdentifier(value.expression.name) && value.expression.name.text === "get" && ts4.isIdentifier(peel(argument));
1216
+ return value.expression.expression.text === "$" && ts3.isIdentifier(value.expression.name) && value.expression.name.text === "get" && ts3.isIdentifier(peel(argument));
1321
1217
  };
1322
- var classifyBody = (node, name, sourceFile, filePath) => {
1323
- if (isSvelteComponentWrapper(node)) {
1324
- return { captureClass: "structure", captureReason: "svelte component wrapper" };
1325
- }
1326
- if (isSvelteCompiledPath(filePath) && /^\$[A-Za-z]/.test(name)) {
1327
- return { captureClass: "skip", captureReason: "svelte store subscription" };
1328
- }
1329
- if (isSvelteCompiledPath(filePath)) {
1330
- if (ts4.isGetAccessorDeclaration(node) || ts4.isSetAccessorDeclaration(node)) {
1331
- return { captureClass: "skip", captureReason: "svelte generated accessor" };
1332
- }
1333
- if (isSvelteGeneratedBlock(node)) {
1334
- return { captureClass: "skip", captureReason: "svelte generated block" };
1335
- }
1336
- if (isSvelteChildPropThunk(node)) {
1337
- const returned2 = singleReturnedExpression(node.body);
1338
- if (isLiteralOnlyBody(node.body) || isIdentityFunction(node) || isSimpleReadBody(node.body) || returned2 !== void 0 && isPredicateExpression(returned2) && !bodyHasDisallowedControl(node.body)) {
1339
- return { captureClass: "skip", captureReason: "svelte prop thunk" };
1340
- }
1341
- return { captureClass: "full", captureReason: "svelte user callback" };
1342
- }
1343
- }
1344
- if (isSvelteCompiledPath(filePath)) {
1345
- const runtimeMethod = svelteRuntimeMethod(node);
1346
- if (runtimeMethod) {
1347
- const reactive = SVELTE_REACTIVE_CALLBACKS.get(runtimeMethod);
1348
- if (reactive) {
1349
- if (isLiteralOnlyBody(node.body)) {
1350
- return { captureClass: "skip", captureReason: "literal-only return" };
1351
- }
1352
- return {
1353
- captureClass: "reactive-sparse",
1354
- captureReason: reactive.reason,
1355
- inferredName: name === "anonymous" ? reactive.name : void 0,
1356
- reactiveKind: reactive.kind
1357
- };
1358
- }
1359
- if (SVELTE_EVENT_CALLBACKS.has(runtimeMethod)) {
1360
- if (isLiteralOnlyBody(node.body)) {
1361
- return { captureClass: "skip", captureReason: "literal-only return" };
1362
- }
1363
- return { captureClass: "full", captureReason: "svelte user callback" };
1364
- }
1365
- return { captureClass: "skip", captureReason: "svelte generated callback" };
1366
- }
1367
- if (enclosingSvelteRuntimeMethod(node)) {
1368
- return { captureClass: "skip", captureReason: "svelte generated callback" };
1369
- }
1370
- }
1371
- if (isLiteralOnlyBody(node.body)) {
1372
- return { captureClass: "skip", captureReason: "literal-only return" };
1218
+ var classifyBody = (node, name, sourceFile, filePath, policy) => {
1219
+ const returned = singleReturnedExpression(node.body);
1220
+ const body = {
1221
+ isLiteralOnly: isLiteralOnlyBody(node.body),
1222
+ isIdentity: isIdentityFunction(node),
1223
+ isSimpleRead: isSimpleReadBody(node.body),
1224
+ isPredicate: Boolean(
1225
+ returned && isPredicateExpression(returned) && !bodyHasDisallowedControl(node.body)
1226
+ )
1227
+ };
1228
+ const decided = policy?.classifyFunction({ node, sourceFile, filePath, name, body });
1229
+ if (decided) {
1230
+ return {
1231
+ captureClass: decided.captureClass,
1232
+ captureReason: decided.captureReason,
1233
+ inferredName: decided.inferredName,
1234
+ reactiveKind: decided.reactiveKind,
1235
+ compilerRole: decided.role,
1236
+ useSyntheticLocation: decided.useSyntheticLocation
1237
+ };
1373
1238
  }
1374
1239
  if (isIdentityFunction(node)) {
1375
1240
  return { captureClass: "structure", captureReason: "identity wrapper" };
1376
1241
  }
1377
- const returned = singleReturnedExpression(node.body);
1378
- if (returned && isPredicateExpression(returned) && !bodyHasDisallowedControl(node.body)) {
1242
+ if (body.isPredicate) {
1379
1243
  return { captureClass: "structure", captureReason: "tiny predicate" };
1380
1244
  }
1381
1245
  if (isObjectEntriesWrapper(node.body) && !bodyHasDisallowedControl(node.body)) {
@@ -1386,29 +1250,24 @@ var classifyBody = (node, name, sourceFile, filePath) => {
1386
1250
  }
1387
1251
  return { captureClass: "full", captureReason: "application function" };
1388
1252
  };
1389
- var classifyFunctions = (source, filePath, mapLocation) => {
1253
+ var classifyFunctions = (source, filePath, mapLocation, policy) => {
1390
1254
  const sourceFile = parseSource(source, filePath);
1391
1255
  const absolutePath = resolve3(filePath);
1392
1256
  const classifications = [];
1393
1257
  const visit = (node) => {
1394
1258
  if (isSupportedFunction(node) && node.body) {
1395
- let location;
1396
- if (isSvelteComponentWrapper(node)) {
1397
- location = { filePath: absolutePath, line: 1, column: 1 };
1398
- } else {
1399
- location = mappedLocation(
1400
- sourceFile,
1401
- functionLocationPosition(node, sourceFile),
1402
- absolutePath,
1403
- mapLocation
1404
- );
1405
- if (!location) {
1406
- ts4.forEachChild(node, visit);
1407
- return;
1408
- }
1409
- }
1410
1259
  const rawName = functionName(node, sourceFile).replace(/@\d+:\d+$/, "");
1411
- const classified = classifyBody(node, rawName, sourceFile, filePath);
1260
+ const classified = classifyBody(node, rawName, sourceFile, filePath, policy);
1261
+ const location = classified.useSyntheticLocation ? { filePath: absolutePath, line: 1, column: 1 } : mappedLocation(
1262
+ sourceFile,
1263
+ functionLocationPosition(node, sourceFile),
1264
+ absolutePath,
1265
+ mapLocation
1266
+ );
1267
+ if (!location) {
1268
+ ts3.forEachChild(node, visit);
1269
+ return;
1270
+ }
1412
1271
  const name = classified.inferredName ?? rawName;
1413
1272
  const plan = encodeFunctionPlan({
1414
1273
  filePath: location.filePath,
@@ -1428,23 +1287,14 @@ var classifyFunctions = (source, filePath, mapLocation) => {
1428
1287
  end: node.end,
1429
1288
  bodyStart: node.body.getStart(sourceFile),
1430
1289
  bodyEnd: node.body.end,
1431
- ...classified.reactiveKind ? { reactiveKind: classified.reactiveKind } : {}
1290
+ ...classified.reactiveKind ? { reactiveKind: classified.reactiveKind } : {},
1291
+ ...classified.compilerRole ? { compilerRole: classified.compilerRole } : {}
1432
1292
  });
1433
1293
  }
1434
- ts4.forEachChild(node, visit);
1294
+ ts3.forEachChild(node, visit);
1435
1295
  };
1436
1296
  visit(sourceFile);
1437
- const hasUserWork = classifications.some(
1438
- (item) => item.captureClass === "full" || item.captureClass === "reactive-sparse"
1439
- );
1440
- if (!hasUserWork) {
1441
- for (const item of classifications) {
1442
- if (item.captureReason === "svelte component wrapper") {
1443
- item.captureClass = "skip";
1444
- item.captureReason = "svelte presentational wrapper";
1445
- }
1446
- }
1447
- }
1297
+ policy?.finalizeClassifications?.(classifications);
1448
1298
  return classifications;
1449
1299
  };
1450
1300
 
@@ -1495,7 +1345,7 @@ var applyEdits = (source, edits) => {
1495
1345
  };
1496
1346
  var textOf = (edit) => edit.text;
1497
1347
 
1498
- // ../node_modules/.bun/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
1348
+ // ../../node_modules/.bun/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
1499
1349
  var SetArray = class {
1500
1350
  constructor() {
1501
1351
  this._indexes = { __proto__: null };
@@ -1775,11 +1625,11 @@ var exactTransformMap = (original, generated, file, edits) => {
1775
1625
  import { basename as basename2 } from "node:path";
1776
1626
 
1777
1627
  // ../instrumentation/src/browser-function-edits.ts
1778
- import ts10 from "typescript";
1628
+ import ts9 from "typescript";
1779
1629
 
1780
1630
  // ../instrumentation/src/suspension-whitelist.ts
1781
- import ts5 from "typescript";
1782
- var nodeFlags = ts5.NodeFlags;
1631
+ import ts4 from "typescript";
1632
+ var nodeFlags = ts4.NodeFlags;
1783
1633
  var AWAIT_USING_FLAG = nodeFlags.AwaitUsing ?? 0;
1784
1634
  var USING_FLAG = nodeFlags.Using ?? 0;
1785
1635
  var KNOWN_SUSPENSION_KIND_NAMES = [
@@ -1789,25 +1639,25 @@ var KNOWN_SUSPENSION_KIND_NAMES = [
1789
1639
  "YieldKeyword",
1790
1640
  "UsingKeyword"
1791
1641
  ];
1792
- var isFunctionLike2 = (node) => ts5.isFunctionLike(node);
1793
- var isAsyncFunctionLike = (node) => (ts5.getCombinedModifierFlags(node) & ts5.ModifierFlags.Async) !== 0;
1794
- var isAsyncGeneratorLike = (node) => isFunctionLike2(node) && isAsyncFunctionLike(node) && "asteriskToken" in node && Boolean(node.asteriskToken);
1642
+ var isFunctionLike = (node) => ts4.isFunctionLike(node);
1643
+ var isAsyncFunctionLike = (node) => (ts4.getCombinedModifierFlags(node) & ts4.ModifierFlags.Async) !== 0;
1644
+ var isAsyncGeneratorLike = (node) => isFunctionLike(node) && isAsyncFunctionLike(node) && "asteriskToken" in node && Boolean(node.asteriskToken);
1795
1645
  var visitOwnBody = (node, visitNode) => {
1796
1646
  if (!node.body) return;
1797
1647
  const visit = (candidate) => {
1798
- if (candidate !== node && isFunctionLike2(candidate)) {
1648
+ if (candidate !== node && isFunctionLike(candidate)) {
1799
1649
  visitNode(candidate);
1800
1650
  return;
1801
1651
  }
1802
1652
  if (visitNode(candidate)) return;
1803
- ts5.forEachChild(candidate, visit);
1653
+ ts4.forEachChild(candidate, visit);
1804
1654
  };
1805
1655
  visit(node.body);
1806
1656
  };
1807
1657
  var nestedFunctionSpans = (node, sourceFile) => {
1808
1658
  const spans = [];
1809
1659
  visitOwnBody(node, (candidate) => {
1810
- if (candidate !== node && isFunctionLike2(candidate)) {
1660
+ if (candidate !== node && isFunctionLike(candidate)) {
1811
1661
  spans.push([candidate.getStart(sourceFile), candidate.end]);
1812
1662
  }
1813
1663
  return void 0;
@@ -1828,16 +1678,16 @@ var slicesOutside = (start, end, spans) => {
1828
1678
  };
1829
1679
  var sliceHasAwaitKeyword = (source, start, end) => {
1830
1680
  if (end <= start) return false;
1831
- const scanner = ts5.createScanner(
1832
- ts5.ScriptTarget.Latest,
1681
+ const scanner = ts4.createScanner(
1682
+ ts4.ScriptTarget.Latest,
1833
1683
  true,
1834
- ts5.LanguageVariant.Standard,
1684
+ ts4.LanguageVariant.Standard,
1835
1685
  source.slice(start, end)
1836
1686
  );
1837
1687
  while (true) {
1838
1688
  const token = scanner.scan();
1839
- if (token === ts5.SyntaxKind.EndOfFileToken) return false;
1840
- if (token === ts5.SyntaxKind.AwaitKeyword) return true;
1689
+ if (token === ts4.SyntaxKind.EndOfFileToken) return false;
1690
+ if (token === ts4.SyntaxKind.AwaitKeyword) return true;
1841
1691
  }
1842
1692
  };
1843
1693
  var ownBodyHasAwaitKeyword = (node, sourceFile) => {
@@ -1855,7 +1705,7 @@ var isAwaitUsingList = (node) => {
1855
1705
  return (node.flags & AWAIT_USING_FLAG) === AWAIT_USING_FLAG && (node.flags & USING_FLAG) !== 0;
1856
1706
  };
1857
1707
  var unknownSuspensionKind = (node) => {
1858
- const name = ts5.SyntaxKind[node.kind];
1708
+ const name = ts4.SyntaxKind[node.kind];
1859
1709
  if (typeof name !== "string" || !/Await|Yield|Using/.test(name)) return false;
1860
1710
  return !KNOWN_SUSPENSION_KIND_NAMES.includes(name);
1861
1711
  };
@@ -1868,9 +1718,9 @@ var ownSuspensionFacts = (node, sourceFile) => {
1868
1718
  awaitKeyword: ownBodyHasAwaitKeyword(node, sourceFile)
1869
1719
  };
1870
1720
  visitOwnBody(node, (candidate) => {
1871
- if (ts5.isAwaitExpression(candidate)) facts.awaitExpressions = true;
1872
- if (ts5.isForOfStatement(candidate) && candidate.awaitModifier) facts.forAwait = true;
1873
- if (ts5.isVariableDeclarationList(candidate) && isAwaitUsingList(candidate)) {
1721
+ if (ts4.isAwaitExpression(candidate)) facts.awaitExpressions = true;
1722
+ if (ts4.isForOfStatement(candidate) && candidate.awaitModifier) facts.forAwait = true;
1723
+ if (ts4.isVariableDeclarationList(candidate) && isAwaitUsingList(candidate)) {
1874
1724
  facts.awaitUsing = true;
1875
1725
  }
1876
1726
  if (unknownSuspensionKind(candidate)) facts.unknown = true;
@@ -1881,7 +1731,7 @@ var ownSuspensionFacts = (node, sourceFile) => {
1881
1731
  var bodyHasDirectEval = (node) => {
1882
1732
  let found2 = false;
1883
1733
  visitOwnBody(node, (candidate) => {
1884
- if (ts5.isCallExpression(candidate) && ts5.isIdentifier(candidate.expression) && candidate.expression.text === "eval") {
1734
+ if (ts4.isCallExpression(candidate) && ts4.isIdentifier(candidate.expression) && candidate.expression.text === "eval") {
1885
1735
  found2 = true;
1886
1736
  }
1887
1737
  return found2;
@@ -1904,23 +1754,23 @@ var decideAsyncInstrumentation = (node, sourceFile) => {
1904
1754
  };
1905
1755
 
1906
1756
  // ../instrumentation/src/transform-source.ts
1907
- import ts9 from "typescript";
1757
+ import ts8 from "typescript";
1908
1758
 
1909
1759
  // ../instrumentation/src/parameter-initializer-may-run-code.ts
1910
- import ts6 from "typescript";
1760
+ import ts5 from "typescript";
1911
1761
 
1912
1762
  // ../instrumentation/src/verify-instrumentation-isomorphism.ts
1913
- import ts7 from "typescript";
1763
+ import ts6 from "typescript";
1914
1764
 
1915
1765
  // ../instrumentation/src/verify-transformed-source.ts
1916
- import ts8 from "typescript";
1917
- var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
1766
+ import ts7 from "typescript";
1767
+ var transpileForVerification = (filePath, code) => ts7.transpileModule(code, {
1918
1768
  compilerOptions: {
1919
1769
  // ES2020 downlevel keeps native @decorators out of `new Function`.
1920
- target: ts8.ScriptTarget.ES2020,
1921
- module: ts8.ModuleKind.ESNext,
1770
+ target: ts7.ScriptTarget.ES2020,
1771
+ module: ts7.ModuleKind.ESNext,
1922
1772
  allowJs: true,
1923
- jsx: ts8.JsxEmit.React,
1773
+ jsx: ts7.JsxEmit.React,
1924
1774
  experimentalDecorators: true
1925
1775
  },
1926
1776
  reportDiagnostics: true,
@@ -1928,7 +1778,7 @@ var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
1928
1778
  });
1929
1779
  var hasScanOrParseError = (diagnostics) => Boolean(
1930
1780
  diagnostics?.some(
1931
- (diagnostic) => diagnostic.category === ts8.DiagnosticCategory.Error && diagnostic.code < 2e3
1781
+ (diagnostic) => diagnostic.category === ts7.DiagnosticCategory.Error && diagnostic.code < 2e3
1932
1782
  )
1933
1783
  );
1934
1784
  var scriptBodyForEngine = (emitted) => (
@@ -1937,39 +1787,39 @@ var scriptBodyForEngine = (emitted) => (
1937
1787
  );
1938
1788
  var looksTyped = (filePath) => /\.[cm]?tsx?$/i.test(filePath);
1939
1789
  var scriptKindFor2 = (filePath) => {
1940
- if (/\.tsx$/i.test(filePath)) return ts8.ScriptKind.TSX;
1941
- if (/\.jsx$/i.test(filePath)) return ts8.ScriptKind.JSX;
1942
- if (/\.[cm]?ts$/i.test(filePath)) return ts8.ScriptKind.TS;
1943
- return ts8.ScriptKind.JS;
1790
+ if (/\.tsx$/i.test(filePath)) return ts7.ScriptKind.TSX;
1791
+ if (/\.jsx$/i.test(filePath)) return ts7.ScriptKind.JSX;
1792
+ if (/\.[cm]?ts$/i.test(filePath)) return ts7.ScriptKind.TS;
1793
+ return ts7.ScriptKind.JS;
1944
1794
  };
1945
- var isIterationStatement = (node) => ts8.isForStatement(node) || ts8.isForOfStatement(node) || ts8.isForInStatement(node) || ts8.isWhileStatement(node) || ts8.isDoStatement(node);
1795
+ var isIterationStatement = (node) => ts7.isForStatement(node) || ts7.isForOfStatement(node) || ts7.isForInStatement(node) || ts7.isWhileStatement(node) || ts7.isDoStatement(node);
1946
1796
  var unwrapLabeled = (node) => {
1947
1797
  let current = node;
1948
- while (ts8.isLabeledStatement(current)) current = current.statement;
1798
+ while (ts7.isLabeledStatement(current)) current = current.statement;
1949
1799
  return current;
1950
1800
  };
1951
1801
  var hasInvalidLabelJump = (sourceFile) => {
1952
1802
  const visit = (node, labels) => {
1953
- if (ts8.isFunctionLike(node)) {
1803
+ if (ts7.isFunctionLike(node)) {
1954
1804
  let nestedInvalid = false;
1955
- ts8.forEachChild(node, (child) => {
1805
+ ts7.forEachChild(node, (child) => {
1956
1806
  if (visit(child, /* @__PURE__ */ new Map())) nestedInvalid = true;
1957
1807
  });
1958
1808
  return nestedInvalid;
1959
1809
  }
1960
- if (ts8.isLabeledStatement(node)) {
1810
+ if (ts7.isLabeledStatement(node)) {
1961
1811
  const next = new Map(labels);
1962
1812
  next.set(node.label.text, isIterationStatement(unwrapLabeled(node.statement)));
1963
1813
  return visit(node.statement, next);
1964
1814
  }
1965
- if (ts8.isContinueStatement(node) && node.label) {
1815
+ if (ts7.isContinueStatement(node) && node.label) {
1966
1816
  if (labels.get(node.label.text) !== true) return true;
1967
1817
  }
1968
- if (ts8.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
1818
+ if (ts7.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
1969
1819
  return true;
1970
1820
  }
1971
1821
  let invalid = false;
1972
- ts8.forEachChild(node, (child) => {
1822
+ ts7.forEachChild(node, (child) => {
1973
1823
  if (visit(child, labels)) invalid = true;
1974
1824
  });
1975
1825
  return invalid;
@@ -2012,10 +1862,10 @@ var UNTERMINATED_BARE_LEAVE = /\breturn\s+__rasputin\w*\.leave\(\)(?!\s*;|\()/;
2012
1862
  var transformedSourceIsInvalid = (filePath, code) => {
2013
1863
  if (GLUED_INSTRUMENTATION.test(code)) return true;
2014
1864
  if (UNTERMINATED_BARE_LEAVE.test(code)) return true;
2015
- const sourceFile = ts8.createSourceFile(
1865
+ const sourceFile = ts7.createSourceFile(
2016
1866
  filePath,
2017
1867
  code,
2018
- ts8.ScriptTarget.Latest,
1868
+ ts7.ScriptTarget.Latest,
2019
1869
  true,
2020
1870
  scriptKindFor2(filePath)
2021
1871
  );
@@ -2041,8 +1891,8 @@ var REACTIVE_REG = "__rasputinReg";
2041
1891
  var OBSERVE_GUARD = "globalThis.__rasputinO??=function(i,v){return v};";
2042
1892
  var STRUCT_GUARD = "globalThis.__rasputinK??=function(o){return o};";
2043
1893
  var REACTIVE_GUARD = "globalThis.__rasputinR??=function(){return 1};globalThis.__rasputinL??=function(i,v){return v};globalThis.__rasputinT??=function(){};globalThis.__rasputinD??=function(){};globalThis.__rasputinReg??=function(){};";
2044
- var isWrapTarget = (node) => (ts10.isFunctionDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node) || ts10.isMethodDeclaration(node) || ts10.isGetAccessorDeclaration(node) || ts10.isSetAccessorDeclaration(node)) && node.body !== void 0;
2045
- var isDirectivePrologue = (statement) => ts10.isExpressionStatement(statement) && ts10.isStringLiteral(statement.expression);
1894
+ var isWrapTarget = (node) => (ts9.isFunctionDeclaration(node) || ts9.isFunctionExpression(node) || ts9.isArrowFunction(node) || ts9.isMethodDeclaration(node) || ts9.isGetAccessorDeclaration(node) || ts9.isSetAccessorDeclaration(node)) && node.body !== void 0;
1895
+ var isDirectivePrologue = (statement) => ts9.isExpressionStatement(statement) && ts9.isStringLiteral(statement.expression);
2046
1896
  var insertPositionAfterPrologue = (source, sourceFile) => {
2047
1897
  const shebangEnd = source.startsWith("#!") ? source.indexOf("\n") + 1 : 0;
2048
1898
  let end = shebangEnd;
@@ -2069,7 +1919,7 @@ var insertAfterSuperOrPrologue = (body, sourceFile) => {
2069
1919
  const end = functionBodyPrologueEnd(body, sourceFile);
2070
1920
  for (const statement of body.statements) {
2071
1921
  if (isDirectivePrologue(statement)) continue;
2072
- if (ts10.isExpressionStatement(statement) && ts10.isCallExpression(statement.expression) && statement.expression.expression.kind === ts10.SyntaxKind.SuperKeyword) {
1922
+ if (ts9.isExpressionStatement(statement) && ts9.isCallExpression(statement.expression) && statement.expression.expression.kind === ts9.SyntaxKind.SuperKeyword) {
2073
1923
  return statement.end;
2074
1924
  }
2075
1925
  break;
@@ -2077,14 +1927,14 @@ var insertAfterSuperOrPrologue = (body, sourceFile) => {
2077
1927
  return end;
2078
1928
  };
2079
1929
  var functionRef = (node) => {
2080
- if (node.name && ts10.isIdentifier(node.name)) {
2081
- if (ts10.isGetAccessorDeclaration(node) || ts10.isSetAccessorDeclaration(node) || ts10.isMethodDeclaration(node)) {
1930
+ if (node.name && ts9.isIdentifier(node.name)) {
1931
+ if (ts9.isGetAccessorDeclaration(node) || ts9.isSetAccessorDeclaration(node) || ts9.isMethodDeclaration(node)) {
2082
1932
  return void 0;
2083
1933
  }
2084
1934
  return node.name.text;
2085
1935
  }
2086
1936
  const parent = node.parent;
2087
- if (ts10.isVariableDeclaration(parent) && ts10.isIdentifier(parent.name) && parent.initializer === node) {
1937
+ if (ts9.isVariableDeclaration(parent) && ts9.isIdentifier(parent.name) && parent.initializer === node) {
2088
1938
  return parent.name.text;
2089
1939
  }
2090
1940
  return void 0;
@@ -2097,17 +1947,17 @@ var matchingFunction = (sourceFile, item) => {
2097
1947
  found2 = node;
2098
1948
  return;
2099
1949
  }
2100
- ts10.forEachChild(node, visit);
1950
+ ts9.forEachChild(node, visit);
2101
1951
  };
2102
1952
  visit(sourceFile);
2103
1953
  return found2;
2104
1954
  };
2105
- var isStaticPropertyName = (name) => ts10.isIdentifier(name) || ts10.isStringLiteral(name) || ts10.isNoSubstitutionTemplateLiteral(name) || ts10.isNumericLiteral(name);
1955
+ var isStaticPropertyName = (name) => ts9.isIdentifier(name) || ts9.isStringLiteral(name) || ts9.isNoSubstitutionTemplateLiteral(name) || ts9.isNumericLiteral(name);
2106
1956
  var canReconstructBinding = (name) => {
2107
- if (ts10.isIdentifier(name)) return true;
2108
- if (ts10.isArrayBindingPattern(name)) {
1957
+ if (ts9.isIdentifier(name)) return true;
1958
+ if (ts9.isArrayBindingPattern(name)) {
2109
1959
  return name.elements.every(
2110
- (element) => ts10.isOmittedExpression(element) || canReconstructBinding(element.name)
1960
+ (element) => ts9.isOmittedExpression(element) || canReconstructBinding(element.name)
2111
1961
  );
2112
1962
  }
2113
1963
  return name.elements.every((element) => {
@@ -2117,16 +1967,16 @@ var canReconstructBinding = (name) => {
2117
1967
  };
2118
1968
  var REDACTED_ARG_EXPR = 'Symbol.for("rasputin.redacted.v1")';
2119
1969
  var staticBindingKey = (name) => {
2120
- if (ts10.isIdentifier(name)) return name.text;
2121
- if (ts10.isStringLiteral(name) || ts10.isNoSubstitutionTemplateLiteral(name)) return name.text;
2122
- if (ts10.isNumericLiteral(name)) return name.text;
1970
+ if (ts9.isIdentifier(name)) return name.text;
1971
+ if (ts9.isStringLiteral(name) || ts9.isNoSubstitutionTemplateLiteral(name)) return name.text;
1972
+ if (ts9.isNumericLiteral(name)) return name.text;
2123
1973
  return void 0;
2124
1974
  };
2125
1975
  var bindingHasSensitiveName = (name) => {
2126
- if (ts10.isIdentifier(name)) return propertyNameIsSensitive(name.text);
2127
- if (ts10.isArrayBindingPattern(name)) {
1976
+ if (ts9.isIdentifier(name)) return propertyNameIsSensitive(name.text);
1977
+ if (ts9.isArrayBindingPattern(name)) {
2128
1978
  return name.elements.some(
2129
- (element) => !ts10.isOmittedExpression(element) && bindingHasSensitiveName(element.name)
1979
+ (element) => !ts9.isOmittedExpression(element) && bindingHasSensitiveName(element.name)
2130
1980
  );
2131
1981
  }
2132
1982
  return name.elements.some((element) => {
@@ -2136,12 +1986,12 @@ var bindingHasSensitiveName = (name) => {
2136
1986
  });
2137
1987
  };
2138
1988
  var capturedBinding = (name, sourceFile) => {
2139
- if (ts10.isIdentifier(name)) {
1989
+ if (ts9.isIdentifier(name)) {
2140
1990
  return propertyNameIsSensitive(name.text) ? REDACTED_ARG_EXPR : name.text;
2141
1991
  }
2142
- if (ts10.isArrayBindingPattern(name)) {
1992
+ if (ts9.isArrayBindingPattern(name)) {
2143
1993
  const values = name.elements.map((element) => {
2144
- if (ts10.isOmittedExpression(element)) return "";
1994
+ if (ts9.isOmittedExpression(element)) return "";
2145
1995
  const value = capturedBinding(element.name, sourceFile);
2146
1996
  return element.dotDotDotToken ? `...${value}` : value;
2147
1997
  });
@@ -2149,14 +1999,14 @@ var capturedBinding = (name, sourceFile) => {
2149
1999
  }
2150
2000
  const properties = name.elements.map((element) => {
2151
2001
  const key = element.propertyName ? staticBindingKey(element.propertyName) : void 0;
2152
- const sensitive = key !== void 0 && propertyNameIsSensitive(key) || ts10.isIdentifier(element.name) && propertyNameIsSensitive(element.name.text);
2002
+ const sensitive = key !== void 0 && propertyNameIsSensitive(key) || ts9.isIdentifier(element.name) && propertyNameIsSensitive(element.name.text);
2153
2003
  if (element.dotDotDotToken) {
2154
2004
  return `...${sensitive ? REDACTED_ARG_EXPR : capturedBinding(element.name, sourceFile)}`;
2155
2005
  }
2156
2006
  if (!element.propertyName) {
2157
- return sensitive && ts10.isIdentifier(element.name) ? `${element.name.text}:${REDACTED_ARG_EXPR}` : capturedBinding(element.name, sourceFile);
2007
+ return sensitive && ts9.isIdentifier(element.name) ? `${element.name.text}:${REDACTED_ARG_EXPR}` : capturedBinding(element.name, sourceFile);
2158
2008
  }
2159
- const printedKey = ts10.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
2009
+ const printedKey = ts9.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
2160
2010
  return `${printedKey}:${sensitive ? REDACTED_ARG_EXPR : capturedBinding(element.name, sourceFile)}`;
2161
2011
  });
2162
2012
  return `{${properties.join(",")}}`;
@@ -2164,12 +2014,12 @@ var capturedBinding = (name, sourceFile) => {
2164
2014
  var captureArgs = (node) => {
2165
2015
  const sourceFile = node.getSourceFile();
2166
2016
  const params = node.parameters.filter(
2167
- (parameter) => !(ts10.isIdentifier(parameter.name) && parameter.name.text === "this")
2017
+ (parameter) => !(ts9.isIdentifier(parameter.name) && parameter.name.text === "this")
2168
2018
  );
2169
2019
  const reconstructable = params.every((parameter) => canReconstructBinding(parameter.name));
2170
2020
  const sensitive = params.some((parameter) => bindingHasSensitiveName(parameter.name));
2171
2021
  if (!reconstructable) {
2172
- if (ts10.isArrowFunction(node) || sensitive) {
2022
+ if (ts9.isArrowFunction(node) || sensitive) {
2173
2023
  return {
2174
2024
  args: `[${Array.from({ length: params.length }, () => "void 0").join(",")}]`,
2175
2025
  omitValues: true
@@ -2177,7 +2027,7 @@ var captureArgs = (node) => {
2177
2027
  }
2178
2028
  return { args: "arguments", omitValues: false };
2179
2029
  }
2180
- if (!ts10.isArrowFunction(node) && !sensitive) {
2030
+ if (!ts9.isArrowFunction(node) && !sensitive) {
2181
2031
  return { args: "arguments", omitValues: false };
2182
2032
  }
2183
2033
  const values = params.map((parameter) => {
@@ -2188,16 +2038,16 @@ var captureArgs = (node) => {
2188
2038
  };
2189
2039
  var walkOwnBody = (node, visitNode) => {
2190
2040
  const visit = (candidate) => {
2191
- if (candidate !== node && ts10.isFunctionLike(candidate)) return;
2041
+ if (candidate !== node && ts9.isFunctionLike(candidate)) return;
2192
2042
  visitNode(candidate);
2193
- ts10.forEachChild(candidate, visit);
2043
+ ts9.forEachChild(candidate, visit);
2194
2044
  };
2195
2045
  visit(node.body);
2196
2046
  };
2197
2047
  var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
2198
- if (!ts10.isBlock(node.body)) return;
2048
+ if (!ts9.isBlock(node.body)) return;
2199
2049
  walkOwnBody(node, (candidate) => {
2200
- if (!ts10.isReturnStatement(candidate) || !candidate.expression) return;
2050
+ if (!ts9.isReturnStatement(candidate) || !candidate.expression) return;
2201
2051
  wrap(
2202
2052
  edits,
2203
2053
  candidate.expression.getStart(sourceFile),
@@ -2210,7 +2060,7 @@ var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
2210
2060
  };
2211
2061
  var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
2212
2062
  walkOwnBody(node, (candidate) => {
2213
- if (!ts10.isAwaitExpression(candidate)) return;
2063
+ if (!ts9.isAwaitExpression(candidate)) return;
2214
2064
  wrap(
2215
2065
  edits,
2216
2066
  candidate.expression.getStart(sourceFile),
@@ -2231,7 +2081,7 @@ var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
2231
2081
  };
2232
2082
  var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) => {
2233
2083
  walkOwnBody(node, (candidate) => {
2234
- if (!ts10.isTryStatement(candidate)) return;
2084
+ if (!ts9.isTryStatement(candidate)) return;
2235
2085
  for (const block of [candidate.catchClause?.block, candidate.finallyBlock]) {
2236
2086
  if (!block) continue;
2237
2087
  edits.push({
@@ -2246,9 +2096,9 @@ var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) =>
2246
2096
  });
2247
2097
  };
2248
2098
  var collectReactiveReturnWraps = (node, sourceFile, siteId, edits, depth) => {
2249
- if (!ts10.isBlock(node.body)) return;
2099
+ if (!ts9.isBlock(node.body)) return;
2250
2100
  walkOwnBody(node, (candidate) => {
2251
- if (!ts10.isReturnStatement(candidate)) return;
2101
+ if (!ts9.isReturnStatement(candidate)) return;
2252
2102
  if (!candidate.expression) {
2253
2103
  edits.push({
2254
2104
  position: candidate.getStart(sourceFile),
@@ -2295,7 +2145,7 @@ var toManifestFunction = (item, node, sourceFile, asyncFunction, instrumented, m
2295
2145
  asyncFunction
2296
2146
  };
2297
2147
  };
2298
- var collectCallerSites = (sourceFile, classifications, functions, absolutePath, mapLocation) => {
2148
+ var collectCallerSites = (sourceFile, classifications, functions, absolutePath, mapLocation, policy) => {
2299
2149
  const bySpan = /* @__PURE__ */ new Map();
2300
2150
  const classified = new Map(
2301
2151
  classifications.map((item) => [`${item.start}:${item.end}`, item])
@@ -2308,31 +2158,33 @@ var collectCallerSites = (sourceFile, classifications, functions, absolutePath,
2308
2158
  const callSites = [];
2309
2159
  const destructures = [];
2310
2160
  const collectContext = { sourceFile, absolutePath, mapLocation };
2311
- const svelteFile = isSvelteCompiledPath(absolutePath);
2312
- const identifierCallees = svelteFile ? svelteGeneratedIdentifierCallees(sourceFile) : void 0;
2313
2161
  const visit = (node, caller) => {
2314
2162
  if (isWrapTarget(node)) {
2315
2163
  const item = classified.get(`${node.getStart(sourceFile)}:${node.end}`);
2316
2164
  if (item) {
2317
2165
  const fn = bySpan.get(`${item.start}:${item.end}`);
2318
2166
  const next = fn && fn.instrumented !== false ? fn : caller;
2319
- ts10.forEachChild(node, (child) => visit(child, next));
2167
+ ts9.forEachChild(node, (child) => visit(child, next));
2320
2168
  return;
2321
2169
  }
2322
2170
  }
2323
- if (caller && (ts10.isCallExpression(node) || ts10.isNewExpression(node))) {
2324
- if (svelteFile && isSvelteCompilerCall(node, sourceFile, identifierCallees)) {
2325
- ts10.forEachChild(node, (child) => visit(child, caller));
2171
+ if (caller && (ts9.isCallExpression(node) || ts9.isNewExpression(node))) {
2172
+ if (policy?.isCompilerCall({
2173
+ node,
2174
+ sourceFile,
2175
+ filePath: absolutePath
2176
+ })) {
2177
+ ts9.forEachChild(node, (child) => visit(child, caller));
2326
2178
  return;
2327
2179
  }
2328
2180
  const site = collectCallSite(node, caller, collectContext);
2329
2181
  if (site) callSites.push(site);
2330
2182
  }
2331
- if (caller && ts10.isVariableDeclaration(node)) {
2183
+ if (caller && ts9.isVariableDeclaration(node)) {
2332
2184
  const destructure = collectParamDestructure(node, caller, collectContext);
2333
2185
  if (destructure) destructures.push(destructure);
2334
2186
  }
2335
- ts10.forEachChild(node, (child) => visit(child, caller));
2187
+ ts9.forEachChild(node, (child) => visit(child, caller));
2336
2188
  };
2337
2189
  visit(sourceFile, void 0);
2338
2190
  return { callSites, destructures };
@@ -2393,7 +2245,7 @@ var collectBrowserFunctionEdits = (source, sourceFile, classifications, moduleIn
2393
2245
  const leave = `${REACTIVE_LEAVE}(${siteId})`;
2394
2246
  const fail = `${REACTIVE_THROW}(${siteId},${errorName})`;
2395
2247
  const epilogue2 = `}catch(${errorName}){${fail};throw ${errorName};}finally{${REACTIVE_DONE}()}`;
2396
- if (ts10.isBlock(node.body)) {
2248
+ if (ts9.isBlock(node.body)) {
2397
2249
  wrap(
2398
2250
  edits,
2399
2251
  node.body.getStart(sourceFile) + 1,
@@ -2438,7 +2290,7 @@ var collectBrowserFunctionEdits = (source, sourceFile, classifications, moduleIn
2438
2290
  failArgs,
2439
2291
  decision.action === "suspend_resume"
2440
2292
  );
2441
- if (ts10.isBlock(node.body)) {
2293
+ if (ts9.isBlock(node.body)) {
2442
2294
  const prologueAt = insertAfterSuperOrPrologue(node.body, sourceFile);
2443
2295
  const closeAt = node.body.end - 1;
2444
2296
  wrap(edits, prologueAt, closeAt, `;const ${handleName}=${enterCall};try{`, epilogue, 0);
@@ -2496,7 +2348,8 @@ var collectBrowserFunctionEdits = (source, sourceFile, classifications, moduleIn
2496
2348
  classifications,
2497
2349
  functions,
2498
2350
  classifications[0]?.filePath ?? "",
2499
- options.mapLocation
2351
+ options.mapLocation,
2352
+ options.policy
2500
2353
  );
2501
2354
  return {
2502
2355
  edits,
@@ -2507,42 +2360,42 @@ var collectBrowserFunctionEdits = (source, sourceFile, classifications, moduleIn
2507
2360
  };
2508
2361
 
2509
2362
  // ../instrumentation/src/json-producer-sites.ts
2510
- import ts11 from "typescript";
2363
+ import ts10 from "typescript";
2511
2364
  var JSON_METHOD_CALLEE = "globalThis.__rasputinM";
2512
2365
  var JSON_AWAIT_CALLEE = "globalThis.__rasputinA";
2513
2366
  var JSON_ADOPT_CALLEE = "globalThis.__rasputinP";
2514
2367
  var JSON_PRODUCER_GUARD = "globalThis.__rasputinM??=function(r,f){return Reflect.apply(f,r,[].slice.call(arguments,2))};globalThis.__rasputinA??=function(v){return v};globalThis.__rasputinP??=function(p){return p};";
2515
2368
  var isSimpleReceiver = (expression) => {
2516
2369
  const receiver = peel(expression);
2517
- return ts11.isIdentifier(receiver) || receiver.kind === ts11.SyntaxKind.ThisKeyword;
2370
+ return ts10.isIdentifier(receiver) || receiver.kind === ts10.SyntaxKind.ThisKeyword;
2518
2371
  };
2519
- var isSimpleIdentifierCall = (node) => !node.questionDotToken && ts11.isIdentifier(node.expression);
2372
+ var isSimpleIdentifierCall = (node) => !node.questionDotToken && ts10.isIdentifier(node.expression);
2520
2373
  var isSimpleMethodCall = (node) => {
2521
2374
  if (node.questionDotToken) return false;
2522
2375
  const callee = node.expression;
2523
- return ts11.isPropertyAccessExpression(callee) && !callee.questionDotToken && ts11.isIdentifier(callee.name) && !ts11.isPrivateIdentifier(callee.name) && isSimpleReceiver(callee.expression);
2376
+ return ts10.isPropertyAccessExpression(callee) && !callee.questionDotToken && ts10.isIdentifier(callee.name) && !ts10.isPrivateIdentifier(callee.name) && isSimpleReceiver(callee.expression);
2524
2377
  };
2525
2378
  var isSimpleProvenanceCall = (node) => isSimpleIdentifierCall(node) || isSimpleMethodCall(node);
2526
2379
  var isJsonParseCall = (node) => {
2527
2380
  if (!isSimpleMethodCall(node)) return false;
2528
2381
  const callee = node.expression;
2529
- if (!ts11.isPropertyAccessExpression(callee) || callee.name.text !== "parse") return false;
2382
+ if (!ts10.isPropertyAccessExpression(callee) || callee.name.text !== "parse") return false;
2530
2383
  const object = peel(callee.expression);
2531
- return ts11.isIdentifier(object) && object.text === "JSON";
2384
+ return ts10.isIdentifier(object) && object.text === "JSON";
2532
2385
  };
2533
2386
  var methodName = (node) => {
2534
2387
  if (!isSimpleMethodCall(node)) return void 0;
2535
2388
  const callee = node.expression;
2536
- return ts11.isPropertyAccessExpression(callee) ? callee.name.text : void 0;
2389
+ return ts10.isPropertyAccessExpression(callee) ? callee.name.text : void 0;
2537
2390
  };
2538
2391
  var containsNestedAwaitOrFunction = (node) => {
2539
2392
  let found2 = false;
2540
2393
  const visit = (candidate) => {
2541
- if (candidate !== node && (ts11.isAwaitExpression(candidate) || ts11.isFunctionLike(candidate))) {
2394
+ if (candidate !== node && (ts10.isAwaitExpression(candidate) || ts10.isFunctionLike(candidate))) {
2542
2395
  found2 = true;
2543
2396
  return;
2544
2397
  }
2545
- if (!found2) ts11.forEachChild(candidate, visit);
2398
+ if (!found2) ts10.forEachChild(candidate, visit);
2546
2399
  };
2547
2400
  visit(node);
2548
2401
  return found2;
@@ -2556,45 +2409,24 @@ var isAwaitExpressionOf = (node) => {
2556
2409
  let current = node;
2557
2410
  while (current.parent) {
2558
2411
  const parent = current.parent;
2559
- if (ts11.isParenthesizedExpression(parent) || ts11.isNonNullExpression(parent) || ts11.isAsExpression(parent) || ts11.isTypeAssertionExpression(parent) || ts11.isSatisfiesExpression(parent)) {
2412
+ if (ts10.isParenthesizedExpression(parent) || ts10.isNonNullExpression(parent) || ts10.isAsExpression(parent) || ts10.isTypeAssertionExpression(parent) || ts10.isSatisfiesExpression(parent)) {
2560
2413
  current = parent;
2561
2414
  continue;
2562
2415
  }
2563
- return ts11.isAwaitExpression(parent) && parent.expression === current;
2416
+ return ts10.isAwaitExpression(parent) && parent.expression === current;
2564
2417
  }
2565
2418
  return false;
2566
2419
  };
2567
- var isDirectSuperCall = (node) => node.expression.kind === ts11.SyntaxKind.SuperKeyword;
2568
- var SVELTE_RUNE_ROOTS = /* @__PURE__ */ new Set([
2569
- "$state",
2570
- "$derived",
2571
- "$effect",
2572
- "$props",
2573
- "$bindable",
2574
- "$inspect",
2575
- "$host"
2576
- ]);
2577
- var isSvelteRuneCall = (node) => {
2578
- let current = peel(node.expression);
2579
- while (ts11.isPropertyAccessExpression(current)) {
2580
- current = peel(current.expression);
2581
- }
2582
- return ts11.isIdentifier(current) && SVELTE_RUNE_ROOTS.has(current.text);
2583
- };
2584
- var isSvelteSourcePath = (filePath) => filePath.includes(".svelte");
2585
- var isSvelteCompilerCall2 = (node, filePath) => {
2586
- if (isSvelteRuneCall(node)) return true;
2587
- if (!isSvelteSourcePath(filePath)) return false;
2588
- const callee = peel(node.expression);
2589
- if (!ts11.isPropertyAccessExpression(callee)) return false;
2590
- const object = peel(callee.expression);
2591
- return ts11.isIdentifier(object) && object.text === "$";
2420
+ var isDirectSuperCall = (node) => node.expression.kind === ts10.SyntaxKind.SuperKeyword;
2421
+ var isPolicyCompilerCall = (node, filePath, sourceFile, policy) => {
2422
+ if (!policy) return false;
2423
+ return policy.isCompilerCall({ node, sourceFile, filePath });
2592
2424
  };
2593
2425
  var outerExpression = (node) => {
2594
2426
  let current = node;
2595
2427
  while (current.parent) {
2596
2428
  const parent = current.parent;
2597
- if ((ts11.isParenthesizedExpression(parent) || ts11.isNonNullExpression(parent) || ts11.isAsExpression(parent) || ts11.isTypeAssertionExpression(parent) || ts11.isSatisfiesExpression(parent)) && parent.expression === current) {
2429
+ if ((ts10.isParenthesizedExpression(parent) || ts10.isNonNullExpression(parent) || ts10.isAsExpression(parent) || ts10.isTypeAssertionExpression(parent) || ts10.isSatisfiesExpression(parent)) && parent.expression === current) {
2598
2430
  current = parent;
2599
2431
  continue;
2600
2432
  }
@@ -2606,9 +2438,9 @@ var isReturnedOrBoundCall = (node) => {
2606
2438
  const expression = outerExpression(node);
2607
2439
  const parent = expression.parent;
2608
2440
  if (!parent) return false;
2609
- if (ts11.isReturnStatement(parent) && parent.expression === expression) return true;
2610
- if (ts11.isVariableDeclaration(parent) && parent.initializer === expression) return true;
2611
- if (ts11.isBinaryExpression(parent) && parent.right === expression && parent.operatorToken.kind === ts11.SyntaxKind.EqualsToken) {
2441
+ if (ts10.isReturnStatement(parent) && parent.expression === expression) return true;
2442
+ if (ts10.isVariableDeclaration(parent) && parent.initializer === expression) return true;
2443
+ if (ts10.isBinaryExpression(parent) && parent.right === expression && parent.operatorToken.kind === ts10.SyntaxKind.EqualsToken) {
2612
2444
  return true;
2613
2445
  }
2614
2446
  return false;
@@ -2647,30 +2479,32 @@ var callCanCarryProvenance = (node) => {
2647
2479
  if (name === "json" || name === "parse") return true;
2648
2480
  if (name === "call" || name === "apply") return false;
2649
2481
  const callee = node.expression;
2650
- if (ts11.isIdentifier(callee)) return !NON_PROVENANCE_ROOTS.has(callee.text);
2651
- if (ts11.isPropertyAccessExpression(callee)) {
2482
+ if (ts10.isIdentifier(callee)) return !NON_PROVENANCE_ROOTS.has(callee.text);
2483
+ if (ts10.isPropertyAccessExpression(callee)) {
2652
2484
  const object = peel(callee.expression);
2653
- if (ts11.isIdentifier(object) && NON_PROVENANCE_ROOTS.has(object.text)) {
2485
+ if (ts10.isIdentifier(object) && NON_PROVENANCE_ROOTS.has(object.text)) {
2654
2486
  return object.text === "JSON" && callee.name.text === "parse";
2655
2487
  }
2656
2488
  }
2657
2489
  return true;
2658
2490
  };
2659
- var shouldAdoptCall = (node, filePath) => {
2660
- if (isAwaitExpressionOf(node) || isDirectSuperCall(node) || isSvelteCompilerCall2(node, filePath)) {
2491
+ var shouldAdoptCall = (node, filePath, sourceFile, policy) => {
2492
+ if (isAwaitExpressionOf(node) || isDirectSuperCall(node) || isPolicyCompilerCall(node, filePath, sourceFile, policy)) {
2661
2493
  return false;
2662
2494
  }
2663
- if (ts11.isComputedPropertyName(outerExpression(node).parent)) return false;
2495
+ if (ts10.isComputedPropertyName(outerExpression(node).parent)) return false;
2664
2496
  if (!isSimpleProvenanceCall(node)) return false;
2665
2497
  return isReturnedOrBoundCall(node) && callCanCarryProvenance(node);
2666
2498
  };
2667
- var shouldAdoptAwaitCall = (node, filePath) => {
2668
- if (isSvelteCompilerCall2(node, filePath) || !isSimpleProvenanceCall(node)) return false;
2499
+ var shouldAdoptAwaitCall = (node, filePath, sourceFile, policy) => {
2500
+ if (isPolicyCompilerCall(node, filePath, sourceFile, policy) || !isSimpleProvenanceCall(node)) {
2501
+ return false;
2502
+ }
2669
2503
  return callCanCarryProvenance(node);
2670
2504
  };
2671
2505
  var replaceProducerCall = (node, sourceFile, receiverName) => {
2672
2506
  const callee = node.expression;
2673
- if (!ts11.isPropertyAccessExpression(callee)) return node.getText(sourceFile);
2507
+ if (!ts10.isPropertyAccessExpression(callee)) return node.getText(sourceFile);
2674
2508
  const args = node.arguments.map((argument) => argument.getText(sourceFile));
2675
2509
  const extra2 = args.length > 0 ? `,${args.join(",")}` : "";
2676
2510
  const receiver = callee.expression.getText(sourceFile);
@@ -2678,10 +2512,10 @@ var replaceProducerCall = (node, sourceFile, receiverName) => {
2678
2512
  return `((${receiverName})=>${JSON_METHOD_CALLEE}(${receiverName},${method}${extra2}))(${receiver})`;
2679
2513
  };
2680
2514
  var hasBlockBody = (node) => {
2681
- if (!ts11.isFunctionDeclaration(node) && !ts11.isFunctionExpression(node) && !ts11.isArrowFunction(node) && !ts11.isMethodDeclaration(node) && !ts11.isConstructorDeclaration(node) && !ts11.isGetAccessorDeclaration(node) && !ts11.isSetAccessorDeclaration(node)) {
2515
+ if (!ts10.isFunctionDeclaration(node) && !ts10.isFunctionExpression(node) && !ts10.isArrowFunction(node) && !ts10.isMethodDeclaration(node) && !ts10.isConstructorDeclaration(node) && !ts10.isGetAccessorDeclaration(node) && !ts10.isSetAccessorDeclaration(node)) {
2682
2516
  return false;
2683
2517
  }
2684
- return node.body !== void 0 && ts11.isBlock(node.body);
2518
+ return node.body !== void 0 && ts10.isBlock(node.body);
2685
2519
  };
2686
2520
  var owningFunctionBody = (node) => {
2687
2521
  let current = node;
@@ -2712,7 +2546,7 @@ var adoptCall = (edits, node, sourceFile, receiverName, fnName, slotName, slot =
2712
2546
  const wrapOpen = (inner) => slot ? `(${slotName}={p:${inner}` : inner;
2713
2547
  const wrapClose = (inner) => slot ? `${inner}},${slotName}.p)` : inner;
2714
2548
  const callee = node.expression;
2715
- if (ts11.isIdentifier(callee)) {
2549
+ if (ts10.isIdentifier(callee)) {
2716
2550
  wrap(
2717
2551
  edits,
2718
2552
  start,
@@ -2731,7 +2565,7 @@ var adoptCall = (edits, node, sourceFile, receiverName, fnName, slotName, slot =
2731
2565
  });
2732
2566
  return;
2733
2567
  }
2734
- if (!isSimpleMethodCall(node) || !ts11.isPropertyAccessExpression(callee)) return;
2568
+ if (!isSimpleMethodCall(node) || !ts10.isPropertyAccessExpression(callee)) return;
2735
2569
  const receiver = callee.expression.getText(sourceFile);
2736
2570
  const method = callee.name.text;
2737
2571
  const open = callOpenParen(node, sourceFile);
@@ -2761,8 +2595,10 @@ var adoptCall = (edits, node, sourceFile, receiverName, fnName, slotName, slot =
2761
2595
  kind: "replace"
2762
2596
  });
2763
2597
  };
2764
- var skippedComplexCall = (node, filePath) => {
2765
- if (isSvelteCompilerCall2(node, filePath) || isDirectSuperCall(node)) return false;
2598
+ var skippedComplexCall = (node, filePath, sourceFile, policy) => {
2599
+ if (isPolicyCompilerCall(node, filePath, sourceFile, policy) || isDirectSuperCall(node)) {
2600
+ return false;
2601
+ }
2766
2602
  if (isSimpleProvenanceCall(node)) return false;
2767
2603
  if (!callCanCarryProvenance(node)) return false;
2768
2604
  return true;
@@ -2778,7 +2614,7 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
2778
2614
  let callWraps = 0;
2779
2615
  let provenanceSkippedComplexCall = 0;
2780
2616
  const visit = (node) => {
2781
- if (ts11.isCallExpression(node) && isSimpleProducerCall(node) && !isAwaitExpressionOf(node)) {
2617
+ if (ts10.isCallExpression(node) && isSimpleProducerCall(node) && !isAwaitExpressionOf(node)) {
2782
2618
  edits.push({
2783
2619
  position: node.getStart(sourceFile),
2784
2620
  text: replaceProducerCall(node, sourceFile, receiverName),
@@ -2788,19 +2624,19 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
2788
2624
  kind: "replace"
2789
2625
  });
2790
2626
  callWraps += 1;
2791
- } else if (adoptCalls && ts11.isCallExpression(node) && shouldAdoptCall(node, filePath)) {
2627
+ } else if (adoptCalls && ts10.isCallExpression(node) && shouldAdoptCall(node, filePath, sourceFile, options?.policy)) {
2792
2628
  adoptCall(edits, node, sourceFile, receiverName, adoptFnName, slotName);
2793
2629
  callWraps += 1;
2794
- } else if (ts11.isCallExpression(node) && !isAwaitExpressionOf(node) && isReturnedOrBoundCall(node) && skippedComplexCall(node, filePath)) {
2630
+ } else if (ts10.isCallExpression(node) && !isAwaitExpressionOf(node) && isReturnedOrBoundCall(node) && skippedComplexCall(node, filePath, sourceFile, options?.policy)) {
2795
2631
  provenanceSkippedComplexCall += 1;
2796
2632
  }
2797
- if (ts11.isAwaitExpression(node)) {
2633
+ if (ts10.isAwaitExpression(node)) {
2798
2634
  const inner = peel(node.expression);
2799
- const producer = ts11.isCallExpression(inner) && isSimpleProducerCall(inner);
2800
- const adoptInner = adoptCalls && ts11.isCallExpression(inner) && shouldAdoptAwaitCall(inner, filePath);
2801
- const adoptValue = adoptCalls && !ts11.isCallExpression(inner);
2635
+ const producer = ts10.isCallExpression(inner) && isSimpleProducerCall(inner);
2636
+ const adoptInner = adoptCalls && ts10.isCallExpression(inner) && shouldAdoptAwaitCall(inner, filePath, sourceFile, options?.policy);
2637
+ const adoptValue = adoptCalls && !ts10.isCallExpression(inner);
2802
2638
  if (producer || adoptInner || adoptValue) {
2803
- if (producer && ts11.isCallExpression(inner)) {
2639
+ if (producer && ts10.isCallExpression(inner)) {
2804
2640
  edits.push({
2805
2641
  position: node.expression.getStart(sourceFile),
2806
2642
  text: `(${slotName}={p:${replaceProducerCall(inner, sourceFile, receiverName)}},${slotName}.p)`,
@@ -2810,7 +2646,7 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
2810
2646
  kind: "replace"
2811
2647
  });
2812
2648
  callWraps += 1;
2813
- } else if (adoptInner && ts11.isCallExpression(inner)) {
2649
+ } else if (adoptInner && ts10.isCallExpression(inner)) {
2814
2650
  if (node.expression === inner) {
2815
2651
  adoptCall(edits, inner, sourceFile, receiverName, adoptFnName, slotName, true);
2816
2652
  } else {
@@ -2846,11 +2682,11 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
2846
2682
  awaitWraps += 1;
2847
2683
  const body = owningFunctionBody(node);
2848
2684
  if (body) bodies.add(body);
2849
- } else if (ts11.isCallExpression(inner) && skippedComplexCall(inner, filePath)) {
2685
+ } else if (ts10.isCallExpression(inner) && skippedComplexCall(inner, filePath, sourceFile, options?.policy)) {
2850
2686
  provenanceSkippedComplexCall += 1;
2851
2687
  }
2852
2688
  }
2853
- ts11.forEachChild(node, visit);
2689
+ ts10.forEachChild(node, visit);
2854
2690
  };
2855
2691
  visit(sourceFile);
2856
2692
  if (edits.length > 0) {
@@ -2877,7 +2713,7 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
2877
2713
  };
2878
2714
 
2879
2715
  // ../instrumentation/src/literal-sites.ts
2880
- import ts12 from "typescript";
2716
+ import ts11 from "typescript";
2881
2717
  var STRUCT_CALLEE = "globalThis.__rasputinK";
2882
2718
  var owningFunction = (position, classifications) => {
2883
2719
  let owner;
@@ -2897,7 +2733,7 @@ var walkPeelParent = (node) => {
2897
2733
  let current = node;
2898
2734
  while (current.parent) {
2899
2735
  const parent = current.parent;
2900
- if ((ts12.isParenthesizedExpression(parent) || ts12.isNonNullExpression(parent) || ts12.isAsExpression(parent) || ts12.isTypeAssertionExpression(parent) || ts12.isSatisfiesExpression(parent)) && parent.expression === current) {
2736
+ if ((ts11.isParenthesizedExpression(parent) || ts11.isNonNullExpression(parent) || ts11.isAsExpression(parent) || ts11.isTypeAssertionExpression(parent) || ts11.isSatisfiesExpression(parent)) && parent.expression === current) {
2901
2737
  current = parent;
2902
2738
  continue;
2903
2739
  }
@@ -2909,13 +2745,13 @@ var isCapturePosition = (node) => {
2909
2745
  const current = walkPeelParent(node);
2910
2746
  const parent = current.parent;
2911
2747
  if (!parent) return false;
2912
- if (ts12.isReturnStatement(parent) && parent.expression === current) return true;
2913
- if (ts12.isArrowFunction(parent) && parent.body === current) return true;
2914
- if (ts12.isVariableDeclaration(parent) && parent.initializer === current) return true;
2915
- if (ts12.isBinaryExpression(parent) && parent.operatorToken.kind === ts12.SyntaxKind.EqualsToken && parent.right === current) {
2748
+ if (ts11.isReturnStatement(parent) && parent.expression === current) return true;
2749
+ if (ts11.isArrowFunction(parent) && parent.body === current) return true;
2750
+ if (ts11.isVariableDeclaration(parent) && parent.initializer === current) return true;
2751
+ if (ts11.isBinaryExpression(parent) && parent.operatorToken.kind === ts11.SyntaxKind.EqualsToken && parent.right === current) {
2916
2752
  return true;
2917
2753
  }
2918
- if (ts12.isCallExpression(parent) || ts12.isNewExpression(parent)) {
2754
+ if (ts11.isCallExpression(parent) || ts11.isNewExpression(parent)) {
2919
2755
  return parent.arguments?.some((argument) => argument === current) === true;
2920
2756
  }
2921
2757
  return false;
@@ -2924,13 +2760,13 @@ var isInAssignmentPattern = (node) => {
2924
2760
  let current = walkPeelParent(node);
2925
2761
  while (current.parent) {
2926
2762
  const parent = current.parent;
2927
- if (ts12.isBinaryExpression(parent) && parent.operatorToken.kind === ts12.SyntaxKind.EqualsToken && parent.left === current) {
2763
+ if (ts11.isBinaryExpression(parent) && parent.operatorToken.kind === ts11.SyntaxKind.EqualsToken && parent.left === current) {
2928
2764
  return true;
2929
2765
  }
2930
- if ((ts12.isForOfStatement(parent) || ts12.isForInStatement(parent)) && parent.initializer === current) {
2766
+ if ((ts11.isForOfStatement(parent) || ts11.isForInStatement(parent)) && parent.initializer === current) {
2931
2767
  return true;
2932
2768
  }
2933
- if (ts12.isPropertyAssignment(parent) || ts12.isShorthandPropertyAssignment(parent) || ts12.isSpreadAssignment(parent) || ts12.isObjectLiteralExpression(parent) || ts12.isArrayLiteralExpression(parent) || ts12.isParenthesizedExpression(parent) || ts12.isAsExpression(parent) || ts12.isTypeAssertionExpression(parent) || ts12.isNonNullExpression(parent) || ts12.isSatisfiesExpression(parent)) {
2769
+ if (ts11.isPropertyAssignment(parent) || ts11.isShorthandPropertyAssignment(parent) || ts11.isSpreadAssignment(parent) || ts11.isObjectLiteralExpression(parent) || ts11.isArrayLiteralExpression(parent) || ts11.isParenthesizedExpression(parent) || ts11.isAsExpression(parent) || ts11.isTypeAssertionExpression(parent) || ts11.isNonNullExpression(parent) || ts11.isSatisfiesExpression(parent)) {
2934
2770
  current = walkPeelParent(parent);
2935
2771
  continue;
2936
2772
  }
@@ -2942,8 +2778,8 @@ var isLiteralChild = (node) => {
2942
2778
  const current = walkPeelParent(node);
2943
2779
  const parent = current.parent;
2944
2780
  if (!parent) return false;
2945
- if (ts12.isPropertyAssignment(parent) && parent.initializer === current) return true;
2946
- if (ts12.isArrayLiteralExpression(parent)) return true;
2781
+ if (ts11.isPropertyAssignment(parent) && parent.initializer === current) return true;
2782
+ if (ts11.isArrayLiteralExpression(parent)) return true;
2947
2783
  return false;
2948
2784
  };
2949
2785
  var shouldRewrite = (node, classifications, sourceFile) => {
@@ -2955,10 +2791,10 @@ var shouldRewrite = (node, classifications, sourceFile) => {
2955
2791
  var collectLiteralSiteEdits = (source, filePath, options, sourceFile = parseSource(source, filePath)) => {
2956
2792
  const edits = [];
2957
2793
  const visit = (node) => {
2958
- if ((ts12.isObjectLiteralExpression(node) || ts12.isArrayLiteralExpression(node)) && shouldRewrite(node, options.classifications, sourceFile)) {
2794
+ if ((ts11.isObjectLiteralExpression(node) || ts11.isArrayLiteralExpression(node)) && shouldRewrite(node, options.classifications, sourceFile)) {
2959
2795
  wrap(edits, node.getStart(sourceFile), node.end, `${STRUCT_CALLEE}(`, ")", 15);
2960
2796
  }
2961
- ts12.forEachChild(node, visit);
2797
+ ts11.forEachChild(node, visit);
2962
2798
  };
2963
2799
  visit(sourceFile);
2964
2800
  return { edits };
@@ -2967,64 +2803,64 @@ var collectLiteralSiteEdits = (source, filePath, options, sourceFile = parseSour
2967
2803
  // ../instrumentation/src/observe-sites.ts
2968
2804
  import { createHash as createHash2 } from "node:crypto";
2969
2805
  import { resolve as resolve4 } from "node:path";
2970
- import ts13 from "typescript";
2806
+ import ts12 from "typescript";
2971
2807
  var OBSERVE_CALLEE = "globalThis.__rasputinO";
2972
2808
  var siteIdFor = (filePath, line, column, text) => {
2973
2809
  const digest = createHash2("sha256").update(`${resolve4(filePath)}:${line}:${column}:${text}`).digest("base64url").slice(0, 16);
2974
2810
  return `rs_${digest}`;
2975
2811
  };
2976
- var isAssignmentOperator = (kind) => kind === ts13.SyntaxKind.EqualsToken || kind === ts13.SyntaxKind.PlusEqualsToken || kind === ts13.SyntaxKind.MinusEqualsToken || kind === ts13.SyntaxKind.AsteriskEqualsToken || kind === ts13.SyntaxKind.SlashEqualsToken || kind === ts13.SyntaxKind.PercentEqualsToken || kind === ts13.SyntaxKind.AmpersandEqualsToken || kind === ts13.SyntaxKind.BarEqualsToken || kind === ts13.SyntaxKind.CaretEqualsToken || kind === ts13.SyntaxKind.LessThanLessThanEqualsToken || kind === ts13.SyntaxKind.GreaterThanGreaterThanEqualsToken || kind === ts13.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || kind === ts13.SyntaxKind.AsteriskAsteriskEqualsToken || kind === ts13.SyntaxKind.BarBarEqualsToken || kind === ts13.SyntaxKind.AmpersandAmpersandEqualsToken || kind === ts13.SyntaxKind.QuestionQuestionEqualsToken;
2812
+ var isAssignmentOperator = (kind) => kind === ts12.SyntaxKind.EqualsToken || kind === ts12.SyntaxKind.PlusEqualsToken || kind === ts12.SyntaxKind.MinusEqualsToken || kind === ts12.SyntaxKind.AsteriskEqualsToken || kind === ts12.SyntaxKind.SlashEqualsToken || kind === ts12.SyntaxKind.PercentEqualsToken || kind === ts12.SyntaxKind.AmpersandEqualsToken || kind === ts12.SyntaxKind.BarEqualsToken || kind === ts12.SyntaxKind.CaretEqualsToken || kind === ts12.SyntaxKind.LessThanLessThanEqualsToken || kind === ts12.SyntaxKind.GreaterThanGreaterThanEqualsToken || kind === ts12.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || kind === ts12.SyntaxKind.AsteriskAsteriskEqualsToken || kind === ts12.SyntaxKind.BarBarEqualsToken || kind === ts12.SyntaxKind.AmpersandAmpersandEqualsToken || kind === ts12.SyntaxKind.QuestionQuestionEqualsToken;
2977
2813
  var isSafeLiteral = (expression) => {
2978
2814
  const node = peel(expression);
2979
- if (ts13.isStringLiteral(node) || ts13.isNoSubstitutionTemplateLiteral(node)) return true;
2980
- if (ts13.isNumericLiteral(node)) return true;
2981
- if (node.kind === ts13.SyntaxKind.TrueKeyword || node.kind === ts13.SyntaxKind.FalseKeyword || node.kind === ts13.SyntaxKind.NullKeyword) {
2815
+ if (ts12.isStringLiteral(node) || ts12.isNoSubstitutionTemplateLiteral(node)) return true;
2816
+ if (ts12.isNumericLiteral(node)) return true;
2817
+ if (node.kind === ts12.SyntaxKind.TrueKeyword || node.kind === ts12.SyntaxKind.FalseKeyword || node.kind === ts12.SyntaxKind.NullKeyword) {
2982
2818
  return true;
2983
2819
  }
2984
- if (ts13.isIdentifier(node) && (node.text === "undefined" || node.text === "NaN")) return true;
2985
- if (ts13.isPrefixUnaryExpression(node) && node.operator === ts13.SyntaxKind.MinusToken && ts13.isNumericLiteral(node.operand)) {
2820
+ if (ts12.isIdentifier(node) && (node.text === "undefined" || node.text === "NaN")) return true;
2821
+ if (ts12.isPrefixUnaryExpression(node) && node.operator === ts12.SyntaxKind.MinusToken && ts12.isNumericLiteral(node.operand)) {
2986
2822
  return true;
2987
2823
  }
2988
- return ts13.isVoidExpression(node) && ts13.isNumericLiteral(peel(node.expression)) && peel(node.expression).getText() === "0";
2824
+ return ts12.isVoidExpression(node) && ts12.isNumericLiteral(peel(node.expression)) && peel(node.expression).getText() === "0";
2989
2825
  };
2990
2826
  var isPropertyRead = (node) => {
2991
- if (ts13.isPropertyAccessExpression(node)) {
2992
- return !ts13.isPrivateIdentifier(node.name) && node.expression.kind !== ts13.SyntaxKind.SuperKeyword;
2827
+ if (ts12.isPropertyAccessExpression(node)) {
2828
+ return !ts12.isPrivateIdentifier(node.name) && node.expression.kind !== ts12.SyntaxKind.SuperKeyword;
2993
2829
  }
2994
- if (ts13.isElementAccessExpression(node)) {
2995
- return node.expression.kind !== ts13.SyntaxKind.SuperKeyword;
2830
+ if (ts12.isElementAccessExpression(node)) {
2831
+ return node.expression.kind !== ts12.SyntaxKind.SuperKeyword;
2996
2832
  }
2997
2833
  return false;
2998
2834
  };
2999
2835
  var isMetaChain = (node) => {
3000
- if (ts13.isMetaProperty(node)) return true;
3001
- if (ts13.isPropertyAccessExpression(node)) return isMetaChain(node.expression);
3002
- if (ts13.isElementAccessExpression(node)) return isMetaChain(node.expression);
2836
+ if (ts12.isMetaProperty(node)) return true;
2837
+ if (ts12.isPropertyAccessExpression(node)) return isMetaChain(node.expression);
2838
+ if (ts12.isElementAccessExpression(node)) return isMetaChain(node.expression);
3003
2839
  return false;
3004
2840
  };
3005
2841
  var isPatternParent = (parent, child) => {
3006
- if (ts13.isParenthesizedExpression(parent) && parent.expression === child) return true;
3007
- if (ts13.isAsExpression(parent) && parent.expression === child) return true;
3008
- if (ts13.isTypeAssertionExpression(parent) && parent.expression === child) return true;
3009
- if (ts13.isNonNullExpression(parent) && parent.expression === child) return true;
3010
- if (ts13.isSatisfiesExpression(parent) && parent.expression === child) return true;
3011
- if (ts13.isPropertyAssignment(parent) && parent.initializer === child) return true;
3012
- if (ts13.isShorthandPropertyAssignment(parent)) return true;
3013
- if (ts13.isSpreadAssignment(parent) && parent.expression === child) return true;
3014
- if (ts13.isSpreadElement(parent) && parent.expression === child) return true;
3015
- if (ts13.isArrayLiteralExpression(parent)) return true;
3016
- if (ts13.isObjectLiteralExpression(parent)) return true;
2842
+ if (ts12.isParenthesizedExpression(parent) && parent.expression === child) return true;
2843
+ if (ts12.isAsExpression(parent) && parent.expression === child) return true;
2844
+ if (ts12.isTypeAssertionExpression(parent) && parent.expression === child) return true;
2845
+ if (ts12.isNonNullExpression(parent) && parent.expression === child) return true;
2846
+ if (ts12.isSatisfiesExpression(parent) && parent.expression === child) return true;
2847
+ if (ts12.isPropertyAssignment(parent) && parent.initializer === child) return true;
2848
+ if (ts12.isShorthandPropertyAssignment(parent)) return true;
2849
+ if (ts12.isSpreadAssignment(parent) && parent.expression === child) return true;
2850
+ if (ts12.isSpreadElement(parent) && parent.expression === child) return true;
2851
+ if (ts12.isArrayLiteralExpression(parent)) return true;
2852
+ if (ts12.isObjectLiteralExpression(parent)) return true;
3017
2853
  return false;
3018
2854
  };
3019
2855
  var isAssignmentTarget = (node) => {
3020
2856
  let current = node;
3021
2857
  while (current.parent) {
3022
2858
  const parent = current.parent;
3023
- if (ts13.isComputedPropertyName(parent) && parent.expression === current) return false;
3024
- if (ts13.isBinaryExpression(parent) && isAssignmentOperator(parent.operatorToken.kind)) {
2859
+ if (ts12.isComputedPropertyName(parent) && parent.expression === current) return false;
2860
+ if (ts12.isBinaryExpression(parent) && isAssignmentOperator(parent.operatorToken.kind)) {
3025
2861
  return parent.left === current;
3026
2862
  }
3027
- if ((ts13.isForOfStatement(parent) || ts13.isForInStatement(parent)) && parent.initializer === current) {
2863
+ if ((ts12.isForOfStatement(parent) || ts12.isForInStatement(parent)) && parent.initializer === current) {
3028
2864
  return true;
3029
2865
  }
3030
2866
  if (!isPatternParent(parent, current)) return false;
@@ -3036,18 +2872,18 @@ var isValueContext = (node) => {
3036
2872
  if (isAssignmentTarget(node)) return false;
3037
2873
  const parent = node.parent;
3038
2874
  if (!parent) return false;
3039
- if (ts13.isVariableDeclaration(parent) && parent.initializer === node) return true;
3040
- if (ts13.isReturnStatement(parent) && parent.expression === node) return true;
3041
- if (ts13.isPropertyAssignment(parent) && parent.initializer === node) return true;
3042
- if (ts13.isParenthesizedExpression(parent) || ts13.isNonNullExpression(parent) || ts13.isAsExpression(parent) || ts13.isTypeAssertionExpression(parent) || ts13.isSatisfiesExpression(parent)) {
2875
+ if (ts12.isVariableDeclaration(parent) && parent.initializer === node) return true;
2876
+ if (ts12.isReturnStatement(parent) && parent.expression === node) return true;
2877
+ if (ts12.isPropertyAssignment(parent) && parent.initializer === node) return true;
2878
+ if (ts12.isParenthesizedExpression(parent) || ts12.isNonNullExpression(parent) || ts12.isAsExpression(parent) || ts12.isTypeAssertionExpression(parent) || ts12.isSatisfiesExpression(parent)) {
3043
2879
  return isValueContext(parent);
3044
2880
  }
3045
2881
  return false;
3046
2882
  };
3047
2883
  var isCoalesceWithLiteral = (node) => {
3048
- if (!ts13.isBinaryExpression(node)) return false;
2884
+ if (!ts12.isBinaryExpression(node)) return false;
3049
2885
  const operator = node.operatorToken.kind;
3050
- if (operator !== ts13.SyntaxKind.QuestionQuestionToken && operator !== ts13.SyntaxKind.BarBarToken) {
2886
+ if (operator !== ts12.SyntaxKind.QuestionQuestionToken && operator !== ts12.SyntaxKind.BarBarToken) {
3051
2887
  return false;
3052
2888
  }
3053
2889
  return isSafeLiteral(node.right);
@@ -3056,19 +2892,19 @@ var shouldWrapPropertyRead = (node) => {
3056
2892
  if (isMetaChain(node)) return false;
3057
2893
  const parent = node.parent;
3058
2894
  if (!parent) return false;
3059
- if (ts13.isPropertyAccessExpression(parent) && parent.expression === node) return false;
3060
- if (ts13.isElementAccessExpression(parent) && parent.expression === node) return false;
3061
- if (ts13.isCallExpression(parent) && parent.expression === node) return false;
3062
- if (ts13.isNewExpression(parent) && parent.expression === node) return false;
3063
- if (ts13.isTaggedTemplateExpression(parent) && parent.tag === node) return false;
3064
- if (ts13.isDeleteExpression(parent)) return false;
3065
- if (ts13.isPrefixUnaryExpression(parent) && (parent.operator === ts13.SyntaxKind.PlusPlusToken || parent.operator === ts13.SyntaxKind.MinusMinusToken)) {
2895
+ if (ts12.isPropertyAccessExpression(parent) && parent.expression === node) return false;
2896
+ if (ts12.isElementAccessExpression(parent) && parent.expression === node) return false;
2897
+ if (ts12.isCallExpression(parent) && parent.expression === node) return false;
2898
+ if (ts12.isNewExpression(parent) && parent.expression === node) return false;
2899
+ if (ts12.isTaggedTemplateExpression(parent) && parent.tag === node) return false;
2900
+ if (ts12.isDeleteExpression(parent)) return false;
2901
+ if (ts12.isPrefixUnaryExpression(parent) && (parent.operator === ts12.SyntaxKind.PlusPlusToken || parent.operator === ts12.SyntaxKind.MinusMinusToken)) {
3066
2902
  return false;
3067
2903
  }
3068
- if (ts13.isPostfixUnaryExpression(parent) && (parent.operator === ts13.SyntaxKind.PlusPlusToken || parent.operator === ts13.SyntaxKind.MinusMinusToken)) {
2904
+ if (ts12.isPostfixUnaryExpression(parent) && (parent.operator === ts12.SyntaxKind.PlusPlusToken || parent.operator === ts12.SyntaxKind.MinusMinusToken)) {
3069
2905
  return false;
3070
2906
  }
3071
- if (ts13.isBinaryExpression(parent) && isAssignmentOperator(parent.operatorToken.kind)) {
2907
+ if (ts12.isBinaryExpression(parent) && isAssignmentOperator(parent.operatorToken.kind)) {
3072
2908
  if (parent.left === node) return false;
3073
2909
  }
3074
2910
  if (isValueContext(node)) return true;
@@ -3083,15 +2919,15 @@ var shouldWrapRead = (node, classifications, sourceFile) => {
3083
2919
  };
3084
2920
  var hasOptional = (node) => !!node.questionDotToken;
3085
2921
  var isInternalProperty = (node) => {
3086
- if (ts13.isPropertyAccessExpression(node)) return node.name.text.startsWith("__");
3087
- if (!ts13.isStringLiteral(node.argumentExpression) && !ts13.isNoSubstitutionTemplateLiteral(node.argumentExpression)) {
2922
+ if (ts12.isPropertyAccessExpression(node)) return node.name.text.startsWith("__");
2923
+ if (!ts12.isStringLiteral(node.argumentExpression) && !ts12.isNoSubstitutionTemplateLiteral(node.argumentExpression)) {
3088
2924
  return false;
3089
2925
  }
3090
2926
  return node.argumentExpression.text.startsWith("__");
3091
2927
  };
3092
2928
  var staticPropertyName = (node) => {
3093
- if (ts13.isPropertyAccessExpression(node)) return node.name.text;
3094
- if (ts13.isStringLiteral(node.argumentExpression) || ts13.isNoSubstitutionTemplateLiteral(node.argumentExpression)) {
2929
+ if (ts12.isPropertyAccessExpression(node)) return node.name.text;
2930
+ if (ts12.isStringLiteral(node.argumentExpression) || ts12.isNoSubstitutionTemplateLiteral(node.argumentExpression)) {
3095
2931
  return node.argumentExpression.text;
3096
2932
  }
3097
2933
  return void 0;
@@ -3110,21 +2946,21 @@ var isSensitiveRead = (node) => {
3110
2946
  if (name === void 0) return false;
3111
2947
  return propertyNameIsSensitive(name) || BROWSER_SENSITIVE_SURFACES.has(name);
3112
2948
  };
3113
- var allowsExpressionCapture = (owner) => owner.captureClass === "full" || owner.captureClass === "reactive-sparse" || owner.captureReason === "svelte component wrapper";
2949
+ var allowsExpressionCapture = (owner) => owner.captureClass === "full" || owner.captureClass === "reactive-sparse" || owner.compilerRole === "component-wrapper";
3114
2950
  var isReactiveArrowValue = (node, classifications, sourceFile) => {
3115
2951
  let current = node;
3116
2952
  while (current) {
3117
2953
  const parent = current.parent;
3118
2954
  if (!parent) return false;
3119
- if (ts13.isArrowFunction(parent) && parent.body === current) {
2955
+ if (ts12.isArrowFunction(parent) && parent.body === current) {
3120
2956
  const owner = owningFunction2(node.getStart(sourceFile), classifications);
3121
2957
  return owner?.captureClass === "reactive-sparse";
3122
2958
  }
3123
- if (ts13.isBinaryExpression(parent) && (parent.left === current || parent.right === current) && !isAssignmentOperator(parent.operatorToken.kind)) {
2959
+ if (ts12.isBinaryExpression(parent) && (parent.left === current || parent.right === current) && !isAssignmentOperator(parent.operatorToken.kind)) {
3124
2960
  current = parent;
3125
2961
  continue;
3126
2962
  }
3127
- if (ts13.isParenthesizedExpression(parent) || ts13.isNonNullExpression(parent) || ts13.isAsExpression(parent) || ts13.isTypeAssertionExpression(parent) || ts13.isSatisfiesExpression(parent)) {
2963
+ if (ts12.isParenthesizedExpression(parent) || ts12.isNonNullExpression(parent) || ts12.isAsExpression(parent) || ts12.isTypeAssertionExpression(parent) || ts12.isSatisfiesExpression(parent)) {
3128
2964
  current = parent;
3129
2965
  continue;
3130
2966
  }
@@ -3155,7 +2991,7 @@ var collectObserveSiteEdits = (source, filePath, options = {}, sourceFile = pars
3155
2991
  if (options.classifications) {
3156
2992
  const owner = owningFunction2(node.getStart(sourceFile), options.classifications);
3157
2993
  if (!owner || !allowsExpressionCapture(owner)) {
3158
- ts13.forEachChild(node, visit);
2994
+ ts12.forEachChild(node, visit);
3159
2995
  return;
3160
2996
  }
3161
2997
  }
@@ -3180,7 +3016,7 @@ var collectObserveSiteEdits = (source, filePath, options = {}, sourceFile = pars
3180
3016
  }
3181
3017
  });
3182
3018
  }
3183
- ts13.forEachChild(node, visit);
3019
+ ts12.forEachChild(node, visit);
3184
3020
  };
3185
3021
  visit(sourceFile);
3186
3022
  queued.sort((left, right) => right.start - left.start);
@@ -3212,8 +3048,14 @@ var collectObserveSiteEdits = (source, filePath, options = {}, sourceFile = pars
3212
3048
  return { edits, sites: applied };
3213
3049
  };
3214
3050
 
3051
+ // ../instrumentation/src/svelte-module-path.ts
3052
+ var isSvelteCompiledPath = (idOrPath) => {
3053
+ const path = idOrPath.split("?")[0]?.replaceAll("\\", "/") ?? "";
3054
+ return path.endsWith(".svelte") || path.endsWith(".svelte.ts") || path.endsWith(".svelte.js");
3055
+ };
3056
+
3215
3057
  // ../instrumentation/src/verify-browser-source.ts
3216
- import ts14 from "typescript";
3058
+ import ts13 from "typescript";
3217
3059
  var RASPUTIN_IDENT = /^__rasputin/;
3218
3060
  var BROWSER_GLOBALS = /* @__PURE__ */ new Set([
3219
3061
  "__rasputinO",
@@ -3230,13 +3072,13 @@ var BROWSER_GLOBALS = /* @__PURE__ */ new Set([
3230
3072
  ]);
3231
3073
  var isRasputinName = (name) => RASPUTIN_IDENT.test(name);
3232
3074
  var identText = (node) => {
3233
- if (ts14.isIdentifier(node)) return node.text;
3234
- if (ts14.isPrivateIdentifier(node)) return node.text;
3075
+ if (ts13.isIdentifier(node)) return node.text;
3076
+ if (ts13.isPrivateIdentifier(node)) return node.text;
3235
3077
  return void 0;
3236
3078
  };
3237
3079
  var calleeName = (expression) => {
3238
- if (ts14.isIdentifier(expression)) return expression.text;
3239
- if (ts14.isPropertyAccessExpression(expression)) {
3080
+ if (ts13.isIdentifier(expression)) return expression.text;
3081
+ if (ts13.isPropertyAccessExpression(expression)) {
3240
3082
  const object = identText(expression.expression);
3241
3083
  const property = identText(expression.name);
3242
3084
  if (object && isRasputinName(object) && property) return `${object}.${property}`;
@@ -3245,17 +3087,17 @@ var calleeName = (expression) => {
3245
3087
  return void 0;
3246
3088
  };
3247
3089
  var isRasputinCall = (node) => {
3248
- if (!ts14.isCallExpression(node)) return false;
3090
+ if (!ts13.isCallExpression(node)) return false;
3249
3091
  const name = calleeName(node.expression);
3250
3092
  return Boolean(name && (isRasputinName(name) || BROWSER_GLOBALS.has(name)));
3251
3093
  };
3252
3094
  var isRasputinAssignment = (node) => {
3253
- if (!ts14.isBinaryExpression(node)) return false;
3095
+ if (!ts13.isBinaryExpression(node)) return false;
3254
3096
  const operator = node.operatorToken.kind;
3255
- if (operator !== ts14.SyntaxKind.EqualsToken && operator !== ts14.SyntaxKind.QuestionQuestionEqualsToken) {
3097
+ if (operator !== ts13.SyntaxKind.EqualsToken && operator !== ts13.SyntaxKind.QuestionQuestionEqualsToken) {
3256
3098
  return false;
3257
3099
  }
3258
- if (ts14.isPropertyAccessExpression(node.left)) {
3100
+ if (ts13.isPropertyAccessExpression(node.left)) {
3259
3101
  const object = identText(node.left.expression);
3260
3102
  const property = identText(node.left.name);
3261
3103
  return object === "globalThis" && property !== void 0 && BROWSER_GLOBALS.has(property);
@@ -3267,28 +3109,28 @@ var isRasputinOnlyInitializer = (expression) => {
3267
3109
  if (!expression) return true;
3268
3110
  const unwrapped = unwrapCall(expression);
3269
3111
  if (unwrapped !== expression) {
3270
- return ts14.isExpression(unwrapped) ? isRasputinOnlyInitializer(unwrapped) : false;
3112
+ return ts13.isExpression(unwrapped) ? isRasputinOnlyInitializer(unwrapped) : false;
3271
3113
  }
3272
3114
  return isRasputinCall(expression);
3273
3115
  };
3274
3116
  var jsonAwaitSlot = (node) => {
3275
- if (node.operatorToken.kind !== ts14.SyntaxKind.CommaToken) return void 0;
3117
+ if (node.operatorToken.kind !== ts13.SyntaxKind.CommaToken) return void 0;
3276
3118
  const assigned = node.left;
3277
- if (!ts14.isBinaryExpression(assigned) || assigned.operatorToken.kind !== ts14.SyntaxKind.EqualsToken || !ts14.isIdentifier(assigned.left) || !isRasputinName(assigned.left.text) || !ts14.isObjectLiteralExpression(assigned.right)) {
3119
+ if (!ts13.isBinaryExpression(assigned) || assigned.operatorToken.kind !== ts13.SyntaxKind.EqualsToken || !ts13.isIdentifier(assigned.left) || !isRasputinName(assigned.left.text) || !ts13.isObjectLiteralExpression(assigned.right)) {
3278
3120
  return void 0;
3279
3121
  }
3280
3122
  const property = assigned.right.properties[0];
3281
- if (!property || !ts14.isPropertyAssignment(property) || !ts14.isIdentifier(property.name) || property.name.text !== "p") {
3123
+ if (!property || !ts13.isPropertyAssignment(property) || !ts13.isIdentifier(property.name) || property.name.text !== "p") {
3282
3124
  return void 0;
3283
3125
  }
3284
- if (!ts14.isPropertyAccessExpression(node.right) || !ts14.isIdentifier(node.right.expression) || !isRasputinName(node.right.expression.text) || node.right.name.text !== "p") {
3126
+ if (!ts13.isPropertyAccessExpression(node.right) || !ts13.isIdentifier(node.right.expression) || !isRasputinName(node.right.expression.text) || node.right.name.text !== "p") {
3285
3127
  return void 0;
3286
3128
  }
3287
3129
  return property.initializer;
3288
3130
  };
3289
3131
  var peelParens = (node) => {
3290
3132
  let current = node;
3291
- while (ts14.isParenthesizedExpression(current)) current = current.expression;
3133
+ while (ts13.isParenthesizedExpression(current)) current = current.expression;
3292
3134
  return current;
3293
3135
  };
3294
3136
  var jsonMethodCall = (node) => {
@@ -3296,9 +3138,9 @@ var jsonMethodCall = (node) => {
3296
3138
  const fn = node.arguments[1];
3297
3139
  if (!receiver || !fn) return void 0;
3298
3140
  const args = node.arguments.slice(2);
3299
- if (!ts14.isPropertyAccessExpression(fn)) return void 0;
3300
- return ts14.factory.createCallExpression(
3301
- ts14.factory.createPropertyAccessExpression(receiver, fn.name),
3141
+ if (!ts13.isPropertyAccessExpression(fn)) return void 0;
3142
+ return ts13.factory.createCallExpression(
3143
+ ts13.factory.createPropertyAccessExpression(receiver, fn.name),
3302
3144
  void 0,
3303
3145
  args
3304
3146
  );
@@ -3308,55 +3150,55 @@ var unwrapAdoptIife = (node) => {
3308
3150
  const adopted = node.arguments[0];
3309
3151
  if (!adopted) return void 0;
3310
3152
  const callee = peelParens(node.expression);
3311
- if (!ts14.isArrowFunction(callee) || callee.parameters.length !== 1 || ts14.isBlock(callee.body)) {
3153
+ if (!ts13.isArrowFunction(callee) || callee.parameters.length !== 1 || ts13.isBlock(callee.body)) {
3312
3154
  return void 0;
3313
3155
  }
3314
3156
  const param = callee.parameters[0];
3315
- if (!param || !ts14.isIdentifier(param.name) || param.dotDotDotToken || param.initializer) {
3157
+ if (!param || !ts13.isIdentifier(param.name) || param.dotDotDotToken || param.initializer) {
3316
3158
  return void 0;
3317
3159
  }
3318
3160
  const body = peelParens(callee.body);
3319
- if (ts14.isCallExpression(body) && calleeName(body.expression) === "__rasputinP") {
3161
+ if (ts13.isCallExpression(body) && calleeName(body.expression) === "__rasputinP") {
3320
3162
  const invoked = body.arguments[0];
3321
- if (invoked && ts14.isCallExpression(invoked) && ts14.isIdentifier(invoked.expression) && invoked.expression.text === param.name.text) {
3322
- return ts14.factory.createCallExpression(adopted, void 0, invoked.arguments);
3163
+ if (invoked && ts13.isCallExpression(invoked) && ts13.isIdentifier(invoked.expression) && invoked.expression.text === param.name.text) {
3164
+ return ts13.factory.createCallExpression(adopted, void 0, invoked.arguments);
3323
3165
  }
3324
3166
  return void 0;
3325
3167
  }
3326
- if (!ts14.isCallExpression(body) || body.arguments.length !== 1) return void 0;
3168
+ if (!ts13.isCallExpression(body) || body.arguments.length !== 1) return void 0;
3327
3169
  const methodLookup = body.arguments[0];
3328
3170
  if (!methodLookup) return void 0;
3329
3171
  const inner = peelParens(body.expression);
3330
- if (!ts14.isArrowFunction(inner) || inner.parameters.length !== 1 || ts14.isBlock(inner.body)) {
3172
+ if (!ts13.isArrowFunction(inner) || inner.parameters.length !== 1 || ts13.isBlock(inner.body)) {
3331
3173
  return void 0;
3332
3174
  }
3333
3175
  const fnParam = inner.parameters[0];
3334
- if (!fnParam || !ts14.isIdentifier(fnParam.name) || fnParam.dotDotDotToken || fnParam.initializer) {
3176
+ if (!fnParam || !ts13.isIdentifier(fnParam.name) || fnParam.dotDotDotToken || fnParam.initializer) {
3335
3177
  return void 0;
3336
3178
  }
3337
3179
  const innerBody = peelParens(inner.body);
3338
- if (!ts14.isCallExpression(innerBody) || calleeName(innerBody.expression) !== "__rasputinP") {
3180
+ if (!ts13.isCallExpression(innerBody) || calleeName(innerBody.expression) !== "__rasputinP") {
3339
3181
  return void 0;
3340
3182
  }
3341
3183
  const applied = innerBody.arguments[0];
3342
- if (!applied || !ts14.isCallExpression(applied)) return void 0;
3184
+ if (!applied || !ts13.isCallExpression(applied)) return void 0;
3343
3185
  const applyCallee = peelParens(applied.expression);
3344
- if (!ts14.isPropertyAccessExpression(applyCallee) || applyCallee.name.text !== "apply" || !ts14.isIdentifier(applyCallee.expression) || applyCallee.expression.text !== "Reflect") {
3186
+ if (!ts13.isPropertyAccessExpression(applyCallee) || applyCallee.name.text !== "apply" || !ts13.isIdentifier(applyCallee.expression) || applyCallee.expression.text !== "Reflect") {
3345
3187
  return void 0;
3346
3188
  }
3347
3189
  const appliedFn = applied.arguments[0];
3348
3190
  const thisArg = applied.arguments[1];
3349
3191
  const argsArg = applied.arguments[2];
3350
- if (!appliedFn || !ts14.isIdentifier(appliedFn) || appliedFn.text !== fnParam.name.text) {
3192
+ if (!appliedFn || !ts13.isIdentifier(appliedFn) || appliedFn.text !== fnParam.name.text) {
3351
3193
  return void 0;
3352
3194
  }
3353
- if (!thisArg || !ts14.isIdentifier(thisArg) || thisArg.text !== param.name.text) return void 0;
3354
- if (!argsArg || !ts14.isArrayLiteralExpression(argsArg)) return void 0;
3355
- if (!ts14.isPropertyAccessExpression(methodLookup) || !ts14.isIdentifier(methodLookup.expression) || methodLookup.expression.text !== param.name.text || ts14.isPrivateIdentifier(methodLookup.name)) {
3195
+ if (!thisArg || !ts13.isIdentifier(thisArg) || thisArg.text !== param.name.text) return void 0;
3196
+ if (!argsArg || !ts13.isArrayLiteralExpression(argsArg)) return void 0;
3197
+ if (!ts13.isPropertyAccessExpression(methodLookup) || !ts13.isIdentifier(methodLookup.expression) || methodLookup.expression.text !== param.name.text || ts13.isPrivateIdentifier(methodLookup.name)) {
3356
3198
  return void 0;
3357
3199
  }
3358
- return ts14.factory.createCallExpression(
3359
- ts14.factory.createPropertyAccessExpression(adopted, methodLookup.name),
3200
+ return ts13.factory.createCallExpression(
3201
+ ts13.factory.createPropertyAccessExpression(adopted, methodLookup.name),
3360
3202
  void 0,
3361
3203
  [...argsArg.elements]
3362
3204
  );
@@ -3366,23 +3208,23 @@ var unwrapProducerIife = (node) => {
3366
3208
  const receiver = node.arguments[0];
3367
3209
  if (!receiver) return void 0;
3368
3210
  const callee = peelParens(node.expression);
3369
- if (!ts14.isArrowFunction(callee) || callee.parameters.length !== 1 || ts14.isBlock(callee.body)) {
3211
+ if (!ts13.isArrowFunction(callee) || callee.parameters.length !== 1 || ts13.isBlock(callee.body)) {
3370
3212
  return void 0;
3371
3213
  }
3372
3214
  const param = callee.parameters[0];
3373
- if (!param || !ts14.isIdentifier(param.name) || param.dotDotDotToken || param.initializer) {
3215
+ if (!param || !ts13.isIdentifier(param.name) || param.dotDotDotToken || param.initializer) {
3374
3216
  return void 0;
3375
3217
  }
3376
3218
  const body = peelParens(callee.body);
3377
- if (!ts14.isCallExpression(body) || !isRasputinCall(body)) return void 0;
3219
+ if (!ts13.isCallExpression(body) || !isRasputinCall(body)) return void 0;
3378
3220
  if (calleeName(body.expression) !== "__rasputinM") return void 0;
3379
3221
  const bound = body.arguments[0];
3380
3222
  const fn = body.arguments[1];
3381
- if (!bound || !fn || !ts14.isIdentifier(bound) || bound.text !== param.name.text) return void 0;
3382
- if (!ts14.isPropertyAccessExpression(fn)) return void 0;
3383
- if (!ts14.isIdentifier(fn.expression) || fn.expression.text !== param.name.text) return void 0;
3384
- return ts14.factory.createCallExpression(
3385
- ts14.factory.createPropertyAccessExpression(receiver, fn.name),
3223
+ if (!bound || !fn || !ts13.isIdentifier(bound) || bound.text !== param.name.text) return void 0;
3224
+ if (!ts13.isPropertyAccessExpression(fn)) return void 0;
3225
+ if (!ts13.isIdentifier(fn.expression) || fn.expression.text !== param.name.text) return void 0;
3226
+ return ts13.factory.createCallExpression(
3227
+ ts13.factory.createPropertyAccessExpression(receiver, fn.name),
3386
3228
  void 0,
3387
3229
  body.arguments.slice(2)
3388
3230
  );
@@ -3390,22 +3232,22 @@ var unwrapProducerIife = (node) => {
3390
3232
  var unwrapCall = (node) => {
3391
3233
  let current = node;
3392
3234
  while (true) {
3393
- if (ts14.isParenthesizedExpression(current)) {
3235
+ if (ts13.isParenthesizedExpression(current)) {
3394
3236
  current = current.expression;
3395
3237
  continue;
3396
3238
  }
3397
- if (ts14.isBinaryExpression(current)) {
3239
+ if (ts13.isBinaryExpression(current)) {
3398
3240
  const slot = jsonAwaitSlot(current);
3399
3241
  if (slot) {
3400
3242
  current = slot;
3401
3243
  continue;
3402
3244
  }
3403
3245
  }
3404
- if (ts14.isConditionalExpression(current) && isRasputinName(identText(current.condition) ?? "")) {
3246
+ if (ts13.isConditionalExpression(current) && isRasputinName(identText(current.condition) ?? "")) {
3405
3247
  current = current.whenTrue;
3406
3248
  continue;
3407
3249
  }
3408
- if (ts14.isCallExpression(current)) {
3250
+ if (ts13.isCallExpression(current)) {
3409
3251
  const adopted = unwrapAdoptIife(current);
3410
3252
  if (adopted) {
3411
3253
  current = adopted;
@@ -3417,7 +3259,7 @@ var unwrapCall = (node) => {
3417
3259
  continue;
3418
3260
  }
3419
3261
  }
3420
- if (ts14.isCallExpression(current) && isRasputinCall(current)) {
3262
+ if (ts13.isCallExpression(current) && isRasputinCall(current)) {
3421
3263
  const name = calleeName(current.expression);
3422
3264
  if ((name === "__rasputinO" || name === "__rasputinL") && current.arguments.length >= 2 && current.arguments[1]) {
3423
3265
  current = current.arguments[1];
@@ -3450,26 +3292,26 @@ var unwrapCall = (node) => {
3450
3292
  var isRasputinIf = (node) => {
3451
3293
  if (node.elseStatement) return false;
3452
3294
  const condition = node.expression;
3453
- const negated = ts14.isPrefixUnaryExpression(condition) && condition.operator === ts14.SyntaxKind.ExclamationToken && isRasputinName(identText(condition.operand) ?? "");
3295
+ const negated = ts13.isPrefixUnaryExpression(condition) && condition.operator === ts13.SyntaxKind.ExclamationToken && isRasputinName(identText(condition.operand) ?? "");
3454
3296
  if (!negated) return false;
3455
3297
  const then = node.thenStatement;
3456
- if (ts14.isExpressionStatement(then) && isRasputinCall(then.expression)) return true;
3457
- return ts14.isBlock(then) && then.statements.every((statement) => isRasputinStatement(statement));
3298
+ if (ts13.isExpressionStatement(then) && isRasputinCall(then.expression)) return true;
3299
+ return ts13.isBlock(then) && then.statements.every((statement) => isRasputinStatement(statement));
3458
3300
  };
3459
3301
  var isRasputinStatement = (node) => {
3460
- if (ts14.isEmptyStatement(node)) return true;
3461
- if (ts14.isVariableStatement(node)) {
3302
+ if (ts13.isEmptyStatement(node)) return true;
3303
+ if (ts13.isVariableStatement(node)) {
3462
3304
  return node.declarationList.declarations.every((declaration) => {
3463
3305
  const name = identText(declaration.name);
3464
3306
  return Boolean(name && isRasputinName(name));
3465
3307
  });
3466
3308
  }
3467
- if (ts14.isExpressionStatement(node)) {
3309
+ if (ts13.isExpressionStatement(node)) {
3468
3310
  if (isRasputinAssignment(node.expression)) return true;
3469
3311
  if (!isRasputinCall(node.expression)) return false;
3470
3312
  return unwrapCall(node.expression) === node.expression;
3471
3313
  }
3472
- if (ts14.isIfStatement(node)) return isRasputinIf(node);
3314
+ if (ts13.isIfStatement(node)) return isRasputinIf(node);
3473
3315
  return false;
3474
3316
  };
3475
3317
  var isRasputinTryWrapper = (node) => {
@@ -3479,12 +3321,12 @@ var isRasputinTryWrapper = (node) => {
3479
3321
  (statement) => !isRasputinStatement(statement)
3480
3322
  );
3481
3323
  const leftover = catchCalls[0];
3482
- const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts14.isThrowStatement(leftover) && ts14.isIdentifier(leftover.expression);
3324
+ const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts13.isThrowStatement(leftover) && ts13.isIdentifier(leftover.expression);
3483
3325
  if (!leftoverThrow && catchCalls.length > 0) return false;
3484
3326
  return node.finallyBlock.statements.every((statement) => isRasputinStatement(statement));
3485
3327
  };
3486
3328
  var customerTempInit = (statement) => {
3487
- if (!ts14.isVariableStatement(statement)) return void 0;
3329
+ if (!ts13.isVariableStatement(statement)) return void 0;
3488
3330
  for (const declaration of statement.declarationList.declarations) {
3489
3331
  const name = identText(declaration.name);
3490
3332
  if (!name || !isRasputinName(name) || !declaration.initializer) continue;
@@ -3497,7 +3339,7 @@ var flattenStatements = (statements) => {
3497
3339
  const flattened = [];
3498
3340
  for (const statement of statements) {
3499
3341
  if (isRasputinStatement(statement)) continue;
3500
- if (ts14.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
3342
+ if (ts13.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
3501
3343
  flattened.push(...flattenStatements(statement.tryBlock.statements));
3502
3344
  continue;
3503
3345
  }
@@ -3506,27 +3348,27 @@ var flattenStatements = (statements) => {
3506
3348
  return flattened;
3507
3349
  };
3508
3350
  var isRememberIife = (node) => {
3509
- if (!ts14.isCallExpression(node) || node.arguments.length > 0) return void 0;
3351
+ if (!ts13.isCallExpression(node) || node.arguments.length > 0) return void 0;
3510
3352
  let callee = node.expression;
3511
- if (ts14.isParenthesizedExpression(callee)) callee = callee.expression;
3512
- if (!ts14.isArrowFunction(callee) || callee.parameters.length > 0 || !ts14.isBlock(callee.body)) {
3353
+ if (ts13.isParenthesizedExpression(callee)) callee = callee.expression;
3354
+ if (!ts13.isArrowFunction(callee) || callee.parameters.length > 0 || !ts13.isBlock(callee.body)) {
3513
3355
  return void 0;
3514
3356
  }
3515
3357
  const statements = callee.body.statements;
3516
3358
  const last = statements.at(-1);
3517
- if (!last || !ts14.isReturnStatement(last) || !last.expression) return void 0;
3359
+ if (!last || !ts13.isReturnStatement(last) || !last.expression) return void 0;
3518
3360
  let returned = last.expression;
3519
- while (ts14.isParenthesizedExpression(returned)) returned = returned.expression;
3520
- if (!ts14.isCallExpression(returned)) return void 0;
3361
+ while (ts13.isParenthesizedExpression(returned)) returned = returned.expression;
3362
+ if (!ts13.isCallExpression(returned)) return void 0;
3521
3363
  const name = calleeName(returned.expression);
3522
3364
  if (name !== "__rasputinK") return void 0;
3523
3365
  const objectArg = returned.arguments[0];
3524
- if (!objectArg || !ts14.isIdentifier(objectArg)) return void 0;
3366
+ if (!objectArg || !ts13.isIdentifier(objectArg)) return void 0;
3525
3367
  const temps = /* @__PURE__ */ new Map();
3526
3368
  for (const statement of statements.slice(0, -1)) {
3527
- if (!ts14.isVariableStatement(statement)) return void 0;
3369
+ if (!ts13.isVariableStatement(statement)) return void 0;
3528
3370
  for (const declaration of statement.declarationList.declarations) {
3529
- if (!ts14.isIdentifier(declaration.name) || !declaration.initializer) return void 0;
3371
+ if (!ts13.isIdentifier(declaration.name) || !declaration.initializer) return void 0;
3530
3372
  temps.set(declaration.name.text, declaration.initializer);
3531
3373
  }
3532
3374
  }
@@ -3536,10 +3378,10 @@ var isRememberIife = (node) => {
3536
3378
  };
3537
3379
  var resolveRememberTemp = (expression, temps, seen) => {
3538
3380
  let current = expression;
3539
- while (ts14.isParenthesizedExpression(current) || ts14.isNonNullExpression(current) || ts14.isAsExpression(current) || ts14.isTypeAssertionExpression(current) || ts14.isSatisfiesExpression(current)) {
3381
+ while (ts13.isParenthesizedExpression(current) || ts13.isNonNullExpression(current) || ts13.isAsExpression(current) || ts13.isTypeAssertionExpression(current) || ts13.isSatisfiesExpression(current)) {
3540
3382
  current = current.expression;
3541
3383
  }
3542
- if (ts14.isIdentifier(current) && temps.has(current.text) && !seen.has(current.text)) {
3384
+ if (ts13.isIdentifier(current) && temps.has(current.text) && !seen.has(current.text)) {
3543
3385
  const next = temps.get(current.text);
3544
3386
  if (!next) return current;
3545
3387
  seen.add(current.text);
@@ -3548,27 +3390,27 @@ var resolveRememberTemp = (expression, temps, seen) => {
3548
3390
  return current;
3549
3391
  };
3550
3392
  var extra = (node) => {
3551
- if (ts14.isIdentifier(node) || ts14.isPrivateIdentifier(node)) {
3393
+ if (ts13.isIdentifier(node) || ts13.isPrivateIdentifier(node)) {
3552
3394
  return isRasputinName(node.text) ? "" : node.text;
3553
3395
  }
3554
- if (ts14.isStringLiteral(node) || ts14.isNumericLiteral(node) || ts14.isNoSubstitutionTemplateLiteral(node)) {
3396
+ if (ts13.isStringLiteral(node) || ts13.isNumericLiteral(node) || ts13.isNoSubstitutionTemplateLiteral(node)) {
3555
3397
  return node.text;
3556
3398
  }
3557
- if (ts14.isToken(node) && !ts14.isIdentifier(node)) return ts14.SyntaxKind[node.kind] ?? "";
3399
+ if (ts13.isToken(node) && !ts13.isIdentifier(node)) return ts13.SyntaxKind[node.kind] ?? "";
3558
3400
  return "";
3559
3401
  };
3560
3402
  var signatureOfSubstituted = (node, temps) => {
3561
3403
  const remembered = isRememberIife(node);
3562
3404
  if (remembered) return signatureOfSubstituted(remembered.object, remembered.temps);
3563
- if (ts14.isObjectLiteralExpression(node)) {
3405
+ if (ts13.isObjectLiteralExpression(node)) {
3564
3406
  const parts = node.properties.map((property) => {
3565
- if (ts14.isShorthandPropertyAssignment(property)) return signatureOf(property);
3566
- if (!ts14.isPropertyAssignment(property)) return signatureOf(property);
3407
+ if (ts13.isShorthandPropertyAssignment(property)) return signatureOf(property);
3408
+ if (!ts13.isPropertyAssignment(property)) return signatureOf(property);
3567
3409
  const init = resolveRememberTemp(property.initializer, temps, /* @__PURE__ */ new Set());
3568
- if (ts14.isIdentifier(property.name) && ts14.isIdentifier(init) && property.name.text === init.text) {
3569
- return signatureOf(ts14.factory.createShorthandPropertyAssignment(property.name));
3410
+ if (ts13.isIdentifier(property.name) && ts13.isIdentifier(init) && property.name.text === init.text) {
3411
+ return signatureOf(ts13.factory.createShorthandPropertyAssignment(property.name));
3570
3412
  }
3571
- if (ts14.isComputedPropertyName(property.name)) {
3413
+ if (ts13.isComputedPropertyName(property.name)) {
3572
3414
  const key = resolveRememberTemp(property.name.expression, temps, /* @__PURE__ */ new Set());
3573
3415
  return `PropertyAssignment[ComputedPropertyName[${signatureOfSubstituted(key, temps)}],${signatureOfSubstituted(init, temps)}]`;
3574
3416
  }
@@ -3576,7 +3418,7 @@ var signatureOfSubstituted = (node, temps) => {
3576
3418
  });
3577
3419
  return `ObjectLiteralExpression[${parts.join(",")}]`;
3578
3420
  }
3579
- if (ts14.isArrayLiteralExpression(node)) {
3421
+ if (ts13.isArrayLiteralExpression(node)) {
3580
3422
  const parts = node.elements.map(
3581
3423
  (element) => signatureOfSubstituted(resolveRememberTemp(element, temps, /* @__PURE__ */ new Set()), temps)
3582
3424
  );
@@ -3594,33 +3436,33 @@ var signatureOf = (node) => {
3594
3436
  if (unwrapped !== node) return signatureOf(unwrapped);
3595
3437
  const remembered = signatureOfRememberedLiteral(unwrapped);
3596
3438
  if (remembered !== void 0) return remembered;
3597
- if (ts14.isPropertyAssignment(unwrapped) && ts14.isIdentifier(unwrapped.name) && ts14.isIdentifier(unwrapped.initializer) && unwrapped.name.text === unwrapped.initializer.text) {
3598
- return signatureOf(ts14.factory.createShorthandPropertyAssignment(unwrapped.name));
3439
+ if (ts13.isPropertyAssignment(unwrapped) && ts13.isIdentifier(unwrapped.name) && ts13.isIdentifier(unwrapped.initializer) && unwrapped.name.text === unwrapped.initializer.text) {
3440
+ return signatureOf(ts13.factory.createShorthandPropertyAssignment(unwrapped.name));
3599
3441
  }
3600
- if (ts14.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
3601
- if (ts14.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
3442
+ if (ts13.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
3443
+ if (ts13.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
3602
3444
  return flattenStatements(unwrapped.tryBlock.statements).map(signatureOf).filter(Boolean).join("");
3603
3445
  }
3604
- if (ts14.isCatchClause(unwrapped)) {
3446
+ if (ts13.isCatchClause(unwrapped)) {
3605
3447
  const statements = flattenStatements(unwrapped.block.statements);
3606
3448
  const variable = unwrapped.variableDeclaration ? signatureOf(unwrapped.variableDeclaration) : "";
3607
3449
  return `Catch${variable}[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
3608
3450
  }
3609
- if (ts14.isBlock(unwrapped)) {
3451
+ if (ts13.isBlock(unwrapped)) {
3610
3452
  const statements = flattenStatements(unwrapped.statements);
3611
3453
  return `Block[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
3612
3454
  }
3613
- if (ts14.isArrowFunction(unwrapped) && ts14.isBlock(unwrapped.body)) {
3455
+ if (ts13.isArrowFunction(unwrapped) && ts13.isBlock(unwrapped.body)) {
3614
3456
  const raw = unwrapped.body.statements;
3615
- const tryWrap = raw.length === 1 && raw[0] && ts14.isTryStatement(raw[0]) ? raw[0] : void 0;
3457
+ const tryWrap = raw.length === 1 && raw[0] && ts13.isTryStatement(raw[0]) ? raw[0] : void 0;
3616
3458
  const inner = tryWrap && isRasputinTryWrapper(tryWrap) ? tryWrap.tryBlock.statements : raw;
3617
3459
  const temp = inner[0] ? customerTempInit(inner[0]) : void 0;
3618
3460
  const returned = inner[1];
3619
- if (temp && returned && ts14.isReturnStatement(returned) && returned.expression && inner.length === 2) {
3461
+ if (temp && returned && ts13.isReturnStatement(returned) && returned.expression && inner.length === 2) {
3620
3462
  const value = unwrapCall(returned.expression);
3621
- if (ts14.isIdentifier(value) && value.text === temp.name) {
3463
+ if (ts13.isIdentifier(value) && value.text === temp.name) {
3622
3464
  const parts2 = [];
3623
- ts14.forEachChild(unwrapped, (child) => {
3465
+ ts13.forEachChild(unwrapped, (child) => {
3624
3466
  if (child === unwrapped.body) {
3625
3467
  const part2 = signatureOf(temp.init);
3626
3468
  if (part2) parts2.push(part2);
@@ -3634,10 +3476,10 @@ var signatureOf = (node) => {
3634
3476
  }
3635
3477
  const statements = flattenStatements(unwrapped.body.statements);
3636
3478
  const only = statements[0];
3637
- const onlyExpression = only && ts14.isReturnStatement(only) ? only.expression : void 0;
3479
+ const onlyExpression = only && ts13.isReturnStatement(only) ? only.expression : void 0;
3638
3480
  if (statements.length === 1 && onlyExpression) {
3639
3481
  const parts2 = [];
3640
- ts14.forEachChild(unwrapped, (child) => {
3482
+ ts13.forEachChild(unwrapped, (child) => {
3641
3483
  if (child === unwrapped.body) {
3642
3484
  const part2 = signatureOf(onlyExpression);
3643
3485
  if (part2) parts2.push(part2);
@@ -3649,20 +3491,20 @@ var signatureOf = (node) => {
3649
3491
  return `ArrowFunction[${parts2.join(",")}]`;
3650
3492
  }
3651
3493
  }
3652
- if (ts14.isReturnStatement(unwrapped)) {
3494
+ if (ts13.isReturnStatement(unwrapped)) {
3653
3495
  if (!unwrapped.expression) return "ReturnStatement[]";
3654
3496
  const expression = unwrapCall(unwrapped.expression);
3655
- if (ts14.isVoidExpression(expression) && isRasputinCall(expression.expression)) {
3497
+ if (ts13.isVoidExpression(expression) && isRasputinCall(expression.expression)) {
3656
3498
  return "ReturnStatement[]";
3657
3499
  }
3658
3500
  return `Return[${signatureOf(unwrapped.expression)}]`;
3659
3501
  }
3660
3502
  const parts = [];
3661
- ts14.forEachChild(unwrapped, (child) => {
3503
+ ts13.forEachChild(unwrapped, (child) => {
3662
3504
  const part = signatureOf(child);
3663
3505
  if (part) parts.push(part);
3664
3506
  });
3665
- const kind = ts14.SyntaxKind[unwrapped.kind] ?? "Node";
3507
+ const kind = ts13.SyntaxKind[unwrapped.kind] ?? "Node";
3666
3508
  return `${kind}${extra(unwrapped)}[${parts.join(",")}]`;
3667
3509
  };
3668
3510
  var browserInstrumentationIsSafe = (filePath, original, transformed) => {
@@ -3685,6 +3527,15 @@ var refuse = (source, classifications) => ({
3685
3527
  verificationFailed: true
3686
3528
  });
3687
3529
  var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleIndex = 0, options) => {
3530
+ if (isSvelteCompiledPath(filePath) && !options?.policy) {
3531
+ return {
3532
+ code: source,
3533
+ classifications: [],
3534
+ sites: [],
3535
+ identities: [],
3536
+ delta: { functions: [], callSites: [], destructures: [] }
3537
+ };
3538
+ }
3688
3539
  if (source.includes("@rasputin-ignore-file") || sourceIsRasputinInstrumented(source)) {
3689
3540
  return {
3690
3541
  code: source,
@@ -3695,7 +3546,12 @@ var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleInd
3695
3546
  };
3696
3547
  }
3697
3548
  const sourceFile = parseSource(source, filePath);
3698
- const classifications = classifyFunctions(source, filePath, options?.mapLocation);
3549
+ const classifications = classifyFunctions(
3550
+ source,
3551
+ filePath,
3552
+ options?.mapLocation,
3553
+ options?.policy
3554
+ );
3699
3555
  const observe = collectObserveSiteEdits(
3700
3556
  source,
3701
3557
  filePath,
@@ -3703,7 +3559,10 @@ var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleInd
3703
3559
  sourceFile
3704
3560
  );
3705
3561
  const literals = collectLiteralSiteEdits(source, filePath, { classifications }, sourceFile);
3706
- const json = collectJsonProducerEdits(source, filePath, sourceFile, { adoptCalls: true });
3562
+ const json = collectJsonProducerEdits(source, filePath, sourceFile, {
3563
+ adoptCalls: true,
3564
+ policy: options?.policy
3565
+ });
3707
3566
  const functions = collectBrowserFunctionEdits(
3708
3567
  source,
3709
3568
  sourceFile,
@@ -3714,7 +3573,8 @@ var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleInd
3714
3573
  observe: observe.sites.length > 0,
3715
3574
  struct: literals.edits.length > 0,
3716
3575
  includePlans: options?.includePlans === true,
3717
- mapLocation: options?.mapLocation
3576
+ mapLocation: options?.mapLocation,
3577
+ policy: options?.policy
3718
3578
  }
3719
3579
  );
3720
3580
  const edits = [...observe.edits, ...literals.edits, ...json.edits, ...functions.edits];
@@ -3745,11 +3605,11 @@ var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleInd
3745
3605
  import { basename as basename3 } from "node:path";
3746
3606
 
3747
3607
  // ../instrumentation/src/provenance-function-edits.ts
3748
- import ts15 from "typescript";
3608
+ import ts14 from "typescript";
3749
3609
  var PROVENANCE_HANDLE_CALLEE = "globalThis.__rasputinN";
3750
3610
  var PROVENANCE_HANDLE_GUARD = "globalThis.__rasputinN??=function(){return{leave:function(v){return v},end:function(){},suspend:function(v){return v},resume:function(v){return v}}};";
3751
- var isProvenanceTarget = (node) => (ts15.isFunctionDeclaration(node) || ts15.isFunctionExpression(node) || ts15.isArrowFunction(node) || ts15.isMethodDeclaration(node)) && node.body !== void 0 && !node.asteriskToken;
3752
- var isDirectivePrologue2 = (statement) => ts15.isExpressionStatement(statement) && ts15.isStringLiteral(statement.expression);
3611
+ var isProvenanceTarget = (node) => (ts14.isFunctionDeclaration(node) || ts14.isFunctionExpression(node) || ts14.isArrowFunction(node) || ts14.isMethodDeclaration(node)) && node.body !== void 0 && !node.asteriskToken;
3612
+ var isDirectivePrologue2 = (statement) => ts14.isExpressionStatement(statement) && ts14.isStringLiteral(statement.expression);
3753
3613
  var insertPositionAfterPrologue2 = (source, sourceFile) => {
3754
3614
  const shebangEnd = source.startsWith("#!") ? source.indexOf("\n") + 1 : 0;
3755
3615
  let end = shebangEnd;
@@ -3775,15 +3635,15 @@ var functionBodyPrologueEnd2 = (body, sourceFile) => {
3775
3635
  var walkOwnBody2 = (node, visitNode) => {
3776
3636
  if (!node.body) return;
3777
3637
  const visit = (candidate) => {
3778
- if (candidate !== node && ts15.isFunctionLike(candidate)) return;
3638
+ if (candidate !== node && ts14.isFunctionLike(candidate)) return;
3779
3639
  visitNode(candidate);
3780
- ts15.forEachChild(candidate, visit);
3640
+ ts14.forEachChild(candidate, visit);
3781
3641
  };
3782
3642
  visit(node.body);
3783
3643
  };
3784
3644
  var producerName = (node) => {
3785
3645
  const callee = peel(node.expression);
3786
- if (ts15.isPropertyAccessExpression(callee) && ts15.isIdentifier(callee.name)) {
3646
+ if (ts14.isPropertyAccessExpression(callee) && ts14.isIdentifier(callee.name)) {
3787
3647
  return callee.name.text;
3788
3648
  }
3789
3649
  return void 0;
@@ -3822,10 +3682,10 @@ var callCanCarryProvenance2 = (node) => {
3822
3682
  if (name === "json" || name === "parse") return true;
3823
3683
  if (name === "call" || name === "apply") return false;
3824
3684
  const callee = peel(node.expression);
3825
- if (ts15.isIdentifier(callee)) return !NON_PROVENANCE_ROOTS2.has(callee.text);
3826
- if (ts15.isPropertyAccessExpression(callee)) {
3685
+ if (ts14.isIdentifier(callee)) return !NON_PROVENANCE_ROOTS2.has(callee.text);
3686
+ if (ts14.isPropertyAccessExpression(callee)) {
3827
3687
  const object = peel(callee.expression);
3828
- if (ts15.isIdentifier(object) && NON_PROVENANCE_ROOTS2.has(object.text)) {
3688
+ if (ts14.isIdentifier(object) && NON_PROVENANCE_ROOTS2.has(object.text)) {
3829
3689
  return object.text === "JSON" && callee.name.text === "parse";
3830
3690
  }
3831
3691
  }
@@ -3833,29 +3693,29 @@ var callCanCarryProvenance2 = (node) => {
3833
3693
  };
3834
3694
  var returnedExpressionNeedsProvenance = (expression) => {
3835
3695
  const inner = peel(expression);
3836
- if (ts15.isAwaitExpression(inner)) return true;
3837
- if (ts15.isCallExpression(inner)) return callCanCarryProvenance2(inner);
3696
+ if (ts14.isAwaitExpression(inner)) return true;
3697
+ if (ts14.isCallExpression(inner)) return callCanCarryProvenance2(inner);
3838
3698
  return false;
3839
3699
  };
3840
3700
  var functionNeedsProvenance = (node) => {
3841
- if (ts15.isArrowFunction(node) && !ts15.isBlock(node.body)) {
3701
+ if (ts14.isArrowFunction(node) && !ts14.isBlock(node.body)) {
3842
3702
  const body = peel(node.body);
3843
- if (ts15.isAwaitExpression(body)) return true;
3844
- if (ts15.isCallExpression(body)) return callCanCarryProvenance2(body);
3703
+ if (ts14.isAwaitExpression(body)) return true;
3704
+ if (ts14.isCallExpression(body)) return callCanCarryProvenance2(body);
3845
3705
  return false;
3846
3706
  }
3847
3707
  let needed = false;
3848
3708
  walkOwnBody2(node, (candidate) => {
3849
3709
  if (needed) return;
3850
- if (ts15.isAwaitExpression(candidate)) {
3710
+ if (ts14.isAwaitExpression(candidate)) {
3851
3711
  needed = true;
3852
3712
  return;
3853
3713
  }
3854
- if (ts15.isReturnStatement(candidate) && candidate.expression) {
3714
+ if (ts14.isReturnStatement(candidate) && candidate.expression) {
3855
3715
  if (returnedExpressionNeedsProvenance(candidate.expression)) needed = true;
3856
3716
  return;
3857
3717
  }
3858
- if (ts15.isCallExpression(candidate)) {
3718
+ if (ts14.isCallExpression(candidate)) {
3859
3719
  const name = producerName(candidate);
3860
3720
  if (name === "json" || name === "parse") needed = true;
3861
3721
  }
@@ -3863,9 +3723,9 @@ var functionNeedsProvenance = (node) => {
3863
3723
  return needed;
3864
3724
  };
3865
3725
  var collectReturnWraps2 = (node, sourceFile, handleName, edits) => {
3866
- if (!ts15.isBlock(node.body)) return;
3726
+ if (!ts14.isBlock(node.body)) return;
3867
3727
  walkOwnBody2(node, (candidate) => {
3868
- if (!ts15.isReturnStatement(candidate) || !candidate.expression) return;
3728
+ if (!ts14.isReturnStatement(candidate) || !candidate.expression) return;
3869
3729
  wrap(
3870
3730
  edits,
3871
3731
  candidate.expression.getStart(sourceFile),
@@ -3878,7 +3738,7 @@ var collectReturnWraps2 = (node, sourceFile, handleName, edits) => {
3878
3738
  };
3879
3739
  var collectAwaitSuspends = (node, sourceFile, handleName, edits) => {
3880
3740
  walkOwnBody2(node, (candidate) => {
3881
- if (!ts15.isAwaitExpression(candidate)) return;
3741
+ if (!ts14.isAwaitExpression(candidate)) return;
3882
3742
  wrap(
3883
3743
  edits,
3884
3744
  candidate.expression.getStart(sourceFile),
@@ -3890,12 +3750,12 @@ var collectAwaitSuspends = (node, sourceFile, handleName, edits) => {
3890
3750
  });
3891
3751
  };
3892
3752
  var functionRef2 = (node) => {
3893
- if (node.name && ts15.isIdentifier(node.name)) {
3894
- if (ts15.isMethodDeclaration(node)) return void 0;
3753
+ if (node.name && ts14.isIdentifier(node.name)) {
3754
+ if (ts14.isMethodDeclaration(node)) return void 0;
3895
3755
  return node.name.text;
3896
3756
  }
3897
3757
  const parent = node.parent;
3898
- if (ts15.isVariableDeclaration(parent) && ts15.isIdentifier(parent.name) && parent.initializer === node) {
3758
+ if (ts14.isVariableDeclaration(parent) && ts14.isIdentifier(parent.name) && parent.initializer === node) {
3899
3759
  return parent.name.text;
3900
3760
  }
3901
3761
  return void 0;
@@ -3912,7 +3772,7 @@ var collectProvenanceFunctionEdits = (source, sourceFile) => {
3912
3772
  const ref = functionRef2(node);
3913
3773
  const enter = ref ? `${PROVENANCE_HANDLE_CALLEE}(${ref})` : `${PROVENANCE_HANDLE_CALLEE}()`;
3914
3774
  const epilogue = `}catch(${errorName}){throw ${errorName};}finally{${handleName}.end();}`;
3915
- if (ts15.isBlock(node.body)) {
3775
+ if (ts14.isBlock(node.body)) {
3916
3776
  const openAt = functionBodyPrologueEnd2(node.body, sourceFile);
3917
3777
  const closeAt = node.body.end - 1;
3918
3778
  wrap(edits, openAt, closeAt, `;const ${handleName}=${enter};try{`, epilogue, 0);
@@ -3936,7 +3796,7 @@ var collectProvenanceFunctionEdits = (source, sourceFile) => {
3936
3796
  functionWraps += 1;
3937
3797
  }
3938
3798
  }
3939
- ts15.forEachChild(node, visit);
3799
+ ts14.forEachChild(node, visit);
3940
3800
  };
3941
3801
  visit(sourceFile);
3942
3802
  if (functionWraps > 0) {
@@ -4003,7 +3863,7 @@ var instrumentProvenanceSource = (source, filePath) => {
4003
3863
  };
4004
3864
 
4005
3865
  // ../instrumentation/src/provenance-coverage.ts
4006
- var isRasputinSdkPath = (path) => path.includes("/@rasputin-ai/") || path.includes("/recorder/src/") || path.includes("/recorder/dist/") || path.includes("/instrumentation/src/") || path.includes("/instrumentation/dist/") || path.includes("/browser/src/") || path.includes("/browser/dist/") || path.includes("/core/src/") || path.includes("/core/dist/") || path.includes("/node/src/") || path.includes("/elysia/src/");
3866
+ var isRasputinSdkPath = (path) => path.includes("/@rasputin-ai/") || path.includes("/recorder/src/") || path.includes("/recorder/dist/") || path.includes("/instrumentation/src/") || path.includes("/instrumentation/dist/") || path.includes("/browser/src/") || path.includes("/browser/dist/") || path.includes("/core/src/") || path.includes("/core/dist/") || path.includes("/node/src/") || path.includes("/elysia/src/") || path.includes("/sveltekit/src/") || path.includes("/sveltekit/dist/");
4007
3867
  var isBundledDependencyPath = (path) => /(^|\/)node_modules\//.test(path) || path.includes("/.vite/deps/") || path.includes("node_modules/.vite/deps/");
4008
3868
  var coverageForModule = (filePath, options) => {
4009
3869
  const path = filePath.replaceAll("\\", "/");
@@ -4183,7 +4043,7 @@ var uploadBrowserArtifacts = async (input) => {
4183
4043
 
4184
4044
  // src/vite/plugin.ts
4185
4045
  var isServerModule = (path) => path.includes(".server.") || path.endsWith("+server.ts") || path.endsWith("+server.js") || path.includes("/hooks.server.");
4186
- var isRasputinSdkModule = (path) => path.includes("/@rasputin-ai/") || path.includes("/recorder/src/") || path.includes("/recorder/dist/") || path.includes("/instrumentation/src/") || path.includes("/instrumentation/dist/") || path.includes("/browser/src/") || path.includes("/browser/dist/") || path.includes("/core/src/") || path.includes("/core/dist/") || path.includes("/node/src/") || path.includes("/elysia/src/");
4046
+ var isRasputinSdkModule = (path) => path.includes("/@rasputin-ai/") || path.includes("/recorder/src/") || path.includes("/recorder/dist/") || path.includes("/instrumentation/src/") || path.includes("/instrumentation/dist/") || path.includes("/browser/src/") || path.includes("/browser/dist/") || path.includes("/core/src/") || path.includes("/core/dist/") || path.includes("/node/src/") || path.includes("/elysia/src/") || path.includes("/sveltekit/src/") || path.includes("/sveltekit/dist/");
4187
4047
  var isRasputinBrowserRuntimeSource = (code) => code.includes("rasputin.browser.client.v1");
4188
4048
  var isJsModulePath = (path) => /\.[cm]?[jt]sx?$/.test(path) && !isSvelteCompiledPath(path);
4189
4049
  var MAX_PROVENANCE_SOURCE_CHARS = 15e5;