@decantr/verifier 3.0.2 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/index.d.ts +134 -1
- package/dist/index.js +1219 -381
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/schema/evidence-bundle.v2.json +436 -0
- package/schema/runtime-probe-payload.v2.json +218 -0
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { createHash } from "crypto";
|
|
3
|
-
import { existsSync as
|
|
3
|
+
import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync6, realpathSync as realpathSync2, statSync as statSync5 } from "fs";
|
|
4
4
|
import { readFile } from "fs/promises";
|
|
5
|
-
import { basename as basename2, dirname, extname as
|
|
5
|
+
import { basename as basename2, dirname as dirname2, extname as extname6, isAbsolute as isAbsolute4, join as join6, relative as relative6, resolve as resolve3 } from "path";
|
|
6
6
|
import { evaluateGuard, isV4, validateEssence } from "@decantr/essence-spec";
|
|
7
|
-
import * as
|
|
7
|
+
import * as ts6 from "typescript";
|
|
8
8
|
|
|
9
9
|
// src/component-reuse.ts
|
|
10
10
|
import { readFileSync } from "fs";
|
|
@@ -968,6 +968,22 @@ function normalizePath2(path) {
|
|
|
968
968
|
function stringArray(value) {
|
|
969
969
|
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string" && entry.length > 0) : [];
|
|
970
970
|
}
|
|
971
|
+
function normalizedConfidence(value) {
|
|
972
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return null;
|
|
973
|
+
return Math.max(0, Math.min(1, value));
|
|
974
|
+
}
|
|
975
|
+
function nativeTokenHint(mapping) {
|
|
976
|
+
const kind = typeof mapping.native?.kind === "string" ? mapping.native.kind : null;
|
|
977
|
+
const ref = typeof mapping.native?.ref === "string" ? mapping.native.ref : null;
|
|
978
|
+
if (!kind || !ref) return null;
|
|
979
|
+
return kind === "css-var" || kind === "vanilla-extract-token" || kind === "sass-var" ? ref : null;
|
|
980
|
+
}
|
|
981
|
+
function nativeClassHint(mapping) {
|
|
982
|
+
const kind = typeof mapping.native?.kind === "string" ? mapping.native.kind : null;
|
|
983
|
+
const ref = typeof mapping.native?.ref === "string" ? mapping.native.ref : null;
|
|
984
|
+
if (!kind || !ref) return null;
|
|
985
|
+
return kind === "class" || kind === "tailwind-class" || kind === "component" ? ref : null;
|
|
986
|
+
}
|
|
971
987
|
function isNonProductionStyleBridgeDriftFile(file) {
|
|
972
988
|
const normalized = normalizePath2(file);
|
|
973
989
|
return /(?:^|\/)(?:__tests__|__mocks__|tests?|specs?|fixtures?|mocks?|stories?)(?:\/|$)/i.test(
|
|
@@ -1022,12 +1038,28 @@ function readAcceptedStyleBridge(projectRoot) {
|
|
|
1022
1038
|
(mapping, index) => typeof mapping.id === "string" && mapping.id.length > 0 ? mapping.id : typeof mapping.label === "string" && mapping.label.length > 0 ? mapping.label : `mapping-${index + 1}`
|
|
1023
1039
|
).slice(0, 12);
|
|
1024
1040
|
const tokenHints = [
|
|
1025
|
-
...new Set(
|
|
1026
|
-
|
|
1041
|
+
...new Set(
|
|
1042
|
+
mappings.flatMap((mapping) => [...stringArray(mapping.tokenHints), nativeTokenHint(mapping)])
|
|
1043
|
+
)
|
|
1044
|
+
].filter((entry) => Boolean(entry)).slice(0, 16);
|
|
1027
1045
|
const classHints = [
|
|
1028
|
-
...new Set(
|
|
1046
|
+
...new Set(
|
|
1047
|
+
mappings.flatMap((mapping) => [...stringArray(mapping.classHints), nativeClassHint(mapping)])
|
|
1048
|
+
)
|
|
1049
|
+
].filter((entry) => Boolean(entry)).slice(0, 16);
|
|
1050
|
+
const confidences = mappings.map((mapping) => normalizedConfidence(mapping.confidence)).filter((entry) => entry !== null);
|
|
1051
|
+
const sources = [
|
|
1052
|
+
...new Set(
|
|
1053
|
+
mappings.map((mapping) => mapping.source).filter((source) => typeof source === "string" && source.length > 0)
|
|
1054
|
+
)
|
|
1029
1055
|
].slice(0, 16);
|
|
1030
|
-
return {
|
|
1056
|
+
return {
|
|
1057
|
+
mappingIds,
|
|
1058
|
+
confidence: confidences.length > 0 ? Math.max(...confidences) : null,
|
|
1059
|
+
sources,
|
|
1060
|
+
tokenHints,
|
|
1061
|
+
classHints
|
|
1062
|
+
};
|
|
1031
1063
|
}
|
|
1032
1064
|
function lineForNode2(sourceFile, node) {
|
|
1033
1065
|
return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;
|
|
@@ -1137,7 +1169,7 @@ function arbitraryInlineStyleValue(property, value, tokenHints) {
|
|
|
1137
1169
|
if (isAcceptedTokenValue(normalizedValue, tokenHints)) return null;
|
|
1138
1170
|
if (/(?:^|[\s,(])#[0-9a-f]{3,8}\b|(?:rgba?|hsla?|oklch|oklab|lch|lab|color-mix)\(/i.test(
|
|
1139
1171
|
normalizedValue
|
|
1140
|
-
)
|
|
1172
|
+
)) {
|
|
1141
1173
|
return `${normalizedProperty}: ${normalizedValue}`;
|
|
1142
1174
|
}
|
|
1143
1175
|
return null;
|
|
@@ -1184,11 +1216,15 @@ function collectStyleBridgeDriftFindings(input) {
|
|
|
1184
1216
|
source,
|
|
1185
1217
|
...property ? { property } : {},
|
|
1186
1218
|
bridgeMappingIds: input.bridge.mappingIds,
|
|
1219
|
+
bridgeConfidence: input.bridge.confidence,
|
|
1220
|
+
bridgeSources: input.bridge.sources,
|
|
1187
1221
|
tokenHints: input.bridge.tokenHints,
|
|
1188
1222
|
classHints: input.bridge.classHints,
|
|
1189
1223
|
evidence: [
|
|
1190
1224
|
styleBridgeEvidenceText(file, line, source, value),
|
|
1191
1225
|
`.decantr/style-bridge.json is accepted with mappings: ${input.bridge.mappingIds.join(", ")}`,
|
|
1226
|
+
input.bridge.confidence === null ? "Accepted style bridge has no mapping confidence metadata" : `Accepted style bridge max confidence: ${input.bridge.confidence.toFixed(2)}`,
|
|
1227
|
+
input.bridge.sources.length > 0 ? `Accepted style bridge mapping sources: ${input.bridge.sources.join(", ")}` : "Accepted style bridge has no mapping source metadata",
|
|
1192
1228
|
input.bridge.tokenHints.length > 0 ? `Accepted token hints: ${input.bridge.tokenHints.join(", ")}` : "Accepted style bridge has no token hints for this mapping set",
|
|
1193
1229
|
input.bridge.classHints.length > 0 ? `Accepted class hints: ${input.bridge.classHints.join(", ")}` : "Accepted style bridge has no class hints for this mapping set"
|
|
1194
1230
|
]
|
|
@@ -1265,11 +1301,15 @@ function collectStylesheetBridgeDriftFindings(input) {
|
|
|
1265
1301
|
source: "stylesheet",
|
|
1266
1302
|
property,
|
|
1267
1303
|
bridgeMappingIds: input.bridge.mappingIds,
|
|
1304
|
+
bridgeConfidence: input.bridge.confidence,
|
|
1305
|
+
bridgeSources: input.bridge.sources,
|
|
1268
1306
|
tokenHints: input.bridge.tokenHints,
|
|
1269
1307
|
classHints: input.bridge.classHints,
|
|
1270
1308
|
evidence: [
|
|
1271
1309
|
`${file}:${lineNumber} uses stylesheet value "${value}"`,
|
|
1272
1310
|
`.decantr/style-bridge.json is accepted with mappings: ${input.bridge.mappingIds.join(", ")}`,
|
|
1311
|
+
input.bridge.confidence === null ? "Accepted style bridge has no mapping confidence metadata" : `Accepted style bridge max confidence: ${input.bridge.confidence.toFixed(2)}`,
|
|
1312
|
+
input.bridge.sources.length > 0 ? `Accepted style bridge mapping sources: ${input.bridge.sources.join(", ")}` : "Accepted style bridge has no mapping source metadata",
|
|
1273
1313
|
input.bridge.tokenHints.length > 0 ? `Accepted token hints: ${input.bridge.tokenHints.join(", ")}` : "Accepted style bridge has no token hints for this mapping set",
|
|
1274
1314
|
input.bridge.classHints.length > 0 ? `Accepted class hints: ${input.bridge.classHints.join(", ")}` : "Accepted style bridge has no class hints for this mapping set"
|
|
1275
1315
|
]
|
|
@@ -1324,6 +1364,18 @@ var KNOWN_VERIFICATION_DIAGNOSTICS = [
|
|
|
1324
1364
|
repairId: "fix-route-render",
|
|
1325
1365
|
family: "VISUAL"
|
|
1326
1366
|
},
|
|
1367
|
+
{
|
|
1368
|
+
rule: "browser-runtime-probes-failed",
|
|
1369
|
+
code: "RUNTIME010",
|
|
1370
|
+
repairId: "repair-browser-runtime-probes",
|
|
1371
|
+
family: "RUNTIME"
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
rule: "browser-axe-violations",
|
|
1375
|
+
code: "A11Y020",
|
|
1376
|
+
repairId: "fix-rendered-accessibility",
|
|
1377
|
+
family: "A11Y"
|
|
1378
|
+
},
|
|
1327
1379
|
{
|
|
1328
1380
|
rule: "visual-baseline-screenshot-drift",
|
|
1329
1381
|
code: "VISUAL010",
|
|
@@ -2010,6 +2062,8 @@ var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
2010
2062
|
]);
|
|
2011
2063
|
var STYLE_EXTENSIONS = /* @__PURE__ */ new Set([".css", ".scss", ".sass", ".less"]);
|
|
2012
2064
|
var PAGE_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".vue", ".svelte", ".html"]);
|
|
2065
|
+
var ROUTE_VARIABLE_NAMES = "(?:path|pathname|route|currentPath|currentRoute|locationPath|activePath)";
|
|
2066
|
+
var ROUTE_ASSET_EXTENSION_RE = /\.(?:avif|bmp|css|gif|ico|jpeg|jpg|js|json|map|mp4|pdf|png|svg|webp|woff2?)$/i;
|
|
2013
2067
|
var MAX_FILE_READ_BYTES = 512 * 1024;
|
|
2014
2068
|
var MAX_WALK_FILES = 5e3;
|
|
2015
2069
|
var MAX_REPORT_ROUTES = 80;
|
|
@@ -2290,19 +2344,58 @@ function scanReactRouter(projectRoot) {
|
|
|
2290
2344
|
if (!content) continue;
|
|
2291
2345
|
if (content.includes("HashRouter") || content.includes("createHashRouter")) hashRouting = true;
|
|
2292
2346
|
const jsxRouteRegex = /<Route\b[^>]*\bpath\s*=\s*["']([^"']+)["']/g;
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
routes.set(route, { path: route, file, hasLayout: false });
|
|
2347
|
+
for (const match of content.matchAll(jsxRouteRegex)) {
|
|
2348
|
+
const route = normalizeDetectedRouteLiteral(match[1] || "/");
|
|
2349
|
+
if (route) routes.set(route, { path: route, file, hasLayout: false });
|
|
2297
2350
|
}
|
|
2298
2351
|
const objectRouteRegex = /\bpath\s*:\s*["']([^"']+)["']/g;
|
|
2299
|
-
|
|
2300
|
-
const route = match[1] || "/";
|
|
2301
|
-
if (route
|
|
2352
|
+
for (const match of content.matchAll(objectRouteRegex)) {
|
|
2353
|
+
const route = normalizeDetectedRouteLiteral(match[1] || "/");
|
|
2354
|
+
if (route) routes.set(route, { path: route, file, hasLayout: false });
|
|
2355
|
+
}
|
|
2356
|
+
for (const route of detectPathnameBranchRoutes(content)) {
|
|
2357
|
+
routes.set(route, { path: route, file, hasLayout: false });
|
|
2302
2358
|
}
|
|
2303
2359
|
}
|
|
2304
2360
|
return { routes: [...routes.values()], hashRouting };
|
|
2305
2361
|
}
|
|
2362
|
+
function normalizeDetectedRouteLiteral(value) {
|
|
2363
|
+
const cleaned = value.trim().split(/[?#]/)[0];
|
|
2364
|
+
if (!cleaned || cleaned === "/") return "/";
|
|
2365
|
+
if (cleaned === "*" || cleaned === "**" || cleaned.startsWith("#")) return null;
|
|
2366
|
+
if (!cleaned.startsWith("/") || cleaned.startsWith("//")) return null;
|
|
2367
|
+
if (ROUTE_ASSET_EXTENSION_RE.test(cleaned)) return null;
|
|
2368
|
+
return cleaned.replace(/\/+$/g, "") || "/";
|
|
2369
|
+
}
|
|
2370
|
+
function collectRouteLiterals(pattern, content, routes) {
|
|
2371
|
+
let count = 0;
|
|
2372
|
+
for (const match of content.matchAll(pattern)) {
|
|
2373
|
+
const route = normalizeDetectedRouteLiteral(match[1] ?? "");
|
|
2374
|
+
if (!route) continue;
|
|
2375
|
+
routes.add(route);
|
|
2376
|
+
count += 1;
|
|
2377
|
+
}
|
|
2378
|
+
return count;
|
|
2379
|
+
}
|
|
2380
|
+
function detectPathnameBranchRoutes(content) {
|
|
2381
|
+
const routes = /* @__PURE__ */ new Set();
|
|
2382
|
+
const comparison = new RegExp(
|
|
2383
|
+
`\\b${ROUTE_VARIABLE_NAMES}\\b\\s*(?:===|!==|==|!=)\\s*["'\`](\\/[^"'\`]+)["'\`]`,
|
|
2384
|
+
"g"
|
|
2385
|
+
);
|
|
2386
|
+
const reversedComparison = new RegExp(
|
|
2387
|
+
`["'\`](\\/[^"'\`]+)["'\`]\\s*(?:===|!==|==|!=)\\s*\\b${ROUTE_VARIABLE_NAMES}\\b`,
|
|
2388
|
+
"g"
|
|
2389
|
+
);
|
|
2390
|
+
const strongMatches = collectRouteLiterals(comparison, content, routes) + collectRouteLiterals(reversedComparison, content, routes) + collectRouteLiterals(/\bcase\s+["'`](\/[^"'`]+)["'`]\s*:/g, content, routes);
|
|
2391
|
+
const hasPathnameSignal = /\b(?:window\.|document\.)?location\.pathname\b|\bpathname\b/.test(
|
|
2392
|
+
content
|
|
2393
|
+
);
|
|
2394
|
+
if (strongMatches > 0 || hasPathnameSignal) {
|
|
2395
|
+
collectRouteLiterals(/\b(?:href|to)\s*=\s*["'`](\/[^"'`]+)["'`]/g, content, routes);
|
|
2396
|
+
}
|
|
2397
|
+
return [...routes];
|
|
2398
|
+
}
|
|
2306
2399
|
function scanRoutes(projectRoot, detection) {
|
|
2307
2400
|
const appRoutes = ["src/app", "app"].flatMap(
|
|
2308
2401
|
(dir) => existsSync3(join3(projectRoot, dir)) ? walkNextAppRoutes(join3(projectRoot, dir), projectRoot, []) : []
|
|
@@ -2924,6 +3017,716 @@ function resolveGitHubScanInput(input) {
|
|
|
2924
3017
|
throw new Error("V1 hosted scans support GitHub repositories and GitHub Pages URLs.");
|
|
2925
3018
|
}
|
|
2926
3019
|
|
|
3020
|
+
// src/source/ast.ts
|
|
3021
|
+
import * as ts4 from "typescript";
|
|
3022
|
+
|
|
3023
|
+
// src/source/inventory.ts
|
|
3024
|
+
import { existsSync as existsSync4, readdirSync as readdirSync4, realpathSync, statSync as statSync3 } from "fs";
|
|
3025
|
+
import { extname as extname4, isAbsolute as isAbsolute2, join as join4, relative as relative4, resolve } from "path";
|
|
3026
|
+
import * as ts3 from "typescript";
|
|
3027
|
+
var DEFAULT_MAX_FILES = 5e3;
|
|
3028
|
+
var DEFAULT_MAX_FILE_SIZE_BYTES = 512 * 1024;
|
|
3029
|
+
var DEFAULT_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
3030
|
+
var GENERATED_AND_DEPENDENCY_DIRS = /* @__PURE__ */ new Set([
|
|
3031
|
+
".cache",
|
|
3032
|
+
".git",
|
|
3033
|
+
".next",
|
|
3034
|
+
".nuxt",
|
|
3035
|
+
".svelte-kit",
|
|
3036
|
+
".turbo",
|
|
3037
|
+
".vite",
|
|
3038
|
+
"build",
|
|
3039
|
+
"coverage",
|
|
3040
|
+
"dist",
|
|
3041
|
+
"node_modules",
|
|
3042
|
+
"out",
|
|
3043
|
+
"target",
|
|
3044
|
+
"vendor"
|
|
3045
|
+
]);
|
|
3046
|
+
var TEST_OR_MOCK_DIR_RE = /(?:^|\/)(?:__mocks__|__tests__|mocks?|specs?|tests?)(?:\/|$)/i;
|
|
3047
|
+
var FIXTURE_DIR_RE = /(?:^|\/)fixtures?(?:\/|$)/i;
|
|
3048
|
+
var DECLARATION_FILE_RE = /\.d\.[cm]?ts$/i;
|
|
3049
|
+
var TEST_OR_MOCK_FILE_RE = /\.(?:mock|spec|test)\.[cm]?[jt]sx?$/i;
|
|
3050
|
+
var STORY_FILE_RE = /\.(?:stories|story)\.[cm]?[jt]sx?$/i;
|
|
3051
|
+
var FIXTURE_FILE_RE = /\.fixture\.[cm]?[jt]sx?$/i;
|
|
3052
|
+
function normalizeSourcePath(path) {
|
|
3053
|
+
return path.replace(/\\/g, "/");
|
|
3054
|
+
}
|
|
3055
|
+
function isPathInsideProject(projectRoot, absolutePath) {
|
|
3056
|
+
const normalizedRelative = normalizeSourcePath(relative4(projectRoot, absolutePath));
|
|
3057
|
+
return normalizedRelative === "" || !normalizedRelative.startsWith("../") && normalizedRelative !== "..";
|
|
3058
|
+
}
|
|
3059
|
+
function isSupportedSourceExtension(extension, extensions) {
|
|
3060
|
+
const normalized = extension.toLowerCase();
|
|
3061
|
+
return extensions ? extensions.map((entry) => entry.toLowerCase()).includes(normalized) : DEFAULT_EXTENSIONS.has(normalized);
|
|
3062
|
+
}
|
|
3063
|
+
function sourceKindFromPath(path) {
|
|
3064
|
+
const extension = extname4(path).toLowerCase();
|
|
3065
|
+
switch (extension) {
|
|
3066
|
+
case ".ts":
|
|
3067
|
+
return "ts";
|
|
3068
|
+
case ".tsx":
|
|
3069
|
+
return "tsx";
|
|
3070
|
+
case ".mts":
|
|
3071
|
+
return "mts";
|
|
3072
|
+
case ".cts":
|
|
3073
|
+
return "cts";
|
|
3074
|
+
case ".js":
|
|
3075
|
+
return "js";
|
|
3076
|
+
case ".jsx":
|
|
3077
|
+
return "jsx";
|
|
3078
|
+
case ".mjs":
|
|
3079
|
+
return "mjs";
|
|
3080
|
+
case ".cjs":
|
|
3081
|
+
return "cjs";
|
|
3082
|
+
default:
|
|
3083
|
+
return null;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
function sourceScriptKindFromPath(path) {
|
|
3087
|
+
const kind = sourceKindFromPath(path);
|
|
3088
|
+
switch (kind) {
|
|
3089
|
+
case "ts":
|
|
3090
|
+
case "mts":
|
|
3091
|
+
case "cts":
|
|
3092
|
+
return ts3.ScriptKind.TS;
|
|
3093
|
+
case "tsx":
|
|
3094
|
+
return ts3.ScriptKind.TSX;
|
|
3095
|
+
case "jsx":
|
|
3096
|
+
return ts3.ScriptKind.JSX;
|
|
3097
|
+
case "js":
|
|
3098
|
+
case "mjs":
|
|
3099
|
+
case "cjs":
|
|
3100
|
+
return ts3.ScriptKind.JS;
|
|
3101
|
+
default:
|
|
3102
|
+
return ts3.ScriptKind.Unknown;
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
function sourceLanguageFromPath(path) {
|
|
3106
|
+
const kind = sourceKindFromPath(path);
|
|
3107
|
+
if (!kind) return null;
|
|
3108
|
+
return kind === "ts" || kind === "tsx" || kind === "mts" || kind === "cts" ? "typescript" : "javascript";
|
|
3109
|
+
}
|
|
3110
|
+
function shouldSkipDirectory(relativePath, options) {
|
|
3111
|
+
const normalized = normalizeSourcePath(relativePath);
|
|
3112
|
+
const basename3 = normalized.split("/").at(-1) ?? normalized;
|
|
3113
|
+
if (GENERATED_AND_DEPENDENCY_DIRS.has(basename3)) return true;
|
|
3114
|
+
if (!options.includeTests && TEST_OR_MOCK_DIR_RE.test(normalized)) return true;
|
|
3115
|
+
if (!options.includeFixtures && FIXTURE_DIR_RE.test(normalized)) return true;
|
|
3116
|
+
return false;
|
|
3117
|
+
}
|
|
3118
|
+
function shouldSkipFile(relativePath, options) {
|
|
3119
|
+
const normalized = normalizeSourcePath(relativePath);
|
|
3120
|
+
if (DECLARATION_FILE_RE.test(normalized)) return true;
|
|
3121
|
+
if (!options.includeTests && (TEST_OR_MOCK_FILE_RE.test(normalized) || STORY_FILE_RE.test(normalized))) {
|
|
3122
|
+
return true;
|
|
3123
|
+
}
|
|
3124
|
+
if (!options.includeFixtures && FIXTURE_FILE_RE.test(normalized)) return true;
|
|
3125
|
+
return false;
|
|
3126
|
+
}
|
|
3127
|
+
function inventoryFile(projectRoot, absolutePath) {
|
|
3128
|
+
const extension = extname4(absolutePath).toLowerCase();
|
|
3129
|
+
const kind = sourceKindFromPath(absolutePath);
|
|
3130
|
+
const language = sourceLanguageFromPath(absolutePath);
|
|
3131
|
+
if (!kind || !language) return null;
|
|
3132
|
+
const relativePath = normalizeSourcePath(relative4(projectRoot, absolutePath) || absolutePath);
|
|
3133
|
+
const sizeBytes = statSync3(absolutePath).size;
|
|
3134
|
+
return {
|
|
3135
|
+
absolutePath,
|
|
3136
|
+
relativePath,
|
|
3137
|
+
extension,
|
|
3138
|
+
kind,
|
|
3139
|
+
language,
|
|
3140
|
+
scriptKind: sourceScriptKindFromPath(absolutePath),
|
|
3141
|
+
jsx: kind === "tsx" || kind === "jsx",
|
|
3142
|
+
sizeBytes
|
|
3143
|
+
};
|
|
3144
|
+
}
|
|
3145
|
+
function compareSourceFiles(a, b) {
|
|
3146
|
+
return a.relativePath.localeCompare(b.relativePath);
|
|
3147
|
+
}
|
|
3148
|
+
function compareSkipped(a, b) {
|
|
3149
|
+
return a.path.localeCompare(b.path) || a.reason.localeCompare(b.reason);
|
|
3150
|
+
}
|
|
3151
|
+
function createSourceInventory(projectRoot, options = {}) {
|
|
3152
|
+
const root = realpathSync(resolve(projectRoot));
|
|
3153
|
+
const files = [];
|
|
3154
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
3155
|
+
const skipped = [];
|
|
3156
|
+
const maxFiles = options.maxFiles ?? DEFAULT_MAX_FILES;
|
|
3157
|
+
const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
|
|
3158
|
+
const requestedRoots = options.roots?.length ? [...options.roots] : ["."];
|
|
3159
|
+
const roots = requestedRoots.map((entry) => isAbsolute2(entry) ? resolve(entry) : resolve(root, entry)).filter((entry) => existsSync4(entry) && isPathInsideProject(root, entry));
|
|
3160
|
+
const addSkipped = (path, reason) => {
|
|
3161
|
+
skipped.push({ path: normalizeSourcePath(relative4(root, path) || path), reason });
|
|
3162
|
+
};
|
|
3163
|
+
const addFile = (absolutePath) => {
|
|
3164
|
+
const normalized = normalizeSourcePath(resolve(absolutePath));
|
|
3165
|
+
if (seenFiles.has(normalized)) return;
|
|
3166
|
+
const sourceFile = inventoryFile(root, absolutePath);
|
|
3167
|
+
if (!sourceFile) return;
|
|
3168
|
+
seenFiles.add(normalized);
|
|
3169
|
+
files.push(sourceFile);
|
|
3170
|
+
};
|
|
3171
|
+
const walk = (directory) => {
|
|
3172
|
+
if (files.length >= maxFiles) {
|
|
3173
|
+
addSkipped(directory, "walk-limit");
|
|
3174
|
+
return;
|
|
3175
|
+
}
|
|
3176
|
+
const entries = readdirSync4(directory, { withFileTypes: true }).sort(
|
|
3177
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
3178
|
+
);
|
|
3179
|
+
for (const entry of entries) {
|
|
3180
|
+
if (files.length >= maxFiles) {
|
|
3181
|
+
addSkipped(join4(directory, entry.name), "walk-limit");
|
|
3182
|
+
continue;
|
|
3183
|
+
}
|
|
3184
|
+
const absolutePath = join4(directory, entry.name);
|
|
3185
|
+
const relativePath = normalizeSourcePath(relative4(root, absolutePath) || absolutePath);
|
|
3186
|
+
if (entry.isSymbolicLink()) {
|
|
3187
|
+
addSkipped(absolutePath, "symlink");
|
|
3188
|
+
continue;
|
|
3189
|
+
}
|
|
3190
|
+
if (entry.isDirectory()) {
|
|
3191
|
+
if (shouldSkipDirectory(relativePath, options)) {
|
|
3192
|
+
addSkipped(absolutePath, "ignored-directory");
|
|
3193
|
+
continue;
|
|
3194
|
+
}
|
|
3195
|
+
walk(absolutePath);
|
|
3196
|
+
continue;
|
|
3197
|
+
}
|
|
3198
|
+
if (!entry.isFile()) continue;
|
|
3199
|
+
const extension = extname4(entry.name).toLowerCase();
|
|
3200
|
+
if (!isSupportedSourceExtension(extension, options.extensions)) continue;
|
|
3201
|
+
if (shouldSkipFile(relativePath, options)) {
|
|
3202
|
+
addSkipped(absolutePath, "ignored-file");
|
|
3203
|
+
continue;
|
|
3204
|
+
}
|
|
3205
|
+
const stat = statSync3(absolutePath);
|
|
3206
|
+
if (stat.size > maxFileSizeBytes) {
|
|
3207
|
+
addSkipped(absolutePath, "oversized");
|
|
3208
|
+
continue;
|
|
3209
|
+
}
|
|
3210
|
+
addFile(absolutePath);
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
for (const rootPath of roots) {
|
|
3214
|
+
if (files.length >= maxFiles) {
|
|
3215
|
+
addSkipped(rootPath, "walk-limit");
|
|
3216
|
+
continue;
|
|
3217
|
+
}
|
|
3218
|
+
const stat = statSync3(rootPath);
|
|
3219
|
+
if (stat.isDirectory()) {
|
|
3220
|
+
const relativeRoot = normalizeSourcePath(relative4(root, rootPath));
|
|
3221
|
+
if (relativeRoot && shouldSkipDirectory(relativeRoot, options)) {
|
|
3222
|
+
addSkipped(rootPath, "ignored-directory");
|
|
3223
|
+
continue;
|
|
3224
|
+
}
|
|
3225
|
+
walk(rootPath);
|
|
3226
|
+
} else if (stat.isFile()) {
|
|
3227
|
+
const extension = extname4(rootPath).toLowerCase();
|
|
3228
|
+
if (!isSupportedSourceExtension(extension, options.extensions)) continue;
|
|
3229
|
+
const relativeFile = normalizeSourcePath(relative4(root, rootPath));
|
|
3230
|
+
if (shouldSkipFile(relativeFile, options)) {
|
|
3231
|
+
addSkipped(rootPath, "ignored-file");
|
|
3232
|
+
continue;
|
|
3233
|
+
}
|
|
3234
|
+
addFile(rootPath);
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
const sortedFiles = files.sort(compareSourceFiles);
|
|
3238
|
+
const hasTypeScript = sortedFiles.some((file) => file.language === "typescript");
|
|
3239
|
+
const hasJavaScript = sortedFiles.some((file) => file.language === "javascript");
|
|
3240
|
+
return {
|
|
3241
|
+
projectRoot: root,
|
|
3242
|
+
files: sortedFiles,
|
|
3243
|
+
skipped: skipped.sort(compareSkipped),
|
|
3244
|
+
hasTypeScript,
|
|
3245
|
+
hasJavaScript,
|
|
3246
|
+
primaryLanguage: hasTypeScript && hasJavaScript ? "mixed" : hasTypeScript ? "typescript" : hasJavaScript ? "javascript" : "unknown"
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3249
|
+
|
|
3250
|
+
// src/source/ast.ts
|
|
3251
|
+
function sourceLocationForNode(sourceFile, node) {
|
|
3252
|
+
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
3253
|
+
return {
|
|
3254
|
+
file: normalizeSourcePath(sourceFile.fileName),
|
|
3255
|
+
line: position.line + 1,
|
|
3256
|
+
column: position.character + 1
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
function literalRawText(node) {
|
|
3260
|
+
return node.getText();
|
|
3261
|
+
}
|
|
3262
|
+
function isStringLiteralLike(node) {
|
|
3263
|
+
return ts4.isStringLiteral(node) || ts4.isNoSubstitutionTemplateLiteral(node);
|
|
3264
|
+
}
|
|
3265
|
+
function isImportSpecifierLiteral(node) {
|
|
3266
|
+
const parent = node.parent;
|
|
3267
|
+
return ts4.isImportDeclaration(parent) && parent.moduleSpecifier === node || ts4.isExternalModuleReference(parent) && parent.expression === node;
|
|
3268
|
+
}
|
|
3269
|
+
function isExportSpecifierLiteral(node) {
|
|
3270
|
+
const parent = node.parent;
|
|
3271
|
+
return ts4.isExportDeclaration(parent) && parent.moduleSpecifier === node;
|
|
3272
|
+
}
|
|
3273
|
+
function requireOrDynamicImportContext(node) {
|
|
3274
|
+
const parent = node.parent;
|
|
3275
|
+
if (!ts4.isCallExpression(parent) || parent.arguments[0] !== node) return null;
|
|
3276
|
+
if (parent.expression.kind === ts4.SyntaxKind.ImportKeyword) return "dynamic-import-specifier";
|
|
3277
|
+
if (ts4.isIdentifier(parent.expression) && parent.expression.text === "require") {
|
|
3278
|
+
return "require-specifier";
|
|
3279
|
+
}
|
|
3280
|
+
return null;
|
|
3281
|
+
}
|
|
3282
|
+
function propertyNameContext(node) {
|
|
3283
|
+
const parent = node.parent;
|
|
3284
|
+
if ((ts4.isPropertyAssignment(parent) || ts4.isPropertyDeclaration(parent) || ts4.isMethodDeclaration(parent) || ts4.isGetAccessorDeclaration(parent) || ts4.isSetAccessorDeclaration(parent)) && parent.name === node) {
|
|
3285
|
+
return "property-name";
|
|
3286
|
+
}
|
|
3287
|
+
return null;
|
|
3288
|
+
}
|
|
3289
|
+
function jsxAttributeContext(node) {
|
|
3290
|
+
const parent = node.parent;
|
|
3291
|
+
if (!ts4.isJsxAttribute(parent) || parent.initializer !== node) return null;
|
|
3292
|
+
return {
|
|
3293
|
+
context: "jsx-attribute",
|
|
3294
|
+
attributeName: parent.name.getText()
|
|
3295
|
+
};
|
|
3296
|
+
}
|
|
3297
|
+
function literalContext(node) {
|
|
3298
|
+
const jsxContext = jsxAttributeContext(node);
|
|
3299
|
+
if (jsxContext) return jsxContext;
|
|
3300
|
+
const importLikeContext = requireOrDynamicImportContext(node);
|
|
3301
|
+
if (importLikeContext) return { context: importLikeContext };
|
|
3302
|
+
if (isImportSpecifierLiteral(node)) return { context: "import-specifier" };
|
|
3303
|
+
if (isExportSpecifierLiteral(node)) return { context: "export-specifier" };
|
|
3304
|
+
const propertyContext = propertyNameContext(node);
|
|
3305
|
+
if (propertyContext) return { context: propertyContext };
|
|
3306
|
+
return {
|
|
3307
|
+
context: ts4.isNoSubstitutionTemplateLiteral(node) ? "template-literal" : "string-literal"
|
|
3308
|
+
};
|
|
3309
|
+
}
|
|
3310
|
+
function extractSourceStringLiterals(sourceFile, options = {}) {
|
|
3311
|
+
const includeImportSpecifiers = options.includeImportSpecifiers ?? true;
|
|
3312
|
+
const includeObjectPropertyNames = options.includeObjectPropertyNames ?? true;
|
|
3313
|
+
const literals = [];
|
|
3314
|
+
const visit = (node) => {
|
|
3315
|
+
if (isStringLiteralLike(node)) {
|
|
3316
|
+
const context = literalContext(node);
|
|
3317
|
+
const isImportLike = context.context === "import-specifier" || context.context === "export-specifier" || context.context === "require-specifier" || context.context === "dynamic-import-specifier";
|
|
3318
|
+
if ((includeImportSpecifiers || !isImportLike) && (includeObjectPropertyNames || context.context !== "property-name")) {
|
|
3319
|
+
literals.push({
|
|
3320
|
+
value: node.text,
|
|
3321
|
+
rawText: literalRawText(node),
|
|
3322
|
+
context: context.context,
|
|
3323
|
+
location: sourceLocationForNode(sourceFile, node),
|
|
3324
|
+
...context.attributeName ? { attributeName: context.attributeName } : {}
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
ts4.forEachChild(node, visit);
|
|
3329
|
+
};
|
|
3330
|
+
visit(sourceFile);
|
|
3331
|
+
return literals;
|
|
3332
|
+
}
|
|
3333
|
+
|
|
3334
|
+
// src/source/program.ts
|
|
3335
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, statSync as statSync4 } from "fs";
|
|
3336
|
+
import { dirname, extname as extname5, isAbsolute as isAbsolute3, join as join5, relative as relative5, resolve as resolve2 } from "path";
|
|
3337
|
+
import * as ts5 from "typescript";
|
|
3338
|
+
var RESOLUTION_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
3339
|
+
var DEFAULT_COMPILER_OPTIONS = {
|
|
3340
|
+
allowImportingTsExtensions: true,
|
|
3341
|
+
allowJs: true,
|
|
3342
|
+
allowSyntheticDefaultImports: true,
|
|
3343
|
+
checkJs: false,
|
|
3344
|
+
esModuleInterop: true,
|
|
3345
|
+
jsx: ts5.JsxEmit.ReactJSX,
|
|
3346
|
+
module: ts5.ModuleKind.ESNext,
|
|
3347
|
+
moduleResolution: ts5.ModuleResolutionKind.Bundler,
|
|
3348
|
+
noEmit: true,
|
|
3349
|
+
resolveJsonModule: true,
|
|
3350
|
+
skipLibCheck: true,
|
|
3351
|
+
target: ts5.ScriptTarget.ES2022
|
|
3352
|
+
};
|
|
3353
|
+
function findProjectTsConfig(projectRoot, tsconfigPath) {
|
|
3354
|
+
if (tsconfigPath === null) return null;
|
|
3355
|
+
if (tsconfigPath) {
|
|
3356
|
+
const absolutePath = isAbsolute3(tsconfigPath) ? resolve2(tsconfigPath) : resolve2(projectRoot, tsconfigPath);
|
|
3357
|
+
return existsSync5(absolutePath) ? absolutePath : null;
|
|
3358
|
+
}
|
|
3359
|
+
const localTsConfig = join5(projectRoot, "tsconfig.json");
|
|
3360
|
+
return existsSync5(localTsConfig) ? localTsConfig : null;
|
|
3361
|
+
}
|
|
3362
|
+
function fallbackCompilerConfig(tsconfigPath, options, diagnostics = []) {
|
|
3363
|
+
return {
|
|
3364
|
+
tsconfigPath,
|
|
3365
|
+
compilerOptions: {
|
|
3366
|
+
...DEFAULT_COMPILER_OPTIONS,
|
|
3367
|
+
...options.compilerOptions,
|
|
3368
|
+
allowJs: true,
|
|
3369
|
+
noEmit: true,
|
|
3370
|
+
skipLibCheck: true
|
|
3371
|
+
},
|
|
3372
|
+
diagnostics
|
|
3373
|
+
};
|
|
3374
|
+
}
|
|
3375
|
+
function readCompilerConfig(projectRoot, options) {
|
|
3376
|
+
const tsconfigPath = findProjectTsConfig(projectRoot, options.tsconfigPath);
|
|
3377
|
+
if (!tsconfigPath) return fallbackCompilerConfig(null, options);
|
|
3378
|
+
const parsedJson = ts5.parseConfigFileTextToJson(
|
|
3379
|
+
tsconfigPath,
|
|
3380
|
+
readFileSync5(tsconfigPath, "utf-8")
|
|
3381
|
+
);
|
|
3382
|
+
if (parsedJson.error) return fallbackCompilerConfig(tsconfigPath, options, [parsedJson.error]);
|
|
3383
|
+
const parsed = ts5.parseJsonConfigFileContent(
|
|
3384
|
+
parsedJson.config,
|
|
3385
|
+
ts5.sys,
|
|
3386
|
+
dirname(tsconfigPath),
|
|
3387
|
+
DEFAULT_COMPILER_OPTIONS,
|
|
3388
|
+
tsconfigPath
|
|
3389
|
+
);
|
|
3390
|
+
return {
|
|
3391
|
+
tsconfigPath,
|
|
3392
|
+
compilerOptions: {
|
|
3393
|
+
...DEFAULT_COMPILER_OPTIONS,
|
|
3394
|
+
...parsed.options,
|
|
3395
|
+
...options.compilerOptions,
|
|
3396
|
+
allowJs: true,
|
|
3397
|
+
noEmit: true,
|
|
3398
|
+
skipLibCheck: true
|
|
3399
|
+
},
|
|
3400
|
+
diagnostics: parsed.errors
|
|
3401
|
+
};
|
|
3402
|
+
}
|
|
3403
|
+
function inventoryFileByAbsolutePath(inventory) {
|
|
3404
|
+
return new Map(
|
|
3405
|
+
inventory.files.map((file) => [normalizeSourcePath(resolve2(file.absolutePath)), file])
|
|
3406
|
+
);
|
|
3407
|
+
}
|
|
3408
|
+
function createProjectSourceProgram(projectRoot, options = {}) {
|
|
3409
|
+
const inventory = createSourceInventory(projectRoot, options);
|
|
3410
|
+
const config = readCompilerConfig(inventory.projectRoot, options);
|
|
3411
|
+
const host = ts5.createCompilerHost(config.compilerOptions, true);
|
|
3412
|
+
const program = ts5.createProgram({
|
|
3413
|
+
rootNames: inventory.files.map((file) => file.absolutePath),
|
|
3414
|
+
options: config.compilerOptions,
|
|
3415
|
+
host
|
|
3416
|
+
});
|
|
3417
|
+
return {
|
|
3418
|
+
projectRoot: inventory.projectRoot,
|
|
3419
|
+
tsconfigPath: config.tsconfigPath,
|
|
3420
|
+
inventory,
|
|
3421
|
+
program,
|
|
3422
|
+
compilerOptions: config.compilerOptions,
|
|
3423
|
+
diagnostics: [...config.diagnostics, ...program.getOptionsDiagnostics()]
|
|
3424
|
+
};
|
|
3425
|
+
}
|
|
3426
|
+
function getProjectSourceFile(context, pathOrSourceFile) {
|
|
3427
|
+
if (typeof pathOrSourceFile !== "string") return pathOrSourceFile;
|
|
3428
|
+
const absolutePath = isAbsolute3(pathOrSourceFile) ? resolve2(pathOrSourceFile) : resolve2(context.projectRoot, pathOrSourceFile);
|
|
3429
|
+
const normalized = normalizeSourcePath(absolutePath);
|
|
3430
|
+
return context.program.getSourceFiles().find((sourceFile) => normalizeSourcePath(resolve2(sourceFile.fileName)) === normalized);
|
|
3431
|
+
}
|
|
3432
|
+
function sourceFileRelativePath(context, sourceFile) {
|
|
3433
|
+
return normalizeSourcePath(
|
|
3434
|
+
relative5(context.projectRoot, sourceFile.fileName) || sourceFile.fileName
|
|
3435
|
+
);
|
|
3436
|
+
}
|
|
3437
|
+
function sourceLocationLineAndColumn(sourceFile, node) {
|
|
3438
|
+
const location = sourceLocationForNode(sourceFile, node);
|
|
3439
|
+
return { line: location.line, column: location.column };
|
|
3440
|
+
}
|
|
3441
|
+
function bindingNames(name) {
|
|
3442
|
+
if (ts5.isIdentifier(name)) return [name.text];
|
|
3443
|
+
return name.elements.flatMap((element) => {
|
|
3444
|
+
if (ts5.isOmittedExpression(element)) return [];
|
|
3445
|
+
return bindingNames(element.name);
|
|
3446
|
+
});
|
|
3447
|
+
}
|
|
3448
|
+
function importSourceText(node) {
|
|
3449
|
+
if ((ts5.isImportDeclaration(node) || ts5.isExportDeclaration(node)) && node.moduleSpecifier && ts5.isStringLiteral(node.moduleSpecifier)) {
|
|
3450
|
+
return node.moduleSpecifier.text;
|
|
3451
|
+
}
|
|
3452
|
+
if (ts5.isImportEqualsDeclaration(node) && ts5.isExternalModuleReference(node.moduleReference) && node.moduleReference.expression && ts5.isStringLiteral(node.moduleReference.expression)) {
|
|
3453
|
+
return node.moduleReference.expression.text;
|
|
3454
|
+
}
|
|
3455
|
+
if (ts5.isCallExpression(node) && node.arguments.length > 0 && ts5.isStringLiteral(node.arguments[0])) {
|
|
3456
|
+
if (node.expression.kind === ts5.SyntaxKind.ImportKeyword) return node.arguments[0].text;
|
|
3457
|
+
if (ts5.isIdentifier(node.expression) && node.expression.text === "require") {
|
|
3458
|
+
return node.arguments[0].text;
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
return null;
|
|
3462
|
+
}
|
|
3463
|
+
function hasExternalPackageShape(specifier) {
|
|
3464
|
+
return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.startsWith("#");
|
|
3465
|
+
}
|
|
3466
|
+
function manualResolutionCandidates(context, importerPath, specifier) {
|
|
3467
|
+
const candidates = [];
|
|
3468
|
+
const addCandidates = (base) => {
|
|
3469
|
+
candidates.push(base);
|
|
3470
|
+
if (extname5(base)) return;
|
|
3471
|
+
for (const extension of RESOLUTION_EXTENSIONS) candidates.push(`${base}${extension}`);
|
|
3472
|
+
for (const extension of RESOLUTION_EXTENSIONS) {
|
|
3473
|
+
candidates.push(join5(base, `index${extension}`));
|
|
3474
|
+
}
|
|
3475
|
+
};
|
|
3476
|
+
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
3477
|
+
const base = specifier.startsWith("/") ? resolve2(context.projectRoot, specifier.slice(1)) : resolve2(dirname(importerPath), specifier);
|
|
3478
|
+
addCandidates(base);
|
|
3479
|
+
} else if (specifier.startsWith("@/")) {
|
|
3480
|
+
addCandidates(resolve2(context.projectRoot, specifier.slice(2)));
|
|
3481
|
+
addCandidates(resolve2(context.projectRoot, "src", specifier.slice(2)));
|
|
3482
|
+
}
|
|
3483
|
+
return candidates;
|
|
3484
|
+
}
|
|
3485
|
+
function resolveFromInventory(context, source, importerPath) {
|
|
3486
|
+
const inventoryByPath = inventoryFileByAbsolutePath(context.inventory);
|
|
3487
|
+
for (const candidate of manualResolutionCandidates(context, importerPath, source)) {
|
|
3488
|
+
const absolutePath = normalizeSourcePath(resolve2(candidate));
|
|
3489
|
+
const inventoryFile2 = inventoryByPath.get(absolutePath);
|
|
3490
|
+
if (!inventoryFile2 || !existsSync5(inventoryFile2.absolutePath) || !statSync4(inventoryFile2.absolutePath).isFile()) {
|
|
3491
|
+
continue;
|
|
3492
|
+
}
|
|
3493
|
+
return {
|
|
3494
|
+
source,
|
|
3495
|
+
importer: normalizeSourcePath(relative5(context.projectRoot, importerPath) || importerPath),
|
|
3496
|
+
kind: "project-local",
|
|
3497
|
+
resolvedFileName: inventoryFile2.absolutePath,
|
|
3498
|
+
relativePath: inventoryFile2.relativePath,
|
|
3499
|
+
extension: inventoryFile2.extension,
|
|
3500
|
+
isProjectLocal: true,
|
|
3501
|
+
isExternal: false,
|
|
3502
|
+
failed: false
|
|
3503
|
+
};
|
|
3504
|
+
}
|
|
3505
|
+
return null;
|
|
3506
|
+
}
|
|
3507
|
+
function resolveSourceImport(context, importer, source) {
|
|
3508
|
+
const sourceFile = getProjectSourceFile(context, importer);
|
|
3509
|
+
const importerPath = sourceFile ? resolve2(sourceFile.fileName) : isAbsolute3(String(importer)) ? resolve2(String(importer)) : resolve2(context.projectRoot, String(importer));
|
|
3510
|
+
const importerRelativePath = normalizeSourcePath(
|
|
3511
|
+
relative5(context.projectRoot, importerPath) || importerPath
|
|
3512
|
+
);
|
|
3513
|
+
const inventoryByPath = inventoryFileByAbsolutePath(context.inventory);
|
|
3514
|
+
const resolved = ts5.resolveModuleName(
|
|
3515
|
+
source,
|
|
3516
|
+
importerPath,
|
|
3517
|
+
context.compilerOptions,
|
|
3518
|
+
ts5.sys
|
|
3519
|
+
).resolvedModule;
|
|
3520
|
+
if (resolved) {
|
|
3521
|
+
const absolutePath = normalizeSourcePath(resolve2(resolved.resolvedFileName));
|
|
3522
|
+
const inventoryFile2 = inventoryByPath.get(absolutePath);
|
|
3523
|
+
if (inventoryFile2 && isPathInsideProject(context.projectRoot, absolutePath)) {
|
|
3524
|
+
return {
|
|
3525
|
+
source,
|
|
3526
|
+
importer: importerRelativePath,
|
|
3527
|
+
kind: "project-local",
|
|
3528
|
+
resolvedFileName: inventoryFile2.absolutePath,
|
|
3529
|
+
relativePath: inventoryFile2.relativePath,
|
|
3530
|
+
extension: inventoryFile2.extension,
|
|
3531
|
+
isProjectLocal: true,
|
|
3532
|
+
isExternal: false,
|
|
3533
|
+
failed: false
|
|
3534
|
+
};
|
|
3535
|
+
}
|
|
3536
|
+
return {
|
|
3537
|
+
source,
|
|
3538
|
+
importer: importerRelativePath,
|
|
3539
|
+
kind: hasExternalPackageShape(source) ? "external" : "unresolved",
|
|
3540
|
+
resolvedFileName: resolved.resolvedFileName,
|
|
3541
|
+
relativePath: null,
|
|
3542
|
+
extension: extname5(resolved.resolvedFileName).toLowerCase() || null,
|
|
3543
|
+
isProjectLocal: false,
|
|
3544
|
+
isExternal: hasExternalPackageShape(source),
|
|
3545
|
+
failed: !hasExternalPackageShape(source)
|
|
3546
|
+
};
|
|
3547
|
+
}
|
|
3548
|
+
const fallback = resolveFromInventory(context, source, importerPath);
|
|
3549
|
+
if (fallback) return fallback;
|
|
3550
|
+
return {
|
|
3551
|
+
source,
|
|
3552
|
+
importer: importerRelativePath,
|
|
3553
|
+
kind: hasExternalPackageShape(source) ? "external" : "unresolved",
|
|
3554
|
+
resolvedFileName: null,
|
|
3555
|
+
relativePath: null,
|
|
3556
|
+
extension: null,
|
|
3557
|
+
isProjectLocal: false,
|
|
3558
|
+
isExternal: hasExternalPackageShape(source),
|
|
3559
|
+
failed: !hasExternalPackageShape(source)
|
|
3560
|
+
};
|
|
3561
|
+
}
|
|
3562
|
+
function importReferenceBase(context, sourceFile, node, source, kind, localNames, imported = [], extra = {}) {
|
|
3563
|
+
const location = sourceLocationLineAndColumn(sourceFile, node);
|
|
3564
|
+
return {
|
|
3565
|
+
file: sourceFileRelativePath(context, sourceFile),
|
|
3566
|
+
source,
|
|
3567
|
+
kind,
|
|
3568
|
+
line: location.line,
|
|
3569
|
+
column: location.column,
|
|
3570
|
+
imported,
|
|
3571
|
+
localNames,
|
|
3572
|
+
typeOnly: extra.typeOnly ?? false,
|
|
3573
|
+
resolved: resolveSourceImport(context, sourceFile, source),
|
|
3574
|
+
...extra.defaultImport ? { defaultImport: extra.defaultImport } : {},
|
|
3575
|
+
...extra.namespaceImport ? { namespaceImport: extra.namespaceImport } : {}
|
|
3576
|
+
};
|
|
3577
|
+
}
|
|
3578
|
+
function collectSourceImports(context, pathOrSourceFile) {
|
|
3579
|
+
const sourceFile = getProjectSourceFile(context, pathOrSourceFile);
|
|
3580
|
+
if (!sourceFile) return [];
|
|
3581
|
+
const imports = [];
|
|
3582
|
+
const visit = (node) => {
|
|
3583
|
+
if (ts5.isImportDeclaration(node)) {
|
|
3584
|
+
const source = importSourceText(node);
|
|
3585
|
+
if (source) {
|
|
3586
|
+
const imported = [];
|
|
3587
|
+
const localNames = [];
|
|
3588
|
+
let defaultImport;
|
|
3589
|
+
let namespaceImport;
|
|
3590
|
+
let typeOnly = node.importClause?.isTypeOnly ?? false;
|
|
3591
|
+
if (node.importClause?.name) {
|
|
3592
|
+
defaultImport = node.importClause.name.text;
|
|
3593
|
+
localNames.push(defaultImport);
|
|
3594
|
+
}
|
|
3595
|
+
const namedBindings = node.importClause?.namedBindings;
|
|
3596
|
+
if (namedBindings && ts5.isNamedImports(namedBindings)) {
|
|
3597
|
+
for (const element of namedBindings.elements) {
|
|
3598
|
+
imported.push((element.propertyName ?? element.name).text);
|
|
3599
|
+
localNames.push(element.name.text);
|
|
3600
|
+
typeOnly ||= element.isTypeOnly;
|
|
3601
|
+
}
|
|
3602
|
+
} else if (namedBindings && ts5.isNamespaceImport(namedBindings)) {
|
|
3603
|
+
namespaceImport = namedBindings.name.text;
|
|
3604
|
+
localNames.push(namespaceImport);
|
|
3605
|
+
}
|
|
3606
|
+
imports.push(
|
|
3607
|
+
importReferenceBase(
|
|
3608
|
+
context,
|
|
3609
|
+
sourceFile,
|
|
3610
|
+
node,
|
|
3611
|
+
source,
|
|
3612
|
+
"static-import",
|
|
3613
|
+
localNames,
|
|
3614
|
+
imported,
|
|
3615
|
+
{
|
|
3616
|
+
...defaultImport ? { defaultImport } : {},
|
|
3617
|
+
...namespaceImport ? { namespaceImport } : {},
|
|
3618
|
+
typeOnly
|
|
3619
|
+
}
|
|
3620
|
+
)
|
|
3621
|
+
);
|
|
3622
|
+
}
|
|
3623
|
+
} else if (ts5.isExportDeclaration(node)) {
|
|
3624
|
+
const source = importSourceText(node);
|
|
3625
|
+
if (source) {
|
|
3626
|
+
const exported = node.exportClause && ts5.isNamedExports(node.exportClause) ? node.exportClause.elements.map(
|
|
3627
|
+
(element) => (element.propertyName ?? element.name).text
|
|
3628
|
+
) : [];
|
|
3629
|
+
imports.push(
|
|
3630
|
+
importReferenceBase(context, sourceFile, node, source, "re-export", [], exported, {
|
|
3631
|
+
typeOnly: node.isTypeOnly
|
|
3632
|
+
})
|
|
3633
|
+
);
|
|
3634
|
+
}
|
|
3635
|
+
} else if (ts5.isImportEqualsDeclaration(node)) {
|
|
3636
|
+
const source = importSourceText(node);
|
|
3637
|
+
if (source) {
|
|
3638
|
+
imports.push(
|
|
3639
|
+
importReferenceBase(context, sourceFile, node, source, "import-equals", [node.name.text])
|
|
3640
|
+
);
|
|
3641
|
+
}
|
|
3642
|
+
} else if (ts5.isCallExpression(node)) {
|
|
3643
|
+
const source = importSourceText(node);
|
|
3644
|
+
if (source) {
|
|
3645
|
+
const kind = node.expression.kind === ts5.SyntaxKind.ImportKeyword ? "dynamic-import" : "require";
|
|
3646
|
+
const parent = node.parent;
|
|
3647
|
+
const localNames = ts5.isVariableDeclaration(parent) && parent.initializer === node ? bindingNames(parent.name) : [];
|
|
3648
|
+
imports.push(importReferenceBase(context, sourceFile, node, source, kind, localNames));
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
ts5.forEachChild(node, visit);
|
|
3652
|
+
};
|
|
3653
|
+
visit(sourceFile);
|
|
3654
|
+
return imports;
|
|
3655
|
+
}
|
|
3656
|
+
function findImportedFrom(identifier) {
|
|
3657
|
+
let node = identifier;
|
|
3658
|
+
while (node) {
|
|
3659
|
+
if (ts5.isImportDeclaration(node) || ts5.isExportDeclaration(node) || ts5.isImportEqualsDeclaration(node)) {
|
|
3660
|
+
const source = importSourceText(node);
|
|
3661
|
+
return {
|
|
3662
|
+
...source ? { importSource: source } : {},
|
|
3663
|
+
importedFrom: ts5.SyntaxKind[node.kind]
|
|
3664
|
+
};
|
|
3665
|
+
}
|
|
3666
|
+
node = node.parent;
|
|
3667
|
+
}
|
|
3668
|
+
return {};
|
|
3669
|
+
}
|
|
3670
|
+
function preferImportBinding(a, b) {
|
|
3671
|
+
if (!a) return b;
|
|
3672
|
+
const aImport = Boolean(findImportedFrom(a).importSource);
|
|
3673
|
+
const bImport = Boolean(findImportedFrom(b).importSource);
|
|
3674
|
+
if (aImport === bImport) return a;
|
|
3675
|
+
return bImport ? b : a;
|
|
3676
|
+
}
|
|
3677
|
+
function findIdentifier(sourceFile, name, position) {
|
|
3678
|
+
let matched = null;
|
|
3679
|
+
const visit = (node) => {
|
|
3680
|
+
if (matched && position !== void 0) return;
|
|
3681
|
+
if (ts5.isIdentifier(node) && node.text === name) {
|
|
3682
|
+
if (position === void 0) {
|
|
3683
|
+
matched = preferImportBinding(matched, node);
|
|
3684
|
+
} else if (node.getStart(sourceFile) <= position && position <= node.getEnd()) {
|
|
3685
|
+
matched = node;
|
|
3686
|
+
return;
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
ts5.forEachChild(node, visit);
|
|
3690
|
+
};
|
|
3691
|
+
visit(sourceFile);
|
|
3692
|
+
return matched;
|
|
3693
|
+
}
|
|
3694
|
+
function declarationKind(declaration) {
|
|
3695
|
+
return ts5.SyntaxKind[declaration.kind] ?? "Declaration";
|
|
3696
|
+
}
|
|
3697
|
+
function resolveSourceSymbolOrigin(context, pathOrSourceFile, localName, options = {}) {
|
|
3698
|
+
const sourceFile = getProjectSourceFile(context, pathOrSourceFile);
|
|
3699
|
+
if (!sourceFile) return null;
|
|
3700
|
+
const identifier = findIdentifier(sourceFile, localName, options.position);
|
|
3701
|
+
if (!identifier) return null;
|
|
3702
|
+
const checker = context.program.getTypeChecker();
|
|
3703
|
+
const symbol = checker.getSymbolAtLocation(identifier);
|
|
3704
|
+
if (!symbol) return null;
|
|
3705
|
+
const originSymbol = symbol.flags & ts5.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
3706
|
+
const declarations = originSymbol.declarations ?? symbol.declarations ?? [];
|
|
3707
|
+
if (declarations.length === 0) return null;
|
|
3708
|
+
const projectFiles = inventoryFileByAbsolutePath(context.inventory);
|
|
3709
|
+
const declaration = declarations.find(
|
|
3710
|
+
(entry) => projectFiles.has(normalizeSourcePath(resolve2(entry.getSourceFile().fileName)))
|
|
3711
|
+
) ?? declarations[0];
|
|
3712
|
+
const declarationFile = declaration.getSourceFile();
|
|
3713
|
+
const declarationPath = normalizeSourcePath(resolve2(declarationFile.fileName));
|
|
3714
|
+
const projectFile = projectFiles.get(declarationPath);
|
|
3715
|
+
const isProjectLocal = Boolean(projectFile);
|
|
3716
|
+
if (!isProjectLocal && !options.includeExternal) return null;
|
|
3717
|
+
const imported = findImportedFrom(identifier);
|
|
3718
|
+
return {
|
|
3719
|
+
name: originSymbol.getName(),
|
|
3720
|
+
localName,
|
|
3721
|
+
file: projectFile?.relativePath ?? normalizeSourcePath(declarationFile.fileName),
|
|
3722
|
+
absolutePath: projectFile?.absolutePath ?? declarationPath,
|
|
3723
|
+
location: sourceLocationForNode(declarationFile, declaration),
|
|
3724
|
+
declarationKind: declarationKind(declaration),
|
|
3725
|
+
isProjectLocal,
|
|
3726
|
+
...imported
|
|
3727
|
+
};
|
|
3728
|
+
}
|
|
3729
|
+
|
|
2927
3730
|
// src/index.ts
|
|
2928
3731
|
var VERIFICATION_SCHEMA_URLS = {
|
|
2929
3732
|
common: "https://decantr.ai/schemas/verification-report.common.v1.json",
|
|
@@ -2941,16 +3744,16 @@ function hashString(value) {
|
|
|
2941
3744
|
return createHash("sha256").update(value).digest("hex").slice(0, 16);
|
|
2942
3745
|
}
|
|
2943
3746
|
function hashFile(path) {
|
|
2944
|
-
if (!
|
|
3747
|
+
if (!existsSync6(path)) return null;
|
|
2945
3748
|
try {
|
|
2946
|
-
return createHash("sha256").update(
|
|
3749
|
+
return createHash("sha256").update(readFileSync6(path)).digest("hex");
|
|
2947
3750
|
} catch {
|
|
2948
3751
|
return null;
|
|
2949
3752
|
}
|
|
2950
3753
|
}
|
|
2951
3754
|
function provenanceEntry(projectRoot, relativePath) {
|
|
2952
|
-
const path =
|
|
2953
|
-
if (!
|
|
3755
|
+
const path = join6(projectRoot, relativePath);
|
|
3756
|
+
if (!existsSync6(path)) {
|
|
2954
3757
|
return {
|
|
2955
3758
|
path: relativePath,
|
|
2956
3759
|
present: false,
|
|
@@ -2960,7 +3763,7 @@ function provenanceEntry(projectRoot, relativePath) {
|
|
|
2960
3763
|
}
|
|
2961
3764
|
let generatedAt = null;
|
|
2962
3765
|
try {
|
|
2963
|
-
generatedAt =
|
|
3766
|
+
generatedAt = statSync5(path).mtime.toISOString();
|
|
2964
3767
|
} catch {
|
|
2965
3768
|
generatedAt = null;
|
|
2966
3769
|
}
|
|
@@ -2972,7 +3775,7 @@ function provenanceEntry(projectRoot, relativePath) {
|
|
|
2972
3775
|
};
|
|
2973
3776
|
}
|
|
2974
3777
|
function provenanceForPath(projectRoot, path) {
|
|
2975
|
-
const rel =
|
|
3778
|
+
const rel = isAbsolute4(path) ? relative6(projectRoot, path).replace(/\\/g, "/") : path;
|
|
2976
3779
|
return provenanceEntry(projectRoot, rel && !rel.startsWith("..") ? rel : basename2(path));
|
|
2977
3780
|
}
|
|
2978
3781
|
function redactEvidenceText(projectRoot, value) {
|
|
@@ -3109,7 +3912,7 @@ function createContractAssertions(projectRoot, audit) {
|
|
|
3109
3912
|
const assertions = [];
|
|
3110
3913
|
const essence = audit?.essence;
|
|
3111
3914
|
const v4 = essence && isV4(essence) ? essence : null;
|
|
3112
|
-
const contextDir =
|
|
3915
|
+
const contextDir = join6(projectRoot, ".decantr", "context");
|
|
3113
3916
|
const packManifest = audit?.packManifest ?? null;
|
|
3114
3917
|
assertions.push(
|
|
3115
3918
|
assertion({
|
|
@@ -3119,7 +3922,7 @@ function createContractAssertions(projectRoot, audit) {
|
|
|
3119
3922
|
rule: "essence-present",
|
|
3120
3923
|
status: essence ? "passed" : "failed",
|
|
3121
3924
|
message: essence ? "Decantr Essence contract is present." : "No Decantr Essence contract was found.",
|
|
3122
|
-
evidence: [redactEvidenceText(projectRoot,
|
|
3925
|
+
evidence: [redactEvidenceText(projectRoot, join6(projectRoot, "decantr.essence.json"))],
|
|
3123
3926
|
suggestedFix: essence ? void 0 : "Run `decantr init` or restore decantr.essence.json."
|
|
3124
3927
|
})
|
|
3125
3928
|
);
|
|
@@ -3191,7 +3994,7 @@ function createContractAssertions(projectRoot, audit) {
|
|
|
3191
3994
|
rule: "pack-manifest-present",
|
|
3192
3995
|
status: packManifest ? "passed" : "failed",
|
|
3193
3996
|
message: packManifest ? "Compiled execution pack manifest is present." : "Compiled execution pack manifest is missing.",
|
|
3194
|
-
evidence: [redactEvidenceText(projectRoot,
|
|
3997
|
+
evidence: [redactEvidenceText(projectRoot, join6(contextDir, "pack-manifest.json"))],
|
|
3195
3998
|
suggestedFix: packManifest ? void 0 : "Run `decantr registry compile-packs decantr.essence.json --write-context` to hydrate the full context pack bundle."
|
|
3196
3999
|
})
|
|
3197
4000
|
);
|
|
@@ -3203,21 +4006,21 @@ function createContractAssertions(projectRoot, audit) {
|
|
|
3203
4006
|
rule: "review-pack-present",
|
|
3204
4007
|
status: audit?.reviewPack ? "passed" : "failed",
|
|
3205
4008
|
message: audit?.reviewPack ? "Compiled review pack is present." : "Compiled review pack is missing.",
|
|
3206
|
-
evidence: [redactEvidenceText(projectRoot,
|
|
4009
|
+
evidence: [redactEvidenceText(projectRoot, join6(contextDir, "review-pack.json"))],
|
|
3207
4010
|
suggestedFix: audit?.reviewPack ? void 0 : "Run `decantr registry compile-packs decantr.essence.json --write-context` so critique has the compiled review contract."
|
|
3208
4011
|
})
|
|
3209
4012
|
);
|
|
3210
|
-
const tokensPath =
|
|
4013
|
+
const tokensPath = join6(projectRoot, "src", "styles", "tokens.css");
|
|
3211
4014
|
assertions.push(
|
|
3212
4015
|
assertion({
|
|
3213
4016
|
id: "contract.design-token.tokens-file",
|
|
3214
4017
|
category: "design-token",
|
|
3215
|
-
severity:
|
|
4018
|
+
severity: existsSync6(tokensPath) ? "info" : "warn",
|
|
3216
4019
|
rule: "tokens-file-present",
|
|
3217
|
-
status:
|
|
3218
|
-
message:
|
|
4020
|
+
status: existsSync6(tokensPath) ? "passed" : "failed",
|
|
4021
|
+
message: existsSync6(tokensPath) ? "Decantr token CSS file is present." : "Decantr token CSS file was not found.",
|
|
3219
4022
|
evidence: [redactEvidenceText(projectRoot, tokensPath)],
|
|
3220
|
-
suggestedFix:
|
|
4023
|
+
suggestedFix: existsSync6(tokensPath) ? void 0 : "Run `decantr refresh` or map Decantr tokens into the existing styling system."
|
|
3221
4024
|
})
|
|
3222
4025
|
);
|
|
3223
4026
|
return assertions;
|
|
@@ -3226,9 +4029,9 @@ function createEvidenceBundle(input) {
|
|
|
3226
4029
|
const assertions = input.assertions ?? createContractAssertions(input.projectRoot, input.audit);
|
|
3227
4030
|
let resolvedProjectRoot = input.projectRoot;
|
|
3228
4031
|
try {
|
|
3229
|
-
resolvedProjectRoot =
|
|
4032
|
+
resolvedProjectRoot = realpathSync2(input.projectRoot);
|
|
3230
4033
|
} catch {
|
|
3231
|
-
resolvedProjectRoot =
|
|
4034
|
+
resolvedProjectRoot = resolve3(input.projectRoot);
|
|
3232
4035
|
}
|
|
3233
4036
|
const projectId = `project_${hashString(resolvedProjectRoot)}`;
|
|
3234
4037
|
return {
|
|
@@ -3330,21 +4133,21 @@ function scoreRatio(numerator, denominator) {
|
|
|
3330
4133
|
return Math.min(5, Math.max(1, Math.round(numerator / denominator * 5)));
|
|
3331
4134
|
}
|
|
3332
4135
|
function readJsonIfExists(path) {
|
|
3333
|
-
if (!
|
|
4136
|
+
if (!existsSync6(path)) return null;
|
|
3334
4137
|
try {
|
|
3335
|
-
return JSON.parse(
|
|
4138
|
+
return JSON.parse(readFileSync6(path, "utf-8"));
|
|
3336
4139
|
} catch {
|
|
3337
4140
|
return null;
|
|
3338
4141
|
}
|
|
3339
4142
|
}
|
|
3340
4143
|
function loadReviewPack(projectRoot) {
|
|
3341
4144
|
return readJsonIfExists(
|
|
3342
|
-
|
|
4145
|
+
join6(projectRoot, ".decantr", "context", "review-pack.json")
|
|
3343
4146
|
);
|
|
3344
4147
|
}
|
|
3345
4148
|
function loadPackManifest(projectRoot) {
|
|
3346
4149
|
return readJsonIfExists(
|
|
3347
|
-
|
|
4150
|
+
join6(projectRoot, ".decantr", "context", "pack-manifest.json")
|
|
3348
4151
|
);
|
|
3349
4152
|
}
|
|
3350
4153
|
function collectPackManifestReferences(packManifest) {
|
|
@@ -3393,14 +4196,14 @@ function collectPackManifestReferences(packManifest) {
|
|
|
3393
4196
|
}
|
|
3394
4197
|
function collectMissingPackManifestFiles(projectRoot, packManifest = loadPackManifest(projectRoot)) {
|
|
3395
4198
|
if (!packManifest) return [];
|
|
3396
|
-
const contextDir =
|
|
4199
|
+
const contextDir = join6(projectRoot, ".decantr", "context");
|
|
3397
4200
|
const missing = [];
|
|
3398
4201
|
for (const reference of collectPackManifestReferences(packManifest)) {
|
|
3399
4202
|
for (const field of ["markdown", "json"]) {
|
|
3400
4203
|
const fileName = reference[field];
|
|
3401
4204
|
if (!fileName) continue;
|
|
3402
|
-
const absolutePath =
|
|
3403
|
-
if (
|
|
4205
|
+
const absolutePath = join6(contextDir, fileName);
|
|
4206
|
+
if (existsSync6(absolutePath)) continue;
|
|
3404
4207
|
missing.push({
|
|
3405
4208
|
entryId: reference.entryId,
|
|
3406
4209
|
kind: reference.kind,
|
|
@@ -3414,13 +4217,13 @@ function collectMissingPackManifestFiles(projectRoot, packManifest = loadPackMan
|
|
|
3414
4217
|
}
|
|
3415
4218
|
function readTextIfExists(path) {
|
|
3416
4219
|
try {
|
|
3417
|
-
return
|
|
4220
|
+
return existsSync6(path) ? readFileSync6(path, "utf-8") : "";
|
|
3418
4221
|
} catch {
|
|
3419
4222
|
return "";
|
|
3420
4223
|
}
|
|
3421
4224
|
}
|
|
3422
4225
|
function readProjectAdoptionMode(projectRoot) {
|
|
3423
|
-
const projectJson = readJsonIfExists(
|
|
4226
|
+
const projectJson = readJsonIfExists(join6(projectRoot, ".decantr", "project.json"));
|
|
3424
4227
|
const adoptionMode = projectJson?.initialized?.adoptionMode;
|
|
3425
4228
|
return typeof adoptionMode === "string" ? adoptionMode : null;
|
|
3426
4229
|
}
|
|
@@ -3506,7 +4309,7 @@ function collectProjectSourceFiles(projectRoot) {
|
|
|
3506
4309
|
"hooks",
|
|
3507
4310
|
"providers",
|
|
3508
4311
|
"server"
|
|
3509
|
-
].map((dir) =>
|
|
4312
|
+
].map((dir) => join6(projectRoot, dir)).filter((dir) => existsSync6(dir));
|
|
3510
4313
|
const rootFileCandidates = [
|
|
3511
4314
|
"middleware.ts",
|
|
3512
4315
|
"middleware.tsx",
|
|
@@ -3520,7 +4323,7 @@ function collectProjectSourceFiles(projectRoot) {
|
|
|
3520
4323
|
"proxy.jsx",
|
|
3521
4324
|
"proxy.mts",
|
|
3522
4325
|
"proxy.cts"
|
|
3523
|
-
].map((file) =>
|
|
4326
|
+
].map((file) => join6(projectRoot, file)).filter((file) => existsSync6(file));
|
|
3524
4327
|
const files = /* @__PURE__ */ new Set();
|
|
3525
4328
|
const ignoredDirNames = /* @__PURE__ */ new Set([
|
|
3526
4329
|
"node_modules",
|
|
@@ -3531,9 +4334,9 @@ function collectProjectSourceFiles(projectRoot) {
|
|
|
3531
4334
|
"coverage"
|
|
3532
4335
|
]);
|
|
3533
4336
|
const walk = (dir) => {
|
|
3534
|
-
for (const entry of
|
|
4337
|
+
for (const entry of readdirSync5(dir, { withFileTypes: true })) {
|
|
3535
4338
|
if (ignoredDirNames.has(entry.name)) continue;
|
|
3536
|
-
const absolutePath =
|
|
4339
|
+
const absolutePath = join6(dir, entry.name);
|
|
3537
4340
|
if (entry.isDirectory()) {
|
|
3538
4341
|
walk(absolutePath);
|
|
3539
4342
|
continue;
|
|
@@ -3564,7 +4367,7 @@ function isAuditableStyleFile(filePath) {
|
|
|
3564
4367
|
return /\.css$/i.test(filePath);
|
|
3565
4368
|
}
|
|
3566
4369
|
function collectProjectStyleFiles2(projectRoot) {
|
|
3567
|
-
const candidates = ["src", "app", "styles"].map((dir) =>
|
|
4370
|
+
const candidates = ["src", "app", "styles"].map((dir) => join6(projectRoot, dir)).filter((dir) => existsSync6(dir));
|
|
3568
4371
|
const files = /* @__PURE__ */ new Set();
|
|
3569
4372
|
const ignoredDirNames = /* @__PURE__ */ new Set([
|
|
3570
4373
|
"node_modules",
|
|
@@ -3575,9 +4378,9 @@ function collectProjectStyleFiles2(projectRoot) {
|
|
|
3575
4378
|
"coverage"
|
|
3576
4379
|
]);
|
|
3577
4380
|
const walk = (dir) => {
|
|
3578
|
-
for (const entry of
|
|
4381
|
+
for (const entry of readdirSync5(dir, { withFileTypes: true })) {
|
|
3579
4382
|
if (ignoredDirNames.has(entry.name)) continue;
|
|
3580
|
-
const absolutePath =
|
|
4383
|
+
const absolutePath = join6(dir, entry.name);
|
|
3581
4384
|
if (entry.isDirectory()) {
|
|
3582
4385
|
walk(absolutePath);
|
|
3583
4386
|
continue;
|
|
@@ -3605,15 +4408,15 @@ function countReducedMotionSignals(code) {
|
|
|
3605
4408
|
return patterns.reduce((count, pattern) => count + (pattern.test(code) ? 1 : 0), 0);
|
|
3606
4409
|
}
|
|
3607
4410
|
function hasModuleDirective(filePath, code, directive) {
|
|
3608
|
-
const sourceFile =
|
|
4411
|
+
const sourceFile = ts6.createSourceFile(
|
|
3609
4412
|
filePath,
|
|
3610
4413
|
code,
|
|
3611
|
-
|
|
4414
|
+
ts6.ScriptTarget.Latest,
|
|
3612
4415
|
true,
|
|
3613
4416
|
getScriptKind(filePath)
|
|
3614
4417
|
);
|
|
3615
4418
|
for (const statement of sourceFile.statements) {
|
|
3616
|
-
if (
|
|
4419
|
+
if (ts6.isExpressionStatement(statement) && ts6.isStringLiteralLike(statement.expression)) {
|
|
3617
4420
|
if (statement.expression.text === directive) {
|
|
3618
4421
|
return true;
|
|
3619
4422
|
}
|
|
@@ -3629,20 +4432,20 @@ function importDeclarationHasRuntimeBinding(statement) {
|
|
|
3629
4432
|
if (clause.isTypeOnly) return false;
|
|
3630
4433
|
if (clause.name) return true;
|
|
3631
4434
|
if (!clause.namedBindings) return true;
|
|
3632
|
-
if (
|
|
4435
|
+
if (ts6.isNamespaceImport(clause.namedBindings)) return true;
|
|
3633
4436
|
return clause.namedBindings.elements.some((element) => !element.isTypeOnly);
|
|
3634
4437
|
}
|
|
3635
4438
|
function collectRuntimeImportSpecifiers(entry) {
|
|
3636
|
-
const sourceFile =
|
|
4439
|
+
const sourceFile = ts6.createSourceFile(
|
|
3637
4440
|
entry.relativePath,
|
|
3638
4441
|
entry.code,
|
|
3639
|
-
|
|
4442
|
+
ts6.ScriptTarget.Latest,
|
|
3640
4443
|
true,
|
|
3641
4444
|
getScriptKind(entry.relativePath)
|
|
3642
4445
|
);
|
|
3643
4446
|
const specifiers = [];
|
|
3644
4447
|
for (const statement of sourceFile.statements) {
|
|
3645
|
-
if (
|
|
4448
|
+
if (ts6.isImportDeclaration(statement) && ts6.isStringLiteralLike(statement.moduleSpecifier) && importDeclarationHasRuntimeBinding(statement)) {
|
|
3646
4449
|
specifiers.push(statement.moduleSpecifier.text);
|
|
3647
4450
|
}
|
|
3648
4451
|
}
|
|
@@ -3651,9 +4454,9 @@ function collectRuntimeImportSpecifiers(entry) {
|
|
|
3651
4454
|
function resolveSourceImportTarget(projectRoot, sourceAbsolutePath, specifier) {
|
|
3652
4455
|
let basePath = null;
|
|
3653
4456
|
if (specifier.startsWith("@/")) {
|
|
3654
|
-
basePath =
|
|
4457
|
+
basePath = join6(projectRoot, "src", specifier.slice(2));
|
|
3655
4458
|
} else if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
3656
|
-
basePath =
|
|
4459
|
+
basePath = resolve3(dirname2(sourceAbsolutePath), specifier);
|
|
3657
4460
|
}
|
|
3658
4461
|
if (!basePath) return null;
|
|
3659
4462
|
const candidates = [
|
|
@@ -3664,14 +4467,14 @@ function resolveSourceImportTarget(projectRoot, sourceAbsolutePath, specifier) {
|
|
|
3664
4467
|
`${basePath}.jsx`,
|
|
3665
4468
|
`${basePath}.mts`,
|
|
3666
4469
|
`${basePath}.cts`,
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
4470
|
+
join6(basePath, "index.ts"),
|
|
4471
|
+
join6(basePath, "index.tsx"),
|
|
4472
|
+
join6(basePath, "index.js"),
|
|
4473
|
+
join6(basePath, "index.jsx")
|
|
3671
4474
|
];
|
|
3672
4475
|
for (const candidate of candidates) {
|
|
3673
|
-
if (
|
|
3674
|
-
return
|
|
4476
|
+
if (existsSync6(candidate) && isAuditableSourceFile(candidate)) {
|
|
4477
|
+
return relative6(projectRoot, candidate) || candidate;
|
|
3675
4478
|
}
|
|
3676
4479
|
}
|
|
3677
4480
|
return null;
|
|
@@ -3719,8 +4522,8 @@ function isClientAuthHeaderSource(relativePath, code, clientReachableFiles) {
|
|
|
3719
4522
|
function auditProjectSourceTree(projectRoot, sourceFiles = collectProjectSourceFiles(projectRoot)) {
|
|
3720
4523
|
const sourceEntries = sourceFiles.map((sourceFile) => ({
|
|
3721
4524
|
absolutePath: sourceFile,
|
|
3722
|
-
relativePath:
|
|
3723
|
-
code:
|
|
4525
|
+
relativePath: relative6(projectRoot, sourceFile) || sourceFile,
|
|
4526
|
+
code: readFileSync6(sourceFile, "utf-8")
|
|
3724
4527
|
})).filter((entry) => !isNonProductionSourceAuditFile(entry.relativePath));
|
|
3725
4528
|
const clientReachableFiles = collectClientReachableSourceFiles(projectRoot, sourceEntries);
|
|
3726
4529
|
const summary = {
|
|
@@ -4033,8 +4836,8 @@ function auditProjectStyleContracts(projectRoot) {
|
|
|
4033
4836
|
reducedMotionSignals: createSourceAuditBucket()
|
|
4034
4837
|
};
|
|
4035
4838
|
for (const styleFile of styleFiles) {
|
|
4036
|
-
const relativePath =
|
|
4037
|
-
const css =
|
|
4839
|
+
const relativePath = relative6(projectRoot, styleFile) || styleFile;
|
|
4840
|
+
const css = readFileSync6(styleFile, "utf-8");
|
|
4038
4841
|
recordSourceAudit(summary.focusVisibleSignals, relativePath, countFocusVisibleSignals(css));
|
|
4039
4842
|
recordSourceAudit(summary.reducedMotionSignals, relativePath, countReducedMotionSignals(css));
|
|
4040
4843
|
}
|
|
@@ -4043,15 +4846,15 @@ function auditProjectStyleContracts(projectRoot) {
|
|
|
4043
4846
|
function buildRegistryContext(projectRoot) {
|
|
4044
4847
|
const themeRegistry = /* @__PURE__ */ new Map();
|
|
4045
4848
|
const patternRegistry = /* @__PURE__ */ new Map();
|
|
4046
|
-
const cacheDir =
|
|
4047
|
-
const customDir =
|
|
4048
|
-
const cachedThemesDir =
|
|
4849
|
+
const cacheDir = join6(projectRoot, ".decantr", "cache");
|
|
4850
|
+
const customDir = join6(projectRoot, ".decantr", "custom");
|
|
4851
|
+
const cachedThemesDir = join6(cacheDir, "@official", "themes");
|
|
4049
4852
|
try {
|
|
4050
|
-
if (
|
|
4051
|
-
for (const file of
|
|
4853
|
+
if (existsSync6(cachedThemesDir)) {
|
|
4854
|
+
for (const file of readdirSync5(cachedThemesDir).filter(
|
|
4052
4855
|
(name) => name.endsWith(".json") && name !== "index.json"
|
|
4053
4856
|
)) {
|
|
4054
|
-
const data = JSON.parse(
|
|
4857
|
+
const data = JSON.parse(readFileSync6(join6(cachedThemesDir, file), "utf-8"));
|
|
4055
4858
|
if (data.id && !themeRegistry.has(data.id)) {
|
|
4056
4859
|
themeRegistry.set(data.id, { modes: data.modes || ["light", "dark"] });
|
|
4057
4860
|
}
|
|
@@ -4059,11 +4862,11 @@ function buildRegistryContext(projectRoot) {
|
|
|
4059
4862
|
}
|
|
4060
4863
|
} catch {
|
|
4061
4864
|
}
|
|
4062
|
-
const customThemesDir =
|
|
4865
|
+
const customThemesDir = join6(customDir, "themes");
|
|
4063
4866
|
try {
|
|
4064
|
-
if (
|
|
4065
|
-
for (const file of
|
|
4066
|
-
const data = JSON.parse(
|
|
4867
|
+
if (existsSync6(customThemesDir)) {
|
|
4868
|
+
for (const file of readdirSync5(customThemesDir).filter((name) => name.endsWith(".json"))) {
|
|
4869
|
+
const data = JSON.parse(readFileSync6(join6(customThemesDir, file), "utf-8"));
|
|
4067
4870
|
if (data.id) {
|
|
4068
4871
|
themeRegistry.set(`custom:${data.id}`, { modes: data.modes || ["light", "dark"] });
|
|
4069
4872
|
}
|
|
@@ -4071,13 +4874,13 @@ function buildRegistryContext(projectRoot) {
|
|
|
4071
4874
|
}
|
|
4072
4875
|
} catch {
|
|
4073
4876
|
}
|
|
4074
|
-
const cachedPatternsDir =
|
|
4877
|
+
const cachedPatternsDir = join6(cacheDir, "@official", "patterns");
|
|
4075
4878
|
try {
|
|
4076
|
-
if (
|
|
4077
|
-
for (const file of
|
|
4879
|
+
if (existsSync6(cachedPatternsDir)) {
|
|
4880
|
+
for (const file of readdirSync5(cachedPatternsDir).filter(
|
|
4078
4881
|
(name) => name.endsWith(".json") && name !== "index.json"
|
|
4079
4882
|
)) {
|
|
4080
|
-
const data = JSON.parse(
|
|
4883
|
+
const data = JSON.parse(readFileSync6(join6(cachedPatternsDir, file), "utf-8"));
|
|
4081
4884
|
if (data.id && !patternRegistry.has(data.id)) {
|
|
4082
4885
|
patternRegistry.set(data.id, data);
|
|
4083
4886
|
}
|
|
@@ -4391,8 +5194,8 @@ function extractFailedRouteDocumentHardening(runtimeAudit) {
|
|
|
4391
5194
|
return runtimeAudit.failures.filter((failure) => failure.startsWith("route-document-hardening-failed:")).map((failure) => normalizeRouteHint2(failure.slice("route-document-hardening-failed:".length))).filter(Boolean);
|
|
4392
5195
|
}
|
|
4393
5196
|
function appendRuntimeAuditFindings(findings, runtimeAudit, projectRoot, topology, sourceAudit) {
|
|
4394
|
-
const distPath =
|
|
4395
|
-
const indexPath =
|
|
5197
|
+
const distPath = join6(projectRoot, "dist");
|
|
5198
|
+
const indexPath = join6(distPath, "index.html");
|
|
4396
5199
|
const isFrameworkBuildOutput = runtimeAudit.failures.includes("next-build-output");
|
|
4397
5200
|
if (!runtimeAudit.distPresent) {
|
|
4398
5201
|
findings.push(
|
|
@@ -4937,7 +5740,7 @@ function appendRuntimeAuditFindings(findings, runtimeAudit, projectRoot, topolog
|
|
|
4937
5740
|
}
|
|
4938
5741
|
function readBehaviorPatterns(projectRoot) {
|
|
4939
5742
|
const pack = readJsonIfExists(
|
|
4940
|
-
|
|
5743
|
+
join6(projectRoot, ".decantr", "local-patterns.json")
|
|
4941
5744
|
);
|
|
4942
5745
|
return (pack?.patterns ?? []).filter(
|
|
4943
5746
|
(pattern) => pattern.behavior_obligations && Array.isArray(pattern.behavior_obligations.obligations) && pattern.behavior_obligations.obligations.length > 0
|
|
@@ -4965,16 +5768,34 @@ function behaviorRepairPayload(input) {
|
|
|
4965
5768
|
...input.componentPaths?.length ? { component_paths: input.componentPaths } : {}
|
|
4966
5769
|
};
|
|
4967
5770
|
}
|
|
5771
|
+
function isLocalPatternComponentPath(pattern, relativeFile) {
|
|
5772
|
+
const normalizedFile = relativeFile.replace(/\\/g, "/");
|
|
5773
|
+
return (pattern.componentPaths ?? []).some((componentPath) => {
|
|
5774
|
+
const normalizedComponentPath = componentPath.replace(/\\/g, "/");
|
|
5775
|
+
return normalizedFile === normalizedComponentPath || normalizedFile.endsWith(`/${normalizedComponentPath}`);
|
|
5776
|
+
});
|
|
5777
|
+
}
|
|
5778
|
+
function isFormPrimitiveDefinitionFile(pattern, relativeFile) {
|
|
5779
|
+
if (isLocalPatternComponentPath(pattern, relativeFile)) return true;
|
|
5780
|
+
const normalizedFile = relativeFile.replace(/\\/g, "/");
|
|
5781
|
+
if (!/(?:^|\/)(?:components|ui|shared|packages\/[^/]+\/src)\//i.test(normalizedFile)) {
|
|
5782
|
+
return false;
|
|
5783
|
+
}
|
|
5784
|
+
const base = basename2(normalizedFile).toLowerCase();
|
|
5785
|
+
return /^(?:input|select|textarea|field|form|form-field|form-control|label|checkbox|radio|switch|combobox|button)\.[cm]?[jt]sx?$/.test(
|
|
5786
|
+
base
|
|
5787
|
+
);
|
|
5788
|
+
}
|
|
4968
5789
|
function sourceAuditFilePath(projectRoot, file) {
|
|
4969
|
-
return
|
|
5790
|
+
return isAbsolute4(file) ? file : join6(projectRoot, file);
|
|
4970
5791
|
}
|
|
4971
5792
|
function sourceAuditRelativePath(projectRoot, file) {
|
|
4972
|
-
return (
|
|
5793
|
+
return (isAbsolute4(file) ? relative6(projectRoot, file) : file).replace(/\\/g, "/");
|
|
4973
5794
|
}
|
|
4974
5795
|
function sourceFileContainsAny(projectRoot, sourceFiles, patterns) {
|
|
4975
5796
|
for (const file of sourceFiles.slice(0, 400)) {
|
|
4976
5797
|
try {
|
|
4977
|
-
const code =
|
|
5798
|
+
const code = readFileSync6(sourceAuditFilePath(projectRoot, file), "utf-8");
|
|
4978
5799
|
if (patterns.some((pattern) => pattern.test(code))) return true;
|
|
4979
5800
|
} catch {
|
|
4980
5801
|
}
|
|
@@ -5028,11 +5849,12 @@ function appendBehaviorObligationFindings(findings, projectRoot, sourceFiles) {
|
|
|
5028
5849
|
const relativeFile = sourceAuditRelativePath(projectRoot, file);
|
|
5029
5850
|
let code = "";
|
|
5030
5851
|
try {
|
|
5031
|
-
code =
|
|
5852
|
+
code = readFileSync6(sourceAuditFilePath(projectRoot, file), "utf-8");
|
|
5032
5853
|
} catch {
|
|
5033
5854
|
continue;
|
|
5034
5855
|
}
|
|
5035
5856
|
if (!/<\s*(?:form|input|select|textarea|button)\b/i.test(code)) continue;
|
|
5857
|
+
if (isFormPrimitiveDefinitionFile(formPattern, relativeFile)) continue;
|
|
5036
5858
|
const signals = analyzeAstSignals(relativeFile, code);
|
|
5037
5859
|
if (behaviorPatternHasObligation(formPattern, "label-associated") && signals.formControlWithoutLabelCount > 0) {
|
|
5038
5860
|
findings.push(
|
|
@@ -5104,7 +5926,7 @@ function appendBehaviorObligationFindings(findings, projectRoot, sourceFiles) {
|
|
|
5104
5926
|
const relativeFile = sourceAuditRelativePath(projectRoot, file);
|
|
5105
5927
|
let code = "";
|
|
5106
5928
|
try {
|
|
5107
|
-
code =
|
|
5929
|
+
code = readFileSync6(sourceAuditFilePath(projectRoot, file), "utf-8");
|
|
5108
5930
|
} catch {
|
|
5109
5931
|
continue;
|
|
5110
5932
|
}
|
|
@@ -6426,6 +7248,8 @@ function appendStyleBridgeDriftFindings(findings, audit) {
|
|
|
6426
7248
|
source: finding.source,
|
|
6427
7249
|
property: finding.property,
|
|
6428
7250
|
bridge_mappings: finding.bridgeMappingIds,
|
|
7251
|
+
bridge_confidence: finding.bridgeConfidence,
|
|
7252
|
+
bridge_sources: finding.bridgeSources,
|
|
6429
7253
|
token_hints: finding.tokenHints,
|
|
6430
7254
|
class_hints: finding.classHints
|
|
6431
7255
|
}
|
|
@@ -6469,7 +7293,7 @@ function appendStyleContractFindings(findings, styleAudit, essence) {
|
|
|
6469
7293
|
}
|
|
6470
7294
|
}
|
|
6471
7295
|
async function auditProject(projectRoot) {
|
|
6472
|
-
const essencePath =
|
|
7296
|
+
const essencePath = join6(projectRoot, "decantr.essence.json");
|
|
6473
7297
|
const findings = [];
|
|
6474
7298
|
const reviewPack = loadReviewPack(projectRoot);
|
|
6475
7299
|
const packManifest = loadPackManifest(projectRoot);
|
|
@@ -6477,7 +7301,7 @@ async function auditProject(projectRoot) {
|
|
|
6477
7301
|
const packHydrationOptional = adoptionMode === "contract-only" || adoptionMode === "style-bridge";
|
|
6478
7302
|
const packHydrationSeverity = packHydrationOptional ? "info" : "warn";
|
|
6479
7303
|
const runtimeAudit = emptyRuntimeAudit();
|
|
6480
|
-
if (!
|
|
7304
|
+
if (!existsSync6(essencePath)) {
|
|
6481
7305
|
findings.push(
|
|
6482
7306
|
makeFinding({
|
|
6483
7307
|
id: "essence-missing",
|
|
@@ -6512,7 +7336,7 @@ async function auditProject(projectRoot) {
|
|
|
6512
7336
|
}
|
|
6513
7337
|
let essence = null;
|
|
6514
7338
|
try {
|
|
6515
|
-
essence = JSON.parse(
|
|
7339
|
+
essence = JSON.parse(readFileSync6(essencePath, "utf-8"));
|
|
6516
7340
|
} catch (error) {
|
|
6517
7341
|
findings.push(
|
|
6518
7342
|
makeFinding({
|
|
@@ -6555,7 +7379,7 @@ async function auditProject(projectRoot) {
|
|
|
6555
7379
|
category: "Execution Packs",
|
|
6556
7380
|
severity: packHydrationSeverity,
|
|
6557
7381
|
message: packHydrationOptional ? "Compiled execution pack manifest is not hydrated yet; this is optional for contract-only/style-bridge Brownfield adoption." : "Compiled execution pack manifest is missing.",
|
|
6558
|
-
evidence: [
|
|
7382
|
+
evidence: [join6(projectRoot, ".decantr", "context", "pack-manifest.json")],
|
|
6559
7383
|
suggestedFix: packHydrationOptional ? "Optional: run `decantr registry compile-packs decantr.essence.json --write-context` when you want hosted page packs and review packs for richer assistant context." : "Run `decantr registry compile-packs decantr.essence.json --write-context` to hydrate scaffold, review, mutation, section, and page packs."
|
|
6560
7384
|
})
|
|
6561
7385
|
);
|
|
@@ -6619,7 +7443,7 @@ async function auditProject(projectRoot) {
|
|
|
6619
7443
|
category: "Review Contract",
|
|
6620
7444
|
severity: packHydrationSeverity,
|
|
6621
7445
|
message: packHydrationOptional ? "The compiled review pack file is not hydrated yet; contract-only/style-bridge Brownfield projects can continue without it." : "The compiled review pack file is missing.",
|
|
6622
|
-
evidence: [
|
|
7446
|
+
evidence: [join6(projectRoot, ".decantr", "context", "review-pack.json")],
|
|
6623
7447
|
suggestedFix: packHydrationOptional ? "Optional: hydrate hosted packs later if you want critique consumers to anchor findings to the compiled review contract." : "Hydrate the full hosted context bundle with `decantr registry compile-packs decantr.essence.json --write-context` so critique consumers can anchor findings to the compiled review contract."
|
|
6624
7448
|
})
|
|
6625
7449
|
);
|
|
@@ -6766,74 +7590,74 @@ function countKeyboardShortcutSignals(code) {
|
|
|
6766
7590
|
return matches.length;
|
|
6767
7591
|
}
|
|
6768
7592
|
function getScriptKind(filePath) {
|
|
6769
|
-
switch (
|
|
7593
|
+
switch (extname6(filePath).toLowerCase()) {
|
|
6770
7594
|
case ".tsx":
|
|
6771
|
-
return
|
|
7595
|
+
return ts6.ScriptKind.TSX;
|
|
6772
7596
|
case ".jsx":
|
|
6773
|
-
return
|
|
7597
|
+
return ts6.ScriptKind.JSX;
|
|
6774
7598
|
case ".ts":
|
|
6775
|
-
return
|
|
7599
|
+
return ts6.ScriptKind.TS;
|
|
6776
7600
|
case ".js":
|
|
6777
|
-
return
|
|
7601
|
+
return ts6.ScriptKind.JS;
|
|
6778
7602
|
default:
|
|
6779
|
-
return
|
|
7603
|
+
return ts6.ScriptKind.TSX;
|
|
6780
7604
|
}
|
|
6781
7605
|
}
|
|
6782
7606
|
function isPropertyNamed(node, ...names) {
|
|
6783
7607
|
if (!node) return false;
|
|
6784
|
-
if (
|
|
7608
|
+
if (ts6.isIdentifier(node)) {
|
|
6785
7609
|
return names.includes(node.text);
|
|
6786
7610
|
}
|
|
6787
|
-
if (
|
|
7611
|
+
if (ts6.isPrivateIdentifier(node)) {
|
|
6788
7612
|
return names.includes(node.text);
|
|
6789
7613
|
}
|
|
6790
|
-
if (
|
|
7614
|
+
if (ts6.isStringLiteral(node)) {
|
|
6791
7615
|
return names.includes(node.text);
|
|
6792
7616
|
}
|
|
6793
7617
|
return false;
|
|
6794
7618
|
}
|
|
6795
7619
|
function getJsxAttribute(attributes, ...names) {
|
|
6796
7620
|
return attributes.properties.find(
|
|
6797
|
-
(property) =>
|
|
7621
|
+
(property) => ts6.isJsxAttribute(property) && isPropertyNamed(property.name, ...names)
|
|
6798
7622
|
);
|
|
6799
7623
|
}
|
|
6800
7624
|
function getJsxTagName(node) {
|
|
6801
|
-
if (
|
|
7625
|
+
if (ts6.isIdentifier(node.tagName)) {
|
|
6802
7626
|
return node.tagName.text;
|
|
6803
7627
|
}
|
|
6804
|
-
if (
|
|
7628
|
+
if (ts6.isPropertyAccessExpression(node.tagName)) {
|
|
6805
7629
|
return node.tagName.name.text;
|
|
6806
7630
|
}
|
|
6807
7631
|
return null;
|
|
6808
7632
|
}
|
|
6809
7633
|
function getJsxAttributeLiteralValue(attribute) {
|
|
6810
7634
|
if (!attribute?.initializer) return null;
|
|
6811
|
-
if (
|
|
7635
|
+
if (ts6.isStringLiteral(attribute.initializer)) {
|
|
6812
7636
|
return attribute.initializer.text;
|
|
6813
7637
|
}
|
|
6814
|
-
if (
|
|
7638
|
+
if (ts6.isJsxExpression(attribute.initializer)) {
|
|
6815
7639
|
const expression = attribute.initializer.expression;
|
|
6816
7640
|
if (!expression) return "";
|
|
6817
|
-
if (
|
|
7641
|
+
if (ts6.isStringLiteral(expression) || ts6.isNoSubstitutionTemplateLiteral(expression)) {
|
|
6818
7642
|
return expression.text;
|
|
6819
7643
|
}
|
|
6820
7644
|
}
|
|
6821
7645
|
return null;
|
|
6822
7646
|
}
|
|
6823
7647
|
function getJsxTextContent(node) {
|
|
6824
|
-
if (
|
|
7648
|
+
if (ts6.isJsxText(node)) {
|
|
6825
7649
|
return node.getText();
|
|
6826
7650
|
}
|
|
6827
|
-
if (
|
|
7651
|
+
if (ts6.isStringLiteral(node) || ts6.isNoSubstitutionTemplateLiteral(node)) {
|
|
6828
7652
|
return node.text;
|
|
6829
7653
|
}
|
|
6830
|
-
if (
|
|
7654
|
+
if (ts6.isJsxExpression(node)) {
|
|
6831
7655
|
return node.expression ? getJsxTextContent(node.expression) : "";
|
|
6832
7656
|
}
|
|
6833
|
-
if (
|
|
7657
|
+
if (ts6.isJsxSelfClosingElement(node) || ts6.isJsxOpeningElement(node)) {
|
|
6834
7658
|
return "";
|
|
6835
7659
|
}
|
|
6836
|
-
if (
|
|
7660
|
+
if (ts6.isJsxElement(node) || ts6.isJsxFragment(node)) {
|
|
6837
7661
|
return node.children.map((child) => getJsxTextContent(child)).join("");
|
|
6838
7662
|
}
|
|
6839
7663
|
let text = "";
|
|
@@ -6853,7 +7677,7 @@ function isNonSemanticInteractiveTag(tagName) {
|
|
|
6853
7677
|
function collectLabelForIds(root) {
|
|
6854
7678
|
const ids = /* @__PURE__ */ new Set();
|
|
6855
7679
|
const walk = (node) => {
|
|
6856
|
-
if (
|
|
7680
|
+
if (ts6.isJsxSelfClosingElement(node) || ts6.isJsxOpeningElement(node)) {
|
|
6857
7681
|
const tagName = getJsxTagName(node);
|
|
6858
7682
|
if (tagName === "label") {
|
|
6859
7683
|
const htmlForValue = getJsxAttributeLiteralValue(
|
|
@@ -6864,7 +7688,7 @@ function collectLabelForIds(root) {
|
|
|
6864
7688
|
}
|
|
6865
7689
|
}
|
|
6866
7690
|
}
|
|
6867
|
-
|
|
7691
|
+
ts6.forEachChild(node, walk);
|
|
6868
7692
|
};
|
|
6869
7693
|
walk(root);
|
|
6870
7694
|
return ids;
|
|
@@ -6872,7 +7696,7 @@ function collectLabelForIds(root) {
|
|
|
6872
7696
|
function isWrappedInJsxLabel(node) {
|
|
6873
7697
|
let current = node.parent;
|
|
6874
7698
|
while (current) {
|
|
6875
|
-
if (
|
|
7699
|
+
if (ts6.isJsxElement(current) && getJsxTagName(current.openingElement) === "label") {
|
|
6876
7700
|
return true;
|
|
6877
7701
|
}
|
|
6878
7702
|
current = current.parent;
|
|
@@ -6882,7 +7706,7 @@ function isWrappedInJsxLabel(node) {
|
|
|
6882
7706
|
function hasAncestorJsxTag(node, tagName) {
|
|
6883
7707
|
let current = node.parent;
|
|
6884
7708
|
while (current) {
|
|
6885
|
-
if (
|
|
7709
|
+
if (ts6.isJsxElement(current) && getJsxTagName(current.openingElement) === tagName) {
|
|
6886
7710
|
return true;
|
|
6887
7711
|
}
|
|
6888
7712
|
current = current.parent;
|
|
@@ -6960,9 +7784,9 @@ function hasNavigationLabel(attributes) {
|
|
|
6960
7784
|
}
|
|
6961
7785
|
function getJsxAttributeOwner(attribute) {
|
|
6962
7786
|
const attributes = attribute.parent;
|
|
6963
|
-
if (!attributes || !
|
|
7787
|
+
if (!attributes || !ts6.isJsxAttributes(attributes)) return null;
|
|
6964
7788
|
const owner = attributes.parent;
|
|
6965
|
-
if (
|
|
7789
|
+
if (ts6.isJsxOpeningElement(owner) || ts6.isJsxSelfClosingElement(owner)) {
|
|
6966
7790
|
return owner;
|
|
6967
7791
|
}
|
|
6968
7792
|
return null;
|
|
@@ -7049,14 +7873,14 @@ function jsxTreeContainsAuthInput(node) {
|
|
|
7049
7873
|
let found = false;
|
|
7050
7874
|
const visit = (current) => {
|
|
7051
7875
|
if (found) return;
|
|
7052
|
-
if (
|
|
7876
|
+
if (ts6.isJsxSelfClosingElement(current)) {
|
|
7053
7877
|
const tagName = getJsxTagName(current);
|
|
7054
7878
|
if (tagName === "input" && isAuthLikeInputAttributes(current.attributes)) {
|
|
7055
7879
|
found = true;
|
|
7056
7880
|
}
|
|
7057
7881
|
return;
|
|
7058
7882
|
}
|
|
7059
|
-
if (
|
|
7883
|
+
if (ts6.isJsxElement(current)) {
|
|
7060
7884
|
const tagName = getJsxTagName(current.openingElement);
|
|
7061
7885
|
if (tagName === "input" && isAuthLikeInputAttributes(current.openingElement.attributes)) {
|
|
7062
7886
|
found = true;
|
|
@@ -7068,7 +7892,7 @@ function jsxTreeContainsAuthInput(node) {
|
|
|
7068
7892
|
}
|
|
7069
7893
|
return;
|
|
7070
7894
|
}
|
|
7071
|
-
if (
|
|
7895
|
+
if (ts6.isJsxFragment(current)) {
|
|
7072
7896
|
for (const child of current.children) {
|
|
7073
7897
|
visit(child);
|
|
7074
7898
|
if (found) return;
|
|
@@ -7092,7 +7916,7 @@ function jsxTreeHasSubmitControl(node) {
|
|
|
7092
7916
|
let found = false;
|
|
7093
7917
|
const visit = (current) => {
|
|
7094
7918
|
if (found) return;
|
|
7095
|
-
if (
|
|
7919
|
+
if (ts6.isJsxSelfClosingElement(current)) {
|
|
7096
7920
|
const tagName = getJsxTagName(current);
|
|
7097
7921
|
if (tagName === "button") {
|
|
7098
7922
|
const typeValue = getJsxAttributeLiteralValue(getJsxAttribute(current.attributes, "type"))?.trim().toLowerCase();
|
|
@@ -7108,7 +7932,7 @@ function jsxTreeHasSubmitControl(node) {
|
|
|
7108
7932
|
}
|
|
7109
7933
|
return;
|
|
7110
7934
|
}
|
|
7111
|
-
if (
|
|
7935
|
+
if (ts6.isJsxElement(current)) {
|
|
7112
7936
|
const tagName = getJsxTagName(current.openingElement);
|
|
7113
7937
|
if (tagName === "button") {
|
|
7114
7938
|
const typeValue = getJsxAttributeLiteralValue(
|
|
@@ -7132,7 +7956,7 @@ function jsxTreeHasSubmitControl(node) {
|
|
|
7132
7956
|
}
|
|
7133
7957
|
return;
|
|
7134
7958
|
}
|
|
7135
|
-
if (
|
|
7959
|
+
if (ts6.isJsxFragment(current)) {
|
|
7136
7960
|
for (const child of current.children) {
|
|
7137
7961
|
visit(child);
|
|
7138
7962
|
if (found) return;
|
|
@@ -7149,14 +7973,14 @@ function jsxTreeHasTag(node, tagNames) {
|
|
|
7149
7973
|
const wanted = new Set(tagNames);
|
|
7150
7974
|
const visit = (current) => {
|
|
7151
7975
|
if (found) return;
|
|
7152
|
-
if (
|
|
7976
|
+
if (ts6.isJsxSelfClosingElement(current)) {
|
|
7153
7977
|
const tagName = getJsxTagName(current);
|
|
7154
7978
|
if (tagName && wanted.has(tagName)) {
|
|
7155
7979
|
found = true;
|
|
7156
7980
|
}
|
|
7157
7981
|
return;
|
|
7158
7982
|
}
|
|
7159
|
-
if (
|
|
7983
|
+
if (ts6.isJsxElement(current)) {
|
|
7160
7984
|
const tagName = getJsxTagName(current.openingElement);
|
|
7161
7985
|
if (tagName && wanted.has(tagName)) {
|
|
7162
7986
|
found = true;
|
|
@@ -7168,7 +7992,7 @@ function jsxTreeHasTag(node, tagNames) {
|
|
|
7168
7992
|
}
|
|
7169
7993
|
return;
|
|
7170
7994
|
}
|
|
7171
|
-
if (
|
|
7995
|
+
if (ts6.isJsxFragment(current)) {
|
|
7172
7996
|
for (const child of current.children) {
|
|
7173
7997
|
visit(child);
|
|
7174
7998
|
if (found) return;
|
|
@@ -7185,22 +8009,22 @@ function hasAuthFormWithoutSubmitControl(node) {
|
|
|
7185
8009
|
}
|
|
7186
8010
|
function getExpressionLiteralValue(expression) {
|
|
7187
8011
|
if (!expression) return null;
|
|
7188
|
-
if (
|
|
8012
|
+
if (ts6.isStringLiteral(expression) || ts6.isNoSubstitutionTemplateLiteral(expression)) {
|
|
7189
8013
|
return expression.text;
|
|
7190
8014
|
}
|
|
7191
|
-
if (
|
|
8015
|
+
if (ts6.isParenthesizedExpression(expression)) {
|
|
7192
8016
|
return getExpressionLiteralValue(expression.expression);
|
|
7193
8017
|
}
|
|
7194
|
-
if (
|
|
8018
|
+
if (ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression)) {
|
|
7195
8019
|
return getExpressionLiteralValue(expression.expression);
|
|
7196
8020
|
}
|
|
7197
8021
|
return null;
|
|
7198
8022
|
}
|
|
7199
8023
|
function getObjectLiteralStringPropertyValue(expression, ...propertyNames) {
|
|
7200
|
-
if (!expression || !
|
|
8024
|
+
if (!expression || !ts6.isObjectLiteralExpression(expression)) return null;
|
|
7201
8025
|
for (const property of expression.properties) {
|
|
7202
|
-
if (!
|
|
7203
|
-
const propertyName2 =
|
|
8026
|
+
if (!ts6.isPropertyAssignment(property)) continue;
|
|
8027
|
+
const propertyName2 = ts6.isIdentifier(property.name) ? property.name.text : ts6.isStringLiteral(property.name) ? property.name.text : null;
|
|
7204
8028
|
if (!propertyName2 || !propertyNames.includes(propertyName2)) continue;
|
|
7205
8029
|
const value = getExpressionLiteralValue(property.initializer);
|
|
7206
8030
|
if (value) return value;
|
|
@@ -7208,24 +8032,24 @@ function getObjectLiteralStringPropertyValue(expression, ...propertyNames) {
|
|
|
7208
8032
|
return null;
|
|
7209
8033
|
}
|
|
7210
8034
|
function getObjectLiteralBooleanPropertyValue(expression, ...propertyNames) {
|
|
7211
|
-
if (!expression || !
|
|
8035
|
+
if (!expression || !ts6.isObjectLiteralExpression(expression)) return null;
|
|
7212
8036
|
for (const property of expression.properties) {
|
|
7213
|
-
if (!
|
|
7214
|
-
const propertyName2 =
|
|
8037
|
+
if (!ts6.isPropertyAssignment(property)) continue;
|
|
8038
|
+
const propertyName2 = ts6.isIdentifier(property.name) ? property.name.text : ts6.isStringLiteral(property.name) ? property.name.text : null;
|
|
7215
8039
|
if (!propertyName2 || !propertyNames.includes(propertyName2)) continue;
|
|
7216
|
-
if (property.initializer.kind ===
|
|
7217
|
-
if (property.initializer.kind ===
|
|
8040
|
+
if (property.initializer.kind === ts6.SyntaxKind.TrueKeyword) return true;
|
|
8041
|
+
if (property.initializer.kind === ts6.SyntaxKind.FalseKeyword) return false;
|
|
7218
8042
|
}
|
|
7219
8043
|
return null;
|
|
7220
8044
|
}
|
|
7221
8045
|
function collectNamedFunctionLikeDeclarations(root) {
|
|
7222
8046
|
const declarations = /* @__PURE__ */ new Map();
|
|
7223
8047
|
const visit = (node) => {
|
|
7224
|
-
if (
|
|
8048
|
+
if (ts6.isFunctionDeclaration(node) && node.name && ts6.isIdentifier(node.name)) {
|
|
7225
8049
|
declarations.set(node.name.text, node);
|
|
7226
8050
|
}
|
|
7227
|
-
if (
|
|
7228
|
-
if (
|
|
8051
|
+
if (ts6.isVariableDeclaration(node) && ts6.isIdentifier(node.name) && node.initializer) {
|
|
8052
|
+
if (ts6.isArrowFunction(node.initializer) || ts6.isFunctionExpression(node.initializer)) {
|
|
7229
8053
|
declarations.set(node.name.text, node.initializer);
|
|
7230
8054
|
}
|
|
7231
8055
|
}
|
|
@@ -7245,12 +8069,12 @@ function getCachedNamedFunctionLikeDeclarations(sourceFile) {
|
|
|
7245
8069
|
function collectNamedExpressionInitializers(root) {
|
|
7246
8070
|
const initializers = /* @__PURE__ */ new Map();
|
|
7247
8071
|
const visit = (node) => {
|
|
7248
|
-
if (
|
|
8072
|
+
if (ts6.isVariableDeclaration(node) && ts6.isIdentifier(node.name) && node.initializer) {
|
|
7249
8073
|
initializers.set(node.name.text, node.initializer);
|
|
7250
8074
|
}
|
|
7251
|
-
if (
|
|
8075
|
+
if (ts6.isVariableDeclaration(node) && ts6.isArrayBindingPattern(node.name) && node.initializer) {
|
|
7252
8076
|
const firstElement = node.name.elements[0];
|
|
7253
|
-
if (firstElement && !
|
|
8077
|
+
if (firstElement && !ts6.isOmittedExpression(firstElement) && ts6.isBindingElement(firstElement) && ts6.isIdentifier(firstElement.name)) {
|
|
7254
8078
|
initializers.set(firstElement.name.text, node.initializer);
|
|
7255
8079
|
}
|
|
7256
8080
|
}
|
|
@@ -7261,7 +8085,7 @@ function collectNamedExpressionInitializers(root) {
|
|
|
7261
8085
|
}
|
|
7262
8086
|
function getPropertyNameText(name) {
|
|
7263
8087
|
if (!name) return null;
|
|
7264
|
-
if (
|
|
8088
|
+
if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
|
|
7265
8089
|
return name.text;
|
|
7266
8090
|
}
|
|
7267
8091
|
return null;
|
|
@@ -7274,20 +8098,20 @@ function collectNamedPropertyAliases(root) {
|
|
|
7274
8098
|
const propertyName2 = getPropertyNameText(element.propertyName) ?? getPropertyNameText(element.name);
|
|
7275
8099
|
if (!propertyName2) continue;
|
|
7276
8100
|
const nextPath = [...propertyPath, propertyName2];
|
|
7277
|
-
if (
|
|
8101
|
+
if (ts6.isIdentifier(element.name)) {
|
|
7278
8102
|
aliases.set(element.name.text, { initializer, propertyName: propertyName2, propertyPath: nextPath });
|
|
7279
8103
|
continue;
|
|
7280
8104
|
}
|
|
7281
|
-
if (
|
|
8105
|
+
if (ts6.isObjectBindingPattern(element.name)) {
|
|
7282
8106
|
collectFromBindingPattern(element.name, initializer, nextPath);
|
|
7283
8107
|
}
|
|
7284
8108
|
}
|
|
7285
8109
|
};
|
|
7286
8110
|
const visit = (node) => {
|
|
7287
|
-
if (
|
|
8111
|
+
if (ts6.isVariableDeclaration(node) && ts6.isObjectBindingPattern(node.name) && node.initializer) {
|
|
7288
8112
|
collectFromBindingPattern(node.name, node.initializer, []);
|
|
7289
8113
|
}
|
|
7290
|
-
if (
|
|
8114
|
+
if (ts6.isParameter(node) && ts6.isObjectBindingPattern(node.name)) {
|
|
7291
8115
|
collectFromBindingPattern(node.name, void 0, []);
|
|
7292
8116
|
}
|
|
7293
8117
|
node.forEachChild(visit);
|
|
@@ -7297,28 +8121,28 @@ function collectNamedPropertyAliases(root) {
|
|
|
7297
8121
|
}
|
|
7298
8122
|
function resolveFunctionLikeHandler(expression, namedFunctions) {
|
|
7299
8123
|
if (!expression) return null;
|
|
7300
|
-
if (
|
|
8124
|
+
if (ts6.isArrowFunction(expression) || ts6.isFunctionExpression(expression)) {
|
|
7301
8125
|
return expression;
|
|
7302
8126
|
}
|
|
7303
|
-
if (
|
|
8127
|
+
if (ts6.isIdentifier(expression)) {
|
|
7304
8128
|
return namedFunctions.get(expression.text) ?? null;
|
|
7305
8129
|
}
|
|
7306
8130
|
return null;
|
|
7307
8131
|
}
|
|
7308
8132
|
function getFunctionLikeReturnExpressions(node) {
|
|
7309
|
-
if (
|
|
8133
|
+
if (ts6.isArrowFunction(node) && !ts6.isBlock(node.body)) {
|
|
7310
8134
|
return [node.body];
|
|
7311
8135
|
}
|
|
7312
8136
|
const body = node.body;
|
|
7313
|
-
if (!body || !
|
|
8137
|
+
if (!body || !ts6.isBlock(body)) {
|
|
7314
8138
|
return [];
|
|
7315
8139
|
}
|
|
7316
8140
|
const expressions = [];
|
|
7317
8141
|
const visit = (current) => {
|
|
7318
|
-
if (current !== body && (
|
|
8142
|
+
if (current !== body && (ts6.isFunctionDeclaration(current) || ts6.isFunctionExpression(current) || ts6.isArrowFunction(current) || ts6.isMethodDeclaration(current) || ts6.isGetAccessorDeclaration(current) || ts6.isSetAccessorDeclaration(current) || ts6.isConstructorDeclaration(current))) {
|
|
7319
8143
|
return;
|
|
7320
8144
|
}
|
|
7321
|
-
if (
|
|
8145
|
+
if (ts6.isReturnStatement(current) && current.expression) {
|
|
7322
8146
|
expressions.push(current.expression);
|
|
7323
8147
|
return;
|
|
7324
8148
|
}
|
|
@@ -7334,7 +8158,7 @@ function bindFunctionLikeArguments(functionLike, args, namedExpressions) {
|
|
|
7334
8158
|
const boundExpressions = new Map(namedExpressions);
|
|
7335
8159
|
functionLike.parameters.forEach((parameter, index) => {
|
|
7336
8160
|
const argument = args[index];
|
|
7337
|
-
if (!argument || !
|
|
8161
|
+
if (!argument || !ts6.isIdentifier(parameter.name)) return;
|
|
7338
8162
|
boundExpressions.set(parameter.name.text, argument);
|
|
7339
8163
|
});
|
|
7340
8164
|
return boundExpressions;
|
|
@@ -7348,10 +8172,10 @@ function getMemberAccessPropertyName(expression) {
|
|
|
7348
8172
|
}
|
|
7349
8173
|
function getObjectLiteralPropertyExpression(objectLiteral, propertyName2, namedExpressions) {
|
|
7350
8174
|
for (const property of objectLiteral.properties) {
|
|
7351
|
-
if (
|
|
8175
|
+
if (ts6.isPropertyAssignment(property) && getPropertyNameText(property.name) === propertyName2) {
|
|
7352
8176
|
return property.initializer;
|
|
7353
8177
|
}
|
|
7354
|
-
if (
|
|
8178
|
+
if (ts6.isShorthandPropertyAssignment(property) && property.name.text === propertyName2) {
|
|
7355
8179
|
return namedExpressions.get(property.name.text) ?? null;
|
|
7356
8180
|
}
|
|
7357
8181
|
}
|
|
@@ -7417,7 +8241,7 @@ function resolveReturnedObjectLiteralExpression(functionLike, args, sourceFile,
|
|
|
7417
8241
|
function resolveObjectLiteralExpression(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers, seenFunctions = /* @__PURE__ */ new Set(), depth = 0) {
|
|
7418
8242
|
if (!expression) return null;
|
|
7419
8243
|
if (depth > MAX_OPEN_REDIRECT_RESOLUTION_DEPTH) return null;
|
|
7420
|
-
if (
|
|
8244
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
7421
8245
|
return resolveObjectLiteralExpression(
|
|
7422
8246
|
expression.expression,
|
|
7423
8247
|
sourceFile,
|
|
@@ -7428,10 +8252,10 @@ function resolveObjectLiteralExpression(expression, sourceFile, namedExpressions
|
|
|
7428
8252
|
depth + 1
|
|
7429
8253
|
);
|
|
7430
8254
|
}
|
|
7431
|
-
if (
|
|
8255
|
+
if (ts6.isObjectLiteralExpression(expression)) {
|
|
7432
8256
|
return { objectLiteral: expression, namedExpressions };
|
|
7433
8257
|
}
|
|
7434
|
-
if (
|
|
8258
|
+
if (ts6.isIdentifier(expression)) {
|
|
7435
8259
|
if (seenIdentifiers.has(expression.text)) return null;
|
|
7436
8260
|
const initializer = namedExpressions.get(expression.text);
|
|
7437
8261
|
if (initializer) {
|
|
@@ -7504,13 +8328,13 @@ function resolveObjectLiteralExpression(expression, sourceFile, namedExpressions
|
|
|
7504
8328
|
}
|
|
7505
8329
|
function findFunctionLikeOnObjectLiteral(objectLiteral, propertyName2, namedFunctions) {
|
|
7506
8330
|
for (const property of objectLiteral.properties) {
|
|
7507
|
-
if (
|
|
8331
|
+
if (ts6.isMethodDeclaration(property) && getPropertyNameText(property.name) === propertyName2) {
|
|
7508
8332
|
return property;
|
|
7509
8333
|
}
|
|
7510
|
-
if (
|
|
8334
|
+
if (ts6.isPropertyAssignment(property) && getPropertyNameText(property.name) === propertyName2) {
|
|
7511
8335
|
return resolveFunctionLikeHandler(property.initializer, namedFunctions);
|
|
7512
8336
|
}
|
|
7513
|
-
if (
|
|
8337
|
+
if (ts6.isShorthandPropertyAssignment(property) && property.name.text === propertyName2) {
|
|
7514
8338
|
return namedFunctions.get(property.name.text) ?? null;
|
|
7515
8339
|
}
|
|
7516
8340
|
}
|
|
@@ -7545,7 +8369,7 @@ function resolveTrackedOpenRedirectFunctionLike(expression, sourceFile, namedExp
|
|
|
7545
8369
|
if (directFunctionLike) {
|
|
7546
8370
|
return { functionLike: directFunctionLike, namedExpressions };
|
|
7547
8371
|
}
|
|
7548
|
-
if (
|
|
8372
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
7549
8373
|
return resolveTrackedOpenRedirectFunctionLike(
|
|
7550
8374
|
expression.expression,
|
|
7551
8375
|
sourceFile,
|
|
@@ -7578,7 +8402,7 @@ function resolveTrackedOpenRedirectFunctionLike(expression, sourceFile, namedExp
|
|
|
7578
8402
|
depth + 1
|
|
7579
8403
|
);
|
|
7580
8404
|
}
|
|
7581
|
-
if (
|
|
8405
|
+
if (ts6.isIdentifier(expression)) {
|
|
7582
8406
|
if (seenIdentifiers.has(expression.text)) return null;
|
|
7583
8407
|
const initializer = namedExpressions.get(expression.text);
|
|
7584
8408
|
if (initializer) {
|
|
@@ -7641,16 +8465,16 @@ function functionLikeReferencesOrigin(node) {
|
|
|
7641
8465
|
let found = false;
|
|
7642
8466
|
const visit = (current) => {
|
|
7643
8467
|
if (found) return;
|
|
7644
|
-
if (
|
|
8468
|
+
if (ts6.isPropertyAccessExpression(current) && isPropertyNamed(current.name, "origin")) {
|
|
7645
8469
|
found = true;
|
|
7646
8470
|
return;
|
|
7647
8471
|
}
|
|
7648
|
-
if (
|
|
8472
|
+
if (ts6.isIdentifier(current) && current.text === "origin") {
|
|
7649
8473
|
found = true;
|
|
7650
8474
|
return;
|
|
7651
8475
|
}
|
|
7652
|
-
if (
|
|
7653
|
-
if (
|
|
8476
|
+
if (ts6.isBindingElement(current)) {
|
|
8477
|
+
if (ts6.isIdentifier(current.name) && current.name.text === "origin") {
|
|
7654
8478
|
found = true;
|
|
7655
8479
|
return;
|
|
7656
8480
|
}
|
|
@@ -7665,13 +8489,13 @@ function functionLikeReferencesOrigin(node) {
|
|
|
7665
8489
|
return found;
|
|
7666
8490
|
}
|
|
7667
8491
|
function isAddEventListenerCall(node) {
|
|
7668
|
-
return
|
|
8492
|
+
return ts6.isIdentifier(node.expression) && node.expression.text === "addEventListener" || ts6.isPropertyAccessExpression(node.expression) && isPropertyNamed(node.expression.name, "addEventListener");
|
|
7669
8493
|
}
|
|
7670
8494
|
function isCookieMutationSetCall(node) {
|
|
7671
|
-
if (!
|
|
8495
|
+
if (!ts6.isPropertyAccessExpression(node.expression) || !isPropertyNamed(node.expression.name, "set")) {
|
|
7672
8496
|
return false;
|
|
7673
8497
|
}
|
|
7674
|
-
return
|
|
8498
|
+
return ts6.isIdentifier(node.expression.expression) && ["Cookies", "cookieStore", "cookies"].includes(node.expression.expression.text) || ts6.isPropertyAccessExpression(node.expression.expression) && isPropertyNamed(node.expression.expression.name, "cookies", "cookieStore");
|
|
7675
8499
|
}
|
|
7676
8500
|
function expressionLooksLikeAuthCookieName(node, sourceFile) {
|
|
7677
8501
|
if (!node) return false;
|
|
@@ -7679,17 +8503,17 @@ function expressionLooksLikeAuthCookieName(node, sourceFile) {
|
|
|
7679
8503
|
return hasAuthCredentialText(node, sourceFile);
|
|
7680
8504
|
}
|
|
7681
8505
|
function objectLiteralLooksLikeAuthCookieConfig(expression, sourceFile) {
|
|
7682
|
-
if (!expression || !
|
|
8506
|
+
if (!expression || !ts6.isObjectLiteralExpression(expression)) return false;
|
|
7683
8507
|
for (const property of expression.properties) {
|
|
7684
|
-
if (!
|
|
7685
|
-
const propertyName2 =
|
|
8508
|
+
if (!ts6.isPropertyAssignment(property)) continue;
|
|
8509
|
+
const propertyName2 = ts6.isIdentifier(property.name) ? property.name.text : ts6.isStringLiteral(property.name) ? property.name.text : null;
|
|
7686
8510
|
if (!propertyName2 || !["name", "key", "cookie"].includes(propertyName2)) continue;
|
|
7687
8511
|
return expressionLooksLikeAuthCookieName(property.initializer, sourceFile);
|
|
7688
8512
|
}
|
|
7689
8513
|
return false;
|
|
7690
8514
|
}
|
|
7691
8515
|
function hasExplicitAuthCookieHardening(expression) {
|
|
7692
|
-
if (!expression || !
|
|
8516
|
+
if (!expression || !ts6.isObjectLiteralExpression(expression)) return false;
|
|
7693
8517
|
const httpOnly = getObjectLiteralBooleanPropertyValue(expression, "httpOnly", "http_only");
|
|
7694
8518
|
const secure = getObjectLiteralBooleanPropertyValue(expression, "secure");
|
|
7695
8519
|
const sameSite = getObjectLiteralStringPropertyValue(expression, "sameSite", "same_site");
|
|
@@ -7709,8 +8533,8 @@ function collectCookieHeaderStrings(expression) {
|
|
|
7709
8533
|
if (!expression) return [];
|
|
7710
8534
|
const literal = getExpressionLiteralValue(expression);
|
|
7711
8535
|
if (literal !== null) return [literal];
|
|
7712
|
-
if (
|
|
7713
|
-
return expression.elements.map((element) =>
|
|
8536
|
+
if (ts6.isArrayLiteralExpression(expression)) {
|
|
8537
|
+
return expression.elements.map((element) => ts6.isExpression(element) ? getExpressionLiteralValue(element) : null).filter((value) => value !== null);
|
|
7714
8538
|
}
|
|
7715
8539
|
return [];
|
|
7716
8540
|
}
|
|
@@ -7718,16 +8542,16 @@ function isInsecureTransportUrl(value) {
|
|
|
7718
8542
|
return typeof value === "string" && /^(?:http|ws):\/\//i.test(value.trim());
|
|
7719
8543
|
}
|
|
7720
8544
|
function isPropertyLikeAccessExpression(node) {
|
|
7721
|
-
return Boolean(node && (
|
|
8545
|
+
return Boolean(node && (ts6.isPropertyAccessExpression(node) || ts6.isPropertyAccessChain(node)));
|
|
7722
8546
|
}
|
|
7723
8547
|
function isElementLikeAccessExpression(node) {
|
|
7724
|
-
return Boolean(node && (
|
|
8548
|
+
return Boolean(node && (ts6.isElementAccessExpression(node) || ts6.isElementAccessChain(node)));
|
|
7725
8549
|
}
|
|
7726
8550
|
function isMemberAccessExpression(node) {
|
|
7727
8551
|
return isPropertyLikeAccessExpression(node) || isElementLikeAccessExpression(node);
|
|
7728
8552
|
}
|
|
7729
8553
|
function isCallLikeExpression(node) {
|
|
7730
|
-
return Boolean(node && (
|
|
8554
|
+
return Boolean(node && (ts6.isCallExpression(node) || ts6.isCallChain(node)));
|
|
7731
8555
|
}
|
|
7732
8556
|
function isMemberAccessNamed(node, ...names) {
|
|
7733
8557
|
if (!node) return false;
|
|
@@ -7740,19 +8564,19 @@ function isMemberAccessNamed(node, ...names) {
|
|
|
7740
8564
|
return false;
|
|
7741
8565
|
}
|
|
7742
8566
|
function isLocationObjectExpression(expression) {
|
|
7743
|
-
return
|
|
8567
|
+
return ts6.isIdentifier(expression) && expression.text === "location" || (ts6.isPropertyAccessExpression(expression) || ts6.isElementAccessExpression(expression)) && ts6.isIdentifier(expression.expression) && ["window", "globalThis", "document", "self", "parent", "top"].includes(
|
|
7744
8568
|
expression.expression.text
|
|
7745
8569
|
) && isMemberAccessNamed(expression, "location");
|
|
7746
8570
|
}
|
|
7747
8571
|
function isLocationAssignmentTarget(expression) {
|
|
7748
|
-
return isLocationObjectExpression(expression) || (
|
|
8572
|
+
return isLocationObjectExpression(expression) || (ts6.isPropertyAccessExpression(expression) || ts6.isElementAccessExpression(expression)) && isLocationObjectExpression(expression.expression) && isMemberAccessNamed(expression, "href");
|
|
7749
8573
|
}
|
|
7750
8574
|
function isFetchLikeCall(node) {
|
|
7751
|
-
return
|
|
8575
|
+
return ts6.isIdentifier(node.expression) && node.expression.text === "fetch" || ts6.isPropertyAccessExpression(node.expression) && isPropertyNamed(node.expression.name, "fetch");
|
|
7752
8576
|
}
|
|
7753
8577
|
function isAxiosLikeCall(node) {
|
|
7754
|
-
if (!
|
|
7755
|
-
return
|
|
8578
|
+
if (!ts6.isPropertyAccessExpression(node.expression)) return false;
|
|
8579
|
+
return ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "axios" && isPropertyNamed(
|
|
7756
8580
|
node.expression.name,
|
|
7757
8581
|
"get",
|
|
7758
8582
|
"post",
|
|
@@ -7765,10 +8589,10 @@ function isAxiosLikeCall(node) {
|
|
|
7765
8589
|
);
|
|
7766
8590
|
}
|
|
7767
8591
|
function isAxiosConfigCall(node) {
|
|
7768
|
-
return
|
|
8592
|
+
return ts6.isIdentifier(node.expression) && node.expression.text === "axios";
|
|
7769
8593
|
}
|
|
7770
8594
|
function isRealtimeTransportConstructor(node) {
|
|
7771
|
-
return
|
|
8595
|
+
return ts6.isIdentifier(node.expression) && (node.expression.text === "WebSocket" || node.expression.text === "EventSource");
|
|
7772
8596
|
}
|
|
7773
8597
|
function hasPlaceholderNavigationTarget(attributes) {
|
|
7774
8598
|
const targetValue = getJsxAttributeLiteralValue(getJsxAttribute(attributes, "href", "to"));
|
|
@@ -7835,40 +8659,40 @@ function getSkipNavTargetId(attributes, tagName) {
|
|
|
7835
8659
|
}
|
|
7836
8660
|
function isAuthStorageKeyLiteral(node) {
|
|
7837
8661
|
if (!node) return false;
|
|
7838
|
-
if (
|
|
8662
|
+
if (ts6.isStringLiteral(node) || ts6.isNoSubstitutionTemplateLiteral(node)) {
|
|
7839
8663
|
if (node.text === "decantr_authenticated") return false;
|
|
7840
8664
|
return /(?:token|auth|jwt|session|access_token|refresh_token)/i.test(node.text);
|
|
7841
8665
|
}
|
|
7842
8666
|
return false;
|
|
7843
8667
|
}
|
|
7844
8668
|
function isBrowserStorageObject(node) {
|
|
7845
|
-
return
|
|
8669
|
+
return ts6.isIdentifier(node) && (node.text === "localStorage" || node.text === "sessionStorage");
|
|
7846
8670
|
}
|
|
7847
8671
|
function isDocumentObject(node) {
|
|
7848
|
-
return
|
|
8672
|
+
return ts6.isIdentifier(node) && node.text === "document";
|
|
7849
8673
|
}
|
|
7850
8674
|
function isCookiePropertyAccess(node) {
|
|
7851
|
-
return
|
|
8675
|
+
return ts6.isPropertyAccessExpression(node) && isDocumentObject(node.expression) && isPropertyNamed(node.name, "cookie");
|
|
7852
8676
|
}
|
|
7853
8677
|
function hasAuthCredentialText(node, sourceFile) {
|
|
7854
8678
|
return /(?:token|auth|jwt|session|access_token|refresh_token)/i.test(node.getText(sourceFile));
|
|
7855
8679
|
}
|
|
7856
8680
|
function isAuthorizationHeaderName(node) {
|
|
7857
8681
|
if (!node) return false;
|
|
7858
|
-
if (
|
|
8682
|
+
if (ts6.isIdentifier(node)) {
|
|
7859
8683
|
return /^authorization$/i.test(node.text);
|
|
7860
8684
|
}
|
|
7861
|
-
if (
|
|
8685
|
+
if (ts6.isStringLiteral(node) || ts6.isNoSubstitutionTemplateLiteral(node)) {
|
|
7862
8686
|
return /^authorization$/i.test(node.text);
|
|
7863
8687
|
}
|
|
7864
|
-
if (
|
|
8688
|
+
if (ts6.isComputedPropertyName(node)) {
|
|
7865
8689
|
return isAuthorizationHeaderName(node.expression);
|
|
7866
8690
|
}
|
|
7867
8691
|
return false;
|
|
7868
8692
|
}
|
|
7869
8693
|
function isAuthorizationHeaderAccess(node) {
|
|
7870
8694
|
if (!node) return false;
|
|
7871
|
-
return
|
|
8695
|
+
return ts6.isPropertyAccessExpression(node) && isAuthorizationHeaderName(node.name) || ts6.isElementAccessExpression(node) && isAuthorizationHeaderName(node.argumentExpression);
|
|
7872
8696
|
}
|
|
7873
8697
|
function isHeaderClearValue(node) {
|
|
7874
8698
|
if (!node) return false;
|
|
@@ -7876,7 +8700,7 @@ function isHeaderClearValue(node) {
|
|
|
7876
8700
|
if (literal !== null) {
|
|
7877
8701
|
return literal.trim().length === 0;
|
|
7878
8702
|
}
|
|
7879
|
-
return node.kind ===
|
|
8703
|
+
return node.kind === ts6.SyntaxKind.NullKeyword || node.kind === ts6.SyntaxKind.UndefinedKeyword || ts6.isIdentifier(node) && node.text === "undefined";
|
|
7880
8704
|
}
|
|
7881
8705
|
function countAuthGuardSignals(code) {
|
|
7882
8706
|
const patterns = [
|
|
@@ -8625,7 +9449,7 @@ function propertyPathLooksLikeOpenRedirectQueryContainerBase(propertyPath) {
|
|
|
8625
9449
|
}
|
|
8626
9450
|
function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFile, namedExpressions = /* @__PURE__ */ new Map(), namedPropertyAliases = /* @__PURE__ */ new Map(), seenIdentifiers = /* @__PURE__ */ new Set(), seenFunctions = /* @__PURE__ */ new Set()) {
|
|
8627
9451
|
if (!expression) return false;
|
|
8628
|
-
if (
|
|
9452
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
8629
9453
|
return expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8630
9454
|
expression.expression,
|
|
8631
9455
|
sourceFile,
|
|
@@ -8652,7 +9476,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8652
9476
|
)
|
|
8653
9477
|
);
|
|
8654
9478
|
}
|
|
8655
|
-
if (
|
|
9479
|
+
if (ts6.isBinaryExpression(expression) && (expression.operatorToken.kind === ts6.SyntaxKind.QuestionQuestionToken || expression.operatorToken.kind === ts6.SyntaxKind.BarBarToken)) {
|
|
8656
9480
|
return expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8657
9481
|
expression.left,
|
|
8658
9482
|
sourceFile,
|
|
@@ -8669,7 +9493,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8669
9493
|
seenFunctions
|
|
8670
9494
|
);
|
|
8671
9495
|
}
|
|
8672
|
-
if (
|
|
9496
|
+
if (ts6.isConditionalExpression(expression)) {
|
|
8673
9497
|
return expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8674
9498
|
expression.whenTrue,
|
|
8675
9499
|
sourceFile,
|
|
@@ -8686,7 +9510,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8686
9510
|
seenFunctions
|
|
8687
9511
|
);
|
|
8688
9512
|
}
|
|
8689
|
-
if (
|
|
9513
|
+
if (ts6.isTemplateExpression(expression)) {
|
|
8690
9514
|
return expression.templateSpans.some(
|
|
8691
9515
|
(span) => expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8692
9516
|
span.expression,
|
|
@@ -8698,7 +9522,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8698
9522
|
)
|
|
8699
9523
|
);
|
|
8700
9524
|
}
|
|
8701
|
-
if (
|
|
9525
|
+
if (ts6.isTaggedTemplateExpression(expression)) {
|
|
8702
9526
|
return expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8703
9527
|
expression.template,
|
|
8704
9528
|
sourceFile,
|
|
@@ -8708,7 +9532,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8708
9532
|
seenFunctions
|
|
8709
9533
|
);
|
|
8710
9534
|
}
|
|
8711
|
-
if (
|
|
9535
|
+
if (ts6.isNewExpression(expression) && expression.arguments && expression.arguments.length > 0 && expressionLooksLikeBrowserGlobalBooleanHelper(
|
|
8712
9536
|
expression.expression,
|
|
8713
9537
|
sourceFile,
|
|
8714
9538
|
namedExpressions,
|
|
@@ -8724,7 +9548,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8724
9548
|
)) {
|
|
8725
9549
|
return true;
|
|
8726
9550
|
}
|
|
8727
|
-
if (
|
|
9551
|
+
if (ts6.isNewExpression(expression) && expression.arguments && expression.arguments.length > 0 && expressionLooksLikeBrowserGlobalNumberHelper(
|
|
8728
9552
|
expression.expression,
|
|
8729
9553
|
sourceFile,
|
|
8730
9554
|
namedExpressions,
|
|
@@ -8740,7 +9564,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8740
9564
|
)) {
|
|
8741
9565
|
return true;
|
|
8742
9566
|
}
|
|
8743
|
-
if (
|
|
9567
|
+
if (ts6.isNewExpression(expression) && expression.arguments && expression.arguments.length > 0 && expressionLooksLikeBrowserGlobalObjectHelper(
|
|
8744
9568
|
expression.expression,
|
|
8745
9569
|
sourceFile,
|
|
8746
9570
|
namedExpressions,
|
|
@@ -8756,7 +9580,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8756
9580
|
)) {
|
|
8757
9581
|
return true;
|
|
8758
9582
|
}
|
|
8759
|
-
if (
|
|
9583
|
+
if (ts6.isNewExpression(expression) && expression.arguments && expression.arguments.length > 0 && expressionLooksLikeBrowserGlobalStringHelper(
|
|
8760
9584
|
expression.expression,
|
|
8761
9585
|
sourceFile,
|
|
8762
9586
|
namedExpressions,
|
|
@@ -8788,7 +9612,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8788
9612
|
)) {
|
|
8789
9613
|
return true;
|
|
8790
9614
|
}
|
|
8791
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
9615
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeBrowserGlobalSymbolHelper(
|
|
8792
9616
|
expression.arguments[0],
|
|
8793
9617
|
sourceFile,
|
|
8794
9618
|
namedExpressions,
|
|
@@ -8852,7 +9676,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8852
9676
|
)) {
|
|
8853
9677
|
return true;
|
|
8854
9678
|
}
|
|
8855
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
9679
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeBrowserGlobalBigIntHelper(
|
|
8856
9680
|
expression.arguments[0],
|
|
8857
9681
|
sourceFile,
|
|
8858
9682
|
namedExpressions,
|
|
@@ -8916,7 +9740,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8916
9740
|
)) {
|
|
8917
9741
|
return true;
|
|
8918
9742
|
}
|
|
8919
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
9743
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeBrowserGlobalBooleanHelper(
|
|
8920
9744
|
expression.arguments[0],
|
|
8921
9745
|
sourceFile,
|
|
8922
9746
|
namedExpressions,
|
|
@@ -8980,7 +9804,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8980
9804
|
)) {
|
|
8981
9805
|
return true;
|
|
8982
9806
|
}
|
|
8983
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
9807
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeBrowserGlobalNumberHelper(
|
|
8984
9808
|
expression.arguments[0],
|
|
8985
9809
|
sourceFile,
|
|
8986
9810
|
namedExpressions,
|
|
@@ -9044,7 +9868,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9044
9868
|
)) {
|
|
9045
9869
|
return true;
|
|
9046
9870
|
}
|
|
9047
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
9871
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeBrowserGlobalObjectHelper(
|
|
9048
9872
|
expression.arguments[0],
|
|
9049
9873
|
sourceFile,
|
|
9050
9874
|
namedExpressions,
|
|
@@ -9092,7 +9916,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9092
9916
|
)) {
|
|
9093
9917
|
return true;
|
|
9094
9918
|
}
|
|
9095
|
-
if (isCallLikeExpression(expression) &&
|
|
9919
|
+
if (isCallLikeExpression(expression) && ts6.isIdentifier(expression.expression) && [
|
|
9096
9920
|
"String",
|
|
9097
9921
|
"atob",
|
|
9098
9922
|
"btoa",
|
|
@@ -9128,7 +9952,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9128
9952
|
)) {
|
|
9129
9953
|
return true;
|
|
9130
9954
|
}
|
|
9131
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
9955
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeJsonStringifyHelper(
|
|
9132
9956
|
expression.arguments[0],
|
|
9133
9957
|
sourceFile,
|
|
9134
9958
|
namedExpressions,
|
|
@@ -9192,7 +10016,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9192
10016
|
)) {
|
|
9193
10017
|
return true;
|
|
9194
10018
|
}
|
|
9195
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
10019
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeJsonParseHelper(
|
|
9196
10020
|
expression.arguments[0],
|
|
9197
10021
|
sourceFile,
|
|
9198
10022
|
namedExpressions,
|
|
@@ -9256,7 +10080,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9256
10080
|
)) {
|
|
9257
10081
|
return true;
|
|
9258
10082
|
}
|
|
9259
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
10083
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeStructuredCloneHelper(
|
|
9260
10084
|
expression.arguments[0],
|
|
9261
10085
|
sourceFile,
|
|
9262
10086
|
namedExpressions,
|
|
@@ -9320,7 +10144,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9320
10144
|
)) {
|
|
9321
10145
|
return true;
|
|
9322
10146
|
}
|
|
9323
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
10147
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeBrowserGlobalStringHelper(
|
|
9324
10148
|
expression.arguments[0],
|
|
9325
10149
|
sourceFile,
|
|
9326
10150
|
namedExpressions,
|
|
@@ -9400,7 +10224,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9400
10224
|
)) {
|
|
9401
10225
|
return true;
|
|
9402
10226
|
}
|
|
9403
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
10227
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeBrowserGlobalUriCodecHelper(
|
|
9404
10228
|
expression.arguments[0],
|
|
9405
10229
|
sourceFile,
|
|
9406
10230
|
namedExpressions,
|
|
@@ -9448,7 +10272,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9448
10272
|
)) {
|
|
9449
10273
|
return true;
|
|
9450
10274
|
}
|
|
9451
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
10275
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeBrowserGlobalBase64Helper(
|
|
9452
10276
|
expression.arguments[0],
|
|
9453
10277
|
sourceFile,
|
|
9454
10278
|
namedExpressions,
|
|
@@ -9496,7 +10320,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9496
10320
|
)) {
|
|
9497
10321
|
return true;
|
|
9498
10322
|
}
|
|
9499
|
-
if (isCallLikeExpression(expression) && (
|
|
10323
|
+
if (isCallLikeExpression(expression) && (ts6.isIdentifier(expression.expression) || isMemberAccessExpression(expression.expression)) && expression.arguments.length > 0 && expressionLooksLikeBufferFromHelper(
|
|
9500
10324
|
expression.expression,
|
|
9501
10325
|
sourceFile,
|
|
9502
10326
|
namedExpressions,
|
|
@@ -9548,7 +10372,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9548
10372
|
)) {
|
|
9549
10373
|
return true;
|
|
9550
10374
|
}
|
|
9551
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
10375
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && expression.arguments.length > 2 && expressionLooksLikeBufferFromHelper(
|
|
9552
10376
|
expression.arguments[0],
|
|
9553
10377
|
sourceFile,
|
|
9554
10378
|
namedExpressions,
|
|
@@ -9596,7 +10420,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9596
10420
|
)) {
|
|
9597
10421
|
return true;
|
|
9598
10422
|
}
|
|
9599
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && isMemberAccessNamed(expression.expression, "from") &&
|
|
10423
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && isMemberAccessNamed(expression.expression, "from") && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Buffer" && expression.arguments.length > 0 && expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
9600
10424
|
expression.arguments[0],
|
|
9601
10425
|
sourceFile,
|
|
9602
10426
|
namedExpressions,
|
|
@@ -9775,7 +10599,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9775
10599
|
)) {
|
|
9776
10600
|
return true;
|
|
9777
10601
|
}
|
|
9778
|
-
if (isElementLikeAccessExpression(expression) &&
|
|
10602
|
+
if (isElementLikeAccessExpression(expression) && ts6.isNumericLiteral(expression.argumentExpression) && expression.argumentExpression.text === "1" && isMemberAccessExpression(expression.expression) && isMemberAccessNamed(expression.expression, "value") && isCallLikeExpression(expression.expression.expression) && isMemberAccessExpression(expression.expression.expression.expression) && isMemberAccessNamed(expression.expression.expression.expression, "next") && isCallLikeExpression(expression.expression.expression.expression.expression) && isMemberAccessExpression(expression.expression.expression.expression.expression.expression) && isMemberAccessNamed(
|
|
9779
10603
|
expression.expression.expression.expression.expression.expression,
|
|
9780
10604
|
"entries"
|
|
9781
10605
|
) && expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
@@ -9808,7 +10632,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9808
10632
|
)) {
|
|
9809
10633
|
return true;
|
|
9810
10634
|
}
|
|
9811
|
-
if (isCallLikeExpression(expression) && isPropertyLikeAccessExpression(expression.expression) &&
|
|
10635
|
+
if (isCallLikeExpression(expression) && isPropertyLikeAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Array" && isPropertyNamed(expression.expression.name, "from") && expression.arguments.length > 0 && expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
9812
10636
|
expression.arguments[0],
|
|
9813
10637
|
sourceFile,
|
|
9814
10638
|
namedExpressions,
|
|
@@ -9818,8 +10642,8 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9818
10642
|
)) {
|
|
9819
10643
|
return true;
|
|
9820
10644
|
}
|
|
9821
|
-
if (
|
|
9822
|
-
(element) =>
|
|
10645
|
+
if (ts6.isArrayLiteralExpression(expression) && expression.elements.some(
|
|
10646
|
+
(element) => ts6.isSpreadElement(element) && expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
9823
10647
|
element.expression,
|
|
9824
10648
|
sourceFile,
|
|
9825
10649
|
namedExpressions,
|
|
@@ -9870,7 +10694,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9870
10694
|
)) {
|
|
9871
10695
|
return true;
|
|
9872
10696
|
}
|
|
9873
|
-
if (
|
|
10697
|
+
if (ts6.isIdentifier(expression)) {
|
|
9874
10698
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
9875
10699
|
const initializer = namedExpressions.get(expression.text);
|
|
9876
10700
|
if (initializer) {
|
|
@@ -9904,7 +10728,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9904
10728
|
if (OPEN_REDIRECT_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
9905
10729
|
return true;
|
|
9906
10730
|
}
|
|
9907
|
-
if (
|
|
10731
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
9908
10732
|
return expressionContainsOpenRedirectSource(
|
|
9909
10733
|
expression.expression,
|
|
9910
10734
|
sourceFile,
|
|
@@ -9914,7 +10738,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9914
10738
|
seenFunctions
|
|
9915
10739
|
);
|
|
9916
10740
|
}
|
|
9917
|
-
if (
|
|
10741
|
+
if (ts6.isBinaryExpression(expression)) {
|
|
9918
10742
|
return expressionContainsOpenRedirectSource(
|
|
9919
10743
|
expression.left,
|
|
9920
10744
|
sourceFile,
|
|
@@ -9931,7 +10755,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9931
10755
|
seenFunctions
|
|
9932
10756
|
);
|
|
9933
10757
|
}
|
|
9934
|
-
if (
|
|
10758
|
+
if (ts6.isConditionalExpression(expression)) {
|
|
9935
10759
|
return expressionContainsOpenRedirectSource(
|
|
9936
10760
|
expression.condition,
|
|
9937
10761
|
sourceFile,
|
|
@@ -9955,7 +10779,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9955
10779
|
seenFunctions
|
|
9956
10780
|
);
|
|
9957
10781
|
}
|
|
9958
|
-
if (
|
|
10782
|
+
if (ts6.isTemplateExpression(expression)) {
|
|
9959
10783
|
return expression.templateSpans.some(
|
|
9960
10784
|
(span) => expressionContainsOpenRedirectSource(
|
|
9961
10785
|
span.expression,
|
|
@@ -9967,7 +10791,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9967
10791
|
)
|
|
9968
10792
|
);
|
|
9969
10793
|
}
|
|
9970
|
-
if (
|
|
10794
|
+
if (ts6.isTaggedTemplateExpression(expression)) {
|
|
9971
10795
|
return expressionContainsOpenRedirectSource(
|
|
9972
10796
|
expression.template,
|
|
9973
10797
|
sourceFile,
|
|
@@ -9977,7 +10801,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9977
10801
|
seenFunctions
|
|
9978
10802
|
);
|
|
9979
10803
|
}
|
|
9980
|
-
if (
|
|
10804
|
+
if (ts6.isNewExpression(expression)) {
|
|
9981
10805
|
return (expression.arguments ?? []).some(
|
|
9982
10806
|
(argument) => expressionContainsOpenRedirectSource(
|
|
9983
10807
|
argument,
|
|
@@ -9989,9 +10813,9 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9989
10813
|
)
|
|
9990
10814
|
);
|
|
9991
10815
|
}
|
|
9992
|
-
if (
|
|
10816
|
+
if (ts6.isArrayLiteralExpression(expression)) {
|
|
9993
10817
|
return expression.elements.some((element) => {
|
|
9994
|
-
if (
|
|
10818
|
+
if (ts6.isSpreadElement(element)) {
|
|
9995
10819
|
return expressionContainsOpenRedirectSource(
|
|
9996
10820
|
element.expression,
|
|
9997
10821
|
sourceFile,
|
|
@@ -10001,7 +10825,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10001
10825
|
seenFunctions
|
|
10002
10826
|
);
|
|
10003
10827
|
}
|
|
10004
|
-
return
|
|
10828
|
+
return ts6.isExpression(element) && expressionContainsOpenRedirectSource(
|
|
10005
10829
|
element,
|
|
10006
10830
|
sourceFile,
|
|
10007
10831
|
namedExpressions,
|
|
@@ -10011,9 +10835,9 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10011
10835
|
);
|
|
10012
10836
|
});
|
|
10013
10837
|
}
|
|
10014
|
-
if (
|
|
10838
|
+
if (ts6.isObjectLiteralExpression(expression)) {
|
|
10015
10839
|
return expression.properties.some((property) => {
|
|
10016
|
-
if (
|
|
10840
|
+
if (ts6.isPropertyAssignment(property)) {
|
|
10017
10841
|
return expressionContainsOpenRedirectSource(
|
|
10018
10842
|
property.initializer,
|
|
10019
10843
|
sourceFile,
|
|
@@ -10023,7 +10847,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10023
10847
|
seenFunctions
|
|
10024
10848
|
);
|
|
10025
10849
|
}
|
|
10026
|
-
if (
|
|
10850
|
+
if (ts6.isShorthandPropertyAssignment(property)) {
|
|
10027
10851
|
return expressionContainsOpenRedirectSource(
|
|
10028
10852
|
property.name,
|
|
10029
10853
|
sourceFile,
|
|
@@ -10033,7 +10857,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10033
10857
|
seenFunctions
|
|
10034
10858
|
);
|
|
10035
10859
|
}
|
|
10036
|
-
if (
|
|
10860
|
+
if (ts6.isSpreadAssignment(property)) {
|
|
10037
10861
|
return expressionContainsOpenRedirectSource(
|
|
10038
10862
|
property.expression,
|
|
10039
10863
|
sourceFile,
|
|
@@ -10088,7 +10912,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10088
10912
|
}
|
|
10089
10913
|
}
|
|
10090
10914
|
}
|
|
10091
|
-
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) &&
|
|
10915
|
+
if (isCallLikeExpression(expression) && isMemberAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Reflect" && isMemberAccessNamed(expression.expression, "apply") && isOpenRedirectQueryKeyExpression(
|
|
10092
10916
|
getAliasedApplyArgumentExpression(expression.arguments[2], 0, namedExpressions, /* @__PURE__ */ new Set()),
|
|
10093
10917
|
namedExpressions,
|
|
10094
10918
|
seenIdentifiers
|
|
@@ -10204,7 +11028,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10204
11028
|
)) {
|
|
10205
11029
|
return true;
|
|
10206
11030
|
}
|
|
10207
|
-
if (
|
|
11031
|
+
if (ts6.isIdentifier(expression)) {
|
|
10208
11032
|
if (seenIdentifiers.has(expression.text)) {
|
|
10209
11033
|
return false;
|
|
10210
11034
|
}
|
|
@@ -10242,14 +11066,14 @@ function isOpenRedirectQueryKeyExpression(expression, namedExpressions = /* @__P
|
|
|
10242
11066
|
return true;
|
|
10243
11067
|
}
|
|
10244
11068
|
if (!expression) return false;
|
|
10245
|
-
if (
|
|
11069
|
+
if (ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression) || ts6.isParenthesizedExpression(expression)) {
|
|
10246
11070
|
return isOpenRedirectQueryKeyExpression(
|
|
10247
11071
|
expression.expression,
|
|
10248
11072
|
namedExpressions,
|
|
10249
11073
|
seenIdentifiers
|
|
10250
11074
|
);
|
|
10251
11075
|
}
|
|
10252
|
-
if (
|
|
11076
|
+
if (ts6.isIdentifier(expression)) {
|
|
10253
11077
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10254
11078
|
const initializer = namedExpressions.get(expression.text);
|
|
10255
11079
|
if (!initializer) return false;
|
|
@@ -10265,7 +11089,7 @@ function expressionLooksLikeOpenRedirectQueryCarrier(expression, sourceFile, nam
|
|
|
10265
11089
|
if (OPEN_REDIRECT_QUERY_CARRIER_REGEX.test(expression.getText(sourceFile))) {
|
|
10266
11090
|
return true;
|
|
10267
11091
|
}
|
|
10268
|
-
if (
|
|
11092
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10269
11093
|
return expressionLooksLikeOpenRedirectQueryCarrier(
|
|
10270
11094
|
expression.expression,
|
|
10271
11095
|
sourceFile,
|
|
@@ -10274,7 +11098,7 @@ function expressionLooksLikeOpenRedirectQueryCarrier(expression, sourceFile, nam
|
|
|
10274
11098
|
seenIdentifiers
|
|
10275
11099
|
);
|
|
10276
11100
|
}
|
|
10277
|
-
if (isCallLikeExpression(expression) && isPropertyLikeAccessExpression(expression.expression) &&
|
|
11101
|
+
if (isCallLikeExpression(expression) && isPropertyLikeAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Object" && isPropertyNamed(expression.expression.name, "fromEntries") && expression.arguments.length > 0) {
|
|
10278
11102
|
const entriesExpression = expression.arguments[0];
|
|
10279
11103
|
if (expressionLooksLikeOpenRedirectSearchParamsCarrier(
|
|
10280
11104
|
entriesExpression,
|
|
@@ -10304,7 +11128,7 @@ function expressionLooksLikeOpenRedirectQueryCarrier(expression, sourceFile, nam
|
|
|
10304
11128
|
seenIdentifiers
|
|
10305
11129
|
);
|
|
10306
11130
|
}
|
|
10307
|
-
if (
|
|
11131
|
+
if (ts6.isIdentifier(expression)) {
|
|
10308
11132
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10309
11133
|
const initializer = namedExpressions.get(expression.text);
|
|
10310
11134
|
if (initializer) {
|
|
@@ -10337,7 +11161,7 @@ function expressionLooksLikeOpenRedirectQueryCarrier(expression, sourceFile, nam
|
|
|
10337
11161
|
}
|
|
10338
11162
|
function expressionLooksLikeOpenRedirectEntriesCarrier(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10339
11163
|
if (!expression) return false;
|
|
10340
|
-
if (
|
|
11164
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10341
11165
|
return expressionLooksLikeOpenRedirectEntriesCarrier(
|
|
10342
11166
|
expression.expression,
|
|
10343
11167
|
sourceFile,
|
|
@@ -10346,7 +11170,7 @@ function expressionLooksLikeOpenRedirectEntriesCarrier(expression, sourceFile, n
|
|
|
10346
11170
|
seenIdentifiers
|
|
10347
11171
|
);
|
|
10348
11172
|
}
|
|
10349
|
-
if (isCallLikeExpression(expression) && isPropertyLikeAccessExpression(expression.expression) &&
|
|
11173
|
+
if (isCallLikeExpression(expression) && isPropertyLikeAccessExpression(expression.expression) && ts6.isIdentifier(expression.expression.expression) && expression.expression.expression.text === "Array" && isPropertyNamed(expression.expression.name, "from") && expression.arguments.length > 0 && (expressionLooksLikeOpenRedirectEntriesCarrier(
|
|
10350
11174
|
expression.arguments[0],
|
|
10351
11175
|
sourceFile,
|
|
10352
11176
|
namedExpressions,
|
|
@@ -10361,8 +11185,8 @@ function expressionLooksLikeOpenRedirectEntriesCarrier(expression, sourceFile, n
|
|
|
10361
11185
|
))) {
|
|
10362
11186
|
return true;
|
|
10363
11187
|
}
|
|
10364
|
-
if (
|
|
10365
|
-
(element) =>
|
|
11188
|
+
if (ts6.isArrayLiteralExpression(expression) && expression.elements.some(
|
|
11189
|
+
(element) => ts6.isSpreadElement(element) && (expressionLooksLikeOpenRedirectEntriesCarrier(
|
|
10366
11190
|
element.expression,
|
|
10367
11191
|
sourceFile,
|
|
10368
11192
|
namedExpressions,
|
|
@@ -10387,7 +11211,7 @@ function expressionLooksLikeOpenRedirectEntriesCarrier(expression, sourceFile, n
|
|
|
10387
11211
|
)) {
|
|
10388
11212
|
return true;
|
|
10389
11213
|
}
|
|
10390
|
-
if (
|
|
11214
|
+
if (ts6.isIdentifier(expression)) {
|
|
10391
11215
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10392
11216
|
const initializer = namedExpressions.get(expression.text);
|
|
10393
11217
|
if (!initializer) return false;
|
|
@@ -10409,7 +11233,7 @@ function expressionLooksLikeOpenRedirectQueryContainerBase(expression, sourceFil
|
|
|
10409
11233
|
if (OPEN_REDIRECT_QUERY_CONTAINER_BASE_REGEX.test(expression.getText(sourceFile))) {
|
|
10410
11234
|
return true;
|
|
10411
11235
|
}
|
|
10412
|
-
if (
|
|
11236
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10413
11237
|
return expressionLooksLikeOpenRedirectQueryContainerBase(
|
|
10414
11238
|
expression.expression,
|
|
10415
11239
|
sourceFile,
|
|
@@ -10418,10 +11242,10 @@ function expressionLooksLikeOpenRedirectQueryContainerBase(expression, sourceFil
|
|
|
10418
11242
|
seenIdentifiers
|
|
10419
11243
|
);
|
|
10420
11244
|
}
|
|
10421
|
-
if (isCallLikeExpression(expression) && (
|
|
11245
|
+
if (isCallLikeExpression(expression) && (ts6.isIdentifier(expression.expression) && expression.expression.text === "useRouter" || isMemberAccessExpression(expression.expression) && isMemberAccessNamed(expression.expression, "useRouter"))) {
|
|
10422
11246
|
return true;
|
|
10423
11247
|
}
|
|
10424
|
-
if (
|
|
11248
|
+
if (ts6.isIdentifier(expression)) {
|
|
10425
11249
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10426
11250
|
const initializer = namedExpressions.get(expression.text);
|
|
10427
11251
|
if (initializer) {
|
|
@@ -10459,7 +11283,7 @@ function expressionLooksLikeLocationQuerySource(expression, sourceFile, namedExp
|
|
|
10459
11283
|
if (LOCATION_QUERY_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
10460
11284
|
return true;
|
|
10461
11285
|
}
|
|
10462
|
-
if (
|
|
11286
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10463
11287
|
return expressionLooksLikeLocationQuerySource(
|
|
10464
11288
|
expression.expression,
|
|
10465
11289
|
sourceFile,
|
|
@@ -10492,7 +11316,7 @@ function expressionLooksLikeLocationQuerySource(expression, sourceFile, namedExp
|
|
|
10492
11316
|
))) {
|
|
10493
11317
|
return true;
|
|
10494
11318
|
}
|
|
10495
|
-
if (
|
|
11319
|
+
if (ts6.isIdentifier(expression)) {
|
|
10496
11320
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10497
11321
|
const initializer = namedExpressions.get(expression.text);
|
|
10498
11322
|
if (initializer) {
|
|
@@ -10528,10 +11352,10 @@ function expressionLooksLikeLocationQuerySource(expression, sourceFile, namedExp
|
|
|
10528
11352
|
}
|
|
10529
11353
|
function expressionLooksLikeWindowObjectSource(expression, sourceFile, namedExpressions, seenIdentifiers) {
|
|
10530
11354
|
if (!expression) return false;
|
|
10531
|
-
if (
|
|
11355
|
+
if (ts6.isIdentifier(expression) && ["window", "globalThis", "document", "self", "parent", "top"].includes(expression.text)) {
|
|
10532
11356
|
return true;
|
|
10533
11357
|
}
|
|
10534
|
-
if (
|
|
11358
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10535
11359
|
return expressionLooksLikeWindowObjectSource(
|
|
10536
11360
|
expression.expression,
|
|
10537
11361
|
sourceFile,
|
|
@@ -10539,7 +11363,7 @@ function expressionLooksLikeWindowObjectSource(expression, sourceFile, namedExpr
|
|
|
10539
11363
|
seenIdentifiers
|
|
10540
11364
|
);
|
|
10541
11365
|
}
|
|
10542
|
-
if (
|
|
11366
|
+
if (ts6.isIdentifier(expression)) {
|
|
10543
11367
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10544
11368
|
const initializer = namedExpressions.get(expression.text);
|
|
10545
11369
|
if (!initializer) return false;
|
|
@@ -10560,7 +11384,7 @@ function expressionLooksLikeLocationObjectSource(expression, sourceFile, namedEx
|
|
|
10560
11384
|
if (isLocationObjectExpression(expression)) {
|
|
10561
11385
|
return true;
|
|
10562
11386
|
}
|
|
10563
|
-
if (
|
|
11387
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10564
11388
|
return expressionLooksLikeLocationObjectSource(
|
|
10565
11389
|
expression.expression,
|
|
10566
11390
|
sourceFile,
|
|
@@ -10569,7 +11393,7 @@ function expressionLooksLikeLocationObjectSource(expression, sourceFile, namedEx
|
|
|
10569
11393
|
seenIdentifiers
|
|
10570
11394
|
);
|
|
10571
11395
|
}
|
|
10572
|
-
if (isCallLikeExpression(expression) && (
|
|
11396
|
+
if (isCallLikeExpression(expression) && (ts6.isIdentifier(expression.expression) && expression.expression.text === "useLocation" || isMemberAccessExpression(expression.expression) && isMemberAccessNamed(expression.expression, "useLocation"))) {
|
|
10573
11397
|
return true;
|
|
10574
11398
|
}
|
|
10575
11399
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "location") && expressionLooksLikeWindowObjectSource(
|
|
@@ -10580,7 +11404,7 @@ function expressionLooksLikeLocationObjectSource(expression, sourceFile, namedEx
|
|
|
10580
11404
|
)) {
|
|
10581
11405
|
return true;
|
|
10582
11406
|
}
|
|
10583
|
-
if (
|
|
11407
|
+
if (ts6.isIdentifier(expression)) {
|
|
10584
11408
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10585
11409
|
const initializer = namedExpressions.get(expression.text);
|
|
10586
11410
|
if (initializer) {
|
|
@@ -10609,10 +11433,10 @@ function expressionLooksLikeLocationObjectSource(expression, sourceFile, namedEx
|
|
|
10609
11433
|
}
|
|
10610
11434
|
function expressionLooksLikeHistoryObjectSource(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10611
11435
|
if (!expression) return false;
|
|
10612
|
-
if (
|
|
11436
|
+
if (ts6.isIdentifier(expression) && expression.text === "history") {
|
|
10613
11437
|
return true;
|
|
10614
11438
|
}
|
|
10615
|
-
if (
|
|
11439
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10616
11440
|
return expressionLooksLikeHistoryObjectSource(
|
|
10617
11441
|
expression.expression,
|
|
10618
11442
|
sourceFile,
|
|
@@ -10629,7 +11453,7 @@ function expressionLooksLikeHistoryObjectSource(expression, sourceFile, namedExp
|
|
|
10629
11453
|
)) {
|
|
10630
11454
|
return true;
|
|
10631
11455
|
}
|
|
10632
|
-
if (
|
|
11456
|
+
if (ts6.isIdentifier(expression)) {
|
|
10633
11457
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10634
11458
|
const initializer = namedExpressions.get(expression.text);
|
|
10635
11459
|
if (initializer) {
|
|
@@ -10658,10 +11482,10 @@ function expressionLooksLikeHistoryObjectSource(expression, sourceFile, namedExp
|
|
|
10658
11482
|
}
|
|
10659
11483
|
function expressionLooksLikeBufferObjectSource(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10660
11484
|
if (!expression) return false;
|
|
10661
|
-
if (
|
|
11485
|
+
if (ts6.isIdentifier(expression) && expression.text === "Buffer") {
|
|
10662
11486
|
return true;
|
|
10663
11487
|
}
|
|
10664
|
-
if (
|
|
11488
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10665
11489
|
return expressionLooksLikeBufferObjectSource(
|
|
10666
11490
|
expression.expression,
|
|
10667
11491
|
sourceFile,
|
|
@@ -10678,7 +11502,7 @@ function expressionLooksLikeBufferObjectSource(expression, sourceFile, namedExpr
|
|
|
10678
11502
|
)) {
|
|
10679
11503
|
return true;
|
|
10680
11504
|
}
|
|
10681
|
-
if (
|
|
11505
|
+
if (ts6.isIdentifier(expression)) {
|
|
10682
11506
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10683
11507
|
const initializer = namedExpressions.get(expression.text);
|
|
10684
11508
|
if (initializer) {
|
|
@@ -10725,7 +11549,7 @@ function expressionLooksLikeBufferFromHelper(expression, sourceFile, namedExpres
|
|
|
10725
11549
|
)) {
|
|
10726
11550
|
return true;
|
|
10727
11551
|
}
|
|
10728
|
-
if (
|
|
11552
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10729
11553
|
return expressionLooksLikeBufferFromHelper(
|
|
10730
11554
|
expression.expression,
|
|
10731
11555
|
sourceFile,
|
|
@@ -10734,7 +11558,7 @@ function expressionLooksLikeBufferFromHelper(expression, sourceFile, namedExpres
|
|
|
10734
11558
|
seenIdentifiers
|
|
10735
11559
|
);
|
|
10736
11560
|
}
|
|
10737
|
-
if (
|
|
11561
|
+
if (ts6.isIdentifier(expression)) {
|
|
10738
11562
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10739
11563
|
const initializer = namedExpressions.get(expression.text);
|
|
10740
11564
|
if (initializer) {
|
|
@@ -10764,10 +11588,10 @@ function expressionLooksLikeBufferFromHelper(expression, sourceFile, namedExpres
|
|
|
10764
11588
|
}
|
|
10765
11589
|
function expressionLooksLikeJsonObjectSource(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10766
11590
|
if (!expression) return false;
|
|
10767
|
-
if (
|
|
11591
|
+
if (ts6.isIdentifier(expression) && expression.text === "JSON") {
|
|
10768
11592
|
return true;
|
|
10769
11593
|
}
|
|
10770
|
-
if (
|
|
11594
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10771
11595
|
return expressionLooksLikeJsonObjectSource(
|
|
10772
11596
|
expression.expression,
|
|
10773
11597
|
sourceFile,
|
|
@@ -10784,7 +11608,7 @@ function expressionLooksLikeJsonObjectSource(expression, sourceFile, namedExpres
|
|
|
10784
11608
|
)) {
|
|
10785
11609
|
return true;
|
|
10786
11610
|
}
|
|
10787
|
-
if (
|
|
11611
|
+
if (ts6.isIdentifier(expression)) {
|
|
10788
11612
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10789
11613
|
const initializer = namedExpressions.get(expression.text);
|
|
10790
11614
|
if (initializer) {
|
|
@@ -10831,7 +11655,7 @@ function expressionLooksLikeJsonStringifyHelper(expression, sourceFile, namedExp
|
|
|
10831
11655
|
)) {
|
|
10832
11656
|
return true;
|
|
10833
11657
|
}
|
|
10834
|
-
if (
|
|
11658
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10835
11659
|
return expressionLooksLikeJsonStringifyHelper(
|
|
10836
11660
|
expression.expression,
|
|
10837
11661
|
sourceFile,
|
|
@@ -10840,7 +11664,7 @@ function expressionLooksLikeJsonStringifyHelper(expression, sourceFile, namedExp
|
|
|
10840
11664
|
seenIdentifiers
|
|
10841
11665
|
);
|
|
10842
11666
|
}
|
|
10843
|
-
if (
|
|
11667
|
+
if (ts6.isIdentifier(expression)) {
|
|
10844
11668
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10845
11669
|
const initializer = namedExpressions.get(expression.text);
|
|
10846
11670
|
if (initializer) {
|
|
@@ -10888,7 +11712,7 @@ function expressionLooksLikeJsonParseHelper(expression, sourceFile, namedExpress
|
|
|
10888
11712
|
)) {
|
|
10889
11713
|
return true;
|
|
10890
11714
|
}
|
|
10891
|
-
if (
|
|
11715
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10892
11716
|
return expressionLooksLikeJsonParseHelper(
|
|
10893
11717
|
expression.expression,
|
|
10894
11718
|
sourceFile,
|
|
@@ -10897,7 +11721,7 @@ function expressionLooksLikeJsonParseHelper(expression, sourceFile, namedExpress
|
|
|
10897
11721
|
seenIdentifiers
|
|
10898
11722
|
);
|
|
10899
11723
|
}
|
|
10900
|
-
if (
|
|
11724
|
+
if (ts6.isIdentifier(expression)) {
|
|
10901
11725
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10902
11726
|
const initializer = namedExpressions.get(expression.text);
|
|
10903
11727
|
if (initializer) {
|
|
@@ -10927,7 +11751,7 @@ function expressionLooksLikeJsonParseHelper(expression, sourceFile, namedExpress
|
|
|
10927
11751
|
}
|
|
10928
11752
|
function expressionLooksLikeStructuredCloneHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10929
11753
|
if (!expression) return false;
|
|
10930
|
-
if (
|
|
11754
|
+
if (ts6.isIdentifier(expression) && expression.text === "structuredClone") {
|
|
10931
11755
|
return true;
|
|
10932
11756
|
}
|
|
10933
11757
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "structuredClone") && expressionLooksLikeWindowObjectSource(
|
|
@@ -10947,7 +11771,7 @@ function expressionLooksLikeStructuredCloneHelper(expression, sourceFile, namedE
|
|
|
10947
11771
|
)) {
|
|
10948
11772
|
return true;
|
|
10949
11773
|
}
|
|
10950
|
-
if (
|
|
11774
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10951
11775
|
return expressionLooksLikeStructuredCloneHelper(
|
|
10952
11776
|
expression.expression,
|
|
10953
11777
|
sourceFile,
|
|
@@ -10956,7 +11780,7 @@ function expressionLooksLikeStructuredCloneHelper(expression, sourceFile, namedE
|
|
|
10956
11780
|
seenIdentifiers
|
|
10957
11781
|
);
|
|
10958
11782
|
}
|
|
10959
|
-
if (
|
|
11783
|
+
if (ts6.isIdentifier(expression)) {
|
|
10960
11784
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10961
11785
|
const initializer = namedExpressions.get(expression.text);
|
|
10962
11786
|
if (initializer) {
|
|
@@ -10985,7 +11809,7 @@ function expressionLooksLikeStructuredCloneHelper(expression, sourceFile, namedE
|
|
|
10985
11809
|
}
|
|
10986
11810
|
function expressionLooksLikeBrowserGlobalSymbolHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10987
11811
|
if (!expression) return false;
|
|
10988
|
-
if (
|
|
11812
|
+
if (ts6.isIdentifier(expression) && expression.text === "Symbol") {
|
|
10989
11813
|
return true;
|
|
10990
11814
|
}
|
|
10991
11815
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "Symbol") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11005,7 +11829,7 @@ function expressionLooksLikeBrowserGlobalSymbolHelper(expression, sourceFile, na
|
|
|
11005
11829
|
)) {
|
|
11006
11830
|
return true;
|
|
11007
11831
|
}
|
|
11008
|
-
if (
|
|
11832
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11009
11833
|
return expressionLooksLikeBrowserGlobalSymbolHelper(
|
|
11010
11834
|
expression.expression,
|
|
11011
11835
|
sourceFile,
|
|
@@ -11014,7 +11838,7 @@ function expressionLooksLikeBrowserGlobalSymbolHelper(expression, sourceFile, na
|
|
|
11014
11838
|
seenIdentifiers
|
|
11015
11839
|
);
|
|
11016
11840
|
}
|
|
11017
|
-
if (
|
|
11841
|
+
if (ts6.isIdentifier(expression)) {
|
|
11018
11842
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11019
11843
|
const initializer = namedExpressions.get(expression.text);
|
|
11020
11844
|
if (initializer) {
|
|
@@ -11043,7 +11867,7 @@ function expressionLooksLikeBrowserGlobalSymbolHelper(expression, sourceFile, na
|
|
|
11043
11867
|
}
|
|
11044
11868
|
function expressionLooksLikeBrowserGlobalBigIntHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11045
11869
|
if (!expression) return false;
|
|
11046
|
-
if (
|
|
11870
|
+
if (ts6.isIdentifier(expression) && expression.text === "BigInt") {
|
|
11047
11871
|
return true;
|
|
11048
11872
|
}
|
|
11049
11873
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "BigInt") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11063,7 +11887,7 @@ function expressionLooksLikeBrowserGlobalBigIntHelper(expression, sourceFile, na
|
|
|
11063
11887
|
)) {
|
|
11064
11888
|
return true;
|
|
11065
11889
|
}
|
|
11066
|
-
if (
|
|
11890
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11067
11891
|
return expressionLooksLikeBrowserGlobalBigIntHelper(
|
|
11068
11892
|
expression.expression,
|
|
11069
11893
|
sourceFile,
|
|
@@ -11072,7 +11896,7 @@ function expressionLooksLikeBrowserGlobalBigIntHelper(expression, sourceFile, na
|
|
|
11072
11896
|
seenIdentifiers
|
|
11073
11897
|
);
|
|
11074
11898
|
}
|
|
11075
|
-
if (
|
|
11899
|
+
if (ts6.isIdentifier(expression)) {
|
|
11076
11900
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11077
11901
|
const initializer = namedExpressions.get(expression.text);
|
|
11078
11902
|
if (initializer) {
|
|
@@ -11101,7 +11925,7 @@ function expressionLooksLikeBrowserGlobalBigIntHelper(expression, sourceFile, na
|
|
|
11101
11925
|
}
|
|
11102
11926
|
function expressionLooksLikeBrowserGlobalBooleanHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11103
11927
|
if (!expression) return false;
|
|
11104
|
-
if (
|
|
11928
|
+
if (ts6.isIdentifier(expression) && expression.text === "Boolean") {
|
|
11105
11929
|
return true;
|
|
11106
11930
|
}
|
|
11107
11931
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "Boolean") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11121,7 +11945,7 @@ function expressionLooksLikeBrowserGlobalBooleanHelper(expression, sourceFile, n
|
|
|
11121
11945
|
)) {
|
|
11122
11946
|
return true;
|
|
11123
11947
|
}
|
|
11124
|
-
if (
|
|
11948
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11125
11949
|
return expressionLooksLikeBrowserGlobalBooleanHelper(
|
|
11126
11950
|
expression.expression,
|
|
11127
11951
|
sourceFile,
|
|
@@ -11130,7 +11954,7 @@ function expressionLooksLikeBrowserGlobalBooleanHelper(expression, sourceFile, n
|
|
|
11130
11954
|
seenIdentifiers
|
|
11131
11955
|
);
|
|
11132
11956
|
}
|
|
11133
|
-
if (
|
|
11957
|
+
if (ts6.isIdentifier(expression)) {
|
|
11134
11958
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11135
11959
|
const initializer = namedExpressions.get(expression.text);
|
|
11136
11960
|
if (initializer) {
|
|
@@ -11159,7 +11983,7 @@ function expressionLooksLikeBrowserGlobalBooleanHelper(expression, sourceFile, n
|
|
|
11159
11983
|
}
|
|
11160
11984
|
function expressionLooksLikeBrowserGlobalNumberHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11161
11985
|
if (!expression) return false;
|
|
11162
|
-
if (
|
|
11986
|
+
if (ts6.isIdentifier(expression) && expression.text === "Number") {
|
|
11163
11987
|
return true;
|
|
11164
11988
|
}
|
|
11165
11989
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "Number") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11179,7 +12003,7 @@ function expressionLooksLikeBrowserGlobalNumberHelper(expression, sourceFile, na
|
|
|
11179
12003
|
)) {
|
|
11180
12004
|
return true;
|
|
11181
12005
|
}
|
|
11182
|
-
if (
|
|
12006
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11183
12007
|
return expressionLooksLikeBrowserGlobalNumberHelper(
|
|
11184
12008
|
expression.expression,
|
|
11185
12009
|
sourceFile,
|
|
@@ -11188,7 +12012,7 @@ function expressionLooksLikeBrowserGlobalNumberHelper(expression, sourceFile, na
|
|
|
11188
12012
|
seenIdentifiers
|
|
11189
12013
|
);
|
|
11190
12014
|
}
|
|
11191
|
-
if (
|
|
12015
|
+
if (ts6.isIdentifier(expression)) {
|
|
11192
12016
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11193
12017
|
const initializer = namedExpressions.get(expression.text);
|
|
11194
12018
|
if (initializer) {
|
|
@@ -11217,7 +12041,7 @@ function expressionLooksLikeBrowserGlobalNumberHelper(expression, sourceFile, na
|
|
|
11217
12041
|
}
|
|
11218
12042
|
function expressionLooksLikeBrowserGlobalObjectHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11219
12043
|
if (!expression) return false;
|
|
11220
|
-
if (
|
|
12044
|
+
if (ts6.isIdentifier(expression) && expression.text === "Object") {
|
|
11221
12045
|
return true;
|
|
11222
12046
|
}
|
|
11223
12047
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "Object") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11237,7 +12061,7 @@ function expressionLooksLikeBrowserGlobalObjectHelper(expression, sourceFile, na
|
|
|
11237
12061
|
)) {
|
|
11238
12062
|
return true;
|
|
11239
12063
|
}
|
|
11240
|
-
if (
|
|
12064
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11241
12065
|
return expressionLooksLikeBrowserGlobalObjectHelper(
|
|
11242
12066
|
expression.expression,
|
|
11243
12067
|
sourceFile,
|
|
@@ -11246,7 +12070,7 @@ function expressionLooksLikeBrowserGlobalObjectHelper(expression, sourceFile, na
|
|
|
11246
12070
|
seenIdentifiers
|
|
11247
12071
|
);
|
|
11248
12072
|
}
|
|
11249
|
-
if (
|
|
12073
|
+
if (ts6.isIdentifier(expression)) {
|
|
11250
12074
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11251
12075
|
const initializer = namedExpressions.get(expression.text);
|
|
11252
12076
|
if (initializer) {
|
|
@@ -11275,7 +12099,7 @@ function expressionLooksLikeBrowserGlobalObjectHelper(expression, sourceFile, na
|
|
|
11275
12099
|
}
|
|
11276
12100
|
function expressionLooksLikeBrowserGlobalStringHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11277
12101
|
if (!expression) return false;
|
|
11278
|
-
if (
|
|
12102
|
+
if (ts6.isIdentifier(expression) && expression.text === "String") {
|
|
11279
12103
|
return true;
|
|
11280
12104
|
}
|
|
11281
12105
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "String") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11295,7 +12119,7 @@ function expressionLooksLikeBrowserGlobalStringHelper(expression, sourceFile, na
|
|
|
11295
12119
|
)) {
|
|
11296
12120
|
return true;
|
|
11297
12121
|
}
|
|
11298
|
-
if (
|
|
12122
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11299
12123
|
return expressionLooksLikeBrowserGlobalStringHelper(
|
|
11300
12124
|
expression.expression,
|
|
11301
12125
|
sourceFile,
|
|
@@ -11304,7 +12128,7 @@ function expressionLooksLikeBrowserGlobalStringHelper(expression, sourceFile, na
|
|
|
11304
12128
|
seenIdentifiers
|
|
11305
12129
|
);
|
|
11306
12130
|
}
|
|
11307
|
-
if (
|
|
12131
|
+
if (ts6.isIdentifier(expression)) {
|
|
11308
12132
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11309
12133
|
const initializer = namedExpressions.get(expression.text);
|
|
11310
12134
|
if (initializer) {
|
|
@@ -11333,7 +12157,7 @@ function expressionLooksLikeBrowserGlobalStringHelper(expression, sourceFile, na
|
|
|
11333
12157
|
}
|
|
11334
12158
|
function expressionLooksLikeBrowserGlobalBase64Helper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11335
12159
|
if (!expression) return false;
|
|
11336
|
-
if (
|
|
12160
|
+
if (ts6.isIdentifier(expression) && ["atob", "btoa"].includes(expression.text)) {
|
|
11337
12161
|
return true;
|
|
11338
12162
|
}
|
|
11339
12163
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "atob", "btoa") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11353,7 +12177,7 @@ function expressionLooksLikeBrowserGlobalBase64Helper(expression, sourceFile, na
|
|
|
11353
12177
|
)) {
|
|
11354
12178
|
return true;
|
|
11355
12179
|
}
|
|
11356
|
-
if (
|
|
12180
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11357
12181
|
return expressionLooksLikeBrowserGlobalBase64Helper(
|
|
11358
12182
|
expression.expression,
|
|
11359
12183
|
sourceFile,
|
|
@@ -11362,7 +12186,7 @@ function expressionLooksLikeBrowserGlobalBase64Helper(expression, sourceFile, na
|
|
|
11362
12186
|
seenIdentifiers
|
|
11363
12187
|
);
|
|
11364
12188
|
}
|
|
11365
|
-
if (
|
|
12189
|
+
if (ts6.isIdentifier(expression)) {
|
|
11366
12190
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11367
12191
|
const initializer = namedExpressions.get(expression.text);
|
|
11368
12192
|
if (initializer) {
|
|
@@ -11391,7 +12215,7 @@ function expressionLooksLikeBrowserGlobalBase64Helper(expression, sourceFile, na
|
|
|
11391
12215
|
}
|
|
11392
12216
|
function expressionLooksLikeBrowserGlobalUriCodecHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11393
12217
|
if (!expression) return false;
|
|
11394
|
-
if (
|
|
12218
|
+
if (ts6.isIdentifier(expression) && [
|
|
11395
12219
|
"decodeURI",
|
|
11396
12220
|
"decodeURIComponent",
|
|
11397
12221
|
"encodeURI",
|
|
@@ -11426,7 +12250,7 @@ function expressionLooksLikeBrowserGlobalUriCodecHelper(expression, sourceFile,
|
|
|
11426
12250
|
)) {
|
|
11427
12251
|
return true;
|
|
11428
12252
|
}
|
|
11429
|
-
if (
|
|
12253
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11430
12254
|
return expressionLooksLikeBrowserGlobalUriCodecHelper(
|
|
11431
12255
|
expression.expression,
|
|
11432
12256
|
sourceFile,
|
|
@@ -11435,7 +12259,7 @@ function expressionLooksLikeBrowserGlobalUriCodecHelper(expression, sourceFile,
|
|
|
11435
12259
|
seenIdentifiers
|
|
11436
12260
|
);
|
|
11437
12261
|
}
|
|
11438
|
-
if (
|
|
12262
|
+
if (ts6.isIdentifier(expression)) {
|
|
11439
12263
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11440
12264
|
const initializer = namedExpressions.get(expression.text);
|
|
11441
12265
|
if (initializer) {
|
|
@@ -11474,7 +12298,7 @@ function expressionLooksLikeLocationUrlSource(expression, sourceFile, namedExpre
|
|
|
11474
12298
|
if (LOCATION_URL_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
11475
12299
|
return true;
|
|
11476
12300
|
}
|
|
11477
|
-
if (
|
|
12301
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11478
12302
|
return expressionLooksLikeLocationUrlSource(
|
|
11479
12303
|
expression.expression,
|
|
11480
12304
|
sourceFile,
|
|
@@ -11483,7 +12307,7 @@ function expressionLooksLikeLocationUrlSource(expression, sourceFile, namedExpre
|
|
|
11483
12307
|
seenIdentifiers
|
|
11484
12308
|
);
|
|
11485
12309
|
}
|
|
11486
|
-
if (
|
|
12310
|
+
if (ts6.isNewExpression(expression) && ts6.isIdentifier(expression.expression) && expression.expression.text === "URL") {
|
|
11487
12311
|
return expressionLooksLikeLocationUrlInput(
|
|
11488
12312
|
expression.arguments?.[0],
|
|
11489
12313
|
sourceFile,
|
|
@@ -11492,7 +12316,7 @@ function expressionLooksLikeLocationUrlSource(expression, sourceFile, namedExpre
|
|
|
11492
12316
|
seenIdentifiers
|
|
11493
12317
|
);
|
|
11494
12318
|
}
|
|
11495
|
-
if (
|
|
12319
|
+
if (ts6.isIdentifier(expression)) {
|
|
11496
12320
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11497
12321
|
const initializer = namedExpressions.get(expression.text);
|
|
11498
12322
|
if (!initializer) return false;
|
|
@@ -11514,7 +12338,7 @@ function expressionLooksLikeLocationUrlInput(expression, sourceFile, namedExpres
|
|
|
11514
12338
|
if (LOCATION_URL_INPUT_REGEX.test(expression.getText(sourceFile))) {
|
|
11515
12339
|
return true;
|
|
11516
12340
|
}
|
|
11517
|
-
if (
|
|
12341
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11518
12342
|
return expressionLooksLikeLocationUrlInput(
|
|
11519
12343
|
expression.expression,
|
|
11520
12344
|
sourceFile,
|
|
@@ -11532,7 +12356,7 @@ function expressionLooksLikeLocationUrlInput(expression, sourceFile, namedExpres
|
|
|
11532
12356
|
)) {
|
|
11533
12357
|
return true;
|
|
11534
12358
|
}
|
|
11535
|
-
if (isCallLikeExpression(expression) &&
|
|
12359
|
+
if (isCallLikeExpression(expression) && ts6.isIdentifier(expression.expression) && expression.expression.text === "String" && expression.arguments.length > 0 && (expressionLooksLikeLocationObjectSource(
|
|
11536
12360
|
expression.arguments[0],
|
|
11537
12361
|
sourceFile,
|
|
11538
12362
|
namedExpressions,
|
|
@@ -11585,7 +12409,7 @@ function expressionLooksLikeLocationUrlInput(expression, sourceFile, namedExpres
|
|
|
11585
12409
|
)) {
|
|
11586
12410
|
return true;
|
|
11587
12411
|
}
|
|
11588
|
-
if (
|
|
12412
|
+
if (ts6.isIdentifier(expression)) {
|
|
11589
12413
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11590
12414
|
const initializer = namedExpressions.get(expression.text);
|
|
11591
12415
|
if (initializer) {
|
|
@@ -11632,7 +12456,7 @@ function expressionLooksLikeRequestObjectSource(expression, sourceFile, namedExp
|
|
|
11632
12456
|
if (REQUEST_OBJECT_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
11633
12457
|
return true;
|
|
11634
12458
|
}
|
|
11635
|
-
if (
|
|
12459
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11636
12460
|
return expressionLooksLikeRequestObjectSource(
|
|
11637
12461
|
expression.expression,
|
|
11638
12462
|
sourceFile,
|
|
@@ -11640,7 +12464,7 @@ function expressionLooksLikeRequestObjectSource(expression, sourceFile, namedExp
|
|
|
11640
12464
|
seenIdentifiers
|
|
11641
12465
|
);
|
|
11642
12466
|
}
|
|
11643
|
-
if (
|
|
12467
|
+
if (ts6.isIdentifier(expression)) {
|
|
11644
12468
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11645
12469
|
const initializer = namedExpressions.get(expression.text);
|
|
11646
12470
|
if (!initializer) return false;
|
|
@@ -11661,7 +12485,7 @@ function expressionLooksLikeNextUrlSource(expression, sourceFile, namedExpressio
|
|
|
11661
12485
|
if (NEXT_URL_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
11662
12486
|
return true;
|
|
11663
12487
|
}
|
|
11664
|
-
if (
|
|
12488
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11665
12489
|
return expressionLooksLikeNextUrlSource(
|
|
11666
12490
|
expression.expression,
|
|
11667
12491
|
sourceFile,
|
|
@@ -11687,7 +12511,7 @@ function expressionLooksLikeNextUrlSource(expression, sourceFile, namedExpressio
|
|
|
11687
12511
|
seenIdentifiers
|
|
11688
12512
|
);
|
|
11689
12513
|
}
|
|
11690
|
-
if (
|
|
12514
|
+
if (ts6.isIdentifier(expression)) {
|
|
11691
12515
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11692
12516
|
const initializer = namedExpressions.get(expression.text);
|
|
11693
12517
|
if (initializer) {
|
|
@@ -11721,7 +12545,7 @@ function expressionLooksLikeOpenRedirectSearchParamsCarrier(expression, sourceFi
|
|
|
11721
12545
|
if (/\b(?:searchParams|(?:request|req)\.nextUrl\.searchParams|url\.searchParams)\b/i.test(text)) {
|
|
11722
12546
|
return true;
|
|
11723
12547
|
}
|
|
11724
|
-
if (
|
|
12548
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11725
12549
|
return expressionLooksLikeOpenRedirectSearchParamsCarrier(
|
|
11726
12550
|
expression.expression,
|
|
11727
12551
|
sourceFile,
|
|
@@ -11730,7 +12554,7 @@ function expressionLooksLikeOpenRedirectSearchParamsCarrier(expression, sourceFi
|
|
|
11730
12554
|
seenIdentifiers
|
|
11731
12555
|
);
|
|
11732
12556
|
}
|
|
11733
|
-
if (
|
|
12557
|
+
if (ts6.isNewExpression(expression) && ts6.isIdentifier(expression.expression) && expression.expression.text === "URLSearchParams") {
|
|
11734
12558
|
return expressionLooksLikeLocationQuerySource(
|
|
11735
12559
|
expression.arguments?.[0],
|
|
11736
12560
|
sourceFile,
|
|
@@ -11739,7 +12563,7 @@ function expressionLooksLikeOpenRedirectSearchParamsCarrier(expression, sourceFi
|
|
|
11739
12563
|
seenIdentifiers
|
|
11740
12564
|
);
|
|
11741
12565
|
}
|
|
11742
|
-
if (isCallLikeExpression(expression) && (
|
|
12566
|
+
if (isCallLikeExpression(expression) && (ts6.isIdentifier(expression.expression) && expression.expression.text === "useSearchParams" || isMemberAccessExpression(expression.expression) && isMemberAccessNamed(expression.expression, "useSearchParams"))) {
|
|
11743
12567
|
return true;
|
|
11744
12568
|
}
|
|
11745
12569
|
if (isPropertyLikeAccessExpression(expression) && isPropertyNamed(expression.name, "searchParams")) {
|
|
@@ -11757,7 +12581,7 @@ function expressionLooksLikeOpenRedirectSearchParamsCarrier(expression, sourceFi
|
|
|
11757
12581
|
seenIdentifiers
|
|
11758
12582
|
);
|
|
11759
12583
|
}
|
|
11760
|
-
if (
|
|
12584
|
+
if (ts6.isIdentifier(expression)) {
|
|
11761
12585
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11762
12586
|
const initializer = namedExpressions.get(expression.text);
|
|
11763
12587
|
if (initializer) {
|
|
@@ -11797,7 +12621,7 @@ function expressionLooksLikeLocationAssignmentTarget(expression, sourceFile, nam
|
|
|
11797
12621
|
if (isLocationAssignmentTarget(expression)) {
|
|
11798
12622
|
return true;
|
|
11799
12623
|
}
|
|
11800
|
-
if (
|
|
12624
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11801
12625
|
return expressionLooksLikeLocationAssignmentTarget(
|
|
11802
12626
|
expression.expression,
|
|
11803
12627
|
sourceFile,
|
|
@@ -11819,7 +12643,7 @@ function expressionLooksLikeLocationAssignmentTarget(expression, sourceFile, nam
|
|
|
11819
12643
|
}
|
|
11820
12644
|
function expressionLooksLikeLocationMutationCall(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11821
12645
|
if (!expression) return false;
|
|
11822
|
-
if (
|
|
12646
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11823
12647
|
return expressionLooksLikeLocationMutationCall(
|
|
11824
12648
|
expression.expression,
|
|
11825
12649
|
sourceFile,
|
|
@@ -11846,7 +12670,7 @@ function expressionLooksLikeLocationMutationCall(expression, sourceFile, namedEx
|
|
|
11846
12670
|
seenIdentifiers
|
|
11847
12671
|
);
|
|
11848
12672
|
}
|
|
11849
|
-
if (
|
|
12673
|
+
if (ts6.isIdentifier(expression)) {
|
|
11850
12674
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11851
12675
|
const initializer = namedExpressions.get(expression.text);
|
|
11852
12676
|
if (initializer) {
|
|
@@ -11885,7 +12709,7 @@ function expressionLooksLikeLocationMutationCall(expression, sourceFile, namedEx
|
|
|
11885
12709
|
}
|
|
11886
12710
|
function expressionLooksLikeWindowOpenCall(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11887
12711
|
if (!expression) return false;
|
|
11888
|
-
if (
|
|
12712
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11889
12713
|
return expressionLooksLikeWindowOpenCall(
|
|
11890
12714
|
expression.expression,
|
|
11891
12715
|
sourceFile,
|
|
@@ -11903,10 +12727,10 @@ function expressionLooksLikeWindowOpenCall(expression, sourceFile, namedExpressi
|
|
|
11903
12727
|
seenIdentifiers
|
|
11904
12728
|
);
|
|
11905
12729
|
}
|
|
11906
|
-
if (
|
|
12730
|
+
if (ts6.isIdentifier(expression) && expression.text === "open") {
|
|
11907
12731
|
return true;
|
|
11908
12732
|
}
|
|
11909
|
-
if (
|
|
12733
|
+
if (ts6.isIdentifier(expression)) {
|
|
11910
12734
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11911
12735
|
const initializer = namedExpressions.get(expression.text);
|
|
11912
12736
|
if (initializer) {
|
|
@@ -11942,7 +12766,7 @@ function expressionLooksLikeWindowOpenCall(expression, sourceFile, namedExpressi
|
|
|
11942
12766
|
}
|
|
11943
12767
|
function expressionLooksLikeHistoryMutationCall(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11944
12768
|
if (!expression) return false;
|
|
11945
|
-
if (
|
|
12769
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11946
12770
|
return expressionLooksLikeHistoryMutationCall(
|
|
11947
12771
|
expression.expression,
|
|
11948
12772
|
sourceFile,
|
|
@@ -11969,7 +12793,7 @@ function expressionLooksLikeHistoryMutationCall(expression, sourceFile, namedExp
|
|
|
11969
12793
|
seenIdentifiers
|
|
11970
12794
|
);
|
|
11971
12795
|
}
|
|
11972
|
-
if (
|
|
12796
|
+
if (ts6.isIdentifier(expression)) {
|
|
11973
12797
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11974
12798
|
const initializer = namedExpressions.get(expression.text);
|
|
11975
12799
|
if (initializer) {
|
|
@@ -12008,7 +12832,7 @@ function expressionLooksLikeHistoryMutationCall(expression, sourceFile, namedExp
|
|
|
12008
12832
|
}
|
|
12009
12833
|
function expressionLooksLikeRouteTransitionCall(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
12010
12834
|
if (!expression) return false;
|
|
12011
|
-
if (
|
|
12835
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
12012
12836
|
return expressionLooksLikeRouteTransitionCall(
|
|
12013
12837
|
expression.expression,
|
|
12014
12838
|
sourceFile,
|
|
@@ -12035,7 +12859,7 @@ function expressionLooksLikeRouteTransitionCall(expression, sourceFile, namedExp
|
|
|
12035
12859
|
seenIdentifiers
|
|
12036
12860
|
);
|
|
12037
12861
|
}
|
|
12038
|
-
if (
|
|
12862
|
+
if (ts6.isIdentifier(expression)) {
|
|
12039
12863
|
if (["redirect", "navigate"].includes(expression.text)) {
|
|
12040
12864
|
return true;
|
|
12041
12865
|
}
|
|
@@ -12081,7 +12905,7 @@ function expressionLooksLikeRouteTransitionCall(expression, sourceFile, namedExp
|
|
|
12081
12905
|
);
|
|
12082
12906
|
}
|
|
12083
12907
|
function getRouteTransitionTargetExpression(node, sourceFile, namedExpressions, namedPropertyAliases) {
|
|
12084
|
-
if (isMemberAccessExpression(node.expression) &&
|
|
12908
|
+
if (isMemberAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "Reflect" && isMemberAccessNamed(node.expression, "apply") && expressionLooksLikeRouteTransitionCall(
|
|
12085
12909
|
node.arguments[0],
|
|
12086
12910
|
sourceFile,
|
|
12087
12911
|
namedExpressions,
|
|
@@ -12126,7 +12950,7 @@ function getRouteTransitionTargetExpression(node, sourceFile, namedExpressions,
|
|
|
12126
12950
|
)) {
|
|
12127
12951
|
return getAliasedApplyArgumentExpression(node.arguments[1], 2, namedExpressions, /* @__PURE__ */ new Set());
|
|
12128
12952
|
}
|
|
12129
|
-
if (isMemberAccessExpression(node.expression) &&
|
|
12953
|
+
if (isMemberAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "Reflect" && isMemberAccessNamed(node.expression, "apply") && expressionLooksLikeHistoryMutationCall(
|
|
12130
12954
|
node.arguments[0],
|
|
12131
12955
|
sourceFile,
|
|
12132
12956
|
namedExpressions,
|
|
@@ -12157,7 +12981,7 @@ function getRouteTransitionTargetExpression(node, sourceFile, namedExpressions,
|
|
|
12157
12981
|
}
|
|
12158
12982
|
function getAliasedApplyArgumentExpression(expression, index, namedExpressions, seenIdentifiers) {
|
|
12159
12983
|
if (!expression) return void 0;
|
|
12160
|
-
if (
|
|
12984
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
12161
12985
|
return getAliasedApplyArgumentExpression(
|
|
12162
12986
|
expression.expression,
|
|
12163
12987
|
index,
|
|
@@ -12165,7 +12989,7 @@ function getAliasedApplyArgumentExpression(expression, index, namedExpressions,
|
|
|
12165
12989
|
seenIdentifiers
|
|
12166
12990
|
);
|
|
12167
12991
|
}
|
|
12168
|
-
if (
|
|
12992
|
+
if (ts6.isIdentifier(expression)) {
|
|
12169
12993
|
if (seenIdentifiers.has(expression.text)) return void 0;
|
|
12170
12994
|
const initializer = namedExpressions.get(expression.text);
|
|
12171
12995
|
if (!initializer) return void 0;
|
|
@@ -12179,12 +13003,12 @@ function getAliasedApplyArgumentExpression(expression, index, namedExpressions,
|
|
|
12179
13003
|
seenIdentifiers.delete(expression.text);
|
|
12180
13004
|
return result;
|
|
12181
13005
|
}
|
|
12182
|
-
if (!
|
|
13006
|
+
if (!ts6.isArrayLiteralExpression(expression)) return void 0;
|
|
12183
13007
|
const argument = expression.elements[index];
|
|
12184
|
-
return
|
|
13008
|
+
return ts6.isExpression(argument) ? argument : void 0;
|
|
12185
13009
|
}
|
|
12186
13010
|
function getLocationMutationTargetExpression(node, sourceFile, namedExpressions, namedPropertyAliases) {
|
|
12187
|
-
if (isMemberAccessExpression(node.expression) &&
|
|
13011
|
+
if (isMemberAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "Reflect" && isMemberAccessNamed(node.expression, "apply") && expressionLooksLikeLocationMutationCall(
|
|
12188
13012
|
node.arguments[0],
|
|
12189
13013
|
sourceFile,
|
|
12190
13014
|
namedExpressions,
|
|
@@ -12223,7 +13047,7 @@ function getLocationMutationTargetExpression(node, sourceFile, namedExpressions,
|
|
|
12223
13047
|
return void 0;
|
|
12224
13048
|
}
|
|
12225
13049
|
function getWindowOpenTargetExpression(node, sourceFile, namedExpressions, namedPropertyAliases) {
|
|
12226
|
-
if (isMemberAccessExpression(node.expression) &&
|
|
13050
|
+
if (isMemberAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "Reflect" && isMemberAccessNamed(node.expression, "apply") && expressionLooksLikeWindowOpenCall(
|
|
12227
13051
|
node.arguments[0],
|
|
12228
13052
|
sourceFile,
|
|
12229
13053
|
namedExpressions,
|
|
@@ -12362,28 +13186,28 @@ var DYNAMIC_GEOMETRY_STYLE_PROPS = /* @__PURE__ */ new Set([
|
|
|
12362
13186
|
"y"
|
|
12363
13187
|
]);
|
|
12364
13188
|
function getJsxAttributeExpression(initializer) {
|
|
12365
|
-
if (!initializer || !
|
|
13189
|
+
if (!initializer || !ts6.isJsxExpression(initializer)) return null;
|
|
12366
13190
|
return initializer.expression ?? null;
|
|
12367
13191
|
}
|
|
12368
13192
|
function getStylePropertyName(name) {
|
|
12369
|
-
if (
|
|
13193
|
+
if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
|
|
12370
13194
|
return name.text;
|
|
12371
13195
|
}
|
|
12372
|
-
if (
|
|
13196
|
+
if (ts6.isComputedPropertyName(name)) {
|
|
12373
13197
|
return getExpressionLiteralValue(name.expression);
|
|
12374
13198
|
}
|
|
12375
13199
|
return null;
|
|
12376
13200
|
}
|
|
12377
13201
|
function unwrapStyleExpression(expression) {
|
|
12378
13202
|
let current = expression;
|
|
12379
|
-
while (
|
|
13203
|
+
while (ts6.isParenthesizedExpression(current) || ts6.isAsExpression(current) || ts6.isTypeAssertionExpression(current) || ts6.isNonNullExpression(current) || ts6.isSatisfiesExpression(current)) {
|
|
12380
13204
|
current = current.expression;
|
|
12381
13205
|
}
|
|
12382
13206
|
return current;
|
|
12383
13207
|
}
|
|
12384
13208
|
function isDynamicStyleValue(expression) {
|
|
12385
13209
|
const unwrapped = unwrapStyleExpression(expression);
|
|
12386
|
-
if (
|
|
13210
|
+
if (ts6.isStringLiteral(unwrapped) || ts6.isNoSubstitutionTemplateLiteral(unwrapped) || ts6.isNumericLiteral(unwrapped) || unwrapped.kind === ts6.SyntaxKind.TrueKeyword || unwrapped.kind === ts6.SyntaxKind.FalseKeyword || unwrapped.kind === ts6.SyntaxKind.NullKeyword) {
|
|
12387
13211
|
return false;
|
|
12388
13212
|
}
|
|
12389
13213
|
return true;
|
|
@@ -12392,7 +13216,7 @@ function isAllowedInlineStyleObject(objectLiteral) {
|
|
|
12392
13216
|
let sawGeometryProperty = false;
|
|
12393
13217
|
let sawDynamicGeometryValue = false;
|
|
12394
13218
|
for (const property of objectLiteral.properties) {
|
|
12395
|
-
if (!
|
|
13219
|
+
if (!ts6.isPropertyAssignment(property)) return false;
|
|
12396
13220
|
const propertyName2 = getStylePropertyName(property.name);
|
|
12397
13221
|
if (!propertyName2) return false;
|
|
12398
13222
|
if (propertyName2.startsWith("--d-")) {
|
|
@@ -12421,10 +13245,10 @@ function isAllowedInlineStyleAttribute(attribute, sourceFile, namedExpressions,
|
|
|
12421
13245
|
return resolved ? isAllowedInlineStyleObject(resolved.objectLiteral) : false;
|
|
12422
13246
|
}
|
|
12423
13247
|
function analyzeAstSignals(filePath, code) {
|
|
12424
|
-
const sourceFile =
|
|
13248
|
+
const sourceFile = ts6.createSourceFile(
|
|
12425
13249
|
filePath,
|
|
12426
13250
|
code,
|
|
12427
|
-
|
|
13251
|
+
ts6.ScriptTarget.Latest,
|
|
12428
13252
|
true,
|
|
12429
13253
|
getScriptKind(filePath)
|
|
12430
13254
|
);
|
|
@@ -12509,7 +13333,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12509
13333
|
let navigationLandmarkCount = 0;
|
|
12510
13334
|
let unlabeledNavigationLandmarkCount = 0;
|
|
12511
13335
|
const walk = (node) => {
|
|
12512
|
-
if (
|
|
13336
|
+
if (ts6.isJsxAttribute(node)) {
|
|
12513
13337
|
if (isPropertyNamed(node.name, "style") && node.initializer) {
|
|
12514
13338
|
if (!isAllowedInlineStyleAttribute(
|
|
12515
13339
|
node,
|
|
@@ -12523,7 +13347,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12523
13347
|
if (isPropertyNamed(node.name, "dangerouslySetInnerHTML") && !isSafeJsonLdDangerouslySetInnerHtml(node)) {
|
|
12524
13348
|
signals.dangerousHtmlCount += 1;
|
|
12525
13349
|
}
|
|
12526
|
-
if (isPropertyNamed(node.name, "href", "to") && node.initializer &&
|
|
13350
|
+
if (isPropertyNamed(node.name, "href", "to") && node.initializer && ts6.isJsxExpression(node.initializer) && expressionContainsOpenRedirectSource(
|
|
12527
13351
|
node.initializer.expression,
|
|
12528
13352
|
sourceFile,
|
|
12529
13353
|
namedExpressionInitializers,
|
|
@@ -12541,10 +13365,10 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12541
13365
|
signals.authProviderNonceMissingCount += 1;
|
|
12542
13366
|
}
|
|
12543
13367
|
}
|
|
12544
|
-
if (
|
|
13368
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && ts6.isPropertyAccessExpression(node.left) && isPropertyNamed(node.left.name, "innerHTML", "outerHTML")) {
|
|
12545
13369
|
signals.rawHtmlInjectionCount += 1;
|
|
12546
13370
|
}
|
|
12547
|
-
if (
|
|
13371
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && expressionLooksLikeLocationAssignmentTarget(
|
|
12548
13372
|
node.left,
|
|
12549
13373
|
sourceFile,
|
|
12550
13374
|
namedExpressionInitializers,
|
|
@@ -12558,7 +13382,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12558
13382
|
)) {
|
|
12559
13383
|
signals.authOpenRedirectSignalCount += 1;
|
|
12560
13384
|
}
|
|
12561
|
-
if (
|
|
13385
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && expressionLooksLikeLocationAssignmentTarget(
|
|
12562
13386
|
node.left,
|
|
12563
13387
|
sourceFile,
|
|
12564
13388
|
namedExpressionInitializers,
|
|
@@ -12567,7 +13391,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12567
13391
|
) && isInsecureTransportUrl(getExpressionLiteralValue(node.right))) {
|
|
12568
13392
|
signals.insecureTransportEndpointCount += 1;
|
|
12569
13393
|
}
|
|
12570
|
-
if (
|
|
13394
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && expressionLooksLikeLocationAssignmentTarget(
|
|
12571
13395
|
node.left,
|
|
12572
13396
|
sourceFile,
|
|
12573
13397
|
namedExpressionInitializers,
|
|
@@ -12585,7 +13409,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12585
13409
|
signals.authProviderNonceMissingCount += 1;
|
|
12586
13410
|
}
|
|
12587
13411
|
}
|
|
12588
|
-
if (
|
|
13412
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && expressionLooksLikeLocationAssignmentTarget(
|
|
12589
13413
|
node.left,
|
|
12590
13414
|
sourceFile,
|
|
12591
13415
|
namedExpressionInitializers,
|
|
@@ -12599,36 +13423,36 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12599
13423
|
)) {
|
|
12600
13424
|
signals.authOpenRedirectSignalCount += 1;
|
|
12601
13425
|
}
|
|
12602
|
-
if (
|
|
13426
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && ts6.isPropertyAccessExpression(node.left) && isPropertyNamed(node.left.name, "onmessage")) {
|
|
12603
13427
|
const handler = resolveFunctionLikeHandler(node.right, namedFunctionDeclarations);
|
|
12604
13428
|
if (handler && !functionLikeReferencesOrigin(handler)) {
|
|
12605
13429
|
signals.messageListenerWithoutOriginCheckCount += 1;
|
|
12606
13430
|
}
|
|
12607
13431
|
}
|
|
12608
|
-
if (
|
|
13432
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && ts6.isPropertyAccessExpression(node.left) && isBrowserStorageObject(node.left.expression) && /(?:token|auth|jwt|session)/i.test(node.left.name.text)) {
|
|
12609
13433
|
signals.authStorageWriteCount += 1;
|
|
12610
13434
|
}
|
|
12611
|
-
if (
|
|
13435
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && ts6.isElementAccessExpression(node.left) && isBrowserStorageObject(node.left.expression) && isAuthStorageKeyLiteral(node.left.argumentExpression)) {
|
|
12612
13436
|
signals.authStorageWriteCount += 1;
|
|
12613
13437
|
}
|
|
12614
|
-
if (
|
|
13438
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && isCookiePropertyAccess(node.left) && hasAuthCredentialText(node.right, sourceFile)) {
|
|
12615
13439
|
signals.authCookieWriteCount += 1;
|
|
12616
13440
|
}
|
|
12617
|
-
if (
|
|
13441
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && isAuthorizationHeaderAccess(node.left)) {
|
|
12618
13442
|
if (isHeaderClearValue(node.right)) {
|
|
12619
13443
|
signals.authHeaderClearCount += 1;
|
|
12620
13444
|
} else {
|
|
12621
13445
|
signals.authHeaderWriteCount += 1;
|
|
12622
13446
|
}
|
|
12623
13447
|
}
|
|
12624
|
-
if (
|
|
13448
|
+
if (ts6.isPropertyAssignment(node) && isAuthorizationHeaderName(node.name)) {
|
|
12625
13449
|
if (isHeaderClearValue(node.initializer)) {
|
|
12626
13450
|
signals.authHeaderClearCount += 1;
|
|
12627
13451
|
} else {
|
|
12628
13452
|
signals.authHeaderWriteCount += 1;
|
|
12629
13453
|
}
|
|
12630
13454
|
}
|
|
12631
|
-
if (
|
|
13455
|
+
if (ts6.isDeleteExpression(node) && isAuthorizationHeaderAccess(node.expression)) {
|
|
12632
13456
|
signals.authHeaderClearCount += 1;
|
|
12633
13457
|
}
|
|
12634
13458
|
if (isCallLikeExpression(node)) {
|
|
@@ -12659,10 +13483,10 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12659
13483
|
namedPropertyAliases
|
|
12660
13484
|
);
|
|
12661
13485
|
const windowOpenTargetLiteral = getExpressionLiteralValue(windowOpenTargetExpression);
|
|
12662
|
-
if (
|
|
13486
|
+
if (ts6.isIdentifier(node.expression) && node.expression.text === "eval") {
|
|
12663
13487
|
signals.dynamicEvalCount += 1;
|
|
12664
13488
|
}
|
|
12665
|
-
if ((
|
|
13489
|
+
if ((ts6.isIdentifier(node.expression) && ["setTimeout", "setInterval"].includes(node.expression.text) || ts6.isPropertyAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "window" && isPropertyNamed(node.expression.name, "setTimeout", "setInterval")) && typeof firstArgumentLiteral === "string") {
|
|
12666
13490
|
signals.dynamicEvalCount += 1;
|
|
12667
13491
|
}
|
|
12668
13492
|
if ((isFetchLikeCall(node) || isAxiosLikeCall(node)) && isInsecureTransportUrl(firstArgumentLiteral)) {
|
|
@@ -12744,7 +13568,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12744
13568
|
signals.authProviderNonceMissingCount += 1;
|
|
12745
13569
|
}
|
|
12746
13570
|
}
|
|
12747
|
-
if (
|
|
13571
|
+
if (ts6.isPropertyAccessExpression(node.expression) && isPropertyNamed(node.expression.name, "postMessage") && secondArgumentLiteral === "*") {
|
|
12748
13572
|
signals.wildcardPostMessageCount += 1;
|
|
12749
13573
|
}
|
|
12750
13574
|
if (isAddEventListenerCall(node) && firstArgumentLiteral === "message") {
|
|
@@ -12753,7 +13577,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12753
13577
|
signals.messageListenerWithoutOriginCheckCount += 1;
|
|
12754
13578
|
}
|
|
12755
13579
|
}
|
|
12756
|
-
if (
|
|
13580
|
+
if (ts6.isPropertyAccessExpression(node.expression) && isPropertyNamed(node.expression.name, "setHeader", "append", "set") && isSetCookieHeaderName(node.arguments[0])) {
|
|
12757
13581
|
const cookieStrings = collectCookieHeaderStrings(node.arguments[1]);
|
|
12758
13582
|
const authCookieStrings = cookieStrings.filter(cookieHeaderStringLooksAuthLike);
|
|
12759
13583
|
if (authCookieStrings.length > 0) {
|
|
@@ -12771,13 +13595,13 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12771
13595
|
}
|
|
12772
13596
|
}
|
|
12773
13597
|
}
|
|
12774
|
-
if ((
|
|
13598
|
+
if ((ts6.isIdentifier(node.expression) && node.expression.text === "open" || ts6.isPropertyAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "window" && isPropertyNamed(node.expression.name, "open")) && secondArgumentLiteral === "_blank") {
|
|
12775
13599
|
const featureLiteral = getExpressionLiteralValue(node.arguments[2])?.toLowerCase() ?? "";
|
|
12776
13600
|
if (!featureLiteral.includes("noopener") || !featureLiteral.includes("noreferrer")) {
|
|
12777
13601
|
signals.windowOpenWithoutNoopenerCount += 1;
|
|
12778
13602
|
}
|
|
12779
13603
|
}
|
|
12780
|
-
if (
|
|
13604
|
+
if (ts6.isPropertyAccessExpression(node.expression)) {
|
|
12781
13605
|
if (isPropertyNamed(node.expression.name, "insertAdjacentHTML")) {
|
|
12782
13606
|
signals.rawHtmlInjectionCount += 1;
|
|
12783
13607
|
}
|
|
@@ -12786,7 +13610,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12786
13610
|
}
|
|
12787
13611
|
if (isCookieMutationSetCall(node)) {
|
|
12788
13612
|
const firstArgument = node.arguments[0];
|
|
12789
|
-
const isObjectConfigCall =
|
|
13613
|
+
const isObjectConfigCall = ts6.isObjectLiteralExpression(firstArgument);
|
|
12790
13614
|
const isAuthCookieWrite = isObjectConfigCall ? objectLiteralLooksLikeAuthCookieConfig(firstArgument, sourceFile) : expressionLooksLikeAuthCookieName(firstArgument, sourceFile);
|
|
12791
13615
|
if (isAuthCookieWrite) {
|
|
12792
13616
|
signals.authCookieWriteCount += 1;
|
|
@@ -12806,7 +13630,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12806
13630
|
signals.authHeaderWriteCount += 1;
|
|
12807
13631
|
}
|
|
12808
13632
|
}
|
|
12809
|
-
if (
|
|
13633
|
+
if (ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "document" && isPropertyNamed(node.expression.name, "write")) {
|
|
12810
13634
|
signals.rawHtmlInjectionCount += 1;
|
|
12811
13635
|
}
|
|
12812
13636
|
if (isPropertyNamed(node.expression.name, "eval")) {
|
|
@@ -12814,16 +13638,16 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12814
13638
|
}
|
|
12815
13639
|
}
|
|
12816
13640
|
}
|
|
12817
|
-
if (
|
|
13641
|
+
if (ts6.isNewExpression(node) && isRealtimeTransportConstructor(node) && isInsecureTransportUrl(getExpressionLiteralValue(node.arguments?.[0]))) {
|
|
12818
13642
|
signals.insecureTransportEndpointCount += 1;
|
|
12819
13643
|
}
|
|
12820
|
-
if (
|
|
13644
|
+
if (ts6.isNewExpression(node) && ts6.isIdentifier(node.expression) && node.expression.text === "Function") {
|
|
12821
13645
|
signals.dynamicEvalCount += 1;
|
|
12822
13646
|
}
|
|
12823
|
-
if (
|
|
13647
|
+
if (ts6.isNewExpression(node) && ts6.isIdentifier(node.expression) && ["WebSocket", "EventSource"].includes(node.expression.text) && isInsecureTransportUrl(getExpressionLiteralValue(node.arguments?.[0]))) {
|
|
12824
13648
|
signals.insecureTransportEndpointCount += 1;
|
|
12825
13649
|
}
|
|
12826
|
-
if (
|
|
13650
|
+
if (ts6.isJsxSelfClosingElement(node)) {
|
|
12827
13651
|
const tagName = getJsxTagName(node);
|
|
12828
13652
|
if (hasMainLandmarkSignal(node.attributes, tagName)) {
|
|
12829
13653
|
signals.mainLandmarkCount += 1;
|
|
@@ -12916,7 +13740,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12916
13740
|
signals.formControlWithoutLabelCount += 1;
|
|
12917
13741
|
}
|
|
12918
13742
|
}
|
|
12919
|
-
if (
|
|
13743
|
+
if (ts6.isJsxElement(node)) {
|
|
12920
13744
|
const tagName = getJsxTagName(node.openingElement);
|
|
12921
13745
|
const textContent = getJsxTextContent(node).replace(/\s+/g, " ").trim();
|
|
12922
13746
|
if (hasMainLandmarkSignal(node.openingElement.attributes, tagName)) {
|
|
@@ -13032,7 +13856,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
13032
13856
|
signals.formControlWithoutLabelCount += 1;
|
|
13033
13857
|
}
|
|
13034
13858
|
}
|
|
13035
|
-
|
|
13859
|
+
ts6.forEachChild(node, walk);
|
|
13036
13860
|
};
|
|
13037
13861
|
walk(sourceFile);
|
|
13038
13862
|
signals.unlabeledNavigationLandmarkCount = navigationLandmarkCount > 1 ? unlabeledNavigationLandmarkCount : 0;
|
|
@@ -14786,11 +15610,11 @@ function critiqueSource({
|
|
|
14786
15610
|
};
|
|
14787
15611
|
}
|
|
14788
15612
|
function resolveProjectFilePath(projectRoot, filePath) {
|
|
14789
|
-
const root =
|
|
14790
|
-
const candidatePath =
|
|
14791
|
-
const resolvedPath =
|
|
14792
|
-
const relativePath =
|
|
14793
|
-
if (relativePath.startsWith("..") ||
|
|
15613
|
+
const root = existsSync6(projectRoot) ? realpathSync2.native(projectRoot) : resolve3(projectRoot);
|
|
15614
|
+
const candidatePath = isAbsolute4(filePath) ? resolve3(filePath) : resolve3(root, filePath);
|
|
15615
|
+
const resolvedPath = existsSync6(candidatePath) ? realpathSync2.native(candidatePath) : candidatePath;
|
|
15616
|
+
const relativePath = relative6(root, resolvedPath);
|
|
15617
|
+
if (relativePath.startsWith("..") || isAbsolute4(relativePath)) {
|
|
14794
15618
|
throw new Error(`Path escapes the project root: ${filePath}`);
|
|
14795
15619
|
}
|
|
14796
15620
|
return resolvedPath;
|
|
@@ -14798,7 +15622,7 @@ function resolveProjectFilePath(projectRoot, filePath) {
|
|
|
14798
15622
|
async function critiqueFile(filePath, projectRoot) {
|
|
14799
15623
|
const resolvedPath = resolveProjectFilePath(projectRoot, filePath);
|
|
14800
15624
|
const code = await readFile(resolvedPath, "utf-8");
|
|
14801
|
-
const treatmentsCss = readTextIfExists(
|
|
15625
|
+
const treatmentsCss = readTextIfExists(join6(projectRoot, "src", "styles", "treatments.css"));
|
|
14802
15626
|
const reviewPack = loadReviewPack(projectRoot);
|
|
14803
15627
|
const packManifest = loadPackManifest(projectRoot);
|
|
14804
15628
|
const adoptionMode = readProjectAdoptionMode(projectRoot);
|
|
@@ -14828,19 +15652,33 @@ export {
|
|
|
14828
15652
|
buildProjectHealthRepairPlan,
|
|
14829
15653
|
collectMissingPackManifestFiles,
|
|
14830
15654
|
collectProjectSourceFiles,
|
|
15655
|
+
collectSourceImports,
|
|
14831
15656
|
createContractAssertions,
|
|
14832
15657
|
createEvidenceBundle,
|
|
15658
|
+
createProjectSourceProgram,
|
|
15659
|
+
createSourceInventory,
|
|
14833
15660
|
createUnavailableScanReport,
|
|
14834
15661
|
critiqueFile,
|
|
14835
15662
|
critiqueSource,
|
|
14836
15663
|
deriveVerificationDiagnostic,
|
|
14837
15664
|
emptyRuntimeAudit,
|
|
14838
15665
|
extractRouteHintsFromEssence,
|
|
15666
|
+
extractSourceStringLiterals,
|
|
15667
|
+
getProjectSourceFile,
|
|
15668
|
+
isPathInsideProject,
|
|
15669
|
+
isSupportedSourceExtension,
|
|
14839
15670
|
listKnownInteractions,
|
|
15671
|
+
normalizeSourcePath,
|
|
14840
15672
|
probePublishedSite,
|
|
14841
15673
|
resolveGitHubScanInput,
|
|
14842
15674
|
resolveGraphAnchorForFinding,
|
|
15675
|
+
resolveSourceImport,
|
|
15676
|
+
resolveSourceSymbolOrigin,
|
|
14843
15677
|
scanProject,
|
|
15678
|
+
sourceKindFromPath,
|
|
15679
|
+
sourceLanguageFromPath,
|
|
15680
|
+
sourceLocationForNode,
|
|
15681
|
+
sourceScriptKindFromPath,
|
|
14844
15682
|
verifyInteractionsInSource
|
|
14845
15683
|
};
|
|
14846
15684
|
//# sourceMappingURL=index.js.map
|