@rasputin-ai/browser 0.6.2 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ingest-event.d.ts.map +1 -1
- package/dist/index.js +20 -1
- package/dist/sdk-meta.d.ts +1 -1
- package/dist/vite/artifacts.d.ts +1 -0
- package/dist/vite/artifacts.d.ts.map +1 -1
- package/dist/vite/index.js +482 -596
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/upload-browser-artifacts.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/vite/index.js
CHANGED
|
@@ -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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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("/");
|
|
@@ -651,6 +651,20 @@ var onInt = tagListener(() => {
|
|
|
651
651
|
handleSignal("SIGINT");
|
|
652
652
|
});
|
|
653
653
|
|
|
654
|
+
// ../core/src/transport/encode-json-request-body.ts
|
|
655
|
+
import { gzipSync } from "node:zlib";
|
|
656
|
+
var GZIP_JSON_THRESHOLD_BYTES = 10 * 1024;
|
|
657
|
+
var encodeJsonRequestBody = (payload, gzipThresholdBytes = GZIP_JSON_THRESHOLD_BYTES) => {
|
|
658
|
+
const json = JSON.stringify(payload);
|
|
659
|
+
if (Buffer.byteLength(json, "utf8") < gzipThresholdBytes) {
|
|
660
|
+
return { body: json, gzip: false };
|
|
661
|
+
}
|
|
662
|
+
const compressed = gzipSync(json);
|
|
663
|
+
const body = new Uint8Array(compressed.byteLength);
|
|
664
|
+
body.set(compressed);
|
|
665
|
+
return { body, gzip: true };
|
|
666
|
+
};
|
|
667
|
+
|
|
654
668
|
// ../core/src/transport/create-transport.ts
|
|
655
669
|
var DEFAULTS = {
|
|
656
670
|
enabled: true,
|
|
@@ -666,6 +680,11 @@ var DEFAULTS = {
|
|
|
666
680
|
shutdownFlushMs: 2e3
|
|
667
681
|
};
|
|
668
682
|
|
|
683
|
+
// ../core/src/create-client/error-observation.ts
|
|
684
|
+
var runtimeStateUnavailable = Symbol.for(
|
|
685
|
+
"rasputin.runtime-state.unavailable"
|
|
686
|
+
);
|
|
687
|
+
|
|
669
688
|
// ../core/src/derivation/sensitive-property-name.ts
|
|
670
689
|
var DEFAULT_SENSITIVE_PROPERTY_NAMES = [
|
|
671
690
|
"password",
|
|
@@ -849,7 +868,7 @@ var encodeFunctionPlan = (source) => {
|
|
|
849
868
|
var AUTOMATIC_RUNTIME_SYMBOL = "rasputin.execution.runtime.v3";
|
|
850
869
|
|
|
851
870
|
// ../instrumentation/src/classify-function.ts
|
|
852
|
-
import
|
|
871
|
+
import ts3 from "typescript";
|
|
853
872
|
|
|
854
873
|
// ../instrumentation/src/collect-instrumentation-delta.ts
|
|
855
874
|
import ts from "typescript";
|
|
@@ -1045,81 +1064,6 @@ var peel = (expression) => {
|
|
|
1045
1064
|
return current;
|
|
1046
1065
|
};
|
|
1047
1066
|
|
|
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
1067
|
// ../instrumentation/src/classify-function.ts
|
|
1124
1068
|
var ALLOWED_STATIC_CALLS = /* @__PURE__ */ new Map([
|
|
1125
1069
|
["Array", /* @__PURE__ */ new Set(["isArray"])],
|
|
@@ -1128,54 +1072,54 @@ var ALLOWED_STATIC_CALLS = /* @__PURE__ */ new Map([
|
|
|
1128
1072
|
["Object", /* @__PURE__ */ new Set(["is"])]
|
|
1129
1073
|
]);
|
|
1130
1074
|
var functionName = (node, sourceFile) => {
|
|
1131
|
-
if (
|
|
1075
|
+
if (ts3.isConstructorDeclaration(node)) return "constructor";
|
|
1132
1076
|
if (node.name) return node.name.getText(sourceFile).replace(/^['"]|['"]$/g, "");
|
|
1133
1077
|
const parent = node.parent;
|
|
1134
|
-
if (
|
|
1135
|
-
if (
|
|
1136
|
-
if (
|
|
1078
|
+
if (ts3.isVariableDeclaration(parent) && ts3.isIdentifier(parent.name)) return parent.name.text;
|
|
1079
|
+
if (ts3.isPropertyAssignment(parent)) return parent.name.getText(sourceFile);
|
|
1080
|
+
if (ts3.isPropertyDeclaration(parent) && parent.name) return parent.name.getText(sourceFile);
|
|
1137
1081
|
const location = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
1138
1082
|
return `anonymous@${location.line + 1}:${location.character + 1}`;
|
|
1139
1083
|
};
|
|
1140
1084
|
var functionLocationPosition = (node, sourceFile) => {
|
|
1141
1085
|
if (node.name) return node.name.getStart(sourceFile);
|
|
1142
1086
|
const parent = node.parent;
|
|
1143
|
-
if ((
|
|
1087
|
+
if ((ts3.isVariableDeclaration(parent) || ts3.isPropertyAssignment(parent)) && parent.name) {
|
|
1144
1088
|
return parent.name.getStart(sourceFile);
|
|
1145
1089
|
}
|
|
1146
1090
|
return node.getStart(sourceFile);
|
|
1147
1091
|
};
|
|
1148
1092
|
var isSupportedFunction = (node) => {
|
|
1149
|
-
if (!
|
|
1093
|
+
if (!ts3.isFunctionDeclaration(node) && !ts3.isFunctionExpression(node) && !ts3.isArrowFunction(node) && !ts3.isMethodDeclaration(node) && !ts3.isGetAccessorDeclaration(node) && !ts3.isSetAccessorDeclaration(node)) {
|
|
1150
1094
|
return false;
|
|
1151
1095
|
}
|
|
1152
1096
|
if (!node.body || "asteriskToken" in node && node.asteriskToken) return false;
|
|
1153
1097
|
return true;
|
|
1154
1098
|
};
|
|
1155
1099
|
var singleReturnedExpression = (body) => {
|
|
1156
|
-
if (!
|
|
1100
|
+
if (!ts3.isBlock(body)) return body;
|
|
1157
1101
|
if (body.statements.length === 0) return void 0;
|
|
1158
1102
|
if (body.statements.length !== 1) return void 0;
|
|
1159
1103
|
const statement = body.statements[0];
|
|
1160
|
-
if (!statement || !
|
|
1104
|
+
if (!statement || !ts3.isReturnStatement(statement)) return void 0;
|
|
1161
1105
|
return statement.expression;
|
|
1162
1106
|
};
|
|
1163
1107
|
var isLiteralExpression = (expression) => {
|
|
1164
1108
|
const node = peel(expression);
|
|
1165
|
-
if (
|
|
1166
|
-
if (
|
|
1167
|
-
if (node.kind ===
|
|
1109
|
+
if (ts3.isStringLiteral(node) || ts3.isNoSubstitutionTemplateLiteral(node)) return true;
|
|
1110
|
+
if (ts3.isNumericLiteral(node)) return true;
|
|
1111
|
+
if (node.kind === ts3.SyntaxKind.TrueKeyword || node.kind === ts3.SyntaxKind.FalseKeyword || node.kind === ts3.SyntaxKind.NullKeyword) {
|
|
1168
1112
|
return true;
|
|
1169
1113
|
}
|
|
1170
|
-
if (
|
|
1114
|
+
if (ts3.isIdentifier(node) && (node.text === "undefined" || node.text === "NaN")) return true;
|
|
1171
1115
|
return false;
|
|
1172
1116
|
};
|
|
1173
1117
|
var isLiteralOnlyBody = (body) => {
|
|
1174
|
-
if (
|
|
1118
|
+
if (ts3.isBlock(body)) {
|
|
1175
1119
|
if (body.statements.length === 0) return true;
|
|
1176
1120
|
if (body.statements.length !== 1) return false;
|
|
1177
1121
|
const statement = body.statements[0];
|
|
1178
|
-
if (!statement || !
|
|
1122
|
+
if (!statement || !ts3.isReturnStatement(statement)) return false;
|
|
1179
1123
|
return !statement.expression || isLiteralExpression(statement.expression);
|
|
1180
1124
|
}
|
|
1181
1125
|
return isLiteralExpression(body);
|
|
@@ -1183,8 +1127,8 @@ var isLiteralOnlyBody = (body) => {
|
|
|
1183
1127
|
var identifierParams = (node) => {
|
|
1184
1128
|
const names = [];
|
|
1185
1129
|
for (const parameter of node.parameters) {
|
|
1186
|
-
if (
|
|
1187
|
-
if (!
|
|
1130
|
+
if (ts3.isIdentifier(parameter.name) && parameter.name.text === "this") continue;
|
|
1131
|
+
if (!ts3.isIdentifier(parameter.name) || parameter.dotDotDotToken) return [];
|
|
1188
1132
|
names.push(parameter.name.text);
|
|
1189
1133
|
}
|
|
1190
1134
|
return names;
|
|
@@ -1195,42 +1139,42 @@ var isIdentityFunction = (node) => {
|
|
|
1195
1139
|
const returned = singleReturnedExpression(node.body);
|
|
1196
1140
|
if (!returned) return false;
|
|
1197
1141
|
const value = peel(returned);
|
|
1198
|
-
return
|
|
1142
|
+
return ts3.isIdentifier(value) && value.text === params[0];
|
|
1199
1143
|
};
|
|
1200
1144
|
var isAllowedTypeCall = (expression) => {
|
|
1201
1145
|
const callee = peel(expression);
|
|
1202
|
-
if (
|
|
1146
|
+
if (ts3.isIdentifier(callee)) {
|
|
1203
1147
|
return callee.text === "Boolean";
|
|
1204
1148
|
}
|
|
1205
|
-
if (!
|
|
1149
|
+
if (!ts3.isPropertyAccessExpression(callee) || !ts3.isIdentifier(callee.expression)) return false;
|
|
1206
1150
|
const allowed = ALLOWED_STATIC_CALLS.get(callee.expression.text);
|
|
1207
|
-
return !!allowed &&
|
|
1151
|
+
return !!allowed && ts3.isIdentifier(callee.name) && allowed.has(callee.name.text);
|
|
1208
1152
|
};
|
|
1209
1153
|
var isPredicateAtom = (expression) => {
|
|
1210
1154
|
const node = peel(expression);
|
|
1211
|
-
if (isLiteralExpression(node) ||
|
|
1212
|
-
if (node.kind ===
|
|
1213
|
-
if (
|
|
1214
|
-
if (
|
|
1155
|
+
if (isLiteralExpression(node) || ts3.isIdentifier(node)) return true;
|
|
1156
|
+
if (node.kind === ts3.SyntaxKind.ThisKeyword) return true;
|
|
1157
|
+
if (ts3.isPropertyAccessExpression(node)) return isPredicateAtom(node.expression);
|
|
1158
|
+
if (ts3.isElementAccessExpression(node)) {
|
|
1215
1159
|
return isPredicateAtom(node.expression) && isPredicateAtom(node.argumentExpression);
|
|
1216
1160
|
}
|
|
1217
1161
|
return false;
|
|
1218
1162
|
};
|
|
1219
1163
|
var isPredicateExpression = (expression) => {
|
|
1220
1164
|
const node = peel(expression);
|
|
1221
|
-
if (
|
|
1222
|
-
if (
|
|
1165
|
+
if (ts3.isTypeOfExpression(node)) return isPredicateAtom(node.expression);
|
|
1166
|
+
if (ts3.isPrefixUnaryExpression(node) && node.operator === ts3.SyntaxKind.ExclamationToken) {
|
|
1223
1167
|
return isPredicateExpression(node.operand) || isPredicateAtom(node.operand);
|
|
1224
1168
|
}
|
|
1225
|
-
if (
|
|
1169
|
+
if (ts3.isBinaryExpression(node)) {
|
|
1226
1170
|
const kind = node.operatorToken.kind;
|
|
1227
|
-
if (kind ===
|
|
1171
|
+
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
1172
|
const side = (value) => isPredicateExpression(value) || isPredicateAtom(value);
|
|
1229
1173
|
return side(node.left) && side(node.right);
|
|
1230
1174
|
}
|
|
1231
1175
|
return false;
|
|
1232
1176
|
}
|
|
1233
|
-
if (
|
|
1177
|
+
if (ts3.isCallExpression(node)) {
|
|
1234
1178
|
return isAllowedTypeCall(node.expression) && node.arguments.every(
|
|
1235
1179
|
(argument) => isPredicateExpression(argument) || isPredicateAtom(argument)
|
|
1236
1180
|
);
|
|
@@ -1241,15 +1185,15 @@ var bodyHasDisallowedControl = (body) => {
|
|
|
1241
1185
|
let found2 = false;
|
|
1242
1186
|
const visit = (node) => {
|
|
1243
1187
|
if (found2) return;
|
|
1244
|
-
if (
|
|
1188
|
+
if (ts3.isAwaitExpression(node) || ts3.isYieldExpression(node) || ts3.isThrowStatement(node) || ts3.isTryStatement(node) || ts3.isNewExpression(node)) {
|
|
1245
1189
|
found2 = true;
|
|
1246
1190
|
return;
|
|
1247
1191
|
}
|
|
1248
|
-
if (
|
|
1192
|
+
if (ts3.isBinaryExpression(node) && node.operatorToken.kind === ts3.SyntaxKind.EqualsToken) {
|
|
1249
1193
|
found2 = true;
|
|
1250
1194
|
return;
|
|
1251
1195
|
}
|
|
1252
|
-
|
|
1196
|
+
ts3.forEachChild(node, visit);
|
|
1253
1197
|
};
|
|
1254
1198
|
visit(body);
|
|
1255
1199
|
return found2;
|
|
@@ -1258,7 +1202,7 @@ var isObjectEntriesWrapper = (body) => {
|
|
|
1258
1202
|
const returned = singleReturnedExpression(body);
|
|
1259
1203
|
if (!returned) return false;
|
|
1260
1204
|
let current = peel(returned);
|
|
1261
|
-
while (
|
|
1205
|
+
while (ts3.isCallExpression(current) && ts3.isPropertyAccessExpression(current.expression)) {
|
|
1262
1206
|
const method = current.expression.name.getText();
|
|
1263
1207
|
if (method === "filter" || method === "map" || method === "flatMap") {
|
|
1264
1208
|
current = peel(current.expression.expression);
|
|
@@ -1266,116 +1210,50 @@ var isObjectEntriesWrapper = (body) => {
|
|
|
1266
1210
|
}
|
|
1267
1211
|
break;
|
|
1268
1212
|
}
|
|
1269
|
-
if (!
|
|
1213
|
+
if (!ts3.isCallExpression(current) || !ts3.isPropertyAccessExpression(current.expression)) {
|
|
1270
1214
|
return false;
|
|
1271
1215
|
}
|
|
1272
|
-
return
|
|
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);
|
|
1216
|
+
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
1217
|
};
|
|
1308
1218
|
var isSimpleReadBody = (body) => {
|
|
1309
1219
|
const returned = singleReturnedExpression(body);
|
|
1310
1220
|
if (!returned || bodyHasDisallowedControl(body)) return false;
|
|
1311
1221
|
const value = peel(returned);
|
|
1312
|
-
if (
|
|
1313
|
-
if (
|
|
1314
|
-
if (!
|
|
1222
|
+
if (ts3.isIdentifier(value)) return true;
|
|
1223
|
+
if (ts3.isPropertyAccessExpression(value) && isPredicateAtom(value)) return true;
|
|
1224
|
+
if (!ts3.isCallExpression(value) || value.arguments.length !== 1) return false;
|
|
1315
1225
|
const argument = value.arguments[0];
|
|
1316
1226
|
if (!argument) return false;
|
|
1317
|
-
if (!
|
|
1227
|
+
if (!ts3.isPropertyAccessExpression(value.expression) || !ts3.isIdentifier(value.expression.expression)) {
|
|
1318
1228
|
return false;
|
|
1319
1229
|
}
|
|
1320
|
-
return value.expression.expression.text === "$" &&
|
|
1230
|
+
return value.expression.expression.text === "$" && ts3.isIdentifier(value.expression.name) && value.expression.name.text === "get" && ts3.isIdentifier(peel(argument));
|
|
1321
1231
|
};
|
|
1322
|
-
var classifyBody = (node, name, sourceFile, filePath) => {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
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" };
|
|
1232
|
+
var classifyBody = (node, name, sourceFile, filePath, policy) => {
|
|
1233
|
+
const returned = singleReturnedExpression(node.body);
|
|
1234
|
+
const body = {
|
|
1235
|
+
isLiteralOnly: isLiteralOnlyBody(node.body),
|
|
1236
|
+
isIdentity: isIdentityFunction(node),
|
|
1237
|
+
isSimpleRead: isSimpleReadBody(node.body),
|
|
1238
|
+
isPredicate: Boolean(
|
|
1239
|
+
returned && isPredicateExpression(returned) && !bodyHasDisallowedControl(node.body)
|
|
1240
|
+
)
|
|
1241
|
+
};
|
|
1242
|
+
const decided = policy?.classifyFunction({ node, sourceFile, filePath, name, body });
|
|
1243
|
+
if (decided) {
|
|
1244
|
+
return {
|
|
1245
|
+
captureClass: decided.captureClass,
|
|
1246
|
+
captureReason: decided.captureReason,
|
|
1247
|
+
inferredName: decided.inferredName,
|
|
1248
|
+
reactiveKind: decided.reactiveKind,
|
|
1249
|
+
compilerRole: decided.role,
|
|
1250
|
+
useSyntheticLocation: decided.useSyntheticLocation
|
|
1251
|
+
};
|
|
1373
1252
|
}
|
|
1374
1253
|
if (isIdentityFunction(node)) {
|
|
1375
1254
|
return { captureClass: "structure", captureReason: "identity wrapper" };
|
|
1376
1255
|
}
|
|
1377
|
-
|
|
1378
|
-
if (returned && isPredicateExpression(returned) && !bodyHasDisallowedControl(node.body)) {
|
|
1256
|
+
if (body.isPredicate) {
|
|
1379
1257
|
return { captureClass: "structure", captureReason: "tiny predicate" };
|
|
1380
1258
|
}
|
|
1381
1259
|
if (isObjectEntriesWrapper(node.body) && !bodyHasDisallowedControl(node.body)) {
|
|
@@ -1386,29 +1264,24 @@ var classifyBody = (node, name, sourceFile, filePath) => {
|
|
|
1386
1264
|
}
|
|
1387
1265
|
return { captureClass: "full", captureReason: "application function" };
|
|
1388
1266
|
};
|
|
1389
|
-
var classifyFunctions = (source, filePath, mapLocation) => {
|
|
1267
|
+
var classifyFunctions = (source, filePath, mapLocation, policy) => {
|
|
1390
1268
|
const sourceFile = parseSource(source, filePath);
|
|
1391
1269
|
const absolutePath = resolve3(filePath);
|
|
1392
1270
|
const classifications = [];
|
|
1393
1271
|
const visit = (node) => {
|
|
1394
1272
|
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
1273
|
const rawName = functionName(node, sourceFile).replace(/@\d+:\d+$/, "");
|
|
1411
|
-
const classified = classifyBody(node, rawName, sourceFile, filePath);
|
|
1274
|
+
const classified = classifyBody(node, rawName, sourceFile, filePath, policy);
|
|
1275
|
+
const location = classified.useSyntheticLocation ? { filePath: absolutePath, line: 1, column: 1 } : mappedLocation(
|
|
1276
|
+
sourceFile,
|
|
1277
|
+
functionLocationPosition(node, sourceFile),
|
|
1278
|
+
absolutePath,
|
|
1279
|
+
mapLocation
|
|
1280
|
+
);
|
|
1281
|
+
if (!location) {
|
|
1282
|
+
ts3.forEachChild(node, visit);
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1412
1285
|
const name = classified.inferredName ?? rawName;
|
|
1413
1286
|
const plan = encodeFunctionPlan({
|
|
1414
1287
|
filePath: location.filePath,
|
|
@@ -1428,23 +1301,14 @@ var classifyFunctions = (source, filePath, mapLocation) => {
|
|
|
1428
1301
|
end: node.end,
|
|
1429
1302
|
bodyStart: node.body.getStart(sourceFile),
|
|
1430
1303
|
bodyEnd: node.body.end,
|
|
1431
|
-
...classified.reactiveKind ? { reactiveKind: classified.reactiveKind } : {}
|
|
1304
|
+
...classified.reactiveKind ? { reactiveKind: classified.reactiveKind } : {},
|
|
1305
|
+
...classified.compilerRole ? { compilerRole: classified.compilerRole } : {}
|
|
1432
1306
|
});
|
|
1433
1307
|
}
|
|
1434
|
-
|
|
1308
|
+
ts3.forEachChild(node, visit);
|
|
1435
1309
|
};
|
|
1436
1310
|
visit(sourceFile);
|
|
1437
|
-
|
|
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
|
-
}
|
|
1311
|
+
policy?.finalizeClassifications?.(classifications);
|
|
1448
1312
|
return classifications;
|
|
1449
1313
|
};
|
|
1450
1314
|
|
|
@@ -1495,7 +1359,7 @@ var applyEdits = (source, edits) => {
|
|
|
1495
1359
|
};
|
|
1496
1360
|
var textOf = (edit) => edit.text;
|
|
1497
1361
|
|
|
1498
|
-
//
|
|
1362
|
+
// ../../node_modules/.bun/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
|
|
1499
1363
|
var SetArray = class {
|
|
1500
1364
|
constructor() {
|
|
1501
1365
|
this._indexes = { __proto__: null };
|
|
@@ -1775,11 +1639,11 @@ var exactTransformMap = (original, generated, file, edits) => {
|
|
|
1775
1639
|
import { basename as basename2 } from "node:path";
|
|
1776
1640
|
|
|
1777
1641
|
// ../instrumentation/src/browser-function-edits.ts
|
|
1778
|
-
import
|
|
1642
|
+
import ts9 from "typescript";
|
|
1779
1643
|
|
|
1780
1644
|
// ../instrumentation/src/suspension-whitelist.ts
|
|
1781
|
-
import
|
|
1782
|
-
var nodeFlags =
|
|
1645
|
+
import ts4 from "typescript";
|
|
1646
|
+
var nodeFlags = ts4.NodeFlags;
|
|
1783
1647
|
var AWAIT_USING_FLAG = nodeFlags.AwaitUsing ?? 0;
|
|
1784
1648
|
var USING_FLAG = nodeFlags.Using ?? 0;
|
|
1785
1649
|
var KNOWN_SUSPENSION_KIND_NAMES = [
|
|
@@ -1789,25 +1653,25 @@ var KNOWN_SUSPENSION_KIND_NAMES = [
|
|
|
1789
1653
|
"YieldKeyword",
|
|
1790
1654
|
"UsingKeyword"
|
|
1791
1655
|
];
|
|
1792
|
-
var
|
|
1793
|
-
var isAsyncFunctionLike = (node) => (
|
|
1794
|
-
var isAsyncGeneratorLike = (node) =>
|
|
1656
|
+
var isFunctionLike = (node) => ts4.isFunctionLike(node);
|
|
1657
|
+
var isAsyncFunctionLike = (node) => (ts4.getCombinedModifierFlags(node) & ts4.ModifierFlags.Async) !== 0;
|
|
1658
|
+
var isAsyncGeneratorLike = (node) => isFunctionLike(node) && isAsyncFunctionLike(node) && "asteriskToken" in node && Boolean(node.asteriskToken);
|
|
1795
1659
|
var visitOwnBody = (node, visitNode) => {
|
|
1796
1660
|
if (!node.body) return;
|
|
1797
1661
|
const visit = (candidate) => {
|
|
1798
|
-
if (candidate !== node &&
|
|
1662
|
+
if (candidate !== node && isFunctionLike(candidate)) {
|
|
1799
1663
|
visitNode(candidate);
|
|
1800
1664
|
return;
|
|
1801
1665
|
}
|
|
1802
1666
|
if (visitNode(candidate)) return;
|
|
1803
|
-
|
|
1667
|
+
ts4.forEachChild(candidate, visit);
|
|
1804
1668
|
};
|
|
1805
1669
|
visit(node.body);
|
|
1806
1670
|
};
|
|
1807
1671
|
var nestedFunctionSpans = (node, sourceFile) => {
|
|
1808
1672
|
const spans = [];
|
|
1809
1673
|
visitOwnBody(node, (candidate) => {
|
|
1810
|
-
if (candidate !== node &&
|
|
1674
|
+
if (candidate !== node && isFunctionLike(candidate)) {
|
|
1811
1675
|
spans.push([candidate.getStart(sourceFile), candidate.end]);
|
|
1812
1676
|
}
|
|
1813
1677
|
return void 0;
|
|
@@ -1828,16 +1692,16 @@ var slicesOutside = (start, end, spans) => {
|
|
|
1828
1692
|
};
|
|
1829
1693
|
var sliceHasAwaitKeyword = (source, start, end) => {
|
|
1830
1694
|
if (end <= start) return false;
|
|
1831
|
-
const scanner =
|
|
1832
|
-
|
|
1695
|
+
const scanner = ts4.createScanner(
|
|
1696
|
+
ts4.ScriptTarget.Latest,
|
|
1833
1697
|
true,
|
|
1834
|
-
|
|
1698
|
+
ts4.LanguageVariant.Standard,
|
|
1835
1699
|
source.slice(start, end)
|
|
1836
1700
|
);
|
|
1837
1701
|
while (true) {
|
|
1838
1702
|
const token = scanner.scan();
|
|
1839
|
-
if (token ===
|
|
1840
|
-
if (token ===
|
|
1703
|
+
if (token === ts4.SyntaxKind.EndOfFileToken) return false;
|
|
1704
|
+
if (token === ts4.SyntaxKind.AwaitKeyword) return true;
|
|
1841
1705
|
}
|
|
1842
1706
|
};
|
|
1843
1707
|
var ownBodyHasAwaitKeyword = (node, sourceFile) => {
|
|
@@ -1855,7 +1719,7 @@ var isAwaitUsingList = (node) => {
|
|
|
1855
1719
|
return (node.flags & AWAIT_USING_FLAG) === AWAIT_USING_FLAG && (node.flags & USING_FLAG) !== 0;
|
|
1856
1720
|
};
|
|
1857
1721
|
var unknownSuspensionKind = (node) => {
|
|
1858
|
-
const name =
|
|
1722
|
+
const name = ts4.SyntaxKind[node.kind];
|
|
1859
1723
|
if (typeof name !== "string" || !/Await|Yield|Using/.test(name)) return false;
|
|
1860
1724
|
return !KNOWN_SUSPENSION_KIND_NAMES.includes(name);
|
|
1861
1725
|
};
|
|
@@ -1868,9 +1732,9 @@ var ownSuspensionFacts = (node, sourceFile) => {
|
|
|
1868
1732
|
awaitKeyword: ownBodyHasAwaitKeyword(node, sourceFile)
|
|
1869
1733
|
};
|
|
1870
1734
|
visitOwnBody(node, (candidate) => {
|
|
1871
|
-
if (
|
|
1872
|
-
if (
|
|
1873
|
-
if (
|
|
1735
|
+
if (ts4.isAwaitExpression(candidate)) facts.awaitExpressions = true;
|
|
1736
|
+
if (ts4.isForOfStatement(candidate) && candidate.awaitModifier) facts.forAwait = true;
|
|
1737
|
+
if (ts4.isVariableDeclarationList(candidate) && isAwaitUsingList(candidate)) {
|
|
1874
1738
|
facts.awaitUsing = true;
|
|
1875
1739
|
}
|
|
1876
1740
|
if (unknownSuspensionKind(candidate)) facts.unknown = true;
|
|
@@ -1881,7 +1745,7 @@ var ownSuspensionFacts = (node, sourceFile) => {
|
|
|
1881
1745
|
var bodyHasDirectEval = (node) => {
|
|
1882
1746
|
let found2 = false;
|
|
1883
1747
|
visitOwnBody(node, (candidate) => {
|
|
1884
|
-
if (
|
|
1748
|
+
if (ts4.isCallExpression(candidate) && ts4.isIdentifier(candidate.expression) && candidate.expression.text === "eval") {
|
|
1885
1749
|
found2 = true;
|
|
1886
1750
|
}
|
|
1887
1751
|
return found2;
|
|
@@ -1904,23 +1768,23 @@ var decideAsyncInstrumentation = (node, sourceFile) => {
|
|
|
1904
1768
|
};
|
|
1905
1769
|
|
|
1906
1770
|
// ../instrumentation/src/transform-source.ts
|
|
1907
|
-
import
|
|
1771
|
+
import ts8 from "typescript";
|
|
1908
1772
|
|
|
1909
1773
|
// ../instrumentation/src/parameter-initializer-may-run-code.ts
|
|
1910
|
-
import
|
|
1774
|
+
import ts5 from "typescript";
|
|
1911
1775
|
|
|
1912
1776
|
// ../instrumentation/src/verify-instrumentation-isomorphism.ts
|
|
1913
|
-
import
|
|
1777
|
+
import ts6 from "typescript";
|
|
1914
1778
|
|
|
1915
1779
|
// ../instrumentation/src/verify-transformed-source.ts
|
|
1916
|
-
import
|
|
1917
|
-
var transpileForVerification = (filePath, code) =>
|
|
1780
|
+
import ts7 from "typescript";
|
|
1781
|
+
var transpileForVerification = (filePath, code) => ts7.transpileModule(code, {
|
|
1918
1782
|
compilerOptions: {
|
|
1919
1783
|
// ES2020 downlevel keeps native @decorators out of `new Function`.
|
|
1920
|
-
target:
|
|
1921
|
-
module:
|
|
1784
|
+
target: ts7.ScriptTarget.ES2020,
|
|
1785
|
+
module: ts7.ModuleKind.ESNext,
|
|
1922
1786
|
allowJs: true,
|
|
1923
|
-
jsx:
|
|
1787
|
+
jsx: ts7.JsxEmit.React,
|
|
1924
1788
|
experimentalDecorators: true
|
|
1925
1789
|
},
|
|
1926
1790
|
reportDiagnostics: true,
|
|
@@ -1928,7 +1792,7 @@ var transpileForVerification = (filePath, code) => ts8.transpileModule(code, {
|
|
|
1928
1792
|
});
|
|
1929
1793
|
var hasScanOrParseError = (diagnostics) => Boolean(
|
|
1930
1794
|
diagnostics?.some(
|
|
1931
|
-
(diagnostic) => diagnostic.category ===
|
|
1795
|
+
(diagnostic) => diagnostic.category === ts7.DiagnosticCategory.Error && diagnostic.code < 2e3
|
|
1932
1796
|
)
|
|
1933
1797
|
);
|
|
1934
1798
|
var scriptBodyForEngine = (emitted) => (
|
|
@@ -1937,39 +1801,39 @@ var scriptBodyForEngine = (emitted) => (
|
|
|
1937
1801
|
);
|
|
1938
1802
|
var looksTyped = (filePath) => /\.[cm]?tsx?$/i.test(filePath);
|
|
1939
1803
|
var scriptKindFor2 = (filePath) => {
|
|
1940
|
-
if (/\.tsx$/i.test(filePath)) return
|
|
1941
|
-
if (/\.jsx$/i.test(filePath)) return
|
|
1942
|
-
if (/\.[cm]?ts$/i.test(filePath)) return
|
|
1943
|
-
return
|
|
1804
|
+
if (/\.tsx$/i.test(filePath)) return ts7.ScriptKind.TSX;
|
|
1805
|
+
if (/\.jsx$/i.test(filePath)) return ts7.ScriptKind.JSX;
|
|
1806
|
+
if (/\.[cm]?ts$/i.test(filePath)) return ts7.ScriptKind.TS;
|
|
1807
|
+
return ts7.ScriptKind.JS;
|
|
1944
1808
|
};
|
|
1945
|
-
var isIterationStatement = (node) =>
|
|
1809
|
+
var isIterationStatement = (node) => ts7.isForStatement(node) || ts7.isForOfStatement(node) || ts7.isForInStatement(node) || ts7.isWhileStatement(node) || ts7.isDoStatement(node);
|
|
1946
1810
|
var unwrapLabeled = (node) => {
|
|
1947
1811
|
let current = node;
|
|
1948
|
-
while (
|
|
1812
|
+
while (ts7.isLabeledStatement(current)) current = current.statement;
|
|
1949
1813
|
return current;
|
|
1950
1814
|
};
|
|
1951
1815
|
var hasInvalidLabelJump = (sourceFile) => {
|
|
1952
1816
|
const visit = (node, labels) => {
|
|
1953
|
-
if (
|
|
1817
|
+
if (ts7.isFunctionLike(node)) {
|
|
1954
1818
|
let nestedInvalid = false;
|
|
1955
|
-
|
|
1819
|
+
ts7.forEachChild(node, (child) => {
|
|
1956
1820
|
if (visit(child, /* @__PURE__ */ new Map())) nestedInvalid = true;
|
|
1957
1821
|
});
|
|
1958
1822
|
return nestedInvalid;
|
|
1959
1823
|
}
|
|
1960
|
-
if (
|
|
1824
|
+
if (ts7.isLabeledStatement(node)) {
|
|
1961
1825
|
const next = new Map(labels);
|
|
1962
1826
|
next.set(node.label.text, isIterationStatement(unwrapLabeled(node.statement)));
|
|
1963
1827
|
return visit(node.statement, next);
|
|
1964
1828
|
}
|
|
1965
|
-
if (
|
|
1829
|
+
if (ts7.isContinueStatement(node) && node.label) {
|
|
1966
1830
|
if (labels.get(node.label.text) !== true) return true;
|
|
1967
1831
|
}
|
|
1968
|
-
if (
|
|
1832
|
+
if (ts7.isBreakStatement(node) && node.label && !labels.has(node.label.text)) {
|
|
1969
1833
|
return true;
|
|
1970
1834
|
}
|
|
1971
1835
|
let invalid = false;
|
|
1972
|
-
|
|
1836
|
+
ts7.forEachChild(node, (child) => {
|
|
1973
1837
|
if (visit(child, labels)) invalid = true;
|
|
1974
1838
|
});
|
|
1975
1839
|
return invalid;
|
|
@@ -2012,10 +1876,10 @@ var UNTERMINATED_BARE_LEAVE = /\breturn\s+__rasputin\w*\.leave\(\)(?!\s*;|\()/;
|
|
|
2012
1876
|
var transformedSourceIsInvalid = (filePath, code) => {
|
|
2013
1877
|
if (GLUED_INSTRUMENTATION.test(code)) return true;
|
|
2014
1878
|
if (UNTERMINATED_BARE_LEAVE.test(code)) return true;
|
|
2015
|
-
const sourceFile =
|
|
1879
|
+
const sourceFile = ts7.createSourceFile(
|
|
2016
1880
|
filePath,
|
|
2017
1881
|
code,
|
|
2018
|
-
|
|
1882
|
+
ts7.ScriptTarget.Latest,
|
|
2019
1883
|
true,
|
|
2020
1884
|
scriptKindFor2(filePath)
|
|
2021
1885
|
);
|
|
@@ -2041,8 +1905,8 @@ var REACTIVE_REG = "__rasputinReg";
|
|
|
2041
1905
|
var OBSERVE_GUARD = "globalThis.__rasputinO??=function(i,v){return v};";
|
|
2042
1906
|
var STRUCT_GUARD = "globalThis.__rasputinK??=function(o){return o};";
|
|
2043
1907
|
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) => (
|
|
2045
|
-
var isDirectivePrologue = (statement) =>
|
|
1908
|
+
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;
|
|
1909
|
+
var isDirectivePrologue = (statement) => ts9.isExpressionStatement(statement) && ts9.isStringLiteral(statement.expression);
|
|
2046
1910
|
var insertPositionAfterPrologue = (source, sourceFile) => {
|
|
2047
1911
|
const shebangEnd = source.startsWith("#!") ? source.indexOf("\n") + 1 : 0;
|
|
2048
1912
|
let end = shebangEnd;
|
|
@@ -2069,7 +1933,7 @@ var insertAfterSuperOrPrologue = (body, sourceFile) => {
|
|
|
2069
1933
|
const end = functionBodyPrologueEnd(body, sourceFile);
|
|
2070
1934
|
for (const statement of body.statements) {
|
|
2071
1935
|
if (isDirectivePrologue(statement)) continue;
|
|
2072
|
-
if (
|
|
1936
|
+
if (ts9.isExpressionStatement(statement) && ts9.isCallExpression(statement.expression) && statement.expression.expression.kind === ts9.SyntaxKind.SuperKeyword) {
|
|
2073
1937
|
return statement.end;
|
|
2074
1938
|
}
|
|
2075
1939
|
break;
|
|
@@ -2077,14 +1941,14 @@ var insertAfterSuperOrPrologue = (body, sourceFile) => {
|
|
|
2077
1941
|
return end;
|
|
2078
1942
|
};
|
|
2079
1943
|
var functionRef = (node) => {
|
|
2080
|
-
if (node.name &&
|
|
2081
|
-
if (
|
|
1944
|
+
if (node.name && ts9.isIdentifier(node.name)) {
|
|
1945
|
+
if (ts9.isGetAccessorDeclaration(node) || ts9.isSetAccessorDeclaration(node) || ts9.isMethodDeclaration(node)) {
|
|
2082
1946
|
return void 0;
|
|
2083
1947
|
}
|
|
2084
1948
|
return node.name.text;
|
|
2085
1949
|
}
|
|
2086
1950
|
const parent = node.parent;
|
|
2087
|
-
if (
|
|
1951
|
+
if (ts9.isVariableDeclaration(parent) && ts9.isIdentifier(parent.name) && parent.initializer === node) {
|
|
2088
1952
|
return parent.name.text;
|
|
2089
1953
|
}
|
|
2090
1954
|
return void 0;
|
|
@@ -2097,17 +1961,17 @@ var matchingFunction = (sourceFile, item) => {
|
|
|
2097
1961
|
found2 = node;
|
|
2098
1962
|
return;
|
|
2099
1963
|
}
|
|
2100
|
-
|
|
1964
|
+
ts9.forEachChild(node, visit);
|
|
2101
1965
|
};
|
|
2102
1966
|
visit(sourceFile);
|
|
2103
1967
|
return found2;
|
|
2104
1968
|
};
|
|
2105
|
-
var isStaticPropertyName = (name) =>
|
|
1969
|
+
var isStaticPropertyName = (name) => ts9.isIdentifier(name) || ts9.isStringLiteral(name) || ts9.isNoSubstitutionTemplateLiteral(name) || ts9.isNumericLiteral(name);
|
|
2106
1970
|
var canReconstructBinding = (name) => {
|
|
2107
|
-
if (
|
|
2108
|
-
if (
|
|
1971
|
+
if (ts9.isIdentifier(name)) return true;
|
|
1972
|
+
if (ts9.isArrayBindingPattern(name)) {
|
|
2109
1973
|
return name.elements.every(
|
|
2110
|
-
(element) =>
|
|
1974
|
+
(element) => ts9.isOmittedExpression(element) || canReconstructBinding(element.name)
|
|
2111
1975
|
);
|
|
2112
1976
|
}
|
|
2113
1977
|
return name.elements.every((element) => {
|
|
@@ -2117,16 +1981,16 @@ var canReconstructBinding = (name) => {
|
|
|
2117
1981
|
};
|
|
2118
1982
|
var REDACTED_ARG_EXPR = 'Symbol.for("rasputin.redacted.v1")';
|
|
2119
1983
|
var staticBindingKey = (name) => {
|
|
2120
|
-
if (
|
|
2121
|
-
if (
|
|
2122
|
-
if (
|
|
1984
|
+
if (ts9.isIdentifier(name)) return name.text;
|
|
1985
|
+
if (ts9.isStringLiteral(name) || ts9.isNoSubstitutionTemplateLiteral(name)) return name.text;
|
|
1986
|
+
if (ts9.isNumericLiteral(name)) return name.text;
|
|
2123
1987
|
return void 0;
|
|
2124
1988
|
};
|
|
2125
1989
|
var bindingHasSensitiveName = (name) => {
|
|
2126
|
-
if (
|
|
2127
|
-
if (
|
|
1990
|
+
if (ts9.isIdentifier(name)) return propertyNameIsSensitive(name.text);
|
|
1991
|
+
if (ts9.isArrayBindingPattern(name)) {
|
|
2128
1992
|
return name.elements.some(
|
|
2129
|
-
(element) => !
|
|
1993
|
+
(element) => !ts9.isOmittedExpression(element) && bindingHasSensitiveName(element.name)
|
|
2130
1994
|
);
|
|
2131
1995
|
}
|
|
2132
1996
|
return name.elements.some((element) => {
|
|
@@ -2136,12 +2000,12 @@ var bindingHasSensitiveName = (name) => {
|
|
|
2136
2000
|
});
|
|
2137
2001
|
};
|
|
2138
2002
|
var capturedBinding = (name, sourceFile) => {
|
|
2139
|
-
if (
|
|
2003
|
+
if (ts9.isIdentifier(name)) {
|
|
2140
2004
|
return propertyNameIsSensitive(name.text) ? REDACTED_ARG_EXPR : name.text;
|
|
2141
2005
|
}
|
|
2142
|
-
if (
|
|
2006
|
+
if (ts9.isArrayBindingPattern(name)) {
|
|
2143
2007
|
const values = name.elements.map((element) => {
|
|
2144
|
-
if (
|
|
2008
|
+
if (ts9.isOmittedExpression(element)) return "";
|
|
2145
2009
|
const value = capturedBinding(element.name, sourceFile);
|
|
2146
2010
|
return element.dotDotDotToken ? `...${value}` : value;
|
|
2147
2011
|
});
|
|
@@ -2149,14 +2013,14 @@ var capturedBinding = (name, sourceFile) => {
|
|
|
2149
2013
|
}
|
|
2150
2014
|
const properties = name.elements.map((element) => {
|
|
2151
2015
|
const key = element.propertyName ? staticBindingKey(element.propertyName) : void 0;
|
|
2152
|
-
const sensitive = key !== void 0 && propertyNameIsSensitive(key) ||
|
|
2016
|
+
const sensitive = key !== void 0 && propertyNameIsSensitive(key) || ts9.isIdentifier(element.name) && propertyNameIsSensitive(element.name.text);
|
|
2153
2017
|
if (element.dotDotDotToken) {
|
|
2154
2018
|
return `...${sensitive ? REDACTED_ARG_EXPR : capturedBinding(element.name, sourceFile)}`;
|
|
2155
2019
|
}
|
|
2156
2020
|
if (!element.propertyName) {
|
|
2157
|
-
return sensitive &&
|
|
2021
|
+
return sensitive && ts9.isIdentifier(element.name) ? `${element.name.text}:${REDACTED_ARG_EXPR}` : capturedBinding(element.name, sourceFile);
|
|
2158
2022
|
}
|
|
2159
|
-
const printedKey =
|
|
2023
|
+
const printedKey = ts9.isIdentifier(element.propertyName) ? element.propertyName.text : element.propertyName.getText(sourceFile);
|
|
2160
2024
|
return `${printedKey}:${sensitive ? REDACTED_ARG_EXPR : capturedBinding(element.name, sourceFile)}`;
|
|
2161
2025
|
});
|
|
2162
2026
|
return `{${properties.join(",")}}`;
|
|
@@ -2164,12 +2028,12 @@ var capturedBinding = (name, sourceFile) => {
|
|
|
2164
2028
|
var captureArgs = (node) => {
|
|
2165
2029
|
const sourceFile = node.getSourceFile();
|
|
2166
2030
|
const params = node.parameters.filter(
|
|
2167
|
-
(parameter) => !(
|
|
2031
|
+
(parameter) => !(ts9.isIdentifier(parameter.name) && parameter.name.text === "this")
|
|
2168
2032
|
);
|
|
2169
2033
|
const reconstructable = params.every((parameter) => canReconstructBinding(parameter.name));
|
|
2170
2034
|
const sensitive = params.some((parameter) => bindingHasSensitiveName(parameter.name));
|
|
2171
2035
|
if (!reconstructable) {
|
|
2172
|
-
if (
|
|
2036
|
+
if (ts9.isArrowFunction(node) || sensitive) {
|
|
2173
2037
|
return {
|
|
2174
2038
|
args: `[${Array.from({ length: params.length }, () => "void 0").join(",")}]`,
|
|
2175
2039
|
omitValues: true
|
|
@@ -2177,7 +2041,7 @@ var captureArgs = (node) => {
|
|
|
2177
2041
|
}
|
|
2178
2042
|
return { args: "arguments", omitValues: false };
|
|
2179
2043
|
}
|
|
2180
|
-
if (!
|
|
2044
|
+
if (!ts9.isArrowFunction(node) && !sensitive) {
|
|
2181
2045
|
return { args: "arguments", omitValues: false };
|
|
2182
2046
|
}
|
|
2183
2047
|
const values = params.map((parameter) => {
|
|
@@ -2188,16 +2052,16 @@ var captureArgs = (node) => {
|
|
|
2188
2052
|
};
|
|
2189
2053
|
var walkOwnBody = (node, visitNode) => {
|
|
2190
2054
|
const visit = (candidate) => {
|
|
2191
|
-
if (candidate !== node &&
|
|
2055
|
+
if (candidate !== node && ts9.isFunctionLike(candidate)) return;
|
|
2192
2056
|
visitNode(candidate);
|
|
2193
|
-
|
|
2057
|
+
ts9.forEachChild(candidate, visit);
|
|
2194
2058
|
};
|
|
2195
2059
|
visit(node.body);
|
|
2196
2060
|
};
|
|
2197
2061
|
var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
|
|
2198
|
-
if (!
|
|
2062
|
+
if (!ts9.isBlock(node.body)) return;
|
|
2199
2063
|
walkOwnBody(node, (candidate) => {
|
|
2200
|
-
if (!
|
|
2064
|
+
if (!ts9.isReturnStatement(candidate) || !candidate.expression) return;
|
|
2201
2065
|
wrap(
|
|
2202
2066
|
edits,
|
|
2203
2067
|
candidate.expression.getStart(sourceFile),
|
|
@@ -2210,7 +2074,7 @@ var collectReturnWraps = (node, sourceFile, handleName, edits, depth) => {
|
|
|
2210
2074
|
};
|
|
2211
2075
|
var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
|
|
2212
2076
|
walkOwnBody(node, (candidate) => {
|
|
2213
|
-
if (!
|
|
2077
|
+
if (!ts9.isAwaitExpression(candidate)) return;
|
|
2214
2078
|
wrap(
|
|
2215
2079
|
edits,
|
|
2216
2080
|
candidate.expression.getStart(sourceFile),
|
|
@@ -2231,7 +2095,7 @@ var collectAwaitWraps = (node, sourceFile, handleName, edits, depth) => {
|
|
|
2231
2095
|
};
|
|
2232
2096
|
var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) => {
|
|
2233
2097
|
walkOwnBody(node, (candidate) => {
|
|
2234
|
-
if (!
|
|
2098
|
+
if (!ts9.isTryStatement(candidate)) return;
|
|
2235
2099
|
for (const block of [candidate.catchClause?.block, candidate.finallyBlock]) {
|
|
2236
2100
|
if (!block) continue;
|
|
2237
2101
|
edits.push({
|
|
@@ -2246,9 +2110,9 @@ var collectCatchFinallyResumes = (node, sourceFile, handleName, edits, depth) =>
|
|
|
2246
2110
|
});
|
|
2247
2111
|
};
|
|
2248
2112
|
var collectReactiveReturnWraps = (node, sourceFile, siteId, edits, depth) => {
|
|
2249
|
-
if (!
|
|
2113
|
+
if (!ts9.isBlock(node.body)) return;
|
|
2250
2114
|
walkOwnBody(node, (candidate) => {
|
|
2251
|
-
if (!
|
|
2115
|
+
if (!ts9.isReturnStatement(candidate)) return;
|
|
2252
2116
|
if (!candidate.expression) {
|
|
2253
2117
|
edits.push({
|
|
2254
2118
|
position: candidate.getStart(sourceFile),
|
|
@@ -2295,7 +2159,7 @@ var toManifestFunction = (item, node, sourceFile, asyncFunction, instrumented, m
|
|
|
2295
2159
|
asyncFunction
|
|
2296
2160
|
};
|
|
2297
2161
|
};
|
|
2298
|
-
var collectCallerSites = (sourceFile, classifications, functions, absolutePath, mapLocation) => {
|
|
2162
|
+
var collectCallerSites = (sourceFile, classifications, functions, absolutePath, mapLocation, policy) => {
|
|
2299
2163
|
const bySpan = /* @__PURE__ */ new Map();
|
|
2300
2164
|
const classified = new Map(
|
|
2301
2165
|
classifications.map((item) => [`${item.start}:${item.end}`, item])
|
|
@@ -2308,31 +2172,33 @@ var collectCallerSites = (sourceFile, classifications, functions, absolutePath,
|
|
|
2308
2172
|
const callSites = [];
|
|
2309
2173
|
const destructures = [];
|
|
2310
2174
|
const collectContext = { sourceFile, absolutePath, mapLocation };
|
|
2311
|
-
const svelteFile = isSvelteCompiledPath(absolutePath);
|
|
2312
|
-
const identifierCallees = svelteFile ? svelteGeneratedIdentifierCallees(sourceFile) : void 0;
|
|
2313
2175
|
const visit = (node, caller) => {
|
|
2314
2176
|
if (isWrapTarget(node)) {
|
|
2315
2177
|
const item = classified.get(`${node.getStart(sourceFile)}:${node.end}`);
|
|
2316
2178
|
if (item) {
|
|
2317
2179
|
const fn = bySpan.get(`${item.start}:${item.end}`);
|
|
2318
2180
|
const next = fn && fn.instrumented !== false ? fn : caller;
|
|
2319
|
-
|
|
2181
|
+
ts9.forEachChild(node, (child) => visit(child, next));
|
|
2320
2182
|
return;
|
|
2321
2183
|
}
|
|
2322
2184
|
}
|
|
2323
|
-
if (caller && (
|
|
2324
|
-
if (
|
|
2325
|
-
|
|
2185
|
+
if (caller && (ts9.isCallExpression(node) || ts9.isNewExpression(node))) {
|
|
2186
|
+
if (policy?.isCompilerCall({
|
|
2187
|
+
node,
|
|
2188
|
+
sourceFile,
|
|
2189
|
+
filePath: absolutePath
|
|
2190
|
+
})) {
|
|
2191
|
+
ts9.forEachChild(node, (child) => visit(child, caller));
|
|
2326
2192
|
return;
|
|
2327
2193
|
}
|
|
2328
2194
|
const site = collectCallSite(node, caller, collectContext);
|
|
2329
2195
|
if (site) callSites.push(site);
|
|
2330
2196
|
}
|
|
2331
|
-
if (caller &&
|
|
2197
|
+
if (caller && ts9.isVariableDeclaration(node)) {
|
|
2332
2198
|
const destructure = collectParamDestructure(node, caller, collectContext);
|
|
2333
2199
|
if (destructure) destructures.push(destructure);
|
|
2334
2200
|
}
|
|
2335
|
-
|
|
2201
|
+
ts9.forEachChild(node, (child) => visit(child, caller));
|
|
2336
2202
|
};
|
|
2337
2203
|
visit(sourceFile, void 0);
|
|
2338
2204
|
return { callSites, destructures };
|
|
@@ -2393,7 +2259,7 @@ var collectBrowserFunctionEdits = (source, sourceFile, classifications, moduleIn
|
|
|
2393
2259
|
const leave = `${REACTIVE_LEAVE}(${siteId})`;
|
|
2394
2260
|
const fail = `${REACTIVE_THROW}(${siteId},${errorName})`;
|
|
2395
2261
|
const epilogue2 = `}catch(${errorName}){${fail};throw ${errorName};}finally{${REACTIVE_DONE}()}`;
|
|
2396
|
-
if (
|
|
2262
|
+
if (ts9.isBlock(node.body)) {
|
|
2397
2263
|
wrap(
|
|
2398
2264
|
edits,
|
|
2399
2265
|
node.body.getStart(sourceFile) + 1,
|
|
@@ -2438,7 +2304,7 @@ var collectBrowserFunctionEdits = (source, sourceFile, classifications, moduleIn
|
|
|
2438
2304
|
failArgs,
|
|
2439
2305
|
decision.action === "suspend_resume"
|
|
2440
2306
|
);
|
|
2441
|
-
if (
|
|
2307
|
+
if (ts9.isBlock(node.body)) {
|
|
2442
2308
|
const prologueAt = insertAfterSuperOrPrologue(node.body, sourceFile);
|
|
2443
2309
|
const closeAt = node.body.end - 1;
|
|
2444
2310
|
wrap(edits, prologueAt, closeAt, `;const ${handleName}=${enterCall};try{`, epilogue, 0);
|
|
@@ -2496,7 +2362,8 @@ var collectBrowserFunctionEdits = (source, sourceFile, classifications, moduleIn
|
|
|
2496
2362
|
classifications,
|
|
2497
2363
|
functions,
|
|
2498
2364
|
classifications[0]?.filePath ?? "",
|
|
2499
|
-
options.mapLocation
|
|
2365
|
+
options.mapLocation,
|
|
2366
|
+
options.policy
|
|
2500
2367
|
);
|
|
2501
2368
|
return {
|
|
2502
2369
|
edits,
|
|
@@ -2507,42 +2374,42 @@ var collectBrowserFunctionEdits = (source, sourceFile, classifications, moduleIn
|
|
|
2507
2374
|
};
|
|
2508
2375
|
|
|
2509
2376
|
// ../instrumentation/src/json-producer-sites.ts
|
|
2510
|
-
import
|
|
2377
|
+
import ts10 from "typescript";
|
|
2511
2378
|
var JSON_METHOD_CALLEE = "globalThis.__rasputinM";
|
|
2512
2379
|
var JSON_AWAIT_CALLEE = "globalThis.__rasputinA";
|
|
2513
2380
|
var JSON_ADOPT_CALLEE = "globalThis.__rasputinP";
|
|
2514
2381
|
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
2382
|
var isSimpleReceiver = (expression) => {
|
|
2516
2383
|
const receiver = peel(expression);
|
|
2517
|
-
return
|
|
2384
|
+
return ts10.isIdentifier(receiver) || receiver.kind === ts10.SyntaxKind.ThisKeyword;
|
|
2518
2385
|
};
|
|
2519
|
-
var isSimpleIdentifierCall = (node) => !node.questionDotToken &&
|
|
2386
|
+
var isSimpleIdentifierCall = (node) => !node.questionDotToken && ts10.isIdentifier(node.expression);
|
|
2520
2387
|
var isSimpleMethodCall = (node) => {
|
|
2521
2388
|
if (node.questionDotToken) return false;
|
|
2522
2389
|
const callee = node.expression;
|
|
2523
|
-
return
|
|
2390
|
+
return ts10.isPropertyAccessExpression(callee) && !callee.questionDotToken && ts10.isIdentifier(callee.name) && !ts10.isPrivateIdentifier(callee.name) && isSimpleReceiver(callee.expression);
|
|
2524
2391
|
};
|
|
2525
2392
|
var isSimpleProvenanceCall = (node) => isSimpleIdentifierCall(node) || isSimpleMethodCall(node);
|
|
2526
2393
|
var isJsonParseCall = (node) => {
|
|
2527
2394
|
if (!isSimpleMethodCall(node)) return false;
|
|
2528
2395
|
const callee = node.expression;
|
|
2529
|
-
if (!
|
|
2396
|
+
if (!ts10.isPropertyAccessExpression(callee) || callee.name.text !== "parse") return false;
|
|
2530
2397
|
const object = peel(callee.expression);
|
|
2531
|
-
return
|
|
2398
|
+
return ts10.isIdentifier(object) && object.text === "JSON";
|
|
2532
2399
|
};
|
|
2533
2400
|
var methodName = (node) => {
|
|
2534
2401
|
if (!isSimpleMethodCall(node)) return void 0;
|
|
2535
2402
|
const callee = node.expression;
|
|
2536
|
-
return
|
|
2403
|
+
return ts10.isPropertyAccessExpression(callee) ? callee.name.text : void 0;
|
|
2537
2404
|
};
|
|
2538
2405
|
var containsNestedAwaitOrFunction = (node) => {
|
|
2539
2406
|
let found2 = false;
|
|
2540
2407
|
const visit = (candidate) => {
|
|
2541
|
-
if (candidate !== node && (
|
|
2408
|
+
if (candidate !== node && (ts10.isAwaitExpression(candidate) || ts10.isFunctionLike(candidate))) {
|
|
2542
2409
|
found2 = true;
|
|
2543
2410
|
return;
|
|
2544
2411
|
}
|
|
2545
|
-
if (!found2)
|
|
2412
|
+
if (!found2) ts10.forEachChild(candidate, visit);
|
|
2546
2413
|
};
|
|
2547
2414
|
visit(node);
|
|
2548
2415
|
return found2;
|
|
@@ -2556,45 +2423,24 @@ var isAwaitExpressionOf = (node) => {
|
|
|
2556
2423
|
let current = node;
|
|
2557
2424
|
while (current.parent) {
|
|
2558
2425
|
const parent = current.parent;
|
|
2559
|
-
if (
|
|
2426
|
+
if (ts10.isParenthesizedExpression(parent) || ts10.isNonNullExpression(parent) || ts10.isAsExpression(parent) || ts10.isTypeAssertionExpression(parent) || ts10.isSatisfiesExpression(parent)) {
|
|
2560
2427
|
current = parent;
|
|
2561
2428
|
continue;
|
|
2562
2429
|
}
|
|
2563
|
-
return
|
|
2430
|
+
return ts10.isAwaitExpression(parent) && parent.expression === current;
|
|
2564
2431
|
}
|
|
2565
2432
|
return false;
|
|
2566
2433
|
};
|
|
2567
|
-
var isDirectSuperCall = (node) => node.expression.kind ===
|
|
2568
|
-
var
|
|
2569
|
-
|
|
2570
|
-
|
|
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 === "$";
|
|
2434
|
+
var isDirectSuperCall = (node) => node.expression.kind === ts10.SyntaxKind.SuperKeyword;
|
|
2435
|
+
var isPolicyCompilerCall = (node, filePath, sourceFile, policy) => {
|
|
2436
|
+
if (!policy) return false;
|
|
2437
|
+
return policy.isCompilerCall({ node, sourceFile, filePath });
|
|
2592
2438
|
};
|
|
2593
2439
|
var outerExpression = (node) => {
|
|
2594
2440
|
let current = node;
|
|
2595
2441
|
while (current.parent) {
|
|
2596
2442
|
const parent = current.parent;
|
|
2597
|
-
if ((
|
|
2443
|
+
if ((ts10.isParenthesizedExpression(parent) || ts10.isNonNullExpression(parent) || ts10.isAsExpression(parent) || ts10.isTypeAssertionExpression(parent) || ts10.isSatisfiesExpression(parent)) && parent.expression === current) {
|
|
2598
2444
|
current = parent;
|
|
2599
2445
|
continue;
|
|
2600
2446
|
}
|
|
@@ -2606,9 +2452,9 @@ var isReturnedOrBoundCall = (node) => {
|
|
|
2606
2452
|
const expression = outerExpression(node);
|
|
2607
2453
|
const parent = expression.parent;
|
|
2608
2454
|
if (!parent) return false;
|
|
2609
|
-
if (
|
|
2610
|
-
if (
|
|
2611
|
-
if (
|
|
2455
|
+
if (ts10.isReturnStatement(parent) && parent.expression === expression) return true;
|
|
2456
|
+
if (ts10.isVariableDeclaration(parent) && parent.initializer === expression) return true;
|
|
2457
|
+
if (ts10.isBinaryExpression(parent) && parent.right === expression && parent.operatorToken.kind === ts10.SyntaxKind.EqualsToken) {
|
|
2612
2458
|
return true;
|
|
2613
2459
|
}
|
|
2614
2460
|
return false;
|
|
@@ -2647,30 +2493,32 @@ var callCanCarryProvenance = (node) => {
|
|
|
2647
2493
|
if (name === "json" || name === "parse") return true;
|
|
2648
2494
|
if (name === "call" || name === "apply") return false;
|
|
2649
2495
|
const callee = node.expression;
|
|
2650
|
-
if (
|
|
2651
|
-
if (
|
|
2496
|
+
if (ts10.isIdentifier(callee)) return !NON_PROVENANCE_ROOTS.has(callee.text);
|
|
2497
|
+
if (ts10.isPropertyAccessExpression(callee)) {
|
|
2652
2498
|
const object = peel(callee.expression);
|
|
2653
|
-
if (
|
|
2499
|
+
if (ts10.isIdentifier(object) && NON_PROVENANCE_ROOTS.has(object.text)) {
|
|
2654
2500
|
return object.text === "JSON" && callee.name.text === "parse";
|
|
2655
2501
|
}
|
|
2656
2502
|
}
|
|
2657
2503
|
return true;
|
|
2658
2504
|
};
|
|
2659
|
-
var shouldAdoptCall = (node, filePath) => {
|
|
2660
|
-
if (isAwaitExpressionOf(node) || isDirectSuperCall(node) ||
|
|
2505
|
+
var shouldAdoptCall = (node, filePath, sourceFile, policy) => {
|
|
2506
|
+
if (isAwaitExpressionOf(node) || isDirectSuperCall(node) || isPolicyCompilerCall(node, filePath, sourceFile, policy)) {
|
|
2661
2507
|
return false;
|
|
2662
2508
|
}
|
|
2663
|
-
if (
|
|
2509
|
+
if (ts10.isComputedPropertyName(outerExpression(node).parent)) return false;
|
|
2664
2510
|
if (!isSimpleProvenanceCall(node)) return false;
|
|
2665
2511
|
return isReturnedOrBoundCall(node) && callCanCarryProvenance(node);
|
|
2666
2512
|
};
|
|
2667
|
-
var shouldAdoptAwaitCall = (node, filePath) => {
|
|
2668
|
-
if (
|
|
2513
|
+
var shouldAdoptAwaitCall = (node, filePath, sourceFile, policy) => {
|
|
2514
|
+
if (isPolicyCompilerCall(node, filePath, sourceFile, policy) || !isSimpleProvenanceCall(node)) {
|
|
2515
|
+
return false;
|
|
2516
|
+
}
|
|
2669
2517
|
return callCanCarryProvenance(node);
|
|
2670
2518
|
};
|
|
2671
2519
|
var replaceProducerCall = (node, sourceFile, receiverName) => {
|
|
2672
2520
|
const callee = node.expression;
|
|
2673
|
-
if (!
|
|
2521
|
+
if (!ts10.isPropertyAccessExpression(callee)) return node.getText(sourceFile);
|
|
2674
2522
|
const args = node.arguments.map((argument) => argument.getText(sourceFile));
|
|
2675
2523
|
const extra2 = args.length > 0 ? `,${args.join(",")}` : "";
|
|
2676
2524
|
const receiver = callee.expression.getText(sourceFile);
|
|
@@ -2678,10 +2526,10 @@ var replaceProducerCall = (node, sourceFile, receiverName) => {
|
|
|
2678
2526
|
return `((${receiverName})=>${JSON_METHOD_CALLEE}(${receiverName},${method}${extra2}))(${receiver})`;
|
|
2679
2527
|
};
|
|
2680
2528
|
var hasBlockBody = (node) => {
|
|
2681
|
-
if (!
|
|
2529
|
+
if (!ts10.isFunctionDeclaration(node) && !ts10.isFunctionExpression(node) && !ts10.isArrowFunction(node) && !ts10.isMethodDeclaration(node) && !ts10.isConstructorDeclaration(node) && !ts10.isGetAccessorDeclaration(node) && !ts10.isSetAccessorDeclaration(node)) {
|
|
2682
2530
|
return false;
|
|
2683
2531
|
}
|
|
2684
|
-
return node.body !== void 0 &&
|
|
2532
|
+
return node.body !== void 0 && ts10.isBlock(node.body);
|
|
2685
2533
|
};
|
|
2686
2534
|
var owningFunctionBody = (node) => {
|
|
2687
2535
|
let current = node;
|
|
@@ -2712,7 +2560,7 @@ var adoptCall = (edits, node, sourceFile, receiverName, fnName, slotName, slot =
|
|
|
2712
2560
|
const wrapOpen = (inner) => slot ? `(${slotName}={p:${inner}` : inner;
|
|
2713
2561
|
const wrapClose = (inner) => slot ? `${inner}},${slotName}.p)` : inner;
|
|
2714
2562
|
const callee = node.expression;
|
|
2715
|
-
if (
|
|
2563
|
+
if (ts10.isIdentifier(callee)) {
|
|
2716
2564
|
wrap(
|
|
2717
2565
|
edits,
|
|
2718
2566
|
start,
|
|
@@ -2731,7 +2579,7 @@ var adoptCall = (edits, node, sourceFile, receiverName, fnName, slotName, slot =
|
|
|
2731
2579
|
});
|
|
2732
2580
|
return;
|
|
2733
2581
|
}
|
|
2734
|
-
if (!isSimpleMethodCall(node) || !
|
|
2582
|
+
if (!isSimpleMethodCall(node) || !ts10.isPropertyAccessExpression(callee)) return;
|
|
2735
2583
|
const receiver = callee.expression.getText(sourceFile);
|
|
2736
2584
|
const method = callee.name.text;
|
|
2737
2585
|
const open = callOpenParen(node, sourceFile);
|
|
@@ -2761,8 +2609,10 @@ var adoptCall = (edits, node, sourceFile, receiverName, fnName, slotName, slot =
|
|
|
2761
2609
|
kind: "replace"
|
|
2762
2610
|
});
|
|
2763
2611
|
};
|
|
2764
|
-
var skippedComplexCall = (node, filePath) => {
|
|
2765
|
-
if (
|
|
2612
|
+
var skippedComplexCall = (node, filePath, sourceFile, policy) => {
|
|
2613
|
+
if (isPolicyCompilerCall(node, filePath, sourceFile, policy) || isDirectSuperCall(node)) {
|
|
2614
|
+
return false;
|
|
2615
|
+
}
|
|
2766
2616
|
if (isSimpleProvenanceCall(node)) return false;
|
|
2767
2617
|
if (!callCanCarryProvenance(node)) return false;
|
|
2768
2618
|
return true;
|
|
@@ -2778,7 +2628,7 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
|
|
|
2778
2628
|
let callWraps = 0;
|
|
2779
2629
|
let provenanceSkippedComplexCall = 0;
|
|
2780
2630
|
const visit = (node) => {
|
|
2781
|
-
if (
|
|
2631
|
+
if (ts10.isCallExpression(node) && isSimpleProducerCall(node) && !isAwaitExpressionOf(node)) {
|
|
2782
2632
|
edits.push({
|
|
2783
2633
|
position: node.getStart(sourceFile),
|
|
2784
2634
|
text: replaceProducerCall(node, sourceFile, receiverName),
|
|
@@ -2788,19 +2638,19 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
|
|
|
2788
2638
|
kind: "replace"
|
|
2789
2639
|
});
|
|
2790
2640
|
callWraps += 1;
|
|
2791
|
-
} else if (adoptCalls &&
|
|
2641
|
+
} else if (adoptCalls && ts10.isCallExpression(node) && shouldAdoptCall(node, filePath, sourceFile, options?.policy)) {
|
|
2792
2642
|
adoptCall(edits, node, sourceFile, receiverName, adoptFnName, slotName);
|
|
2793
2643
|
callWraps += 1;
|
|
2794
|
-
} else if (
|
|
2644
|
+
} else if (ts10.isCallExpression(node) && !isAwaitExpressionOf(node) && isReturnedOrBoundCall(node) && skippedComplexCall(node, filePath, sourceFile, options?.policy)) {
|
|
2795
2645
|
provenanceSkippedComplexCall += 1;
|
|
2796
2646
|
}
|
|
2797
|
-
if (
|
|
2647
|
+
if (ts10.isAwaitExpression(node)) {
|
|
2798
2648
|
const inner = peel(node.expression);
|
|
2799
|
-
const producer =
|
|
2800
|
-
const adoptInner = adoptCalls &&
|
|
2801
|
-
const adoptValue = adoptCalls && !
|
|
2649
|
+
const producer = ts10.isCallExpression(inner) && isSimpleProducerCall(inner);
|
|
2650
|
+
const adoptInner = adoptCalls && ts10.isCallExpression(inner) && shouldAdoptAwaitCall(inner, filePath, sourceFile, options?.policy);
|
|
2651
|
+
const adoptValue = adoptCalls && !ts10.isCallExpression(inner);
|
|
2802
2652
|
if (producer || adoptInner || adoptValue) {
|
|
2803
|
-
if (producer &&
|
|
2653
|
+
if (producer && ts10.isCallExpression(inner)) {
|
|
2804
2654
|
edits.push({
|
|
2805
2655
|
position: node.expression.getStart(sourceFile),
|
|
2806
2656
|
text: `(${slotName}={p:${replaceProducerCall(inner, sourceFile, receiverName)}},${slotName}.p)`,
|
|
@@ -2810,7 +2660,7 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
|
|
|
2810
2660
|
kind: "replace"
|
|
2811
2661
|
});
|
|
2812
2662
|
callWraps += 1;
|
|
2813
|
-
} else if (adoptInner &&
|
|
2663
|
+
} else if (adoptInner && ts10.isCallExpression(inner)) {
|
|
2814
2664
|
if (node.expression === inner) {
|
|
2815
2665
|
adoptCall(edits, inner, sourceFile, receiverName, adoptFnName, slotName, true);
|
|
2816
2666
|
} else {
|
|
@@ -2846,11 +2696,11 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
|
|
|
2846
2696
|
awaitWraps += 1;
|
|
2847
2697
|
const body = owningFunctionBody(node);
|
|
2848
2698
|
if (body) bodies.add(body);
|
|
2849
|
-
} else if (
|
|
2699
|
+
} else if (ts10.isCallExpression(inner) && skippedComplexCall(inner, filePath, sourceFile, options?.policy)) {
|
|
2850
2700
|
provenanceSkippedComplexCall += 1;
|
|
2851
2701
|
}
|
|
2852
2702
|
}
|
|
2853
|
-
|
|
2703
|
+
ts10.forEachChild(node, visit);
|
|
2854
2704
|
};
|
|
2855
2705
|
visit(sourceFile);
|
|
2856
2706
|
if (edits.length > 0) {
|
|
@@ -2877,7 +2727,7 @@ var collectJsonProducerEdits = (source, filePath, sourceFile = parseSource(sourc
|
|
|
2877
2727
|
};
|
|
2878
2728
|
|
|
2879
2729
|
// ../instrumentation/src/literal-sites.ts
|
|
2880
|
-
import
|
|
2730
|
+
import ts11 from "typescript";
|
|
2881
2731
|
var STRUCT_CALLEE = "globalThis.__rasputinK";
|
|
2882
2732
|
var owningFunction = (position, classifications) => {
|
|
2883
2733
|
let owner;
|
|
@@ -2897,7 +2747,7 @@ var walkPeelParent = (node) => {
|
|
|
2897
2747
|
let current = node;
|
|
2898
2748
|
while (current.parent) {
|
|
2899
2749
|
const parent = current.parent;
|
|
2900
|
-
if ((
|
|
2750
|
+
if ((ts11.isParenthesizedExpression(parent) || ts11.isNonNullExpression(parent) || ts11.isAsExpression(parent) || ts11.isTypeAssertionExpression(parent) || ts11.isSatisfiesExpression(parent)) && parent.expression === current) {
|
|
2901
2751
|
current = parent;
|
|
2902
2752
|
continue;
|
|
2903
2753
|
}
|
|
@@ -2909,13 +2759,13 @@ var isCapturePosition = (node) => {
|
|
|
2909
2759
|
const current = walkPeelParent(node);
|
|
2910
2760
|
const parent = current.parent;
|
|
2911
2761
|
if (!parent) return false;
|
|
2912
|
-
if (
|
|
2913
|
-
if (
|
|
2914
|
-
if (
|
|
2915
|
-
if (
|
|
2762
|
+
if (ts11.isReturnStatement(parent) && parent.expression === current) return true;
|
|
2763
|
+
if (ts11.isArrowFunction(parent) && parent.body === current) return true;
|
|
2764
|
+
if (ts11.isVariableDeclaration(parent) && parent.initializer === current) return true;
|
|
2765
|
+
if (ts11.isBinaryExpression(parent) && parent.operatorToken.kind === ts11.SyntaxKind.EqualsToken && parent.right === current) {
|
|
2916
2766
|
return true;
|
|
2917
2767
|
}
|
|
2918
|
-
if (
|
|
2768
|
+
if (ts11.isCallExpression(parent) || ts11.isNewExpression(parent)) {
|
|
2919
2769
|
return parent.arguments?.some((argument) => argument === current) === true;
|
|
2920
2770
|
}
|
|
2921
2771
|
return false;
|
|
@@ -2924,13 +2774,13 @@ var isInAssignmentPattern = (node) => {
|
|
|
2924
2774
|
let current = walkPeelParent(node);
|
|
2925
2775
|
while (current.parent) {
|
|
2926
2776
|
const parent = current.parent;
|
|
2927
|
-
if (
|
|
2777
|
+
if (ts11.isBinaryExpression(parent) && parent.operatorToken.kind === ts11.SyntaxKind.EqualsToken && parent.left === current) {
|
|
2928
2778
|
return true;
|
|
2929
2779
|
}
|
|
2930
|
-
if ((
|
|
2780
|
+
if ((ts11.isForOfStatement(parent) || ts11.isForInStatement(parent)) && parent.initializer === current) {
|
|
2931
2781
|
return true;
|
|
2932
2782
|
}
|
|
2933
|
-
if (
|
|
2783
|
+
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
2784
|
current = walkPeelParent(parent);
|
|
2935
2785
|
continue;
|
|
2936
2786
|
}
|
|
@@ -2942,8 +2792,8 @@ var isLiteralChild = (node) => {
|
|
|
2942
2792
|
const current = walkPeelParent(node);
|
|
2943
2793
|
const parent = current.parent;
|
|
2944
2794
|
if (!parent) return false;
|
|
2945
|
-
if (
|
|
2946
|
-
if (
|
|
2795
|
+
if (ts11.isPropertyAssignment(parent) && parent.initializer === current) return true;
|
|
2796
|
+
if (ts11.isArrayLiteralExpression(parent)) return true;
|
|
2947
2797
|
return false;
|
|
2948
2798
|
};
|
|
2949
2799
|
var shouldRewrite = (node, classifications, sourceFile) => {
|
|
@@ -2955,10 +2805,10 @@ var shouldRewrite = (node, classifications, sourceFile) => {
|
|
|
2955
2805
|
var collectLiteralSiteEdits = (source, filePath, options, sourceFile = parseSource(source, filePath)) => {
|
|
2956
2806
|
const edits = [];
|
|
2957
2807
|
const visit = (node) => {
|
|
2958
|
-
if ((
|
|
2808
|
+
if ((ts11.isObjectLiteralExpression(node) || ts11.isArrayLiteralExpression(node)) && shouldRewrite(node, options.classifications, sourceFile)) {
|
|
2959
2809
|
wrap(edits, node.getStart(sourceFile), node.end, `${STRUCT_CALLEE}(`, ")", 15);
|
|
2960
2810
|
}
|
|
2961
|
-
|
|
2811
|
+
ts11.forEachChild(node, visit);
|
|
2962
2812
|
};
|
|
2963
2813
|
visit(sourceFile);
|
|
2964
2814
|
return { edits };
|
|
@@ -2967,64 +2817,64 @@ var collectLiteralSiteEdits = (source, filePath, options, sourceFile = parseSour
|
|
|
2967
2817
|
// ../instrumentation/src/observe-sites.ts
|
|
2968
2818
|
import { createHash as createHash2 } from "node:crypto";
|
|
2969
2819
|
import { resolve as resolve4 } from "node:path";
|
|
2970
|
-
import
|
|
2820
|
+
import ts12 from "typescript";
|
|
2971
2821
|
var OBSERVE_CALLEE = "globalThis.__rasputinO";
|
|
2972
2822
|
var siteIdFor = (filePath, line, column, text) => {
|
|
2973
2823
|
const digest = createHash2("sha256").update(`${resolve4(filePath)}:${line}:${column}:${text}`).digest("base64url").slice(0, 16);
|
|
2974
2824
|
return `rs_${digest}`;
|
|
2975
2825
|
};
|
|
2976
|
-
var isAssignmentOperator = (kind) => kind ===
|
|
2826
|
+
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
2827
|
var isSafeLiteral = (expression) => {
|
|
2978
2828
|
const node = peel(expression);
|
|
2979
|
-
if (
|
|
2980
|
-
if (
|
|
2981
|
-
if (node.kind ===
|
|
2829
|
+
if (ts12.isStringLiteral(node) || ts12.isNoSubstitutionTemplateLiteral(node)) return true;
|
|
2830
|
+
if (ts12.isNumericLiteral(node)) return true;
|
|
2831
|
+
if (node.kind === ts12.SyntaxKind.TrueKeyword || node.kind === ts12.SyntaxKind.FalseKeyword || node.kind === ts12.SyntaxKind.NullKeyword) {
|
|
2982
2832
|
return true;
|
|
2983
2833
|
}
|
|
2984
|
-
if (
|
|
2985
|
-
if (
|
|
2834
|
+
if (ts12.isIdentifier(node) && (node.text === "undefined" || node.text === "NaN")) return true;
|
|
2835
|
+
if (ts12.isPrefixUnaryExpression(node) && node.operator === ts12.SyntaxKind.MinusToken && ts12.isNumericLiteral(node.operand)) {
|
|
2986
2836
|
return true;
|
|
2987
2837
|
}
|
|
2988
|
-
return
|
|
2838
|
+
return ts12.isVoidExpression(node) && ts12.isNumericLiteral(peel(node.expression)) && peel(node.expression).getText() === "0";
|
|
2989
2839
|
};
|
|
2990
2840
|
var isPropertyRead = (node) => {
|
|
2991
|
-
if (
|
|
2992
|
-
return !
|
|
2841
|
+
if (ts12.isPropertyAccessExpression(node)) {
|
|
2842
|
+
return !ts12.isPrivateIdentifier(node.name) && node.expression.kind !== ts12.SyntaxKind.SuperKeyword;
|
|
2993
2843
|
}
|
|
2994
|
-
if (
|
|
2995
|
-
return node.expression.kind !==
|
|
2844
|
+
if (ts12.isElementAccessExpression(node)) {
|
|
2845
|
+
return node.expression.kind !== ts12.SyntaxKind.SuperKeyword;
|
|
2996
2846
|
}
|
|
2997
2847
|
return false;
|
|
2998
2848
|
};
|
|
2999
2849
|
var isMetaChain = (node) => {
|
|
3000
|
-
if (
|
|
3001
|
-
if (
|
|
3002
|
-
if (
|
|
2850
|
+
if (ts12.isMetaProperty(node)) return true;
|
|
2851
|
+
if (ts12.isPropertyAccessExpression(node)) return isMetaChain(node.expression);
|
|
2852
|
+
if (ts12.isElementAccessExpression(node)) return isMetaChain(node.expression);
|
|
3003
2853
|
return false;
|
|
3004
2854
|
};
|
|
3005
2855
|
var isPatternParent = (parent, child) => {
|
|
3006
|
-
if (
|
|
3007
|
-
if (
|
|
3008
|
-
if (
|
|
3009
|
-
if (
|
|
3010
|
-
if (
|
|
3011
|
-
if (
|
|
3012
|
-
if (
|
|
3013
|
-
if (
|
|
3014
|
-
if (
|
|
3015
|
-
if (
|
|
3016
|
-
if (
|
|
2856
|
+
if (ts12.isParenthesizedExpression(parent) && parent.expression === child) return true;
|
|
2857
|
+
if (ts12.isAsExpression(parent) && parent.expression === child) return true;
|
|
2858
|
+
if (ts12.isTypeAssertionExpression(parent) && parent.expression === child) return true;
|
|
2859
|
+
if (ts12.isNonNullExpression(parent) && parent.expression === child) return true;
|
|
2860
|
+
if (ts12.isSatisfiesExpression(parent) && parent.expression === child) return true;
|
|
2861
|
+
if (ts12.isPropertyAssignment(parent) && parent.initializer === child) return true;
|
|
2862
|
+
if (ts12.isShorthandPropertyAssignment(parent)) return true;
|
|
2863
|
+
if (ts12.isSpreadAssignment(parent) && parent.expression === child) return true;
|
|
2864
|
+
if (ts12.isSpreadElement(parent) && parent.expression === child) return true;
|
|
2865
|
+
if (ts12.isArrayLiteralExpression(parent)) return true;
|
|
2866
|
+
if (ts12.isObjectLiteralExpression(parent)) return true;
|
|
3017
2867
|
return false;
|
|
3018
2868
|
};
|
|
3019
2869
|
var isAssignmentTarget = (node) => {
|
|
3020
2870
|
let current = node;
|
|
3021
2871
|
while (current.parent) {
|
|
3022
2872
|
const parent = current.parent;
|
|
3023
|
-
if (
|
|
3024
|
-
if (
|
|
2873
|
+
if (ts12.isComputedPropertyName(parent) && parent.expression === current) return false;
|
|
2874
|
+
if (ts12.isBinaryExpression(parent) && isAssignmentOperator(parent.operatorToken.kind)) {
|
|
3025
2875
|
return parent.left === current;
|
|
3026
2876
|
}
|
|
3027
|
-
if ((
|
|
2877
|
+
if ((ts12.isForOfStatement(parent) || ts12.isForInStatement(parent)) && parent.initializer === current) {
|
|
3028
2878
|
return true;
|
|
3029
2879
|
}
|
|
3030
2880
|
if (!isPatternParent(parent, current)) return false;
|
|
@@ -3036,18 +2886,18 @@ var isValueContext = (node) => {
|
|
|
3036
2886
|
if (isAssignmentTarget(node)) return false;
|
|
3037
2887
|
const parent = node.parent;
|
|
3038
2888
|
if (!parent) return false;
|
|
3039
|
-
if (
|
|
3040
|
-
if (
|
|
3041
|
-
if (
|
|
3042
|
-
if (
|
|
2889
|
+
if (ts12.isVariableDeclaration(parent) && parent.initializer === node) return true;
|
|
2890
|
+
if (ts12.isReturnStatement(parent) && parent.expression === node) return true;
|
|
2891
|
+
if (ts12.isPropertyAssignment(parent) && parent.initializer === node) return true;
|
|
2892
|
+
if (ts12.isParenthesizedExpression(parent) || ts12.isNonNullExpression(parent) || ts12.isAsExpression(parent) || ts12.isTypeAssertionExpression(parent) || ts12.isSatisfiesExpression(parent)) {
|
|
3043
2893
|
return isValueContext(parent);
|
|
3044
2894
|
}
|
|
3045
2895
|
return false;
|
|
3046
2896
|
};
|
|
3047
2897
|
var isCoalesceWithLiteral = (node) => {
|
|
3048
|
-
if (!
|
|
2898
|
+
if (!ts12.isBinaryExpression(node)) return false;
|
|
3049
2899
|
const operator = node.operatorToken.kind;
|
|
3050
|
-
if (operator !==
|
|
2900
|
+
if (operator !== ts12.SyntaxKind.QuestionQuestionToken && operator !== ts12.SyntaxKind.BarBarToken) {
|
|
3051
2901
|
return false;
|
|
3052
2902
|
}
|
|
3053
2903
|
return isSafeLiteral(node.right);
|
|
@@ -3056,19 +2906,19 @@ var shouldWrapPropertyRead = (node) => {
|
|
|
3056
2906
|
if (isMetaChain(node)) return false;
|
|
3057
2907
|
const parent = node.parent;
|
|
3058
2908
|
if (!parent) return false;
|
|
3059
|
-
if (
|
|
3060
|
-
if (
|
|
3061
|
-
if (
|
|
3062
|
-
if (
|
|
3063
|
-
if (
|
|
3064
|
-
if (
|
|
3065
|
-
if (
|
|
2909
|
+
if (ts12.isPropertyAccessExpression(parent) && parent.expression === node) return false;
|
|
2910
|
+
if (ts12.isElementAccessExpression(parent) && parent.expression === node) return false;
|
|
2911
|
+
if (ts12.isCallExpression(parent) && parent.expression === node) return false;
|
|
2912
|
+
if (ts12.isNewExpression(parent) && parent.expression === node) return false;
|
|
2913
|
+
if (ts12.isTaggedTemplateExpression(parent) && parent.tag === node) return false;
|
|
2914
|
+
if (ts12.isDeleteExpression(parent)) return false;
|
|
2915
|
+
if (ts12.isPrefixUnaryExpression(parent) && (parent.operator === ts12.SyntaxKind.PlusPlusToken || parent.operator === ts12.SyntaxKind.MinusMinusToken)) {
|
|
3066
2916
|
return false;
|
|
3067
2917
|
}
|
|
3068
|
-
if (
|
|
2918
|
+
if (ts12.isPostfixUnaryExpression(parent) && (parent.operator === ts12.SyntaxKind.PlusPlusToken || parent.operator === ts12.SyntaxKind.MinusMinusToken)) {
|
|
3069
2919
|
return false;
|
|
3070
2920
|
}
|
|
3071
|
-
if (
|
|
2921
|
+
if (ts12.isBinaryExpression(parent) && isAssignmentOperator(parent.operatorToken.kind)) {
|
|
3072
2922
|
if (parent.left === node) return false;
|
|
3073
2923
|
}
|
|
3074
2924
|
if (isValueContext(node)) return true;
|
|
@@ -3083,15 +2933,15 @@ var shouldWrapRead = (node, classifications, sourceFile) => {
|
|
|
3083
2933
|
};
|
|
3084
2934
|
var hasOptional = (node) => !!node.questionDotToken;
|
|
3085
2935
|
var isInternalProperty = (node) => {
|
|
3086
|
-
if (
|
|
3087
|
-
if (!
|
|
2936
|
+
if (ts12.isPropertyAccessExpression(node)) return node.name.text.startsWith("__");
|
|
2937
|
+
if (!ts12.isStringLiteral(node.argumentExpression) && !ts12.isNoSubstitutionTemplateLiteral(node.argumentExpression)) {
|
|
3088
2938
|
return false;
|
|
3089
2939
|
}
|
|
3090
2940
|
return node.argumentExpression.text.startsWith("__");
|
|
3091
2941
|
};
|
|
3092
2942
|
var staticPropertyName = (node) => {
|
|
3093
|
-
if (
|
|
3094
|
-
if (
|
|
2943
|
+
if (ts12.isPropertyAccessExpression(node)) return node.name.text;
|
|
2944
|
+
if (ts12.isStringLiteral(node.argumentExpression) || ts12.isNoSubstitutionTemplateLiteral(node.argumentExpression)) {
|
|
3095
2945
|
return node.argumentExpression.text;
|
|
3096
2946
|
}
|
|
3097
2947
|
return void 0;
|
|
@@ -3110,21 +2960,21 @@ var isSensitiveRead = (node) => {
|
|
|
3110
2960
|
if (name === void 0) return false;
|
|
3111
2961
|
return propertyNameIsSensitive(name) || BROWSER_SENSITIVE_SURFACES.has(name);
|
|
3112
2962
|
};
|
|
3113
|
-
var allowsExpressionCapture = (owner) => owner.captureClass === "full" || owner.captureClass === "reactive-sparse" || owner.
|
|
2963
|
+
var allowsExpressionCapture = (owner) => owner.captureClass === "full" || owner.captureClass === "reactive-sparse" || owner.compilerRole === "component-wrapper";
|
|
3114
2964
|
var isReactiveArrowValue = (node, classifications, sourceFile) => {
|
|
3115
2965
|
let current = node;
|
|
3116
2966
|
while (current) {
|
|
3117
2967
|
const parent = current.parent;
|
|
3118
2968
|
if (!parent) return false;
|
|
3119
|
-
if (
|
|
2969
|
+
if (ts12.isArrowFunction(parent) && parent.body === current) {
|
|
3120
2970
|
const owner = owningFunction2(node.getStart(sourceFile), classifications);
|
|
3121
2971
|
return owner?.captureClass === "reactive-sparse";
|
|
3122
2972
|
}
|
|
3123
|
-
if (
|
|
2973
|
+
if (ts12.isBinaryExpression(parent) && (parent.left === current || parent.right === current) && !isAssignmentOperator(parent.operatorToken.kind)) {
|
|
3124
2974
|
current = parent;
|
|
3125
2975
|
continue;
|
|
3126
2976
|
}
|
|
3127
|
-
if (
|
|
2977
|
+
if (ts12.isParenthesizedExpression(parent) || ts12.isNonNullExpression(parent) || ts12.isAsExpression(parent) || ts12.isTypeAssertionExpression(parent) || ts12.isSatisfiesExpression(parent)) {
|
|
3128
2978
|
current = parent;
|
|
3129
2979
|
continue;
|
|
3130
2980
|
}
|
|
@@ -3155,7 +3005,7 @@ var collectObserveSiteEdits = (source, filePath, options = {}, sourceFile = pars
|
|
|
3155
3005
|
if (options.classifications) {
|
|
3156
3006
|
const owner = owningFunction2(node.getStart(sourceFile), options.classifications);
|
|
3157
3007
|
if (!owner || !allowsExpressionCapture(owner)) {
|
|
3158
|
-
|
|
3008
|
+
ts12.forEachChild(node, visit);
|
|
3159
3009
|
return;
|
|
3160
3010
|
}
|
|
3161
3011
|
}
|
|
@@ -3180,7 +3030,7 @@ var collectObserveSiteEdits = (source, filePath, options = {}, sourceFile = pars
|
|
|
3180
3030
|
}
|
|
3181
3031
|
});
|
|
3182
3032
|
}
|
|
3183
|
-
|
|
3033
|
+
ts12.forEachChild(node, visit);
|
|
3184
3034
|
};
|
|
3185
3035
|
visit(sourceFile);
|
|
3186
3036
|
queued.sort((left, right) => right.start - left.start);
|
|
@@ -3212,8 +3062,14 @@ var collectObserveSiteEdits = (source, filePath, options = {}, sourceFile = pars
|
|
|
3212
3062
|
return { edits, sites: applied };
|
|
3213
3063
|
};
|
|
3214
3064
|
|
|
3065
|
+
// ../instrumentation/src/svelte-module-path.ts
|
|
3066
|
+
var isSvelteCompiledPath = (idOrPath) => {
|
|
3067
|
+
const path = idOrPath.split("?")[0]?.replaceAll("\\", "/") ?? "";
|
|
3068
|
+
return path.endsWith(".svelte") || path.endsWith(".svelte.ts") || path.endsWith(".svelte.js");
|
|
3069
|
+
};
|
|
3070
|
+
|
|
3215
3071
|
// ../instrumentation/src/verify-browser-source.ts
|
|
3216
|
-
import
|
|
3072
|
+
import ts13 from "typescript";
|
|
3217
3073
|
var RASPUTIN_IDENT = /^__rasputin/;
|
|
3218
3074
|
var BROWSER_GLOBALS = /* @__PURE__ */ new Set([
|
|
3219
3075
|
"__rasputinO",
|
|
@@ -3230,13 +3086,13 @@ var BROWSER_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
3230
3086
|
]);
|
|
3231
3087
|
var isRasputinName = (name) => RASPUTIN_IDENT.test(name);
|
|
3232
3088
|
var identText = (node) => {
|
|
3233
|
-
if (
|
|
3234
|
-
if (
|
|
3089
|
+
if (ts13.isIdentifier(node)) return node.text;
|
|
3090
|
+
if (ts13.isPrivateIdentifier(node)) return node.text;
|
|
3235
3091
|
return void 0;
|
|
3236
3092
|
};
|
|
3237
3093
|
var calleeName = (expression) => {
|
|
3238
|
-
if (
|
|
3239
|
-
if (
|
|
3094
|
+
if (ts13.isIdentifier(expression)) return expression.text;
|
|
3095
|
+
if (ts13.isPropertyAccessExpression(expression)) {
|
|
3240
3096
|
const object = identText(expression.expression);
|
|
3241
3097
|
const property = identText(expression.name);
|
|
3242
3098
|
if (object && isRasputinName(object) && property) return `${object}.${property}`;
|
|
@@ -3245,17 +3101,17 @@ var calleeName = (expression) => {
|
|
|
3245
3101
|
return void 0;
|
|
3246
3102
|
};
|
|
3247
3103
|
var isRasputinCall = (node) => {
|
|
3248
|
-
if (!
|
|
3104
|
+
if (!ts13.isCallExpression(node)) return false;
|
|
3249
3105
|
const name = calleeName(node.expression);
|
|
3250
3106
|
return Boolean(name && (isRasputinName(name) || BROWSER_GLOBALS.has(name)));
|
|
3251
3107
|
};
|
|
3252
3108
|
var isRasputinAssignment = (node) => {
|
|
3253
|
-
if (!
|
|
3109
|
+
if (!ts13.isBinaryExpression(node)) return false;
|
|
3254
3110
|
const operator = node.operatorToken.kind;
|
|
3255
|
-
if (operator !==
|
|
3111
|
+
if (operator !== ts13.SyntaxKind.EqualsToken && operator !== ts13.SyntaxKind.QuestionQuestionEqualsToken) {
|
|
3256
3112
|
return false;
|
|
3257
3113
|
}
|
|
3258
|
-
if (
|
|
3114
|
+
if (ts13.isPropertyAccessExpression(node.left)) {
|
|
3259
3115
|
const object = identText(node.left.expression);
|
|
3260
3116
|
const property = identText(node.left.name);
|
|
3261
3117
|
return object === "globalThis" && property !== void 0 && BROWSER_GLOBALS.has(property);
|
|
@@ -3267,28 +3123,28 @@ var isRasputinOnlyInitializer = (expression) => {
|
|
|
3267
3123
|
if (!expression) return true;
|
|
3268
3124
|
const unwrapped = unwrapCall(expression);
|
|
3269
3125
|
if (unwrapped !== expression) {
|
|
3270
|
-
return
|
|
3126
|
+
return ts13.isExpression(unwrapped) ? isRasputinOnlyInitializer(unwrapped) : false;
|
|
3271
3127
|
}
|
|
3272
3128
|
return isRasputinCall(expression);
|
|
3273
3129
|
};
|
|
3274
3130
|
var jsonAwaitSlot = (node) => {
|
|
3275
|
-
if (node.operatorToken.kind !==
|
|
3131
|
+
if (node.operatorToken.kind !== ts13.SyntaxKind.CommaToken) return void 0;
|
|
3276
3132
|
const assigned = node.left;
|
|
3277
|
-
if (!
|
|
3133
|
+
if (!ts13.isBinaryExpression(assigned) || assigned.operatorToken.kind !== ts13.SyntaxKind.EqualsToken || !ts13.isIdentifier(assigned.left) || !isRasputinName(assigned.left.text) || !ts13.isObjectLiteralExpression(assigned.right)) {
|
|
3278
3134
|
return void 0;
|
|
3279
3135
|
}
|
|
3280
3136
|
const property = assigned.right.properties[0];
|
|
3281
|
-
if (!property || !
|
|
3137
|
+
if (!property || !ts13.isPropertyAssignment(property) || !ts13.isIdentifier(property.name) || property.name.text !== "p") {
|
|
3282
3138
|
return void 0;
|
|
3283
3139
|
}
|
|
3284
|
-
if (!
|
|
3140
|
+
if (!ts13.isPropertyAccessExpression(node.right) || !ts13.isIdentifier(node.right.expression) || !isRasputinName(node.right.expression.text) || node.right.name.text !== "p") {
|
|
3285
3141
|
return void 0;
|
|
3286
3142
|
}
|
|
3287
3143
|
return property.initializer;
|
|
3288
3144
|
};
|
|
3289
3145
|
var peelParens = (node) => {
|
|
3290
3146
|
let current = node;
|
|
3291
|
-
while (
|
|
3147
|
+
while (ts13.isParenthesizedExpression(current)) current = current.expression;
|
|
3292
3148
|
return current;
|
|
3293
3149
|
};
|
|
3294
3150
|
var jsonMethodCall = (node) => {
|
|
@@ -3296,9 +3152,9 @@ var jsonMethodCall = (node) => {
|
|
|
3296
3152
|
const fn = node.arguments[1];
|
|
3297
3153
|
if (!receiver || !fn) return void 0;
|
|
3298
3154
|
const args = node.arguments.slice(2);
|
|
3299
|
-
if (!
|
|
3300
|
-
return
|
|
3301
|
-
|
|
3155
|
+
if (!ts13.isPropertyAccessExpression(fn)) return void 0;
|
|
3156
|
+
return ts13.factory.createCallExpression(
|
|
3157
|
+
ts13.factory.createPropertyAccessExpression(receiver, fn.name),
|
|
3302
3158
|
void 0,
|
|
3303
3159
|
args
|
|
3304
3160
|
);
|
|
@@ -3308,55 +3164,55 @@ var unwrapAdoptIife = (node) => {
|
|
|
3308
3164
|
const adopted = node.arguments[0];
|
|
3309
3165
|
if (!adopted) return void 0;
|
|
3310
3166
|
const callee = peelParens(node.expression);
|
|
3311
|
-
if (!
|
|
3167
|
+
if (!ts13.isArrowFunction(callee) || callee.parameters.length !== 1 || ts13.isBlock(callee.body)) {
|
|
3312
3168
|
return void 0;
|
|
3313
3169
|
}
|
|
3314
3170
|
const param = callee.parameters[0];
|
|
3315
|
-
if (!param || !
|
|
3171
|
+
if (!param || !ts13.isIdentifier(param.name) || param.dotDotDotToken || param.initializer) {
|
|
3316
3172
|
return void 0;
|
|
3317
3173
|
}
|
|
3318
3174
|
const body = peelParens(callee.body);
|
|
3319
|
-
if (
|
|
3175
|
+
if (ts13.isCallExpression(body) && calleeName(body.expression) === "__rasputinP") {
|
|
3320
3176
|
const invoked = body.arguments[0];
|
|
3321
|
-
if (invoked &&
|
|
3322
|
-
return
|
|
3177
|
+
if (invoked && ts13.isCallExpression(invoked) && ts13.isIdentifier(invoked.expression) && invoked.expression.text === param.name.text) {
|
|
3178
|
+
return ts13.factory.createCallExpression(adopted, void 0, invoked.arguments);
|
|
3323
3179
|
}
|
|
3324
3180
|
return void 0;
|
|
3325
3181
|
}
|
|
3326
|
-
if (!
|
|
3182
|
+
if (!ts13.isCallExpression(body) || body.arguments.length !== 1) return void 0;
|
|
3327
3183
|
const methodLookup = body.arguments[0];
|
|
3328
3184
|
if (!methodLookup) return void 0;
|
|
3329
3185
|
const inner = peelParens(body.expression);
|
|
3330
|
-
if (!
|
|
3186
|
+
if (!ts13.isArrowFunction(inner) || inner.parameters.length !== 1 || ts13.isBlock(inner.body)) {
|
|
3331
3187
|
return void 0;
|
|
3332
3188
|
}
|
|
3333
3189
|
const fnParam = inner.parameters[0];
|
|
3334
|
-
if (!fnParam || !
|
|
3190
|
+
if (!fnParam || !ts13.isIdentifier(fnParam.name) || fnParam.dotDotDotToken || fnParam.initializer) {
|
|
3335
3191
|
return void 0;
|
|
3336
3192
|
}
|
|
3337
3193
|
const innerBody = peelParens(inner.body);
|
|
3338
|
-
if (!
|
|
3194
|
+
if (!ts13.isCallExpression(innerBody) || calleeName(innerBody.expression) !== "__rasputinP") {
|
|
3339
3195
|
return void 0;
|
|
3340
3196
|
}
|
|
3341
3197
|
const applied = innerBody.arguments[0];
|
|
3342
|
-
if (!applied || !
|
|
3198
|
+
if (!applied || !ts13.isCallExpression(applied)) return void 0;
|
|
3343
3199
|
const applyCallee = peelParens(applied.expression);
|
|
3344
|
-
if (!
|
|
3200
|
+
if (!ts13.isPropertyAccessExpression(applyCallee) || applyCallee.name.text !== "apply" || !ts13.isIdentifier(applyCallee.expression) || applyCallee.expression.text !== "Reflect") {
|
|
3345
3201
|
return void 0;
|
|
3346
3202
|
}
|
|
3347
3203
|
const appliedFn = applied.arguments[0];
|
|
3348
3204
|
const thisArg = applied.arguments[1];
|
|
3349
3205
|
const argsArg = applied.arguments[2];
|
|
3350
|
-
if (!appliedFn || !
|
|
3206
|
+
if (!appliedFn || !ts13.isIdentifier(appliedFn) || appliedFn.text !== fnParam.name.text) {
|
|
3351
3207
|
return void 0;
|
|
3352
3208
|
}
|
|
3353
|
-
if (!thisArg || !
|
|
3354
|
-
if (!argsArg || !
|
|
3355
|
-
if (!
|
|
3209
|
+
if (!thisArg || !ts13.isIdentifier(thisArg) || thisArg.text !== param.name.text) return void 0;
|
|
3210
|
+
if (!argsArg || !ts13.isArrayLiteralExpression(argsArg)) return void 0;
|
|
3211
|
+
if (!ts13.isPropertyAccessExpression(methodLookup) || !ts13.isIdentifier(methodLookup.expression) || methodLookup.expression.text !== param.name.text || ts13.isPrivateIdentifier(methodLookup.name)) {
|
|
3356
3212
|
return void 0;
|
|
3357
3213
|
}
|
|
3358
|
-
return
|
|
3359
|
-
|
|
3214
|
+
return ts13.factory.createCallExpression(
|
|
3215
|
+
ts13.factory.createPropertyAccessExpression(adopted, methodLookup.name),
|
|
3360
3216
|
void 0,
|
|
3361
3217
|
[...argsArg.elements]
|
|
3362
3218
|
);
|
|
@@ -3366,23 +3222,23 @@ var unwrapProducerIife = (node) => {
|
|
|
3366
3222
|
const receiver = node.arguments[0];
|
|
3367
3223
|
if (!receiver) return void 0;
|
|
3368
3224
|
const callee = peelParens(node.expression);
|
|
3369
|
-
if (!
|
|
3225
|
+
if (!ts13.isArrowFunction(callee) || callee.parameters.length !== 1 || ts13.isBlock(callee.body)) {
|
|
3370
3226
|
return void 0;
|
|
3371
3227
|
}
|
|
3372
3228
|
const param = callee.parameters[0];
|
|
3373
|
-
if (!param || !
|
|
3229
|
+
if (!param || !ts13.isIdentifier(param.name) || param.dotDotDotToken || param.initializer) {
|
|
3374
3230
|
return void 0;
|
|
3375
3231
|
}
|
|
3376
3232
|
const body = peelParens(callee.body);
|
|
3377
|
-
if (!
|
|
3233
|
+
if (!ts13.isCallExpression(body) || !isRasputinCall(body)) return void 0;
|
|
3378
3234
|
if (calleeName(body.expression) !== "__rasputinM") return void 0;
|
|
3379
3235
|
const bound = body.arguments[0];
|
|
3380
3236
|
const fn = body.arguments[1];
|
|
3381
|
-
if (!bound || !fn || !
|
|
3382
|
-
if (!
|
|
3383
|
-
if (!
|
|
3384
|
-
return
|
|
3385
|
-
|
|
3237
|
+
if (!bound || !fn || !ts13.isIdentifier(bound) || bound.text !== param.name.text) return void 0;
|
|
3238
|
+
if (!ts13.isPropertyAccessExpression(fn)) return void 0;
|
|
3239
|
+
if (!ts13.isIdentifier(fn.expression) || fn.expression.text !== param.name.text) return void 0;
|
|
3240
|
+
return ts13.factory.createCallExpression(
|
|
3241
|
+
ts13.factory.createPropertyAccessExpression(receiver, fn.name),
|
|
3386
3242
|
void 0,
|
|
3387
3243
|
body.arguments.slice(2)
|
|
3388
3244
|
);
|
|
@@ -3390,22 +3246,22 @@ var unwrapProducerIife = (node) => {
|
|
|
3390
3246
|
var unwrapCall = (node) => {
|
|
3391
3247
|
let current = node;
|
|
3392
3248
|
while (true) {
|
|
3393
|
-
if (
|
|
3249
|
+
if (ts13.isParenthesizedExpression(current)) {
|
|
3394
3250
|
current = current.expression;
|
|
3395
3251
|
continue;
|
|
3396
3252
|
}
|
|
3397
|
-
if (
|
|
3253
|
+
if (ts13.isBinaryExpression(current)) {
|
|
3398
3254
|
const slot = jsonAwaitSlot(current);
|
|
3399
3255
|
if (slot) {
|
|
3400
3256
|
current = slot;
|
|
3401
3257
|
continue;
|
|
3402
3258
|
}
|
|
3403
3259
|
}
|
|
3404
|
-
if (
|
|
3260
|
+
if (ts13.isConditionalExpression(current) && isRasputinName(identText(current.condition) ?? "")) {
|
|
3405
3261
|
current = current.whenTrue;
|
|
3406
3262
|
continue;
|
|
3407
3263
|
}
|
|
3408
|
-
if (
|
|
3264
|
+
if (ts13.isCallExpression(current)) {
|
|
3409
3265
|
const adopted = unwrapAdoptIife(current);
|
|
3410
3266
|
if (adopted) {
|
|
3411
3267
|
current = adopted;
|
|
@@ -3417,7 +3273,7 @@ var unwrapCall = (node) => {
|
|
|
3417
3273
|
continue;
|
|
3418
3274
|
}
|
|
3419
3275
|
}
|
|
3420
|
-
if (
|
|
3276
|
+
if (ts13.isCallExpression(current) && isRasputinCall(current)) {
|
|
3421
3277
|
const name = calleeName(current.expression);
|
|
3422
3278
|
if ((name === "__rasputinO" || name === "__rasputinL") && current.arguments.length >= 2 && current.arguments[1]) {
|
|
3423
3279
|
current = current.arguments[1];
|
|
@@ -3450,26 +3306,26 @@ var unwrapCall = (node) => {
|
|
|
3450
3306
|
var isRasputinIf = (node) => {
|
|
3451
3307
|
if (node.elseStatement) return false;
|
|
3452
3308
|
const condition = node.expression;
|
|
3453
|
-
const negated =
|
|
3309
|
+
const negated = ts13.isPrefixUnaryExpression(condition) && condition.operator === ts13.SyntaxKind.ExclamationToken && isRasputinName(identText(condition.operand) ?? "");
|
|
3454
3310
|
if (!negated) return false;
|
|
3455
3311
|
const then = node.thenStatement;
|
|
3456
|
-
if (
|
|
3457
|
-
return
|
|
3312
|
+
if (ts13.isExpressionStatement(then) && isRasputinCall(then.expression)) return true;
|
|
3313
|
+
return ts13.isBlock(then) && then.statements.every((statement) => isRasputinStatement(statement));
|
|
3458
3314
|
};
|
|
3459
3315
|
var isRasputinStatement = (node) => {
|
|
3460
|
-
if (
|
|
3461
|
-
if (
|
|
3316
|
+
if (ts13.isEmptyStatement(node)) return true;
|
|
3317
|
+
if (ts13.isVariableStatement(node)) {
|
|
3462
3318
|
return node.declarationList.declarations.every((declaration) => {
|
|
3463
3319
|
const name = identText(declaration.name);
|
|
3464
3320
|
return Boolean(name && isRasputinName(name));
|
|
3465
3321
|
});
|
|
3466
3322
|
}
|
|
3467
|
-
if (
|
|
3323
|
+
if (ts13.isExpressionStatement(node)) {
|
|
3468
3324
|
if (isRasputinAssignment(node.expression)) return true;
|
|
3469
3325
|
if (!isRasputinCall(node.expression)) return false;
|
|
3470
3326
|
return unwrapCall(node.expression) === node.expression;
|
|
3471
3327
|
}
|
|
3472
|
-
if (
|
|
3328
|
+
if (ts13.isIfStatement(node)) return isRasputinIf(node);
|
|
3473
3329
|
return false;
|
|
3474
3330
|
};
|
|
3475
3331
|
var isRasputinTryWrapper = (node) => {
|
|
@@ -3479,12 +3335,12 @@ var isRasputinTryWrapper = (node) => {
|
|
|
3479
3335
|
(statement) => !isRasputinStatement(statement)
|
|
3480
3336
|
);
|
|
3481
3337
|
const leftover = catchCalls[0];
|
|
3482
|
-
const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 &&
|
|
3338
|
+
const leftoverThrow = catchCalls.length === 1 && leftover !== void 0 && ts13.isThrowStatement(leftover) && ts13.isIdentifier(leftover.expression);
|
|
3483
3339
|
if (!leftoverThrow && catchCalls.length > 0) return false;
|
|
3484
3340
|
return node.finallyBlock.statements.every((statement) => isRasputinStatement(statement));
|
|
3485
3341
|
};
|
|
3486
3342
|
var customerTempInit = (statement) => {
|
|
3487
|
-
if (!
|
|
3343
|
+
if (!ts13.isVariableStatement(statement)) return void 0;
|
|
3488
3344
|
for (const declaration of statement.declarationList.declarations) {
|
|
3489
3345
|
const name = identText(declaration.name);
|
|
3490
3346
|
if (!name || !isRasputinName(name) || !declaration.initializer) continue;
|
|
@@ -3497,7 +3353,7 @@ var flattenStatements = (statements) => {
|
|
|
3497
3353
|
const flattened = [];
|
|
3498
3354
|
for (const statement of statements) {
|
|
3499
3355
|
if (isRasputinStatement(statement)) continue;
|
|
3500
|
-
if (
|
|
3356
|
+
if (ts13.isTryStatement(statement) && isRasputinTryWrapper(statement)) {
|
|
3501
3357
|
flattened.push(...flattenStatements(statement.tryBlock.statements));
|
|
3502
3358
|
continue;
|
|
3503
3359
|
}
|
|
@@ -3506,27 +3362,27 @@ var flattenStatements = (statements) => {
|
|
|
3506
3362
|
return flattened;
|
|
3507
3363
|
};
|
|
3508
3364
|
var isRememberIife = (node) => {
|
|
3509
|
-
if (!
|
|
3365
|
+
if (!ts13.isCallExpression(node) || node.arguments.length > 0) return void 0;
|
|
3510
3366
|
let callee = node.expression;
|
|
3511
|
-
if (
|
|
3512
|
-
if (!
|
|
3367
|
+
if (ts13.isParenthesizedExpression(callee)) callee = callee.expression;
|
|
3368
|
+
if (!ts13.isArrowFunction(callee) || callee.parameters.length > 0 || !ts13.isBlock(callee.body)) {
|
|
3513
3369
|
return void 0;
|
|
3514
3370
|
}
|
|
3515
3371
|
const statements = callee.body.statements;
|
|
3516
3372
|
const last = statements.at(-1);
|
|
3517
|
-
if (!last || !
|
|
3373
|
+
if (!last || !ts13.isReturnStatement(last) || !last.expression) return void 0;
|
|
3518
3374
|
let returned = last.expression;
|
|
3519
|
-
while (
|
|
3520
|
-
if (!
|
|
3375
|
+
while (ts13.isParenthesizedExpression(returned)) returned = returned.expression;
|
|
3376
|
+
if (!ts13.isCallExpression(returned)) return void 0;
|
|
3521
3377
|
const name = calleeName(returned.expression);
|
|
3522
3378
|
if (name !== "__rasputinK") return void 0;
|
|
3523
3379
|
const objectArg = returned.arguments[0];
|
|
3524
|
-
if (!objectArg || !
|
|
3380
|
+
if (!objectArg || !ts13.isIdentifier(objectArg)) return void 0;
|
|
3525
3381
|
const temps = /* @__PURE__ */ new Map();
|
|
3526
3382
|
for (const statement of statements.slice(0, -1)) {
|
|
3527
|
-
if (!
|
|
3383
|
+
if (!ts13.isVariableStatement(statement)) return void 0;
|
|
3528
3384
|
for (const declaration of statement.declarationList.declarations) {
|
|
3529
|
-
if (!
|
|
3385
|
+
if (!ts13.isIdentifier(declaration.name) || !declaration.initializer) return void 0;
|
|
3530
3386
|
temps.set(declaration.name.text, declaration.initializer);
|
|
3531
3387
|
}
|
|
3532
3388
|
}
|
|
@@ -3536,10 +3392,10 @@ var isRememberIife = (node) => {
|
|
|
3536
3392
|
};
|
|
3537
3393
|
var resolveRememberTemp = (expression, temps, seen) => {
|
|
3538
3394
|
let current = expression;
|
|
3539
|
-
while (
|
|
3395
|
+
while (ts13.isParenthesizedExpression(current) || ts13.isNonNullExpression(current) || ts13.isAsExpression(current) || ts13.isTypeAssertionExpression(current) || ts13.isSatisfiesExpression(current)) {
|
|
3540
3396
|
current = current.expression;
|
|
3541
3397
|
}
|
|
3542
|
-
if (
|
|
3398
|
+
if (ts13.isIdentifier(current) && temps.has(current.text) && !seen.has(current.text)) {
|
|
3543
3399
|
const next = temps.get(current.text);
|
|
3544
3400
|
if (!next) return current;
|
|
3545
3401
|
seen.add(current.text);
|
|
@@ -3548,27 +3404,27 @@ var resolveRememberTemp = (expression, temps, seen) => {
|
|
|
3548
3404
|
return current;
|
|
3549
3405
|
};
|
|
3550
3406
|
var extra = (node) => {
|
|
3551
|
-
if (
|
|
3407
|
+
if (ts13.isIdentifier(node) || ts13.isPrivateIdentifier(node)) {
|
|
3552
3408
|
return isRasputinName(node.text) ? "" : node.text;
|
|
3553
3409
|
}
|
|
3554
|
-
if (
|
|
3410
|
+
if (ts13.isStringLiteral(node) || ts13.isNumericLiteral(node) || ts13.isNoSubstitutionTemplateLiteral(node)) {
|
|
3555
3411
|
return node.text;
|
|
3556
3412
|
}
|
|
3557
|
-
if (
|
|
3413
|
+
if (ts13.isToken(node) && !ts13.isIdentifier(node)) return ts13.SyntaxKind[node.kind] ?? "";
|
|
3558
3414
|
return "";
|
|
3559
3415
|
};
|
|
3560
3416
|
var signatureOfSubstituted = (node, temps) => {
|
|
3561
3417
|
const remembered = isRememberIife(node);
|
|
3562
3418
|
if (remembered) return signatureOfSubstituted(remembered.object, remembered.temps);
|
|
3563
|
-
if (
|
|
3419
|
+
if (ts13.isObjectLiteralExpression(node)) {
|
|
3564
3420
|
const parts = node.properties.map((property) => {
|
|
3565
|
-
if (
|
|
3566
|
-
if (!
|
|
3421
|
+
if (ts13.isShorthandPropertyAssignment(property)) return signatureOf(property);
|
|
3422
|
+
if (!ts13.isPropertyAssignment(property)) return signatureOf(property);
|
|
3567
3423
|
const init = resolveRememberTemp(property.initializer, temps, /* @__PURE__ */ new Set());
|
|
3568
|
-
if (
|
|
3569
|
-
return signatureOf(
|
|
3424
|
+
if (ts13.isIdentifier(property.name) && ts13.isIdentifier(init) && property.name.text === init.text) {
|
|
3425
|
+
return signatureOf(ts13.factory.createShorthandPropertyAssignment(property.name));
|
|
3570
3426
|
}
|
|
3571
|
-
if (
|
|
3427
|
+
if (ts13.isComputedPropertyName(property.name)) {
|
|
3572
3428
|
const key = resolveRememberTemp(property.name.expression, temps, /* @__PURE__ */ new Set());
|
|
3573
3429
|
return `PropertyAssignment[ComputedPropertyName[${signatureOfSubstituted(key, temps)}],${signatureOfSubstituted(init, temps)}]`;
|
|
3574
3430
|
}
|
|
@@ -3576,7 +3432,7 @@ var signatureOfSubstituted = (node, temps) => {
|
|
|
3576
3432
|
});
|
|
3577
3433
|
return `ObjectLiteralExpression[${parts.join(",")}]`;
|
|
3578
3434
|
}
|
|
3579
|
-
if (
|
|
3435
|
+
if (ts13.isArrayLiteralExpression(node)) {
|
|
3580
3436
|
const parts = node.elements.map(
|
|
3581
3437
|
(element) => signatureOfSubstituted(resolveRememberTemp(element, temps, /* @__PURE__ */ new Set()), temps)
|
|
3582
3438
|
);
|
|
@@ -3594,33 +3450,33 @@ var signatureOf = (node) => {
|
|
|
3594
3450
|
if (unwrapped !== node) return signatureOf(unwrapped);
|
|
3595
3451
|
const remembered = signatureOfRememberedLiteral(unwrapped);
|
|
3596
3452
|
if (remembered !== void 0) return remembered;
|
|
3597
|
-
if (
|
|
3598
|
-
return signatureOf(
|
|
3453
|
+
if (ts13.isPropertyAssignment(unwrapped) && ts13.isIdentifier(unwrapped.name) && ts13.isIdentifier(unwrapped.initializer) && unwrapped.name.text === unwrapped.initializer.text) {
|
|
3454
|
+
return signatureOf(ts13.factory.createShorthandPropertyAssignment(unwrapped.name));
|
|
3599
3455
|
}
|
|
3600
|
-
if (
|
|
3601
|
-
if (
|
|
3456
|
+
if (ts13.isEmptyStatement(unwrapped) || isRasputinStatement(unwrapped)) return "";
|
|
3457
|
+
if (ts13.isTryStatement(unwrapped) && isRasputinTryWrapper(unwrapped)) {
|
|
3602
3458
|
return flattenStatements(unwrapped.tryBlock.statements).map(signatureOf).filter(Boolean).join("");
|
|
3603
3459
|
}
|
|
3604
|
-
if (
|
|
3460
|
+
if (ts13.isCatchClause(unwrapped)) {
|
|
3605
3461
|
const statements = flattenStatements(unwrapped.block.statements);
|
|
3606
3462
|
const variable = unwrapped.variableDeclaration ? signatureOf(unwrapped.variableDeclaration) : "";
|
|
3607
3463
|
return `Catch${variable}[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
|
|
3608
3464
|
}
|
|
3609
|
-
if (
|
|
3465
|
+
if (ts13.isBlock(unwrapped)) {
|
|
3610
3466
|
const statements = flattenStatements(unwrapped.statements);
|
|
3611
3467
|
return `Block[${statements.map(signatureOf).filter(Boolean).join(",")}]`;
|
|
3612
3468
|
}
|
|
3613
|
-
if (
|
|
3469
|
+
if (ts13.isArrowFunction(unwrapped) && ts13.isBlock(unwrapped.body)) {
|
|
3614
3470
|
const raw = unwrapped.body.statements;
|
|
3615
|
-
const tryWrap = raw.length === 1 && raw[0] &&
|
|
3471
|
+
const tryWrap = raw.length === 1 && raw[0] && ts13.isTryStatement(raw[0]) ? raw[0] : void 0;
|
|
3616
3472
|
const inner = tryWrap && isRasputinTryWrapper(tryWrap) ? tryWrap.tryBlock.statements : raw;
|
|
3617
3473
|
const temp = inner[0] ? customerTempInit(inner[0]) : void 0;
|
|
3618
3474
|
const returned = inner[1];
|
|
3619
|
-
if (temp && returned &&
|
|
3475
|
+
if (temp && returned && ts13.isReturnStatement(returned) && returned.expression && inner.length === 2) {
|
|
3620
3476
|
const value = unwrapCall(returned.expression);
|
|
3621
|
-
if (
|
|
3477
|
+
if (ts13.isIdentifier(value) && value.text === temp.name) {
|
|
3622
3478
|
const parts2 = [];
|
|
3623
|
-
|
|
3479
|
+
ts13.forEachChild(unwrapped, (child) => {
|
|
3624
3480
|
if (child === unwrapped.body) {
|
|
3625
3481
|
const part2 = signatureOf(temp.init);
|
|
3626
3482
|
if (part2) parts2.push(part2);
|
|
@@ -3634,10 +3490,10 @@ var signatureOf = (node) => {
|
|
|
3634
3490
|
}
|
|
3635
3491
|
const statements = flattenStatements(unwrapped.body.statements);
|
|
3636
3492
|
const only = statements[0];
|
|
3637
|
-
const onlyExpression = only &&
|
|
3493
|
+
const onlyExpression = only && ts13.isReturnStatement(only) ? only.expression : void 0;
|
|
3638
3494
|
if (statements.length === 1 && onlyExpression) {
|
|
3639
3495
|
const parts2 = [];
|
|
3640
|
-
|
|
3496
|
+
ts13.forEachChild(unwrapped, (child) => {
|
|
3641
3497
|
if (child === unwrapped.body) {
|
|
3642
3498
|
const part2 = signatureOf(onlyExpression);
|
|
3643
3499
|
if (part2) parts2.push(part2);
|
|
@@ -3649,20 +3505,20 @@ var signatureOf = (node) => {
|
|
|
3649
3505
|
return `ArrowFunction[${parts2.join(",")}]`;
|
|
3650
3506
|
}
|
|
3651
3507
|
}
|
|
3652
|
-
if (
|
|
3508
|
+
if (ts13.isReturnStatement(unwrapped)) {
|
|
3653
3509
|
if (!unwrapped.expression) return "ReturnStatement[]";
|
|
3654
3510
|
const expression = unwrapCall(unwrapped.expression);
|
|
3655
|
-
if (
|
|
3511
|
+
if (ts13.isVoidExpression(expression) && isRasputinCall(expression.expression)) {
|
|
3656
3512
|
return "ReturnStatement[]";
|
|
3657
3513
|
}
|
|
3658
3514
|
return `Return[${signatureOf(unwrapped.expression)}]`;
|
|
3659
3515
|
}
|
|
3660
3516
|
const parts = [];
|
|
3661
|
-
|
|
3517
|
+
ts13.forEachChild(unwrapped, (child) => {
|
|
3662
3518
|
const part = signatureOf(child);
|
|
3663
3519
|
if (part) parts.push(part);
|
|
3664
3520
|
});
|
|
3665
|
-
const kind =
|
|
3521
|
+
const kind = ts13.SyntaxKind[unwrapped.kind] ?? "Node";
|
|
3666
3522
|
return `${kind}${extra(unwrapped)}[${parts.join(",")}]`;
|
|
3667
3523
|
};
|
|
3668
3524
|
var browserInstrumentationIsSafe = (filePath, original, transformed) => {
|
|
@@ -3685,6 +3541,15 @@ var refuse = (source, classifications) => ({
|
|
|
3685
3541
|
verificationFailed: true
|
|
3686
3542
|
});
|
|
3687
3543
|
var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleIndex = 0, options) => {
|
|
3544
|
+
if (isSvelteCompiledPath(filePath) && !options?.policy) {
|
|
3545
|
+
return {
|
|
3546
|
+
code: source,
|
|
3547
|
+
classifications: [],
|
|
3548
|
+
sites: [],
|
|
3549
|
+
identities: [],
|
|
3550
|
+
delta: { functions: [], callSites: [], destructures: [] }
|
|
3551
|
+
};
|
|
3552
|
+
}
|
|
3688
3553
|
if (source.includes("@rasputin-ignore-file") || sourceIsRasputinInstrumented(source)) {
|
|
3689
3554
|
return {
|
|
3690
3555
|
code: source,
|
|
@@ -3695,7 +3560,12 @@ var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleInd
|
|
|
3695
3560
|
};
|
|
3696
3561
|
}
|
|
3697
3562
|
const sourceFile = parseSource(source, filePath);
|
|
3698
|
-
const classifications = classifyFunctions(
|
|
3563
|
+
const classifications = classifyFunctions(
|
|
3564
|
+
source,
|
|
3565
|
+
filePath,
|
|
3566
|
+
options?.mapLocation,
|
|
3567
|
+
options?.policy
|
|
3568
|
+
);
|
|
3699
3569
|
const observe = collectObserveSiteEdits(
|
|
3700
3570
|
source,
|
|
3701
3571
|
filePath,
|
|
@@ -3703,7 +3573,10 @@ var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleInd
|
|
|
3703
3573
|
sourceFile
|
|
3704
3574
|
);
|
|
3705
3575
|
const literals = collectLiteralSiteEdits(source, filePath, { classifications }, sourceFile);
|
|
3706
|
-
const json = collectJsonProducerEdits(source, filePath, sourceFile, {
|
|
3576
|
+
const json = collectJsonProducerEdits(source, filePath, sourceFile, {
|
|
3577
|
+
adoptCalls: true,
|
|
3578
|
+
policy: options?.policy
|
|
3579
|
+
});
|
|
3707
3580
|
const functions = collectBrowserFunctionEdits(
|
|
3708
3581
|
source,
|
|
3709
3582
|
sourceFile,
|
|
@@ -3714,7 +3587,8 @@ var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleInd
|
|
|
3714
3587
|
observe: observe.sites.length > 0,
|
|
3715
3588
|
struct: literals.edits.length > 0,
|
|
3716
3589
|
includePlans: options?.includePlans === true,
|
|
3717
|
-
mapLocation: options?.mapLocation
|
|
3590
|
+
mapLocation: options?.mapLocation,
|
|
3591
|
+
policy: options?.policy
|
|
3718
3592
|
}
|
|
3719
3593
|
);
|
|
3720
3594
|
const edits = [...observe.edits, ...literals.edits, ...json.edits, ...functions.edits];
|
|
@@ -3745,11 +3619,11 @@ var instrumentBrowserSource = (source, filePath, emitIds, reactiveIds, moduleInd
|
|
|
3745
3619
|
import { basename as basename3 } from "node:path";
|
|
3746
3620
|
|
|
3747
3621
|
// ../instrumentation/src/provenance-function-edits.ts
|
|
3748
|
-
import
|
|
3622
|
+
import ts14 from "typescript";
|
|
3749
3623
|
var PROVENANCE_HANDLE_CALLEE = "globalThis.__rasputinN";
|
|
3750
3624
|
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) => (
|
|
3752
|
-
var isDirectivePrologue2 = (statement) =>
|
|
3625
|
+
var isProvenanceTarget = (node) => (ts14.isFunctionDeclaration(node) || ts14.isFunctionExpression(node) || ts14.isArrowFunction(node) || ts14.isMethodDeclaration(node)) && node.body !== void 0 && !node.asteriskToken;
|
|
3626
|
+
var isDirectivePrologue2 = (statement) => ts14.isExpressionStatement(statement) && ts14.isStringLiteral(statement.expression);
|
|
3753
3627
|
var insertPositionAfterPrologue2 = (source, sourceFile) => {
|
|
3754
3628
|
const shebangEnd = source.startsWith("#!") ? source.indexOf("\n") + 1 : 0;
|
|
3755
3629
|
let end = shebangEnd;
|
|
@@ -3775,15 +3649,15 @@ var functionBodyPrologueEnd2 = (body, sourceFile) => {
|
|
|
3775
3649
|
var walkOwnBody2 = (node, visitNode) => {
|
|
3776
3650
|
if (!node.body) return;
|
|
3777
3651
|
const visit = (candidate) => {
|
|
3778
|
-
if (candidate !== node &&
|
|
3652
|
+
if (candidate !== node && ts14.isFunctionLike(candidate)) return;
|
|
3779
3653
|
visitNode(candidate);
|
|
3780
|
-
|
|
3654
|
+
ts14.forEachChild(candidate, visit);
|
|
3781
3655
|
};
|
|
3782
3656
|
visit(node.body);
|
|
3783
3657
|
};
|
|
3784
3658
|
var producerName = (node) => {
|
|
3785
3659
|
const callee = peel(node.expression);
|
|
3786
|
-
if (
|
|
3660
|
+
if (ts14.isPropertyAccessExpression(callee) && ts14.isIdentifier(callee.name)) {
|
|
3787
3661
|
return callee.name.text;
|
|
3788
3662
|
}
|
|
3789
3663
|
return void 0;
|
|
@@ -3822,10 +3696,10 @@ var callCanCarryProvenance2 = (node) => {
|
|
|
3822
3696
|
if (name === "json" || name === "parse") return true;
|
|
3823
3697
|
if (name === "call" || name === "apply") return false;
|
|
3824
3698
|
const callee = peel(node.expression);
|
|
3825
|
-
if (
|
|
3826
|
-
if (
|
|
3699
|
+
if (ts14.isIdentifier(callee)) return !NON_PROVENANCE_ROOTS2.has(callee.text);
|
|
3700
|
+
if (ts14.isPropertyAccessExpression(callee)) {
|
|
3827
3701
|
const object = peel(callee.expression);
|
|
3828
|
-
if (
|
|
3702
|
+
if (ts14.isIdentifier(object) && NON_PROVENANCE_ROOTS2.has(object.text)) {
|
|
3829
3703
|
return object.text === "JSON" && callee.name.text === "parse";
|
|
3830
3704
|
}
|
|
3831
3705
|
}
|
|
@@ -3833,29 +3707,29 @@ var callCanCarryProvenance2 = (node) => {
|
|
|
3833
3707
|
};
|
|
3834
3708
|
var returnedExpressionNeedsProvenance = (expression) => {
|
|
3835
3709
|
const inner = peel(expression);
|
|
3836
|
-
if (
|
|
3837
|
-
if (
|
|
3710
|
+
if (ts14.isAwaitExpression(inner)) return true;
|
|
3711
|
+
if (ts14.isCallExpression(inner)) return callCanCarryProvenance2(inner);
|
|
3838
3712
|
return false;
|
|
3839
3713
|
};
|
|
3840
3714
|
var functionNeedsProvenance = (node) => {
|
|
3841
|
-
if (
|
|
3715
|
+
if (ts14.isArrowFunction(node) && !ts14.isBlock(node.body)) {
|
|
3842
3716
|
const body = peel(node.body);
|
|
3843
|
-
if (
|
|
3844
|
-
if (
|
|
3717
|
+
if (ts14.isAwaitExpression(body)) return true;
|
|
3718
|
+
if (ts14.isCallExpression(body)) return callCanCarryProvenance2(body);
|
|
3845
3719
|
return false;
|
|
3846
3720
|
}
|
|
3847
3721
|
let needed = false;
|
|
3848
3722
|
walkOwnBody2(node, (candidate) => {
|
|
3849
3723
|
if (needed) return;
|
|
3850
|
-
if (
|
|
3724
|
+
if (ts14.isAwaitExpression(candidate)) {
|
|
3851
3725
|
needed = true;
|
|
3852
3726
|
return;
|
|
3853
3727
|
}
|
|
3854
|
-
if (
|
|
3728
|
+
if (ts14.isReturnStatement(candidate) && candidate.expression) {
|
|
3855
3729
|
if (returnedExpressionNeedsProvenance(candidate.expression)) needed = true;
|
|
3856
3730
|
return;
|
|
3857
3731
|
}
|
|
3858
|
-
if (
|
|
3732
|
+
if (ts14.isCallExpression(candidate)) {
|
|
3859
3733
|
const name = producerName(candidate);
|
|
3860
3734
|
if (name === "json" || name === "parse") needed = true;
|
|
3861
3735
|
}
|
|
@@ -3863,9 +3737,9 @@ var functionNeedsProvenance = (node) => {
|
|
|
3863
3737
|
return needed;
|
|
3864
3738
|
};
|
|
3865
3739
|
var collectReturnWraps2 = (node, sourceFile, handleName, edits) => {
|
|
3866
|
-
if (!
|
|
3740
|
+
if (!ts14.isBlock(node.body)) return;
|
|
3867
3741
|
walkOwnBody2(node, (candidate) => {
|
|
3868
|
-
if (!
|
|
3742
|
+
if (!ts14.isReturnStatement(candidate) || !candidate.expression) return;
|
|
3869
3743
|
wrap(
|
|
3870
3744
|
edits,
|
|
3871
3745
|
candidate.expression.getStart(sourceFile),
|
|
@@ -3878,7 +3752,7 @@ var collectReturnWraps2 = (node, sourceFile, handleName, edits) => {
|
|
|
3878
3752
|
};
|
|
3879
3753
|
var collectAwaitSuspends = (node, sourceFile, handleName, edits) => {
|
|
3880
3754
|
walkOwnBody2(node, (candidate) => {
|
|
3881
|
-
if (!
|
|
3755
|
+
if (!ts14.isAwaitExpression(candidate)) return;
|
|
3882
3756
|
wrap(
|
|
3883
3757
|
edits,
|
|
3884
3758
|
candidate.expression.getStart(sourceFile),
|
|
@@ -3890,12 +3764,12 @@ var collectAwaitSuspends = (node, sourceFile, handleName, edits) => {
|
|
|
3890
3764
|
});
|
|
3891
3765
|
};
|
|
3892
3766
|
var functionRef2 = (node) => {
|
|
3893
|
-
if (node.name &&
|
|
3894
|
-
if (
|
|
3767
|
+
if (node.name && ts14.isIdentifier(node.name)) {
|
|
3768
|
+
if (ts14.isMethodDeclaration(node)) return void 0;
|
|
3895
3769
|
return node.name.text;
|
|
3896
3770
|
}
|
|
3897
3771
|
const parent = node.parent;
|
|
3898
|
-
if (
|
|
3772
|
+
if (ts14.isVariableDeclaration(parent) && ts14.isIdentifier(parent.name) && parent.initializer === node) {
|
|
3899
3773
|
return parent.name.text;
|
|
3900
3774
|
}
|
|
3901
3775
|
return void 0;
|
|
@@ -3912,7 +3786,7 @@ var collectProvenanceFunctionEdits = (source, sourceFile) => {
|
|
|
3912
3786
|
const ref = functionRef2(node);
|
|
3913
3787
|
const enter = ref ? `${PROVENANCE_HANDLE_CALLEE}(${ref})` : `${PROVENANCE_HANDLE_CALLEE}()`;
|
|
3914
3788
|
const epilogue = `}catch(${errorName}){throw ${errorName};}finally{${handleName}.end();}`;
|
|
3915
|
-
if (
|
|
3789
|
+
if (ts14.isBlock(node.body)) {
|
|
3916
3790
|
const openAt = functionBodyPrologueEnd2(node.body, sourceFile);
|
|
3917
3791
|
const closeAt = node.body.end - 1;
|
|
3918
3792
|
wrap(edits, openAt, closeAt, `;const ${handleName}=${enter};try{`, epilogue, 0);
|
|
@@ -3936,7 +3810,7 @@ var collectProvenanceFunctionEdits = (source, sourceFile) => {
|
|
|
3936
3810
|
functionWraps += 1;
|
|
3937
3811
|
}
|
|
3938
3812
|
}
|
|
3939
|
-
|
|
3813
|
+
ts14.forEachChild(node, visit);
|
|
3940
3814
|
};
|
|
3941
3815
|
visit(sourceFile);
|
|
3942
3816
|
if (functionWraps > 0) {
|
|
@@ -4003,7 +3877,7 @@ var instrumentProvenanceSource = (source, filePath) => {
|
|
|
4003
3877
|
};
|
|
4004
3878
|
|
|
4005
3879
|
// ../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/");
|
|
3880
|
+
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
3881
|
var isBundledDependencyPath = (path) => /(^|\/)node_modules\//.test(path) || path.includes("/.vite/deps/") || path.includes("node_modules/.vite/deps/");
|
|
4008
3882
|
var coverageForModule = (filePath, options) => {
|
|
4009
3883
|
const path = filePath.replaceAll("\\", "/");
|
|
@@ -4084,6 +3958,13 @@ var contentDebugId = (source) => {
|
|
|
4084
3958
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
|
|
4085
3959
|
};
|
|
4086
3960
|
var contentHash = (value) => createHash3("sha256").update(JSON.stringify(value)).digest("hex");
|
|
3961
|
+
var omitSourceMapSourcesContent = (map) => {
|
|
3962
|
+
if (!map || typeof map !== "object" || Array.isArray(map)) return map;
|
|
3963
|
+
if (!("sourcesContent" in map)) return map;
|
|
3964
|
+
const next = { ...map };
|
|
3965
|
+
Reflect.deleteProperty(next, "sourcesContent");
|
|
3966
|
+
return next;
|
|
3967
|
+
};
|
|
4087
3968
|
var summarizeClassification = (functions, expressionSites) => {
|
|
4088
3969
|
const counts = {
|
|
4089
3970
|
full: 0,
|
|
@@ -4149,24 +4030,26 @@ var uploadBrowserArtifacts = async (input) => {
|
|
|
4149
4030
|
""
|
|
4150
4031
|
);
|
|
4151
4032
|
try {
|
|
4033
|
+
const { body, gzip } = encodeJsonRequestBody({
|
|
4034
|
+
buildId: input.artifacts.buildId,
|
|
4035
|
+
release: input.release,
|
|
4036
|
+
contentHash: contentHash(input.artifacts),
|
|
4037
|
+
artifact: input.artifacts,
|
|
4038
|
+
...input.replace === true ? { replace: true } : {}
|
|
4039
|
+
});
|
|
4152
4040
|
const response = await fetch(`${apiUrl}/browserArtifacts`, {
|
|
4153
4041
|
method: "POST",
|
|
4154
4042
|
headers: {
|
|
4155
4043
|
authorization: `Bearer ${key}`,
|
|
4156
|
-
"content-type": "application/json"
|
|
4044
|
+
"content-type": "application/json",
|
|
4045
|
+
...gzip ? { "content-encoding": "gzip" } : {}
|
|
4157
4046
|
},
|
|
4158
|
-
body
|
|
4159
|
-
buildId: input.artifacts.buildId,
|
|
4160
|
-
release: input.release,
|
|
4161
|
-
contentHash: contentHash(input.artifacts),
|
|
4162
|
-
artifact: input.artifacts,
|
|
4163
|
-
...input.replace === true ? { replace: true } : {}
|
|
4164
|
-
})
|
|
4047
|
+
body
|
|
4165
4048
|
});
|
|
4166
4049
|
if (response.status === 409) return "conflict";
|
|
4167
4050
|
if (response.status === 200 || response.status === 201) {
|
|
4168
|
-
const
|
|
4169
|
-
if (
|
|
4051
|
+
const body2 = await response.json().catch(() => ({}));
|
|
4052
|
+
if (body2 && typeof body2 === "object" && "duplicate" in body2 && body2.duplicate === true) {
|
|
4170
4053
|
return "duplicate";
|
|
4171
4054
|
}
|
|
4172
4055
|
return "uploaded";
|
|
@@ -4183,7 +4066,7 @@ var uploadBrowserArtifacts = async (input) => {
|
|
|
4183
4066
|
|
|
4184
4067
|
// src/vite/plugin.ts
|
|
4185
4068
|
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/");
|
|
4069
|
+
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
4070
|
var isRasputinBrowserRuntimeSource = (code) => code.includes("rasputin.browser.client.v1");
|
|
4188
4071
|
var isJsModulePath = (path) => /\.[cm]?[jt]sx?$/.test(path) && !isSvelteCompiledPath(path);
|
|
4189
4072
|
var MAX_PROVENANCE_SOURCE_CHARS = 15e5;
|
|
@@ -4365,7 +4248,10 @@ var rasputin = (options) => {
|
|
|
4365
4248
|
destructures: [...destructures.values()],
|
|
4366
4249
|
expressionSites: sites,
|
|
4367
4250
|
classification: summarizeClassification(manifestFunctions, sites),
|
|
4368
|
-
debugImages
|
|
4251
|
+
debugImages: debugImages.map((image) => ({
|
|
4252
|
+
...image,
|
|
4253
|
+
map: omitSourceMapSourcesContent(image.map)
|
|
4254
|
+
})),
|
|
4369
4255
|
verificationFailed: [...verificationFailed],
|
|
4370
4256
|
provenance: { ...provenanceStats }
|
|
4371
4257
|
};
|