@decantr/verifier 3.1.0 → 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 +1151 -373
- 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;
|
|
@@ -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",
|
|
@@ -2965,6 +3017,716 @@ function resolveGitHubScanInput(input) {
|
|
|
2965
3017
|
throw new Error("V1 hosted scans support GitHub repositories and GitHub Pages URLs.");
|
|
2966
3018
|
}
|
|
2967
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
|
+
|
|
2968
3730
|
// src/index.ts
|
|
2969
3731
|
var VERIFICATION_SCHEMA_URLS = {
|
|
2970
3732
|
common: "https://decantr.ai/schemas/verification-report.common.v1.json",
|
|
@@ -2982,16 +3744,16 @@ function hashString(value) {
|
|
|
2982
3744
|
return createHash("sha256").update(value).digest("hex").slice(0, 16);
|
|
2983
3745
|
}
|
|
2984
3746
|
function hashFile(path) {
|
|
2985
|
-
if (!
|
|
3747
|
+
if (!existsSync6(path)) return null;
|
|
2986
3748
|
try {
|
|
2987
|
-
return createHash("sha256").update(
|
|
3749
|
+
return createHash("sha256").update(readFileSync6(path)).digest("hex");
|
|
2988
3750
|
} catch {
|
|
2989
3751
|
return null;
|
|
2990
3752
|
}
|
|
2991
3753
|
}
|
|
2992
3754
|
function provenanceEntry(projectRoot, relativePath) {
|
|
2993
|
-
const path =
|
|
2994
|
-
if (!
|
|
3755
|
+
const path = join6(projectRoot, relativePath);
|
|
3756
|
+
if (!existsSync6(path)) {
|
|
2995
3757
|
return {
|
|
2996
3758
|
path: relativePath,
|
|
2997
3759
|
present: false,
|
|
@@ -3001,7 +3763,7 @@ function provenanceEntry(projectRoot, relativePath) {
|
|
|
3001
3763
|
}
|
|
3002
3764
|
let generatedAt = null;
|
|
3003
3765
|
try {
|
|
3004
|
-
generatedAt =
|
|
3766
|
+
generatedAt = statSync5(path).mtime.toISOString();
|
|
3005
3767
|
} catch {
|
|
3006
3768
|
generatedAt = null;
|
|
3007
3769
|
}
|
|
@@ -3013,7 +3775,7 @@ function provenanceEntry(projectRoot, relativePath) {
|
|
|
3013
3775
|
};
|
|
3014
3776
|
}
|
|
3015
3777
|
function provenanceForPath(projectRoot, path) {
|
|
3016
|
-
const rel =
|
|
3778
|
+
const rel = isAbsolute4(path) ? relative6(projectRoot, path).replace(/\\/g, "/") : path;
|
|
3017
3779
|
return provenanceEntry(projectRoot, rel && !rel.startsWith("..") ? rel : basename2(path));
|
|
3018
3780
|
}
|
|
3019
3781
|
function redactEvidenceText(projectRoot, value) {
|
|
@@ -3150,7 +3912,7 @@ function createContractAssertions(projectRoot, audit) {
|
|
|
3150
3912
|
const assertions = [];
|
|
3151
3913
|
const essence = audit?.essence;
|
|
3152
3914
|
const v4 = essence && isV4(essence) ? essence : null;
|
|
3153
|
-
const contextDir =
|
|
3915
|
+
const contextDir = join6(projectRoot, ".decantr", "context");
|
|
3154
3916
|
const packManifest = audit?.packManifest ?? null;
|
|
3155
3917
|
assertions.push(
|
|
3156
3918
|
assertion({
|
|
@@ -3160,7 +3922,7 @@ function createContractAssertions(projectRoot, audit) {
|
|
|
3160
3922
|
rule: "essence-present",
|
|
3161
3923
|
status: essence ? "passed" : "failed",
|
|
3162
3924
|
message: essence ? "Decantr Essence contract is present." : "No Decantr Essence contract was found.",
|
|
3163
|
-
evidence: [redactEvidenceText(projectRoot,
|
|
3925
|
+
evidence: [redactEvidenceText(projectRoot, join6(projectRoot, "decantr.essence.json"))],
|
|
3164
3926
|
suggestedFix: essence ? void 0 : "Run `decantr init` or restore decantr.essence.json."
|
|
3165
3927
|
})
|
|
3166
3928
|
);
|
|
@@ -3232,7 +3994,7 @@ function createContractAssertions(projectRoot, audit) {
|
|
|
3232
3994
|
rule: "pack-manifest-present",
|
|
3233
3995
|
status: packManifest ? "passed" : "failed",
|
|
3234
3996
|
message: packManifest ? "Compiled execution pack manifest is present." : "Compiled execution pack manifest is missing.",
|
|
3235
|
-
evidence: [redactEvidenceText(projectRoot,
|
|
3997
|
+
evidence: [redactEvidenceText(projectRoot, join6(contextDir, "pack-manifest.json"))],
|
|
3236
3998
|
suggestedFix: packManifest ? void 0 : "Run `decantr registry compile-packs decantr.essence.json --write-context` to hydrate the full context pack bundle."
|
|
3237
3999
|
})
|
|
3238
4000
|
);
|
|
@@ -3244,21 +4006,21 @@ function createContractAssertions(projectRoot, audit) {
|
|
|
3244
4006
|
rule: "review-pack-present",
|
|
3245
4007
|
status: audit?.reviewPack ? "passed" : "failed",
|
|
3246
4008
|
message: audit?.reviewPack ? "Compiled review pack is present." : "Compiled review pack is missing.",
|
|
3247
|
-
evidence: [redactEvidenceText(projectRoot,
|
|
4009
|
+
evidence: [redactEvidenceText(projectRoot, join6(contextDir, "review-pack.json"))],
|
|
3248
4010
|
suggestedFix: audit?.reviewPack ? void 0 : "Run `decantr registry compile-packs decantr.essence.json --write-context` so critique has the compiled review contract."
|
|
3249
4011
|
})
|
|
3250
4012
|
);
|
|
3251
|
-
const tokensPath =
|
|
4013
|
+
const tokensPath = join6(projectRoot, "src", "styles", "tokens.css");
|
|
3252
4014
|
assertions.push(
|
|
3253
4015
|
assertion({
|
|
3254
4016
|
id: "contract.design-token.tokens-file",
|
|
3255
4017
|
category: "design-token",
|
|
3256
|
-
severity:
|
|
4018
|
+
severity: existsSync6(tokensPath) ? "info" : "warn",
|
|
3257
4019
|
rule: "tokens-file-present",
|
|
3258
|
-
status:
|
|
3259
|
-
message:
|
|
4020
|
+
status: existsSync6(tokensPath) ? "passed" : "failed",
|
|
4021
|
+
message: existsSync6(tokensPath) ? "Decantr token CSS file is present." : "Decantr token CSS file was not found.",
|
|
3260
4022
|
evidence: [redactEvidenceText(projectRoot, tokensPath)],
|
|
3261
|
-
suggestedFix:
|
|
4023
|
+
suggestedFix: existsSync6(tokensPath) ? void 0 : "Run `decantr refresh` or map Decantr tokens into the existing styling system."
|
|
3262
4024
|
})
|
|
3263
4025
|
);
|
|
3264
4026
|
return assertions;
|
|
@@ -3267,9 +4029,9 @@ function createEvidenceBundle(input) {
|
|
|
3267
4029
|
const assertions = input.assertions ?? createContractAssertions(input.projectRoot, input.audit);
|
|
3268
4030
|
let resolvedProjectRoot = input.projectRoot;
|
|
3269
4031
|
try {
|
|
3270
|
-
resolvedProjectRoot =
|
|
4032
|
+
resolvedProjectRoot = realpathSync2(input.projectRoot);
|
|
3271
4033
|
} catch {
|
|
3272
|
-
resolvedProjectRoot =
|
|
4034
|
+
resolvedProjectRoot = resolve3(input.projectRoot);
|
|
3273
4035
|
}
|
|
3274
4036
|
const projectId = `project_${hashString(resolvedProjectRoot)}`;
|
|
3275
4037
|
return {
|
|
@@ -3371,21 +4133,21 @@ function scoreRatio(numerator, denominator) {
|
|
|
3371
4133
|
return Math.min(5, Math.max(1, Math.round(numerator / denominator * 5)));
|
|
3372
4134
|
}
|
|
3373
4135
|
function readJsonIfExists(path) {
|
|
3374
|
-
if (!
|
|
4136
|
+
if (!existsSync6(path)) return null;
|
|
3375
4137
|
try {
|
|
3376
|
-
return JSON.parse(
|
|
4138
|
+
return JSON.parse(readFileSync6(path, "utf-8"));
|
|
3377
4139
|
} catch {
|
|
3378
4140
|
return null;
|
|
3379
4141
|
}
|
|
3380
4142
|
}
|
|
3381
4143
|
function loadReviewPack(projectRoot) {
|
|
3382
4144
|
return readJsonIfExists(
|
|
3383
|
-
|
|
4145
|
+
join6(projectRoot, ".decantr", "context", "review-pack.json")
|
|
3384
4146
|
);
|
|
3385
4147
|
}
|
|
3386
4148
|
function loadPackManifest(projectRoot) {
|
|
3387
4149
|
return readJsonIfExists(
|
|
3388
|
-
|
|
4150
|
+
join6(projectRoot, ".decantr", "context", "pack-manifest.json")
|
|
3389
4151
|
);
|
|
3390
4152
|
}
|
|
3391
4153
|
function collectPackManifestReferences(packManifest) {
|
|
@@ -3434,14 +4196,14 @@ function collectPackManifestReferences(packManifest) {
|
|
|
3434
4196
|
}
|
|
3435
4197
|
function collectMissingPackManifestFiles(projectRoot, packManifest = loadPackManifest(projectRoot)) {
|
|
3436
4198
|
if (!packManifest) return [];
|
|
3437
|
-
const contextDir =
|
|
4199
|
+
const contextDir = join6(projectRoot, ".decantr", "context");
|
|
3438
4200
|
const missing = [];
|
|
3439
4201
|
for (const reference of collectPackManifestReferences(packManifest)) {
|
|
3440
4202
|
for (const field of ["markdown", "json"]) {
|
|
3441
4203
|
const fileName = reference[field];
|
|
3442
4204
|
if (!fileName) continue;
|
|
3443
|
-
const absolutePath =
|
|
3444
|
-
if (
|
|
4205
|
+
const absolutePath = join6(contextDir, fileName);
|
|
4206
|
+
if (existsSync6(absolutePath)) continue;
|
|
3445
4207
|
missing.push({
|
|
3446
4208
|
entryId: reference.entryId,
|
|
3447
4209
|
kind: reference.kind,
|
|
@@ -3455,13 +4217,13 @@ function collectMissingPackManifestFiles(projectRoot, packManifest = loadPackMan
|
|
|
3455
4217
|
}
|
|
3456
4218
|
function readTextIfExists(path) {
|
|
3457
4219
|
try {
|
|
3458
|
-
return
|
|
4220
|
+
return existsSync6(path) ? readFileSync6(path, "utf-8") : "";
|
|
3459
4221
|
} catch {
|
|
3460
4222
|
return "";
|
|
3461
4223
|
}
|
|
3462
4224
|
}
|
|
3463
4225
|
function readProjectAdoptionMode(projectRoot) {
|
|
3464
|
-
const projectJson = readJsonIfExists(
|
|
4226
|
+
const projectJson = readJsonIfExists(join6(projectRoot, ".decantr", "project.json"));
|
|
3465
4227
|
const adoptionMode = projectJson?.initialized?.adoptionMode;
|
|
3466
4228
|
return typeof adoptionMode === "string" ? adoptionMode : null;
|
|
3467
4229
|
}
|
|
@@ -3547,7 +4309,7 @@ function collectProjectSourceFiles(projectRoot) {
|
|
|
3547
4309
|
"hooks",
|
|
3548
4310
|
"providers",
|
|
3549
4311
|
"server"
|
|
3550
|
-
].map((dir) =>
|
|
4312
|
+
].map((dir) => join6(projectRoot, dir)).filter((dir) => existsSync6(dir));
|
|
3551
4313
|
const rootFileCandidates = [
|
|
3552
4314
|
"middleware.ts",
|
|
3553
4315
|
"middleware.tsx",
|
|
@@ -3561,7 +4323,7 @@ function collectProjectSourceFiles(projectRoot) {
|
|
|
3561
4323
|
"proxy.jsx",
|
|
3562
4324
|
"proxy.mts",
|
|
3563
4325
|
"proxy.cts"
|
|
3564
|
-
].map((file) =>
|
|
4326
|
+
].map((file) => join6(projectRoot, file)).filter((file) => existsSync6(file));
|
|
3565
4327
|
const files = /* @__PURE__ */ new Set();
|
|
3566
4328
|
const ignoredDirNames = /* @__PURE__ */ new Set([
|
|
3567
4329
|
"node_modules",
|
|
@@ -3572,9 +4334,9 @@ function collectProjectSourceFiles(projectRoot) {
|
|
|
3572
4334
|
"coverage"
|
|
3573
4335
|
]);
|
|
3574
4336
|
const walk = (dir) => {
|
|
3575
|
-
for (const entry of
|
|
4337
|
+
for (const entry of readdirSync5(dir, { withFileTypes: true })) {
|
|
3576
4338
|
if (ignoredDirNames.has(entry.name)) continue;
|
|
3577
|
-
const absolutePath =
|
|
4339
|
+
const absolutePath = join6(dir, entry.name);
|
|
3578
4340
|
if (entry.isDirectory()) {
|
|
3579
4341
|
walk(absolutePath);
|
|
3580
4342
|
continue;
|
|
@@ -3605,7 +4367,7 @@ function isAuditableStyleFile(filePath) {
|
|
|
3605
4367
|
return /\.css$/i.test(filePath);
|
|
3606
4368
|
}
|
|
3607
4369
|
function collectProjectStyleFiles2(projectRoot) {
|
|
3608
|
-
const candidates = ["src", "app", "styles"].map((dir) =>
|
|
4370
|
+
const candidates = ["src", "app", "styles"].map((dir) => join6(projectRoot, dir)).filter((dir) => existsSync6(dir));
|
|
3609
4371
|
const files = /* @__PURE__ */ new Set();
|
|
3610
4372
|
const ignoredDirNames = /* @__PURE__ */ new Set([
|
|
3611
4373
|
"node_modules",
|
|
@@ -3616,9 +4378,9 @@ function collectProjectStyleFiles2(projectRoot) {
|
|
|
3616
4378
|
"coverage"
|
|
3617
4379
|
]);
|
|
3618
4380
|
const walk = (dir) => {
|
|
3619
|
-
for (const entry of
|
|
4381
|
+
for (const entry of readdirSync5(dir, { withFileTypes: true })) {
|
|
3620
4382
|
if (ignoredDirNames.has(entry.name)) continue;
|
|
3621
|
-
const absolutePath =
|
|
4383
|
+
const absolutePath = join6(dir, entry.name);
|
|
3622
4384
|
if (entry.isDirectory()) {
|
|
3623
4385
|
walk(absolutePath);
|
|
3624
4386
|
continue;
|
|
@@ -3646,15 +4408,15 @@ function countReducedMotionSignals(code) {
|
|
|
3646
4408
|
return patterns.reduce((count, pattern) => count + (pattern.test(code) ? 1 : 0), 0);
|
|
3647
4409
|
}
|
|
3648
4410
|
function hasModuleDirective(filePath, code, directive) {
|
|
3649
|
-
const sourceFile =
|
|
4411
|
+
const sourceFile = ts6.createSourceFile(
|
|
3650
4412
|
filePath,
|
|
3651
4413
|
code,
|
|
3652
|
-
|
|
4414
|
+
ts6.ScriptTarget.Latest,
|
|
3653
4415
|
true,
|
|
3654
4416
|
getScriptKind(filePath)
|
|
3655
4417
|
);
|
|
3656
4418
|
for (const statement of sourceFile.statements) {
|
|
3657
|
-
if (
|
|
4419
|
+
if (ts6.isExpressionStatement(statement) && ts6.isStringLiteralLike(statement.expression)) {
|
|
3658
4420
|
if (statement.expression.text === directive) {
|
|
3659
4421
|
return true;
|
|
3660
4422
|
}
|
|
@@ -3670,20 +4432,20 @@ function importDeclarationHasRuntimeBinding(statement) {
|
|
|
3670
4432
|
if (clause.isTypeOnly) return false;
|
|
3671
4433
|
if (clause.name) return true;
|
|
3672
4434
|
if (!clause.namedBindings) return true;
|
|
3673
|
-
if (
|
|
4435
|
+
if (ts6.isNamespaceImport(clause.namedBindings)) return true;
|
|
3674
4436
|
return clause.namedBindings.elements.some((element) => !element.isTypeOnly);
|
|
3675
4437
|
}
|
|
3676
4438
|
function collectRuntimeImportSpecifiers(entry) {
|
|
3677
|
-
const sourceFile =
|
|
4439
|
+
const sourceFile = ts6.createSourceFile(
|
|
3678
4440
|
entry.relativePath,
|
|
3679
4441
|
entry.code,
|
|
3680
|
-
|
|
4442
|
+
ts6.ScriptTarget.Latest,
|
|
3681
4443
|
true,
|
|
3682
4444
|
getScriptKind(entry.relativePath)
|
|
3683
4445
|
);
|
|
3684
4446
|
const specifiers = [];
|
|
3685
4447
|
for (const statement of sourceFile.statements) {
|
|
3686
|
-
if (
|
|
4448
|
+
if (ts6.isImportDeclaration(statement) && ts6.isStringLiteralLike(statement.moduleSpecifier) && importDeclarationHasRuntimeBinding(statement)) {
|
|
3687
4449
|
specifiers.push(statement.moduleSpecifier.text);
|
|
3688
4450
|
}
|
|
3689
4451
|
}
|
|
@@ -3692,9 +4454,9 @@ function collectRuntimeImportSpecifiers(entry) {
|
|
|
3692
4454
|
function resolveSourceImportTarget(projectRoot, sourceAbsolutePath, specifier) {
|
|
3693
4455
|
let basePath = null;
|
|
3694
4456
|
if (specifier.startsWith("@/")) {
|
|
3695
|
-
basePath =
|
|
4457
|
+
basePath = join6(projectRoot, "src", specifier.slice(2));
|
|
3696
4458
|
} else if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
3697
|
-
basePath =
|
|
4459
|
+
basePath = resolve3(dirname2(sourceAbsolutePath), specifier);
|
|
3698
4460
|
}
|
|
3699
4461
|
if (!basePath) return null;
|
|
3700
4462
|
const candidates = [
|
|
@@ -3705,14 +4467,14 @@ function resolveSourceImportTarget(projectRoot, sourceAbsolutePath, specifier) {
|
|
|
3705
4467
|
`${basePath}.jsx`,
|
|
3706
4468
|
`${basePath}.mts`,
|
|
3707
4469
|
`${basePath}.cts`,
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
4470
|
+
join6(basePath, "index.ts"),
|
|
4471
|
+
join6(basePath, "index.tsx"),
|
|
4472
|
+
join6(basePath, "index.js"),
|
|
4473
|
+
join6(basePath, "index.jsx")
|
|
3712
4474
|
];
|
|
3713
4475
|
for (const candidate of candidates) {
|
|
3714
|
-
if (
|
|
3715
|
-
return
|
|
4476
|
+
if (existsSync6(candidate) && isAuditableSourceFile(candidate)) {
|
|
4477
|
+
return relative6(projectRoot, candidate) || candidate;
|
|
3716
4478
|
}
|
|
3717
4479
|
}
|
|
3718
4480
|
return null;
|
|
@@ -3760,8 +4522,8 @@ function isClientAuthHeaderSource(relativePath, code, clientReachableFiles) {
|
|
|
3760
4522
|
function auditProjectSourceTree(projectRoot, sourceFiles = collectProjectSourceFiles(projectRoot)) {
|
|
3761
4523
|
const sourceEntries = sourceFiles.map((sourceFile) => ({
|
|
3762
4524
|
absolutePath: sourceFile,
|
|
3763
|
-
relativePath:
|
|
3764
|
-
code:
|
|
4525
|
+
relativePath: relative6(projectRoot, sourceFile) || sourceFile,
|
|
4526
|
+
code: readFileSync6(sourceFile, "utf-8")
|
|
3765
4527
|
})).filter((entry) => !isNonProductionSourceAuditFile(entry.relativePath));
|
|
3766
4528
|
const clientReachableFiles = collectClientReachableSourceFiles(projectRoot, sourceEntries);
|
|
3767
4529
|
const summary = {
|
|
@@ -4074,8 +4836,8 @@ function auditProjectStyleContracts(projectRoot) {
|
|
|
4074
4836
|
reducedMotionSignals: createSourceAuditBucket()
|
|
4075
4837
|
};
|
|
4076
4838
|
for (const styleFile of styleFiles) {
|
|
4077
|
-
const relativePath =
|
|
4078
|
-
const css =
|
|
4839
|
+
const relativePath = relative6(projectRoot, styleFile) || styleFile;
|
|
4840
|
+
const css = readFileSync6(styleFile, "utf-8");
|
|
4079
4841
|
recordSourceAudit(summary.focusVisibleSignals, relativePath, countFocusVisibleSignals(css));
|
|
4080
4842
|
recordSourceAudit(summary.reducedMotionSignals, relativePath, countReducedMotionSignals(css));
|
|
4081
4843
|
}
|
|
@@ -4084,15 +4846,15 @@ function auditProjectStyleContracts(projectRoot) {
|
|
|
4084
4846
|
function buildRegistryContext(projectRoot) {
|
|
4085
4847
|
const themeRegistry = /* @__PURE__ */ new Map();
|
|
4086
4848
|
const patternRegistry = /* @__PURE__ */ new Map();
|
|
4087
|
-
const cacheDir =
|
|
4088
|
-
const customDir =
|
|
4089
|
-
const cachedThemesDir =
|
|
4849
|
+
const cacheDir = join6(projectRoot, ".decantr", "cache");
|
|
4850
|
+
const customDir = join6(projectRoot, ".decantr", "custom");
|
|
4851
|
+
const cachedThemesDir = join6(cacheDir, "@official", "themes");
|
|
4090
4852
|
try {
|
|
4091
|
-
if (
|
|
4092
|
-
for (const file of
|
|
4853
|
+
if (existsSync6(cachedThemesDir)) {
|
|
4854
|
+
for (const file of readdirSync5(cachedThemesDir).filter(
|
|
4093
4855
|
(name) => name.endsWith(".json") && name !== "index.json"
|
|
4094
4856
|
)) {
|
|
4095
|
-
const data = JSON.parse(
|
|
4857
|
+
const data = JSON.parse(readFileSync6(join6(cachedThemesDir, file), "utf-8"));
|
|
4096
4858
|
if (data.id && !themeRegistry.has(data.id)) {
|
|
4097
4859
|
themeRegistry.set(data.id, { modes: data.modes || ["light", "dark"] });
|
|
4098
4860
|
}
|
|
@@ -4100,11 +4862,11 @@ function buildRegistryContext(projectRoot) {
|
|
|
4100
4862
|
}
|
|
4101
4863
|
} catch {
|
|
4102
4864
|
}
|
|
4103
|
-
const customThemesDir =
|
|
4865
|
+
const customThemesDir = join6(customDir, "themes");
|
|
4104
4866
|
try {
|
|
4105
|
-
if (
|
|
4106
|
-
for (const file of
|
|
4107
|
-
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"));
|
|
4108
4870
|
if (data.id) {
|
|
4109
4871
|
themeRegistry.set(`custom:${data.id}`, { modes: data.modes || ["light", "dark"] });
|
|
4110
4872
|
}
|
|
@@ -4112,13 +4874,13 @@ function buildRegistryContext(projectRoot) {
|
|
|
4112
4874
|
}
|
|
4113
4875
|
} catch {
|
|
4114
4876
|
}
|
|
4115
|
-
const cachedPatternsDir =
|
|
4877
|
+
const cachedPatternsDir = join6(cacheDir, "@official", "patterns");
|
|
4116
4878
|
try {
|
|
4117
|
-
if (
|
|
4118
|
-
for (const file of
|
|
4879
|
+
if (existsSync6(cachedPatternsDir)) {
|
|
4880
|
+
for (const file of readdirSync5(cachedPatternsDir).filter(
|
|
4119
4881
|
(name) => name.endsWith(".json") && name !== "index.json"
|
|
4120
4882
|
)) {
|
|
4121
|
-
const data = JSON.parse(
|
|
4883
|
+
const data = JSON.parse(readFileSync6(join6(cachedPatternsDir, file), "utf-8"));
|
|
4122
4884
|
if (data.id && !patternRegistry.has(data.id)) {
|
|
4123
4885
|
patternRegistry.set(data.id, data);
|
|
4124
4886
|
}
|
|
@@ -4432,8 +5194,8 @@ function extractFailedRouteDocumentHardening(runtimeAudit) {
|
|
|
4432
5194
|
return runtimeAudit.failures.filter((failure) => failure.startsWith("route-document-hardening-failed:")).map((failure) => normalizeRouteHint2(failure.slice("route-document-hardening-failed:".length))).filter(Boolean);
|
|
4433
5195
|
}
|
|
4434
5196
|
function appendRuntimeAuditFindings(findings, runtimeAudit, projectRoot, topology, sourceAudit) {
|
|
4435
|
-
const distPath =
|
|
4436
|
-
const indexPath =
|
|
5197
|
+
const distPath = join6(projectRoot, "dist");
|
|
5198
|
+
const indexPath = join6(distPath, "index.html");
|
|
4437
5199
|
const isFrameworkBuildOutput = runtimeAudit.failures.includes("next-build-output");
|
|
4438
5200
|
if (!runtimeAudit.distPresent) {
|
|
4439
5201
|
findings.push(
|
|
@@ -4978,7 +5740,7 @@ function appendRuntimeAuditFindings(findings, runtimeAudit, projectRoot, topolog
|
|
|
4978
5740
|
}
|
|
4979
5741
|
function readBehaviorPatterns(projectRoot) {
|
|
4980
5742
|
const pack = readJsonIfExists(
|
|
4981
|
-
|
|
5743
|
+
join6(projectRoot, ".decantr", "local-patterns.json")
|
|
4982
5744
|
);
|
|
4983
5745
|
return (pack?.patterns ?? []).filter(
|
|
4984
5746
|
(pattern) => pattern.behavior_obligations && Array.isArray(pattern.behavior_obligations.obligations) && pattern.behavior_obligations.obligations.length > 0
|
|
@@ -5025,15 +5787,15 @@ function isFormPrimitiveDefinitionFile(pattern, relativeFile) {
|
|
|
5025
5787
|
);
|
|
5026
5788
|
}
|
|
5027
5789
|
function sourceAuditFilePath(projectRoot, file) {
|
|
5028
|
-
return
|
|
5790
|
+
return isAbsolute4(file) ? file : join6(projectRoot, file);
|
|
5029
5791
|
}
|
|
5030
5792
|
function sourceAuditRelativePath(projectRoot, file) {
|
|
5031
|
-
return (
|
|
5793
|
+
return (isAbsolute4(file) ? relative6(projectRoot, file) : file).replace(/\\/g, "/");
|
|
5032
5794
|
}
|
|
5033
5795
|
function sourceFileContainsAny(projectRoot, sourceFiles, patterns) {
|
|
5034
5796
|
for (const file of sourceFiles.slice(0, 400)) {
|
|
5035
5797
|
try {
|
|
5036
|
-
const code =
|
|
5798
|
+
const code = readFileSync6(sourceAuditFilePath(projectRoot, file), "utf-8");
|
|
5037
5799
|
if (patterns.some((pattern) => pattern.test(code))) return true;
|
|
5038
5800
|
} catch {
|
|
5039
5801
|
}
|
|
@@ -5087,7 +5849,7 @@ function appendBehaviorObligationFindings(findings, projectRoot, sourceFiles) {
|
|
|
5087
5849
|
const relativeFile = sourceAuditRelativePath(projectRoot, file);
|
|
5088
5850
|
let code = "";
|
|
5089
5851
|
try {
|
|
5090
|
-
code =
|
|
5852
|
+
code = readFileSync6(sourceAuditFilePath(projectRoot, file), "utf-8");
|
|
5091
5853
|
} catch {
|
|
5092
5854
|
continue;
|
|
5093
5855
|
}
|
|
@@ -5164,7 +5926,7 @@ function appendBehaviorObligationFindings(findings, projectRoot, sourceFiles) {
|
|
|
5164
5926
|
const relativeFile = sourceAuditRelativePath(projectRoot, file);
|
|
5165
5927
|
let code = "";
|
|
5166
5928
|
try {
|
|
5167
|
-
code =
|
|
5929
|
+
code = readFileSync6(sourceAuditFilePath(projectRoot, file), "utf-8");
|
|
5168
5930
|
} catch {
|
|
5169
5931
|
continue;
|
|
5170
5932
|
}
|
|
@@ -6486,6 +7248,8 @@ function appendStyleBridgeDriftFindings(findings, audit) {
|
|
|
6486
7248
|
source: finding.source,
|
|
6487
7249
|
property: finding.property,
|
|
6488
7250
|
bridge_mappings: finding.bridgeMappingIds,
|
|
7251
|
+
bridge_confidence: finding.bridgeConfidence,
|
|
7252
|
+
bridge_sources: finding.bridgeSources,
|
|
6489
7253
|
token_hints: finding.tokenHints,
|
|
6490
7254
|
class_hints: finding.classHints
|
|
6491
7255
|
}
|
|
@@ -6529,7 +7293,7 @@ function appendStyleContractFindings(findings, styleAudit, essence) {
|
|
|
6529
7293
|
}
|
|
6530
7294
|
}
|
|
6531
7295
|
async function auditProject(projectRoot) {
|
|
6532
|
-
const essencePath =
|
|
7296
|
+
const essencePath = join6(projectRoot, "decantr.essence.json");
|
|
6533
7297
|
const findings = [];
|
|
6534
7298
|
const reviewPack = loadReviewPack(projectRoot);
|
|
6535
7299
|
const packManifest = loadPackManifest(projectRoot);
|
|
@@ -6537,7 +7301,7 @@ async function auditProject(projectRoot) {
|
|
|
6537
7301
|
const packHydrationOptional = adoptionMode === "contract-only" || adoptionMode === "style-bridge";
|
|
6538
7302
|
const packHydrationSeverity = packHydrationOptional ? "info" : "warn";
|
|
6539
7303
|
const runtimeAudit = emptyRuntimeAudit();
|
|
6540
|
-
if (!
|
|
7304
|
+
if (!existsSync6(essencePath)) {
|
|
6541
7305
|
findings.push(
|
|
6542
7306
|
makeFinding({
|
|
6543
7307
|
id: "essence-missing",
|
|
@@ -6572,7 +7336,7 @@ async function auditProject(projectRoot) {
|
|
|
6572
7336
|
}
|
|
6573
7337
|
let essence = null;
|
|
6574
7338
|
try {
|
|
6575
|
-
essence = JSON.parse(
|
|
7339
|
+
essence = JSON.parse(readFileSync6(essencePath, "utf-8"));
|
|
6576
7340
|
} catch (error) {
|
|
6577
7341
|
findings.push(
|
|
6578
7342
|
makeFinding({
|
|
@@ -6615,7 +7379,7 @@ async function auditProject(projectRoot) {
|
|
|
6615
7379
|
category: "Execution Packs",
|
|
6616
7380
|
severity: packHydrationSeverity,
|
|
6617
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.",
|
|
6618
|
-
evidence: [
|
|
7382
|
+
evidence: [join6(projectRoot, ".decantr", "context", "pack-manifest.json")],
|
|
6619
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."
|
|
6620
7384
|
})
|
|
6621
7385
|
);
|
|
@@ -6679,7 +7443,7 @@ async function auditProject(projectRoot) {
|
|
|
6679
7443
|
category: "Review Contract",
|
|
6680
7444
|
severity: packHydrationSeverity,
|
|
6681
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.",
|
|
6682
|
-
evidence: [
|
|
7446
|
+
evidence: [join6(projectRoot, ".decantr", "context", "review-pack.json")],
|
|
6683
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."
|
|
6684
7448
|
})
|
|
6685
7449
|
);
|
|
@@ -6826,74 +7590,74 @@ function countKeyboardShortcutSignals(code) {
|
|
|
6826
7590
|
return matches.length;
|
|
6827
7591
|
}
|
|
6828
7592
|
function getScriptKind(filePath) {
|
|
6829
|
-
switch (
|
|
7593
|
+
switch (extname6(filePath).toLowerCase()) {
|
|
6830
7594
|
case ".tsx":
|
|
6831
|
-
return
|
|
7595
|
+
return ts6.ScriptKind.TSX;
|
|
6832
7596
|
case ".jsx":
|
|
6833
|
-
return
|
|
7597
|
+
return ts6.ScriptKind.JSX;
|
|
6834
7598
|
case ".ts":
|
|
6835
|
-
return
|
|
7599
|
+
return ts6.ScriptKind.TS;
|
|
6836
7600
|
case ".js":
|
|
6837
|
-
return
|
|
7601
|
+
return ts6.ScriptKind.JS;
|
|
6838
7602
|
default:
|
|
6839
|
-
return
|
|
7603
|
+
return ts6.ScriptKind.TSX;
|
|
6840
7604
|
}
|
|
6841
7605
|
}
|
|
6842
7606
|
function isPropertyNamed(node, ...names) {
|
|
6843
7607
|
if (!node) return false;
|
|
6844
|
-
if (
|
|
7608
|
+
if (ts6.isIdentifier(node)) {
|
|
6845
7609
|
return names.includes(node.text);
|
|
6846
7610
|
}
|
|
6847
|
-
if (
|
|
7611
|
+
if (ts6.isPrivateIdentifier(node)) {
|
|
6848
7612
|
return names.includes(node.text);
|
|
6849
7613
|
}
|
|
6850
|
-
if (
|
|
7614
|
+
if (ts6.isStringLiteral(node)) {
|
|
6851
7615
|
return names.includes(node.text);
|
|
6852
7616
|
}
|
|
6853
7617
|
return false;
|
|
6854
7618
|
}
|
|
6855
7619
|
function getJsxAttribute(attributes, ...names) {
|
|
6856
7620
|
return attributes.properties.find(
|
|
6857
|
-
(property) =>
|
|
7621
|
+
(property) => ts6.isJsxAttribute(property) && isPropertyNamed(property.name, ...names)
|
|
6858
7622
|
);
|
|
6859
7623
|
}
|
|
6860
7624
|
function getJsxTagName(node) {
|
|
6861
|
-
if (
|
|
7625
|
+
if (ts6.isIdentifier(node.tagName)) {
|
|
6862
7626
|
return node.tagName.text;
|
|
6863
7627
|
}
|
|
6864
|
-
if (
|
|
7628
|
+
if (ts6.isPropertyAccessExpression(node.tagName)) {
|
|
6865
7629
|
return node.tagName.name.text;
|
|
6866
7630
|
}
|
|
6867
7631
|
return null;
|
|
6868
7632
|
}
|
|
6869
7633
|
function getJsxAttributeLiteralValue(attribute) {
|
|
6870
7634
|
if (!attribute?.initializer) return null;
|
|
6871
|
-
if (
|
|
7635
|
+
if (ts6.isStringLiteral(attribute.initializer)) {
|
|
6872
7636
|
return attribute.initializer.text;
|
|
6873
7637
|
}
|
|
6874
|
-
if (
|
|
7638
|
+
if (ts6.isJsxExpression(attribute.initializer)) {
|
|
6875
7639
|
const expression = attribute.initializer.expression;
|
|
6876
7640
|
if (!expression) return "";
|
|
6877
|
-
if (
|
|
7641
|
+
if (ts6.isStringLiteral(expression) || ts6.isNoSubstitutionTemplateLiteral(expression)) {
|
|
6878
7642
|
return expression.text;
|
|
6879
7643
|
}
|
|
6880
7644
|
}
|
|
6881
7645
|
return null;
|
|
6882
7646
|
}
|
|
6883
7647
|
function getJsxTextContent(node) {
|
|
6884
|
-
if (
|
|
7648
|
+
if (ts6.isJsxText(node)) {
|
|
6885
7649
|
return node.getText();
|
|
6886
7650
|
}
|
|
6887
|
-
if (
|
|
7651
|
+
if (ts6.isStringLiteral(node) || ts6.isNoSubstitutionTemplateLiteral(node)) {
|
|
6888
7652
|
return node.text;
|
|
6889
7653
|
}
|
|
6890
|
-
if (
|
|
7654
|
+
if (ts6.isJsxExpression(node)) {
|
|
6891
7655
|
return node.expression ? getJsxTextContent(node.expression) : "";
|
|
6892
7656
|
}
|
|
6893
|
-
if (
|
|
7657
|
+
if (ts6.isJsxSelfClosingElement(node) || ts6.isJsxOpeningElement(node)) {
|
|
6894
7658
|
return "";
|
|
6895
7659
|
}
|
|
6896
|
-
if (
|
|
7660
|
+
if (ts6.isJsxElement(node) || ts6.isJsxFragment(node)) {
|
|
6897
7661
|
return node.children.map((child) => getJsxTextContent(child)).join("");
|
|
6898
7662
|
}
|
|
6899
7663
|
let text = "";
|
|
@@ -6913,7 +7677,7 @@ function isNonSemanticInteractiveTag(tagName) {
|
|
|
6913
7677
|
function collectLabelForIds(root) {
|
|
6914
7678
|
const ids = /* @__PURE__ */ new Set();
|
|
6915
7679
|
const walk = (node) => {
|
|
6916
|
-
if (
|
|
7680
|
+
if (ts6.isJsxSelfClosingElement(node) || ts6.isJsxOpeningElement(node)) {
|
|
6917
7681
|
const tagName = getJsxTagName(node);
|
|
6918
7682
|
if (tagName === "label") {
|
|
6919
7683
|
const htmlForValue = getJsxAttributeLiteralValue(
|
|
@@ -6924,7 +7688,7 @@ function collectLabelForIds(root) {
|
|
|
6924
7688
|
}
|
|
6925
7689
|
}
|
|
6926
7690
|
}
|
|
6927
|
-
|
|
7691
|
+
ts6.forEachChild(node, walk);
|
|
6928
7692
|
};
|
|
6929
7693
|
walk(root);
|
|
6930
7694
|
return ids;
|
|
@@ -6932,7 +7696,7 @@ function collectLabelForIds(root) {
|
|
|
6932
7696
|
function isWrappedInJsxLabel(node) {
|
|
6933
7697
|
let current = node.parent;
|
|
6934
7698
|
while (current) {
|
|
6935
|
-
if (
|
|
7699
|
+
if (ts6.isJsxElement(current) && getJsxTagName(current.openingElement) === "label") {
|
|
6936
7700
|
return true;
|
|
6937
7701
|
}
|
|
6938
7702
|
current = current.parent;
|
|
@@ -6942,7 +7706,7 @@ function isWrappedInJsxLabel(node) {
|
|
|
6942
7706
|
function hasAncestorJsxTag(node, tagName) {
|
|
6943
7707
|
let current = node.parent;
|
|
6944
7708
|
while (current) {
|
|
6945
|
-
if (
|
|
7709
|
+
if (ts6.isJsxElement(current) && getJsxTagName(current.openingElement) === tagName) {
|
|
6946
7710
|
return true;
|
|
6947
7711
|
}
|
|
6948
7712
|
current = current.parent;
|
|
@@ -7020,9 +7784,9 @@ function hasNavigationLabel(attributes) {
|
|
|
7020
7784
|
}
|
|
7021
7785
|
function getJsxAttributeOwner(attribute) {
|
|
7022
7786
|
const attributes = attribute.parent;
|
|
7023
|
-
if (!attributes || !
|
|
7787
|
+
if (!attributes || !ts6.isJsxAttributes(attributes)) return null;
|
|
7024
7788
|
const owner = attributes.parent;
|
|
7025
|
-
if (
|
|
7789
|
+
if (ts6.isJsxOpeningElement(owner) || ts6.isJsxSelfClosingElement(owner)) {
|
|
7026
7790
|
return owner;
|
|
7027
7791
|
}
|
|
7028
7792
|
return null;
|
|
@@ -7109,14 +7873,14 @@ function jsxTreeContainsAuthInput(node) {
|
|
|
7109
7873
|
let found = false;
|
|
7110
7874
|
const visit = (current) => {
|
|
7111
7875
|
if (found) return;
|
|
7112
|
-
if (
|
|
7876
|
+
if (ts6.isJsxSelfClosingElement(current)) {
|
|
7113
7877
|
const tagName = getJsxTagName(current);
|
|
7114
7878
|
if (tagName === "input" && isAuthLikeInputAttributes(current.attributes)) {
|
|
7115
7879
|
found = true;
|
|
7116
7880
|
}
|
|
7117
7881
|
return;
|
|
7118
7882
|
}
|
|
7119
|
-
if (
|
|
7883
|
+
if (ts6.isJsxElement(current)) {
|
|
7120
7884
|
const tagName = getJsxTagName(current.openingElement);
|
|
7121
7885
|
if (tagName === "input" && isAuthLikeInputAttributes(current.openingElement.attributes)) {
|
|
7122
7886
|
found = true;
|
|
@@ -7128,7 +7892,7 @@ function jsxTreeContainsAuthInput(node) {
|
|
|
7128
7892
|
}
|
|
7129
7893
|
return;
|
|
7130
7894
|
}
|
|
7131
|
-
if (
|
|
7895
|
+
if (ts6.isJsxFragment(current)) {
|
|
7132
7896
|
for (const child of current.children) {
|
|
7133
7897
|
visit(child);
|
|
7134
7898
|
if (found) return;
|
|
@@ -7152,7 +7916,7 @@ function jsxTreeHasSubmitControl(node) {
|
|
|
7152
7916
|
let found = false;
|
|
7153
7917
|
const visit = (current) => {
|
|
7154
7918
|
if (found) return;
|
|
7155
|
-
if (
|
|
7919
|
+
if (ts6.isJsxSelfClosingElement(current)) {
|
|
7156
7920
|
const tagName = getJsxTagName(current);
|
|
7157
7921
|
if (tagName === "button") {
|
|
7158
7922
|
const typeValue = getJsxAttributeLiteralValue(getJsxAttribute(current.attributes, "type"))?.trim().toLowerCase();
|
|
@@ -7168,7 +7932,7 @@ function jsxTreeHasSubmitControl(node) {
|
|
|
7168
7932
|
}
|
|
7169
7933
|
return;
|
|
7170
7934
|
}
|
|
7171
|
-
if (
|
|
7935
|
+
if (ts6.isJsxElement(current)) {
|
|
7172
7936
|
const tagName = getJsxTagName(current.openingElement);
|
|
7173
7937
|
if (tagName === "button") {
|
|
7174
7938
|
const typeValue = getJsxAttributeLiteralValue(
|
|
@@ -7192,7 +7956,7 @@ function jsxTreeHasSubmitControl(node) {
|
|
|
7192
7956
|
}
|
|
7193
7957
|
return;
|
|
7194
7958
|
}
|
|
7195
|
-
if (
|
|
7959
|
+
if (ts6.isJsxFragment(current)) {
|
|
7196
7960
|
for (const child of current.children) {
|
|
7197
7961
|
visit(child);
|
|
7198
7962
|
if (found) return;
|
|
@@ -7209,14 +7973,14 @@ function jsxTreeHasTag(node, tagNames) {
|
|
|
7209
7973
|
const wanted = new Set(tagNames);
|
|
7210
7974
|
const visit = (current) => {
|
|
7211
7975
|
if (found) return;
|
|
7212
|
-
if (
|
|
7976
|
+
if (ts6.isJsxSelfClosingElement(current)) {
|
|
7213
7977
|
const tagName = getJsxTagName(current);
|
|
7214
7978
|
if (tagName && wanted.has(tagName)) {
|
|
7215
7979
|
found = true;
|
|
7216
7980
|
}
|
|
7217
7981
|
return;
|
|
7218
7982
|
}
|
|
7219
|
-
if (
|
|
7983
|
+
if (ts6.isJsxElement(current)) {
|
|
7220
7984
|
const tagName = getJsxTagName(current.openingElement);
|
|
7221
7985
|
if (tagName && wanted.has(tagName)) {
|
|
7222
7986
|
found = true;
|
|
@@ -7228,7 +7992,7 @@ function jsxTreeHasTag(node, tagNames) {
|
|
|
7228
7992
|
}
|
|
7229
7993
|
return;
|
|
7230
7994
|
}
|
|
7231
|
-
if (
|
|
7995
|
+
if (ts6.isJsxFragment(current)) {
|
|
7232
7996
|
for (const child of current.children) {
|
|
7233
7997
|
visit(child);
|
|
7234
7998
|
if (found) return;
|
|
@@ -7245,22 +8009,22 @@ function hasAuthFormWithoutSubmitControl(node) {
|
|
|
7245
8009
|
}
|
|
7246
8010
|
function getExpressionLiteralValue(expression) {
|
|
7247
8011
|
if (!expression) return null;
|
|
7248
|
-
if (
|
|
8012
|
+
if (ts6.isStringLiteral(expression) || ts6.isNoSubstitutionTemplateLiteral(expression)) {
|
|
7249
8013
|
return expression.text;
|
|
7250
8014
|
}
|
|
7251
|
-
if (
|
|
8015
|
+
if (ts6.isParenthesizedExpression(expression)) {
|
|
7252
8016
|
return getExpressionLiteralValue(expression.expression);
|
|
7253
8017
|
}
|
|
7254
|
-
if (
|
|
8018
|
+
if (ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression)) {
|
|
7255
8019
|
return getExpressionLiteralValue(expression.expression);
|
|
7256
8020
|
}
|
|
7257
8021
|
return null;
|
|
7258
8022
|
}
|
|
7259
8023
|
function getObjectLiteralStringPropertyValue(expression, ...propertyNames) {
|
|
7260
|
-
if (!expression || !
|
|
8024
|
+
if (!expression || !ts6.isObjectLiteralExpression(expression)) return null;
|
|
7261
8025
|
for (const property of expression.properties) {
|
|
7262
|
-
if (!
|
|
7263
|
-
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;
|
|
7264
8028
|
if (!propertyName2 || !propertyNames.includes(propertyName2)) continue;
|
|
7265
8029
|
const value = getExpressionLiteralValue(property.initializer);
|
|
7266
8030
|
if (value) return value;
|
|
@@ -7268,24 +8032,24 @@ function getObjectLiteralStringPropertyValue(expression, ...propertyNames) {
|
|
|
7268
8032
|
return null;
|
|
7269
8033
|
}
|
|
7270
8034
|
function getObjectLiteralBooleanPropertyValue(expression, ...propertyNames) {
|
|
7271
|
-
if (!expression || !
|
|
8035
|
+
if (!expression || !ts6.isObjectLiteralExpression(expression)) return null;
|
|
7272
8036
|
for (const property of expression.properties) {
|
|
7273
|
-
if (!
|
|
7274
|
-
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;
|
|
7275
8039
|
if (!propertyName2 || !propertyNames.includes(propertyName2)) continue;
|
|
7276
|
-
if (property.initializer.kind ===
|
|
7277
|
-
if (property.initializer.kind ===
|
|
8040
|
+
if (property.initializer.kind === ts6.SyntaxKind.TrueKeyword) return true;
|
|
8041
|
+
if (property.initializer.kind === ts6.SyntaxKind.FalseKeyword) return false;
|
|
7278
8042
|
}
|
|
7279
8043
|
return null;
|
|
7280
8044
|
}
|
|
7281
8045
|
function collectNamedFunctionLikeDeclarations(root) {
|
|
7282
8046
|
const declarations = /* @__PURE__ */ new Map();
|
|
7283
8047
|
const visit = (node) => {
|
|
7284
|
-
if (
|
|
8048
|
+
if (ts6.isFunctionDeclaration(node) && node.name && ts6.isIdentifier(node.name)) {
|
|
7285
8049
|
declarations.set(node.name.text, node);
|
|
7286
8050
|
}
|
|
7287
|
-
if (
|
|
7288
|
-
if (
|
|
8051
|
+
if (ts6.isVariableDeclaration(node) && ts6.isIdentifier(node.name) && node.initializer) {
|
|
8052
|
+
if (ts6.isArrowFunction(node.initializer) || ts6.isFunctionExpression(node.initializer)) {
|
|
7289
8053
|
declarations.set(node.name.text, node.initializer);
|
|
7290
8054
|
}
|
|
7291
8055
|
}
|
|
@@ -7305,12 +8069,12 @@ function getCachedNamedFunctionLikeDeclarations(sourceFile) {
|
|
|
7305
8069
|
function collectNamedExpressionInitializers(root) {
|
|
7306
8070
|
const initializers = /* @__PURE__ */ new Map();
|
|
7307
8071
|
const visit = (node) => {
|
|
7308
|
-
if (
|
|
8072
|
+
if (ts6.isVariableDeclaration(node) && ts6.isIdentifier(node.name) && node.initializer) {
|
|
7309
8073
|
initializers.set(node.name.text, node.initializer);
|
|
7310
8074
|
}
|
|
7311
|
-
if (
|
|
8075
|
+
if (ts6.isVariableDeclaration(node) && ts6.isArrayBindingPattern(node.name) && node.initializer) {
|
|
7312
8076
|
const firstElement = node.name.elements[0];
|
|
7313
|
-
if (firstElement && !
|
|
8077
|
+
if (firstElement && !ts6.isOmittedExpression(firstElement) && ts6.isBindingElement(firstElement) && ts6.isIdentifier(firstElement.name)) {
|
|
7314
8078
|
initializers.set(firstElement.name.text, node.initializer);
|
|
7315
8079
|
}
|
|
7316
8080
|
}
|
|
@@ -7321,7 +8085,7 @@ function collectNamedExpressionInitializers(root) {
|
|
|
7321
8085
|
}
|
|
7322
8086
|
function getPropertyNameText(name) {
|
|
7323
8087
|
if (!name) return null;
|
|
7324
|
-
if (
|
|
8088
|
+
if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
|
|
7325
8089
|
return name.text;
|
|
7326
8090
|
}
|
|
7327
8091
|
return null;
|
|
@@ -7334,20 +8098,20 @@ function collectNamedPropertyAliases(root) {
|
|
|
7334
8098
|
const propertyName2 = getPropertyNameText(element.propertyName) ?? getPropertyNameText(element.name);
|
|
7335
8099
|
if (!propertyName2) continue;
|
|
7336
8100
|
const nextPath = [...propertyPath, propertyName2];
|
|
7337
|
-
if (
|
|
8101
|
+
if (ts6.isIdentifier(element.name)) {
|
|
7338
8102
|
aliases.set(element.name.text, { initializer, propertyName: propertyName2, propertyPath: nextPath });
|
|
7339
8103
|
continue;
|
|
7340
8104
|
}
|
|
7341
|
-
if (
|
|
8105
|
+
if (ts6.isObjectBindingPattern(element.name)) {
|
|
7342
8106
|
collectFromBindingPattern(element.name, initializer, nextPath);
|
|
7343
8107
|
}
|
|
7344
8108
|
}
|
|
7345
8109
|
};
|
|
7346
8110
|
const visit = (node) => {
|
|
7347
|
-
if (
|
|
8111
|
+
if (ts6.isVariableDeclaration(node) && ts6.isObjectBindingPattern(node.name) && node.initializer) {
|
|
7348
8112
|
collectFromBindingPattern(node.name, node.initializer, []);
|
|
7349
8113
|
}
|
|
7350
|
-
if (
|
|
8114
|
+
if (ts6.isParameter(node) && ts6.isObjectBindingPattern(node.name)) {
|
|
7351
8115
|
collectFromBindingPattern(node.name, void 0, []);
|
|
7352
8116
|
}
|
|
7353
8117
|
node.forEachChild(visit);
|
|
@@ -7357,28 +8121,28 @@ function collectNamedPropertyAliases(root) {
|
|
|
7357
8121
|
}
|
|
7358
8122
|
function resolveFunctionLikeHandler(expression, namedFunctions) {
|
|
7359
8123
|
if (!expression) return null;
|
|
7360
|
-
if (
|
|
8124
|
+
if (ts6.isArrowFunction(expression) || ts6.isFunctionExpression(expression)) {
|
|
7361
8125
|
return expression;
|
|
7362
8126
|
}
|
|
7363
|
-
if (
|
|
8127
|
+
if (ts6.isIdentifier(expression)) {
|
|
7364
8128
|
return namedFunctions.get(expression.text) ?? null;
|
|
7365
8129
|
}
|
|
7366
8130
|
return null;
|
|
7367
8131
|
}
|
|
7368
8132
|
function getFunctionLikeReturnExpressions(node) {
|
|
7369
|
-
if (
|
|
8133
|
+
if (ts6.isArrowFunction(node) && !ts6.isBlock(node.body)) {
|
|
7370
8134
|
return [node.body];
|
|
7371
8135
|
}
|
|
7372
8136
|
const body = node.body;
|
|
7373
|
-
if (!body || !
|
|
8137
|
+
if (!body || !ts6.isBlock(body)) {
|
|
7374
8138
|
return [];
|
|
7375
8139
|
}
|
|
7376
8140
|
const expressions = [];
|
|
7377
8141
|
const visit = (current) => {
|
|
7378
|
-
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))) {
|
|
7379
8143
|
return;
|
|
7380
8144
|
}
|
|
7381
|
-
if (
|
|
8145
|
+
if (ts6.isReturnStatement(current) && current.expression) {
|
|
7382
8146
|
expressions.push(current.expression);
|
|
7383
8147
|
return;
|
|
7384
8148
|
}
|
|
@@ -7394,7 +8158,7 @@ function bindFunctionLikeArguments(functionLike, args, namedExpressions) {
|
|
|
7394
8158
|
const boundExpressions = new Map(namedExpressions);
|
|
7395
8159
|
functionLike.parameters.forEach((parameter, index) => {
|
|
7396
8160
|
const argument = args[index];
|
|
7397
|
-
if (!argument || !
|
|
8161
|
+
if (!argument || !ts6.isIdentifier(parameter.name)) return;
|
|
7398
8162
|
boundExpressions.set(parameter.name.text, argument);
|
|
7399
8163
|
});
|
|
7400
8164
|
return boundExpressions;
|
|
@@ -7408,10 +8172,10 @@ function getMemberAccessPropertyName(expression) {
|
|
|
7408
8172
|
}
|
|
7409
8173
|
function getObjectLiteralPropertyExpression(objectLiteral, propertyName2, namedExpressions) {
|
|
7410
8174
|
for (const property of objectLiteral.properties) {
|
|
7411
|
-
if (
|
|
8175
|
+
if (ts6.isPropertyAssignment(property) && getPropertyNameText(property.name) === propertyName2) {
|
|
7412
8176
|
return property.initializer;
|
|
7413
8177
|
}
|
|
7414
|
-
if (
|
|
8178
|
+
if (ts6.isShorthandPropertyAssignment(property) && property.name.text === propertyName2) {
|
|
7415
8179
|
return namedExpressions.get(property.name.text) ?? null;
|
|
7416
8180
|
}
|
|
7417
8181
|
}
|
|
@@ -7477,7 +8241,7 @@ function resolveReturnedObjectLiteralExpression(functionLike, args, sourceFile,
|
|
|
7477
8241
|
function resolveObjectLiteralExpression(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers, seenFunctions = /* @__PURE__ */ new Set(), depth = 0) {
|
|
7478
8242
|
if (!expression) return null;
|
|
7479
8243
|
if (depth > MAX_OPEN_REDIRECT_RESOLUTION_DEPTH) return null;
|
|
7480
|
-
if (
|
|
8244
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
7481
8245
|
return resolveObjectLiteralExpression(
|
|
7482
8246
|
expression.expression,
|
|
7483
8247
|
sourceFile,
|
|
@@ -7488,10 +8252,10 @@ function resolveObjectLiteralExpression(expression, sourceFile, namedExpressions
|
|
|
7488
8252
|
depth + 1
|
|
7489
8253
|
);
|
|
7490
8254
|
}
|
|
7491
|
-
if (
|
|
8255
|
+
if (ts6.isObjectLiteralExpression(expression)) {
|
|
7492
8256
|
return { objectLiteral: expression, namedExpressions };
|
|
7493
8257
|
}
|
|
7494
|
-
if (
|
|
8258
|
+
if (ts6.isIdentifier(expression)) {
|
|
7495
8259
|
if (seenIdentifiers.has(expression.text)) return null;
|
|
7496
8260
|
const initializer = namedExpressions.get(expression.text);
|
|
7497
8261
|
if (initializer) {
|
|
@@ -7564,13 +8328,13 @@ function resolveObjectLiteralExpression(expression, sourceFile, namedExpressions
|
|
|
7564
8328
|
}
|
|
7565
8329
|
function findFunctionLikeOnObjectLiteral(objectLiteral, propertyName2, namedFunctions) {
|
|
7566
8330
|
for (const property of objectLiteral.properties) {
|
|
7567
|
-
if (
|
|
8331
|
+
if (ts6.isMethodDeclaration(property) && getPropertyNameText(property.name) === propertyName2) {
|
|
7568
8332
|
return property;
|
|
7569
8333
|
}
|
|
7570
|
-
if (
|
|
8334
|
+
if (ts6.isPropertyAssignment(property) && getPropertyNameText(property.name) === propertyName2) {
|
|
7571
8335
|
return resolveFunctionLikeHandler(property.initializer, namedFunctions);
|
|
7572
8336
|
}
|
|
7573
|
-
if (
|
|
8337
|
+
if (ts6.isShorthandPropertyAssignment(property) && property.name.text === propertyName2) {
|
|
7574
8338
|
return namedFunctions.get(property.name.text) ?? null;
|
|
7575
8339
|
}
|
|
7576
8340
|
}
|
|
@@ -7605,7 +8369,7 @@ function resolveTrackedOpenRedirectFunctionLike(expression, sourceFile, namedExp
|
|
|
7605
8369
|
if (directFunctionLike) {
|
|
7606
8370
|
return { functionLike: directFunctionLike, namedExpressions };
|
|
7607
8371
|
}
|
|
7608
|
-
if (
|
|
8372
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
7609
8373
|
return resolveTrackedOpenRedirectFunctionLike(
|
|
7610
8374
|
expression.expression,
|
|
7611
8375
|
sourceFile,
|
|
@@ -7638,7 +8402,7 @@ function resolveTrackedOpenRedirectFunctionLike(expression, sourceFile, namedExp
|
|
|
7638
8402
|
depth + 1
|
|
7639
8403
|
);
|
|
7640
8404
|
}
|
|
7641
|
-
if (
|
|
8405
|
+
if (ts6.isIdentifier(expression)) {
|
|
7642
8406
|
if (seenIdentifiers.has(expression.text)) return null;
|
|
7643
8407
|
const initializer = namedExpressions.get(expression.text);
|
|
7644
8408
|
if (initializer) {
|
|
@@ -7701,16 +8465,16 @@ function functionLikeReferencesOrigin(node) {
|
|
|
7701
8465
|
let found = false;
|
|
7702
8466
|
const visit = (current) => {
|
|
7703
8467
|
if (found) return;
|
|
7704
|
-
if (
|
|
8468
|
+
if (ts6.isPropertyAccessExpression(current) && isPropertyNamed(current.name, "origin")) {
|
|
7705
8469
|
found = true;
|
|
7706
8470
|
return;
|
|
7707
8471
|
}
|
|
7708
|
-
if (
|
|
8472
|
+
if (ts6.isIdentifier(current) && current.text === "origin") {
|
|
7709
8473
|
found = true;
|
|
7710
8474
|
return;
|
|
7711
8475
|
}
|
|
7712
|
-
if (
|
|
7713
|
-
if (
|
|
8476
|
+
if (ts6.isBindingElement(current)) {
|
|
8477
|
+
if (ts6.isIdentifier(current.name) && current.name.text === "origin") {
|
|
7714
8478
|
found = true;
|
|
7715
8479
|
return;
|
|
7716
8480
|
}
|
|
@@ -7725,13 +8489,13 @@ function functionLikeReferencesOrigin(node) {
|
|
|
7725
8489
|
return found;
|
|
7726
8490
|
}
|
|
7727
8491
|
function isAddEventListenerCall(node) {
|
|
7728
|
-
return
|
|
8492
|
+
return ts6.isIdentifier(node.expression) && node.expression.text === "addEventListener" || ts6.isPropertyAccessExpression(node.expression) && isPropertyNamed(node.expression.name, "addEventListener");
|
|
7729
8493
|
}
|
|
7730
8494
|
function isCookieMutationSetCall(node) {
|
|
7731
|
-
if (!
|
|
8495
|
+
if (!ts6.isPropertyAccessExpression(node.expression) || !isPropertyNamed(node.expression.name, "set")) {
|
|
7732
8496
|
return false;
|
|
7733
8497
|
}
|
|
7734
|
-
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");
|
|
7735
8499
|
}
|
|
7736
8500
|
function expressionLooksLikeAuthCookieName(node, sourceFile) {
|
|
7737
8501
|
if (!node) return false;
|
|
@@ -7739,17 +8503,17 @@ function expressionLooksLikeAuthCookieName(node, sourceFile) {
|
|
|
7739
8503
|
return hasAuthCredentialText(node, sourceFile);
|
|
7740
8504
|
}
|
|
7741
8505
|
function objectLiteralLooksLikeAuthCookieConfig(expression, sourceFile) {
|
|
7742
|
-
if (!expression || !
|
|
8506
|
+
if (!expression || !ts6.isObjectLiteralExpression(expression)) return false;
|
|
7743
8507
|
for (const property of expression.properties) {
|
|
7744
|
-
if (!
|
|
7745
|
-
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;
|
|
7746
8510
|
if (!propertyName2 || !["name", "key", "cookie"].includes(propertyName2)) continue;
|
|
7747
8511
|
return expressionLooksLikeAuthCookieName(property.initializer, sourceFile);
|
|
7748
8512
|
}
|
|
7749
8513
|
return false;
|
|
7750
8514
|
}
|
|
7751
8515
|
function hasExplicitAuthCookieHardening(expression) {
|
|
7752
|
-
if (!expression || !
|
|
8516
|
+
if (!expression || !ts6.isObjectLiteralExpression(expression)) return false;
|
|
7753
8517
|
const httpOnly = getObjectLiteralBooleanPropertyValue(expression, "httpOnly", "http_only");
|
|
7754
8518
|
const secure = getObjectLiteralBooleanPropertyValue(expression, "secure");
|
|
7755
8519
|
const sameSite = getObjectLiteralStringPropertyValue(expression, "sameSite", "same_site");
|
|
@@ -7769,8 +8533,8 @@ function collectCookieHeaderStrings(expression) {
|
|
|
7769
8533
|
if (!expression) return [];
|
|
7770
8534
|
const literal = getExpressionLiteralValue(expression);
|
|
7771
8535
|
if (literal !== null) return [literal];
|
|
7772
|
-
if (
|
|
7773
|
-
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);
|
|
7774
8538
|
}
|
|
7775
8539
|
return [];
|
|
7776
8540
|
}
|
|
@@ -7778,16 +8542,16 @@ function isInsecureTransportUrl(value) {
|
|
|
7778
8542
|
return typeof value === "string" && /^(?:http|ws):\/\//i.test(value.trim());
|
|
7779
8543
|
}
|
|
7780
8544
|
function isPropertyLikeAccessExpression(node) {
|
|
7781
|
-
return Boolean(node && (
|
|
8545
|
+
return Boolean(node && (ts6.isPropertyAccessExpression(node) || ts6.isPropertyAccessChain(node)));
|
|
7782
8546
|
}
|
|
7783
8547
|
function isElementLikeAccessExpression(node) {
|
|
7784
|
-
return Boolean(node && (
|
|
8548
|
+
return Boolean(node && (ts6.isElementAccessExpression(node) || ts6.isElementAccessChain(node)));
|
|
7785
8549
|
}
|
|
7786
8550
|
function isMemberAccessExpression(node) {
|
|
7787
8551
|
return isPropertyLikeAccessExpression(node) || isElementLikeAccessExpression(node);
|
|
7788
8552
|
}
|
|
7789
8553
|
function isCallLikeExpression(node) {
|
|
7790
|
-
return Boolean(node && (
|
|
8554
|
+
return Boolean(node && (ts6.isCallExpression(node) || ts6.isCallChain(node)));
|
|
7791
8555
|
}
|
|
7792
8556
|
function isMemberAccessNamed(node, ...names) {
|
|
7793
8557
|
if (!node) return false;
|
|
@@ -7800,19 +8564,19 @@ function isMemberAccessNamed(node, ...names) {
|
|
|
7800
8564
|
return false;
|
|
7801
8565
|
}
|
|
7802
8566
|
function isLocationObjectExpression(expression) {
|
|
7803
|
-
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(
|
|
7804
8568
|
expression.expression.text
|
|
7805
8569
|
) && isMemberAccessNamed(expression, "location");
|
|
7806
8570
|
}
|
|
7807
8571
|
function isLocationAssignmentTarget(expression) {
|
|
7808
|
-
return isLocationObjectExpression(expression) || (
|
|
8572
|
+
return isLocationObjectExpression(expression) || (ts6.isPropertyAccessExpression(expression) || ts6.isElementAccessExpression(expression)) && isLocationObjectExpression(expression.expression) && isMemberAccessNamed(expression, "href");
|
|
7809
8573
|
}
|
|
7810
8574
|
function isFetchLikeCall(node) {
|
|
7811
|
-
return
|
|
8575
|
+
return ts6.isIdentifier(node.expression) && node.expression.text === "fetch" || ts6.isPropertyAccessExpression(node.expression) && isPropertyNamed(node.expression.name, "fetch");
|
|
7812
8576
|
}
|
|
7813
8577
|
function isAxiosLikeCall(node) {
|
|
7814
|
-
if (!
|
|
7815
|
-
return
|
|
8578
|
+
if (!ts6.isPropertyAccessExpression(node.expression)) return false;
|
|
8579
|
+
return ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "axios" && isPropertyNamed(
|
|
7816
8580
|
node.expression.name,
|
|
7817
8581
|
"get",
|
|
7818
8582
|
"post",
|
|
@@ -7825,10 +8589,10 @@ function isAxiosLikeCall(node) {
|
|
|
7825
8589
|
);
|
|
7826
8590
|
}
|
|
7827
8591
|
function isAxiosConfigCall(node) {
|
|
7828
|
-
return
|
|
8592
|
+
return ts6.isIdentifier(node.expression) && node.expression.text === "axios";
|
|
7829
8593
|
}
|
|
7830
8594
|
function isRealtimeTransportConstructor(node) {
|
|
7831
|
-
return
|
|
8595
|
+
return ts6.isIdentifier(node.expression) && (node.expression.text === "WebSocket" || node.expression.text === "EventSource");
|
|
7832
8596
|
}
|
|
7833
8597
|
function hasPlaceholderNavigationTarget(attributes) {
|
|
7834
8598
|
const targetValue = getJsxAttributeLiteralValue(getJsxAttribute(attributes, "href", "to"));
|
|
@@ -7895,40 +8659,40 @@ function getSkipNavTargetId(attributes, tagName) {
|
|
|
7895
8659
|
}
|
|
7896
8660
|
function isAuthStorageKeyLiteral(node) {
|
|
7897
8661
|
if (!node) return false;
|
|
7898
|
-
if (
|
|
8662
|
+
if (ts6.isStringLiteral(node) || ts6.isNoSubstitutionTemplateLiteral(node)) {
|
|
7899
8663
|
if (node.text === "decantr_authenticated") return false;
|
|
7900
8664
|
return /(?:token|auth|jwt|session|access_token|refresh_token)/i.test(node.text);
|
|
7901
8665
|
}
|
|
7902
8666
|
return false;
|
|
7903
8667
|
}
|
|
7904
8668
|
function isBrowserStorageObject(node) {
|
|
7905
|
-
return
|
|
8669
|
+
return ts6.isIdentifier(node) && (node.text === "localStorage" || node.text === "sessionStorage");
|
|
7906
8670
|
}
|
|
7907
8671
|
function isDocumentObject(node) {
|
|
7908
|
-
return
|
|
8672
|
+
return ts6.isIdentifier(node) && node.text === "document";
|
|
7909
8673
|
}
|
|
7910
8674
|
function isCookiePropertyAccess(node) {
|
|
7911
|
-
return
|
|
8675
|
+
return ts6.isPropertyAccessExpression(node) && isDocumentObject(node.expression) && isPropertyNamed(node.name, "cookie");
|
|
7912
8676
|
}
|
|
7913
8677
|
function hasAuthCredentialText(node, sourceFile) {
|
|
7914
8678
|
return /(?:token|auth|jwt|session|access_token|refresh_token)/i.test(node.getText(sourceFile));
|
|
7915
8679
|
}
|
|
7916
8680
|
function isAuthorizationHeaderName(node) {
|
|
7917
8681
|
if (!node) return false;
|
|
7918
|
-
if (
|
|
8682
|
+
if (ts6.isIdentifier(node)) {
|
|
7919
8683
|
return /^authorization$/i.test(node.text);
|
|
7920
8684
|
}
|
|
7921
|
-
if (
|
|
8685
|
+
if (ts6.isStringLiteral(node) || ts6.isNoSubstitutionTemplateLiteral(node)) {
|
|
7922
8686
|
return /^authorization$/i.test(node.text);
|
|
7923
8687
|
}
|
|
7924
|
-
if (
|
|
8688
|
+
if (ts6.isComputedPropertyName(node)) {
|
|
7925
8689
|
return isAuthorizationHeaderName(node.expression);
|
|
7926
8690
|
}
|
|
7927
8691
|
return false;
|
|
7928
8692
|
}
|
|
7929
8693
|
function isAuthorizationHeaderAccess(node) {
|
|
7930
8694
|
if (!node) return false;
|
|
7931
|
-
return
|
|
8695
|
+
return ts6.isPropertyAccessExpression(node) && isAuthorizationHeaderName(node.name) || ts6.isElementAccessExpression(node) && isAuthorizationHeaderName(node.argumentExpression);
|
|
7932
8696
|
}
|
|
7933
8697
|
function isHeaderClearValue(node) {
|
|
7934
8698
|
if (!node) return false;
|
|
@@ -7936,7 +8700,7 @@ function isHeaderClearValue(node) {
|
|
|
7936
8700
|
if (literal !== null) {
|
|
7937
8701
|
return literal.trim().length === 0;
|
|
7938
8702
|
}
|
|
7939
|
-
return node.kind ===
|
|
8703
|
+
return node.kind === ts6.SyntaxKind.NullKeyword || node.kind === ts6.SyntaxKind.UndefinedKeyword || ts6.isIdentifier(node) && node.text === "undefined";
|
|
7940
8704
|
}
|
|
7941
8705
|
function countAuthGuardSignals(code) {
|
|
7942
8706
|
const patterns = [
|
|
@@ -8685,7 +9449,7 @@ function propertyPathLooksLikeOpenRedirectQueryContainerBase(propertyPath) {
|
|
|
8685
9449
|
}
|
|
8686
9450
|
function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFile, namedExpressions = /* @__PURE__ */ new Map(), namedPropertyAliases = /* @__PURE__ */ new Map(), seenIdentifiers = /* @__PURE__ */ new Set(), seenFunctions = /* @__PURE__ */ new Set()) {
|
|
8687
9451
|
if (!expression) return false;
|
|
8688
|
-
if (
|
|
9452
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
8689
9453
|
return expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8690
9454
|
expression.expression,
|
|
8691
9455
|
sourceFile,
|
|
@@ -8712,7 +9476,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8712
9476
|
)
|
|
8713
9477
|
);
|
|
8714
9478
|
}
|
|
8715
|
-
if (
|
|
9479
|
+
if (ts6.isBinaryExpression(expression) && (expression.operatorToken.kind === ts6.SyntaxKind.QuestionQuestionToken || expression.operatorToken.kind === ts6.SyntaxKind.BarBarToken)) {
|
|
8716
9480
|
return expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8717
9481
|
expression.left,
|
|
8718
9482
|
sourceFile,
|
|
@@ -8729,7 +9493,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8729
9493
|
seenFunctions
|
|
8730
9494
|
);
|
|
8731
9495
|
}
|
|
8732
|
-
if (
|
|
9496
|
+
if (ts6.isConditionalExpression(expression)) {
|
|
8733
9497
|
return expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8734
9498
|
expression.whenTrue,
|
|
8735
9499
|
sourceFile,
|
|
@@ -8746,7 +9510,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8746
9510
|
seenFunctions
|
|
8747
9511
|
);
|
|
8748
9512
|
}
|
|
8749
|
-
if (
|
|
9513
|
+
if (ts6.isTemplateExpression(expression)) {
|
|
8750
9514
|
return expression.templateSpans.some(
|
|
8751
9515
|
(span) => expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8752
9516
|
span.expression,
|
|
@@ -8758,7 +9522,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8758
9522
|
)
|
|
8759
9523
|
);
|
|
8760
9524
|
}
|
|
8761
|
-
if (
|
|
9525
|
+
if (ts6.isTaggedTemplateExpression(expression)) {
|
|
8762
9526
|
return expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
8763
9527
|
expression.template,
|
|
8764
9528
|
sourceFile,
|
|
@@ -8768,7 +9532,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8768
9532
|
seenFunctions
|
|
8769
9533
|
);
|
|
8770
9534
|
}
|
|
8771
|
-
if (
|
|
9535
|
+
if (ts6.isNewExpression(expression) && expression.arguments && expression.arguments.length > 0 && expressionLooksLikeBrowserGlobalBooleanHelper(
|
|
8772
9536
|
expression.expression,
|
|
8773
9537
|
sourceFile,
|
|
8774
9538
|
namedExpressions,
|
|
@@ -8784,7 +9548,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8784
9548
|
)) {
|
|
8785
9549
|
return true;
|
|
8786
9550
|
}
|
|
8787
|
-
if (
|
|
9551
|
+
if (ts6.isNewExpression(expression) && expression.arguments && expression.arguments.length > 0 && expressionLooksLikeBrowserGlobalNumberHelper(
|
|
8788
9552
|
expression.expression,
|
|
8789
9553
|
sourceFile,
|
|
8790
9554
|
namedExpressions,
|
|
@@ -8800,7 +9564,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8800
9564
|
)) {
|
|
8801
9565
|
return true;
|
|
8802
9566
|
}
|
|
8803
|
-
if (
|
|
9567
|
+
if (ts6.isNewExpression(expression) && expression.arguments && expression.arguments.length > 0 && expressionLooksLikeBrowserGlobalObjectHelper(
|
|
8804
9568
|
expression.expression,
|
|
8805
9569
|
sourceFile,
|
|
8806
9570
|
namedExpressions,
|
|
@@ -8816,7 +9580,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8816
9580
|
)) {
|
|
8817
9581
|
return true;
|
|
8818
9582
|
}
|
|
8819
|
-
if (
|
|
9583
|
+
if (ts6.isNewExpression(expression) && expression.arguments && expression.arguments.length > 0 && expressionLooksLikeBrowserGlobalStringHelper(
|
|
8820
9584
|
expression.expression,
|
|
8821
9585
|
sourceFile,
|
|
8822
9586
|
namedExpressions,
|
|
@@ -8848,7 +9612,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8848
9612
|
)) {
|
|
8849
9613
|
return true;
|
|
8850
9614
|
}
|
|
8851
|
-
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(
|
|
8852
9616
|
expression.arguments[0],
|
|
8853
9617
|
sourceFile,
|
|
8854
9618
|
namedExpressions,
|
|
@@ -8912,7 +9676,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8912
9676
|
)) {
|
|
8913
9677
|
return true;
|
|
8914
9678
|
}
|
|
8915
|
-
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(
|
|
8916
9680
|
expression.arguments[0],
|
|
8917
9681
|
sourceFile,
|
|
8918
9682
|
namedExpressions,
|
|
@@ -8976,7 +9740,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
8976
9740
|
)) {
|
|
8977
9741
|
return true;
|
|
8978
9742
|
}
|
|
8979
|
-
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(
|
|
8980
9744
|
expression.arguments[0],
|
|
8981
9745
|
sourceFile,
|
|
8982
9746
|
namedExpressions,
|
|
@@ -9040,7 +9804,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9040
9804
|
)) {
|
|
9041
9805
|
return true;
|
|
9042
9806
|
}
|
|
9043
|
-
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(
|
|
9044
9808
|
expression.arguments[0],
|
|
9045
9809
|
sourceFile,
|
|
9046
9810
|
namedExpressions,
|
|
@@ -9104,7 +9868,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9104
9868
|
)) {
|
|
9105
9869
|
return true;
|
|
9106
9870
|
}
|
|
9107
|
-
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(
|
|
9108
9872
|
expression.arguments[0],
|
|
9109
9873
|
sourceFile,
|
|
9110
9874
|
namedExpressions,
|
|
@@ -9152,7 +9916,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9152
9916
|
)) {
|
|
9153
9917
|
return true;
|
|
9154
9918
|
}
|
|
9155
|
-
if (isCallLikeExpression(expression) &&
|
|
9919
|
+
if (isCallLikeExpression(expression) && ts6.isIdentifier(expression.expression) && [
|
|
9156
9920
|
"String",
|
|
9157
9921
|
"atob",
|
|
9158
9922
|
"btoa",
|
|
@@ -9188,7 +9952,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9188
9952
|
)) {
|
|
9189
9953
|
return true;
|
|
9190
9954
|
}
|
|
9191
|
-
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(
|
|
9192
9956
|
expression.arguments[0],
|
|
9193
9957
|
sourceFile,
|
|
9194
9958
|
namedExpressions,
|
|
@@ -9252,7 +10016,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9252
10016
|
)) {
|
|
9253
10017
|
return true;
|
|
9254
10018
|
}
|
|
9255
|
-
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(
|
|
9256
10020
|
expression.arguments[0],
|
|
9257
10021
|
sourceFile,
|
|
9258
10022
|
namedExpressions,
|
|
@@ -9316,7 +10080,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9316
10080
|
)) {
|
|
9317
10081
|
return true;
|
|
9318
10082
|
}
|
|
9319
|
-
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(
|
|
9320
10084
|
expression.arguments[0],
|
|
9321
10085
|
sourceFile,
|
|
9322
10086
|
namedExpressions,
|
|
@@ -9380,7 +10144,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9380
10144
|
)) {
|
|
9381
10145
|
return true;
|
|
9382
10146
|
}
|
|
9383
|
-
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(
|
|
9384
10148
|
expression.arguments[0],
|
|
9385
10149
|
sourceFile,
|
|
9386
10150
|
namedExpressions,
|
|
@@ -9460,7 +10224,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9460
10224
|
)) {
|
|
9461
10225
|
return true;
|
|
9462
10226
|
}
|
|
9463
|
-
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(
|
|
9464
10228
|
expression.arguments[0],
|
|
9465
10229
|
sourceFile,
|
|
9466
10230
|
namedExpressions,
|
|
@@ -9508,7 +10272,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9508
10272
|
)) {
|
|
9509
10273
|
return true;
|
|
9510
10274
|
}
|
|
9511
|
-
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(
|
|
9512
10276
|
expression.arguments[0],
|
|
9513
10277
|
sourceFile,
|
|
9514
10278
|
namedExpressions,
|
|
@@ -9556,7 +10320,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9556
10320
|
)) {
|
|
9557
10321
|
return true;
|
|
9558
10322
|
}
|
|
9559
|
-
if (isCallLikeExpression(expression) && (
|
|
10323
|
+
if (isCallLikeExpression(expression) && (ts6.isIdentifier(expression.expression) || isMemberAccessExpression(expression.expression)) && expression.arguments.length > 0 && expressionLooksLikeBufferFromHelper(
|
|
9560
10324
|
expression.expression,
|
|
9561
10325
|
sourceFile,
|
|
9562
10326
|
namedExpressions,
|
|
@@ -9608,7 +10372,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9608
10372
|
)) {
|
|
9609
10373
|
return true;
|
|
9610
10374
|
}
|
|
9611
|
-
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(
|
|
9612
10376
|
expression.arguments[0],
|
|
9613
10377
|
sourceFile,
|
|
9614
10378
|
namedExpressions,
|
|
@@ -9656,7 +10420,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9656
10420
|
)) {
|
|
9657
10421
|
return true;
|
|
9658
10422
|
}
|
|
9659
|
-
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(
|
|
9660
10424
|
expression.arguments[0],
|
|
9661
10425
|
sourceFile,
|
|
9662
10426
|
namedExpressions,
|
|
@@ -9835,7 +10599,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9835
10599
|
)) {
|
|
9836
10600
|
return true;
|
|
9837
10601
|
}
|
|
9838
|
-
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(
|
|
9839
10603
|
expression.expression.expression.expression.expression.expression,
|
|
9840
10604
|
"entries"
|
|
9841
10605
|
) && expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
@@ -9868,7 +10632,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9868
10632
|
)) {
|
|
9869
10633
|
return true;
|
|
9870
10634
|
}
|
|
9871
|
-
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(
|
|
9872
10636
|
expression.arguments[0],
|
|
9873
10637
|
sourceFile,
|
|
9874
10638
|
namedExpressions,
|
|
@@ -9878,8 +10642,8 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9878
10642
|
)) {
|
|
9879
10643
|
return true;
|
|
9880
10644
|
}
|
|
9881
|
-
if (
|
|
9882
|
-
(element) =>
|
|
10645
|
+
if (ts6.isArrayLiteralExpression(expression) && expression.elements.some(
|
|
10646
|
+
(element) => ts6.isSpreadElement(element) && expressionLooksLikeOpenRedirectQueryGetterFunction(
|
|
9883
10647
|
element.expression,
|
|
9884
10648
|
sourceFile,
|
|
9885
10649
|
namedExpressions,
|
|
@@ -9930,7 +10694,7 @@ function expressionLooksLikeOpenRedirectQueryGetterFunction(expression, sourceFi
|
|
|
9930
10694
|
)) {
|
|
9931
10695
|
return true;
|
|
9932
10696
|
}
|
|
9933
|
-
if (
|
|
10697
|
+
if (ts6.isIdentifier(expression)) {
|
|
9934
10698
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
9935
10699
|
const initializer = namedExpressions.get(expression.text);
|
|
9936
10700
|
if (initializer) {
|
|
@@ -9964,7 +10728,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9964
10728
|
if (OPEN_REDIRECT_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
9965
10729
|
return true;
|
|
9966
10730
|
}
|
|
9967
|
-
if (
|
|
10731
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
9968
10732
|
return expressionContainsOpenRedirectSource(
|
|
9969
10733
|
expression.expression,
|
|
9970
10734
|
sourceFile,
|
|
@@ -9974,7 +10738,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9974
10738
|
seenFunctions
|
|
9975
10739
|
);
|
|
9976
10740
|
}
|
|
9977
|
-
if (
|
|
10741
|
+
if (ts6.isBinaryExpression(expression)) {
|
|
9978
10742
|
return expressionContainsOpenRedirectSource(
|
|
9979
10743
|
expression.left,
|
|
9980
10744
|
sourceFile,
|
|
@@ -9991,7 +10755,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
9991
10755
|
seenFunctions
|
|
9992
10756
|
);
|
|
9993
10757
|
}
|
|
9994
|
-
if (
|
|
10758
|
+
if (ts6.isConditionalExpression(expression)) {
|
|
9995
10759
|
return expressionContainsOpenRedirectSource(
|
|
9996
10760
|
expression.condition,
|
|
9997
10761
|
sourceFile,
|
|
@@ -10015,7 +10779,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10015
10779
|
seenFunctions
|
|
10016
10780
|
);
|
|
10017
10781
|
}
|
|
10018
|
-
if (
|
|
10782
|
+
if (ts6.isTemplateExpression(expression)) {
|
|
10019
10783
|
return expression.templateSpans.some(
|
|
10020
10784
|
(span) => expressionContainsOpenRedirectSource(
|
|
10021
10785
|
span.expression,
|
|
@@ -10027,7 +10791,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10027
10791
|
)
|
|
10028
10792
|
);
|
|
10029
10793
|
}
|
|
10030
|
-
if (
|
|
10794
|
+
if (ts6.isTaggedTemplateExpression(expression)) {
|
|
10031
10795
|
return expressionContainsOpenRedirectSource(
|
|
10032
10796
|
expression.template,
|
|
10033
10797
|
sourceFile,
|
|
@@ -10037,7 +10801,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10037
10801
|
seenFunctions
|
|
10038
10802
|
);
|
|
10039
10803
|
}
|
|
10040
|
-
if (
|
|
10804
|
+
if (ts6.isNewExpression(expression)) {
|
|
10041
10805
|
return (expression.arguments ?? []).some(
|
|
10042
10806
|
(argument) => expressionContainsOpenRedirectSource(
|
|
10043
10807
|
argument,
|
|
@@ -10049,9 +10813,9 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10049
10813
|
)
|
|
10050
10814
|
);
|
|
10051
10815
|
}
|
|
10052
|
-
if (
|
|
10816
|
+
if (ts6.isArrayLiteralExpression(expression)) {
|
|
10053
10817
|
return expression.elements.some((element) => {
|
|
10054
|
-
if (
|
|
10818
|
+
if (ts6.isSpreadElement(element)) {
|
|
10055
10819
|
return expressionContainsOpenRedirectSource(
|
|
10056
10820
|
element.expression,
|
|
10057
10821
|
sourceFile,
|
|
@@ -10061,7 +10825,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10061
10825
|
seenFunctions
|
|
10062
10826
|
);
|
|
10063
10827
|
}
|
|
10064
|
-
return
|
|
10828
|
+
return ts6.isExpression(element) && expressionContainsOpenRedirectSource(
|
|
10065
10829
|
element,
|
|
10066
10830
|
sourceFile,
|
|
10067
10831
|
namedExpressions,
|
|
@@ -10071,9 +10835,9 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10071
10835
|
);
|
|
10072
10836
|
});
|
|
10073
10837
|
}
|
|
10074
|
-
if (
|
|
10838
|
+
if (ts6.isObjectLiteralExpression(expression)) {
|
|
10075
10839
|
return expression.properties.some((property) => {
|
|
10076
|
-
if (
|
|
10840
|
+
if (ts6.isPropertyAssignment(property)) {
|
|
10077
10841
|
return expressionContainsOpenRedirectSource(
|
|
10078
10842
|
property.initializer,
|
|
10079
10843
|
sourceFile,
|
|
@@ -10083,7 +10847,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10083
10847
|
seenFunctions
|
|
10084
10848
|
);
|
|
10085
10849
|
}
|
|
10086
|
-
if (
|
|
10850
|
+
if (ts6.isShorthandPropertyAssignment(property)) {
|
|
10087
10851
|
return expressionContainsOpenRedirectSource(
|
|
10088
10852
|
property.name,
|
|
10089
10853
|
sourceFile,
|
|
@@ -10093,7 +10857,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10093
10857
|
seenFunctions
|
|
10094
10858
|
);
|
|
10095
10859
|
}
|
|
10096
|
-
if (
|
|
10860
|
+
if (ts6.isSpreadAssignment(property)) {
|
|
10097
10861
|
return expressionContainsOpenRedirectSource(
|
|
10098
10862
|
property.expression,
|
|
10099
10863
|
sourceFile,
|
|
@@ -10148,7 +10912,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10148
10912
|
}
|
|
10149
10913
|
}
|
|
10150
10914
|
}
|
|
10151
|
-
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(
|
|
10152
10916
|
getAliasedApplyArgumentExpression(expression.arguments[2], 0, namedExpressions, /* @__PURE__ */ new Set()),
|
|
10153
10917
|
namedExpressions,
|
|
10154
10918
|
seenIdentifiers
|
|
@@ -10264,7 +11028,7 @@ function expressionContainsOpenRedirectSource(expression, sourceFile, namedExpre
|
|
|
10264
11028
|
)) {
|
|
10265
11029
|
return true;
|
|
10266
11030
|
}
|
|
10267
|
-
if (
|
|
11031
|
+
if (ts6.isIdentifier(expression)) {
|
|
10268
11032
|
if (seenIdentifiers.has(expression.text)) {
|
|
10269
11033
|
return false;
|
|
10270
11034
|
}
|
|
@@ -10302,14 +11066,14 @@ function isOpenRedirectQueryKeyExpression(expression, namedExpressions = /* @__P
|
|
|
10302
11066
|
return true;
|
|
10303
11067
|
}
|
|
10304
11068
|
if (!expression) return false;
|
|
10305
|
-
if (
|
|
11069
|
+
if (ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression) || ts6.isParenthesizedExpression(expression)) {
|
|
10306
11070
|
return isOpenRedirectQueryKeyExpression(
|
|
10307
11071
|
expression.expression,
|
|
10308
11072
|
namedExpressions,
|
|
10309
11073
|
seenIdentifiers
|
|
10310
11074
|
);
|
|
10311
11075
|
}
|
|
10312
|
-
if (
|
|
11076
|
+
if (ts6.isIdentifier(expression)) {
|
|
10313
11077
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10314
11078
|
const initializer = namedExpressions.get(expression.text);
|
|
10315
11079
|
if (!initializer) return false;
|
|
@@ -10325,7 +11089,7 @@ function expressionLooksLikeOpenRedirectQueryCarrier(expression, sourceFile, nam
|
|
|
10325
11089
|
if (OPEN_REDIRECT_QUERY_CARRIER_REGEX.test(expression.getText(sourceFile))) {
|
|
10326
11090
|
return true;
|
|
10327
11091
|
}
|
|
10328
|
-
if (
|
|
11092
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10329
11093
|
return expressionLooksLikeOpenRedirectQueryCarrier(
|
|
10330
11094
|
expression.expression,
|
|
10331
11095
|
sourceFile,
|
|
@@ -10334,7 +11098,7 @@ function expressionLooksLikeOpenRedirectQueryCarrier(expression, sourceFile, nam
|
|
|
10334
11098
|
seenIdentifiers
|
|
10335
11099
|
);
|
|
10336
11100
|
}
|
|
10337
|
-
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) {
|
|
10338
11102
|
const entriesExpression = expression.arguments[0];
|
|
10339
11103
|
if (expressionLooksLikeOpenRedirectSearchParamsCarrier(
|
|
10340
11104
|
entriesExpression,
|
|
@@ -10364,7 +11128,7 @@ function expressionLooksLikeOpenRedirectQueryCarrier(expression, sourceFile, nam
|
|
|
10364
11128
|
seenIdentifiers
|
|
10365
11129
|
);
|
|
10366
11130
|
}
|
|
10367
|
-
if (
|
|
11131
|
+
if (ts6.isIdentifier(expression)) {
|
|
10368
11132
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10369
11133
|
const initializer = namedExpressions.get(expression.text);
|
|
10370
11134
|
if (initializer) {
|
|
@@ -10397,7 +11161,7 @@ function expressionLooksLikeOpenRedirectQueryCarrier(expression, sourceFile, nam
|
|
|
10397
11161
|
}
|
|
10398
11162
|
function expressionLooksLikeOpenRedirectEntriesCarrier(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10399
11163
|
if (!expression) return false;
|
|
10400
|
-
if (
|
|
11164
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10401
11165
|
return expressionLooksLikeOpenRedirectEntriesCarrier(
|
|
10402
11166
|
expression.expression,
|
|
10403
11167
|
sourceFile,
|
|
@@ -10406,7 +11170,7 @@ function expressionLooksLikeOpenRedirectEntriesCarrier(expression, sourceFile, n
|
|
|
10406
11170
|
seenIdentifiers
|
|
10407
11171
|
);
|
|
10408
11172
|
}
|
|
10409
|
-
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(
|
|
10410
11174
|
expression.arguments[0],
|
|
10411
11175
|
sourceFile,
|
|
10412
11176
|
namedExpressions,
|
|
@@ -10421,8 +11185,8 @@ function expressionLooksLikeOpenRedirectEntriesCarrier(expression, sourceFile, n
|
|
|
10421
11185
|
))) {
|
|
10422
11186
|
return true;
|
|
10423
11187
|
}
|
|
10424
|
-
if (
|
|
10425
|
-
(element) =>
|
|
11188
|
+
if (ts6.isArrayLiteralExpression(expression) && expression.elements.some(
|
|
11189
|
+
(element) => ts6.isSpreadElement(element) && (expressionLooksLikeOpenRedirectEntriesCarrier(
|
|
10426
11190
|
element.expression,
|
|
10427
11191
|
sourceFile,
|
|
10428
11192
|
namedExpressions,
|
|
@@ -10447,7 +11211,7 @@ function expressionLooksLikeOpenRedirectEntriesCarrier(expression, sourceFile, n
|
|
|
10447
11211
|
)) {
|
|
10448
11212
|
return true;
|
|
10449
11213
|
}
|
|
10450
|
-
if (
|
|
11214
|
+
if (ts6.isIdentifier(expression)) {
|
|
10451
11215
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10452
11216
|
const initializer = namedExpressions.get(expression.text);
|
|
10453
11217
|
if (!initializer) return false;
|
|
@@ -10469,7 +11233,7 @@ function expressionLooksLikeOpenRedirectQueryContainerBase(expression, sourceFil
|
|
|
10469
11233
|
if (OPEN_REDIRECT_QUERY_CONTAINER_BASE_REGEX.test(expression.getText(sourceFile))) {
|
|
10470
11234
|
return true;
|
|
10471
11235
|
}
|
|
10472
|
-
if (
|
|
11236
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10473
11237
|
return expressionLooksLikeOpenRedirectQueryContainerBase(
|
|
10474
11238
|
expression.expression,
|
|
10475
11239
|
sourceFile,
|
|
@@ -10478,10 +11242,10 @@ function expressionLooksLikeOpenRedirectQueryContainerBase(expression, sourceFil
|
|
|
10478
11242
|
seenIdentifiers
|
|
10479
11243
|
);
|
|
10480
11244
|
}
|
|
10481
|
-
if (isCallLikeExpression(expression) && (
|
|
11245
|
+
if (isCallLikeExpression(expression) && (ts6.isIdentifier(expression.expression) && expression.expression.text === "useRouter" || isMemberAccessExpression(expression.expression) && isMemberAccessNamed(expression.expression, "useRouter"))) {
|
|
10482
11246
|
return true;
|
|
10483
11247
|
}
|
|
10484
|
-
if (
|
|
11248
|
+
if (ts6.isIdentifier(expression)) {
|
|
10485
11249
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10486
11250
|
const initializer = namedExpressions.get(expression.text);
|
|
10487
11251
|
if (initializer) {
|
|
@@ -10519,7 +11283,7 @@ function expressionLooksLikeLocationQuerySource(expression, sourceFile, namedExp
|
|
|
10519
11283
|
if (LOCATION_QUERY_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
10520
11284
|
return true;
|
|
10521
11285
|
}
|
|
10522
|
-
if (
|
|
11286
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10523
11287
|
return expressionLooksLikeLocationQuerySource(
|
|
10524
11288
|
expression.expression,
|
|
10525
11289
|
sourceFile,
|
|
@@ -10552,7 +11316,7 @@ function expressionLooksLikeLocationQuerySource(expression, sourceFile, namedExp
|
|
|
10552
11316
|
))) {
|
|
10553
11317
|
return true;
|
|
10554
11318
|
}
|
|
10555
|
-
if (
|
|
11319
|
+
if (ts6.isIdentifier(expression)) {
|
|
10556
11320
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10557
11321
|
const initializer = namedExpressions.get(expression.text);
|
|
10558
11322
|
if (initializer) {
|
|
@@ -10588,10 +11352,10 @@ function expressionLooksLikeLocationQuerySource(expression, sourceFile, namedExp
|
|
|
10588
11352
|
}
|
|
10589
11353
|
function expressionLooksLikeWindowObjectSource(expression, sourceFile, namedExpressions, seenIdentifiers) {
|
|
10590
11354
|
if (!expression) return false;
|
|
10591
|
-
if (
|
|
11355
|
+
if (ts6.isIdentifier(expression) && ["window", "globalThis", "document", "self", "parent", "top"].includes(expression.text)) {
|
|
10592
11356
|
return true;
|
|
10593
11357
|
}
|
|
10594
|
-
if (
|
|
11358
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10595
11359
|
return expressionLooksLikeWindowObjectSource(
|
|
10596
11360
|
expression.expression,
|
|
10597
11361
|
sourceFile,
|
|
@@ -10599,7 +11363,7 @@ function expressionLooksLikeWindowObjectSource(expression, sourceFile, namedExpr
|
|
|
10599
11363
|
seenIdentifiers
|
|
10600
11364
|
);
|
|
10601
11365
|
}
|
|
10602
|
-
if (
|
|
11366
|
+
if (ts6.isIdentifier(expression)) {
|
|
10603
11367
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10604
11368
|
const initializer = namedExpressions.get(expression.text);
|
|
10605
11369
|
if (!initializer) return false;
|
|
@@ -10620,7 +11384,7 @@ function expressionLooksLikeLocationObjectSource(expression, sourceFile, namedEx
|
|
|
10620
11384
|
if (isLocationObjectExpression(expression)) {
|
|
10621
11385
|
return true;
|
|
10622
11386
|
}
|
|
10623
|
-
if (
|
|
11387
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10624
11388
|
return expressionLooksLikeLocationObjectSource(
|
|
10625
11389
|
expression.expression,
|
|
10626
11390
|
sourceFile,
|
|
@@ -10629,7 +11393,7 @@ function expressionLooksLikeLocationObjectSource(expression, sourceFile, namedEx
|
|
|
10629
11393
|
seenIdentifiers
|
|
10630
11394
|
);
|
|
10631
11395
|
}
|
|
10632
|
-
if (isCallLikeExpression(expression) && (
|
|
11396
|
+
if (isCallLikeExpression(expression) && (ts6.isIdentifier(expression.expression) && expression.expression.text === "useLocation" || isMemberAccessExpression(expression.expression) && isMemberAccessNamed(expression.expression, "useLocation"))) {
|
|
10633
11397
|
return true;
|
|
10634
11398
|
}
|
|
10635
11399
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "location") && expressionLooksLikeWindowObjectSource(
|
|
@@ -10640,7 +11404,7 @@ function expressionLooksLikeLocationObjectSource(expression, sourceFile, namedEx
|
|
|
10640
11404
|
)) {
|
|
10641
11405
|
return true;
|
|
10642
11406
|
}
|
|
10643
|
-
if (
|
|
11407
|
+
if (ts6.isIdentifier(expression)) {
|
|
10644
11408
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10645
11409
|
const initializer = namedExpressions.get(expression.text);
|
|
10646
11410
|
if (initializer) {
|
|
@@ -10669,10 +11433,10 @@ function expressionLooksLikeLocationObjectSource(expression, sourceFile, namedEx
|
|
|
10669
11433
|
}
|
|
10670
11434
|
function expressionLooksLikeHistoryObjectSource(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10671
11435
|
if (!expression) return false;
|
|
10672
|
-
if (
|
|
11436
|
+
if (ts6.isIdentifier(expression) && expression.text === "history") {
|
|
10673
11437
|
return true;
|
|
10674
11438
|
}
|
|
10675
|
-
if (
|
|
11439
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10676
11440
|
return expressionLooksLikeHistoryObjectSource(
|
|
10677
11441
|
expression.expression,
|
|
10678
11442
|
sourceFile,
|
|
@@ -10689,7 +11453,7 @@ function expressionLooksLikeHistoryObjectSource(expression, sourceFile, namedExp
|
|
|
10689
11453
|
)) {
|
|
10690
11454
|
return true;
|
|
10691
11455
|
}
|
|
10692
|
-
if (
|
|
11456
|
+
if (ts6.isIdentifier(expression)) {
|
|
10693
11457
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10694
11458
|
const initializer = namedExpressions.get(expression.text);
|
|
10695
11459
|
if (initializer) {
|
|
@@ -10718,10 +11482,10 @@ function expressionLooksLikeHistoryObjectSource(expression, sourceFile, namedExp
|
|
|
10718
11482
|
}
|
|
10719
11483
|
function expressionLooksLikeBufferObjectSource(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10720
11484
|
if (!expression) return false;
|
|
10721
|
-
if (
|
|
11485
|
+
if (ts6.isIdentifier(expression) && expression.text === "Buffer") {
|
|
10722
11486
|
return true;
|
|
10723
11487
|
}
|
|
10724
|
-
if (
|
|
11488
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10725
11489
|
return expressionLooksLikeBufferObjectSource(
|
|
10726
11490
|
expression.expression,
|
|
10727
11491
|
sourceFile,
|
|
@@ -10738,7 +11502,7 @@ function expressionLooksLikeBufferObjectSource(expression, sourceFile, namedExpr
|
|
|
10738
11502
|
)) {
|
|
10739
11503
|
return true;
|
|
10740
11504
|
}
|
|
10741
|
-
if (
|
|
11505
|
+
if (ts6.isIdentifier(expression)) {
|
|
10742
11506
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10743
11507
|
const initializer = namedExpressions.get(expression.text);
|
|
10744
11508
|
if (initializer) {
|
|
@@ -10785,7 +11549,7 @@ function expressionLooksLikeBufferFromHelper(expression, sourceFile, namedExpres
|
|
|
10785
11549
|
)) {
|
|
10786
11550
|
return true;
|
|
10787
11551
|
}
|
|
10788
|
-
if (
|
|
11552
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10789
11553
|
return expressionLooksLikeBufferFromHelper(
|
|
10790
11554
|
expression.expression,
|
|
10791
11555
|
sourceFile,
|
|
@@ -10794,7 +11558,7 @@ function expressionLooksLikeBufferFromHelper(expression, sourceFile, namedExpres
|
|
|
10794
11558
|
seenIdentifiers
|
|
10795
11559
|
);
|
|
10796
11560
|
}
|
|
10797
|
-
if (
|
|
11561
|
+
if (ts6.isIdentifier(expression)) {
|
|
10798
11562
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10799
11563
|
const initializer = namedExpressions.get(expression.text);
|
|
10800
11564
|
if (initializer) {
|
|
@@ -10824,10 +11588,10 @@ function expressionLooksLikeBufferFromHelper(expression, sourceFile, namedExpres
|
|
|
10824
11588
|
}
|
|
10825
11589
|
function expressionLooksLikeJsonObjectSource(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10826
11590
|
if (!expression) return false;
|
|
10827
|
-
if (
|
|
11591
|
+
if (ts6.isIdentifier(expression) && expression.text === "JSON") {
|
|
10828
11592
|
return true;
|
|
10829
11593
|
}
|
|
10830
|
-
if (
|
|
11594
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10831
11595
|
return expressionLooksLikeJsonObjectSource(
|
|
10832
11596
|
expression.expression,
|
|
10833
11597
|
sourceFile,
|
|
@@ -10844,7 +11608,7 @@ function expressionLooksLikeJsonObjectSource(expression, sourceFile, namedExpres
|
|
|
10844
11608
|
)) {
|
|
10845
11609
|
return true;
|
|
10846
11610
|
}
|
|
10847
|
-
if (
|
|
11611
|
+
if (ts6.isIdentifier(expression)) {
|
|
10848
11612
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10849
11613
|
const initializer = namedExpressions.get(expression.text);
|
|
10850
11614
|
if (initializer) {
|
|
@@ -10891,7 +11655,7 @@ function expressionLooksLikeJsonStringifyHelper(expression, sourceFile, namedExp
|
|
|
10891
11655
|
)) {
|
|
10892
11656
|
return true;
|
|
10893
11657
|
}
|
|
10894
|
-
if (
|
|
11658
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10895
11659
|
return expressionLooksLikeJsonStringifyHelper(
|
|
10896
11660
|
expression.expression,
|
|
10897
11661
|
sourceFile,
|
|
@@ -10900,7 +11664,7 @@ function expressionLooksLikeJsonStringifyHelper(expression, sourceFile, namedExp
|
|
|
10900
11664
|
seenIdentifiers
|
|
10901
11665
|
);
|
|
10902
11666
|
}
|
|
10903
|
-
if (
|
|
11667
|
+
if (ts6.isIdentifier(expression)) {
|
|
10904
11668
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10905
11669
|
const initializer = namedExpressions.get(expression.text);
|
|
10906
11670
|
if (initializer) {
|
|
@@ -10948,7 +11712,7 @@ function expressionLooksLikeJsonParseHelper(expression, sourceFile, namedExpress
|
|
|
10948
11712
|
)) {
|
|
10949
11713
|
return true;
|
|
10950
11714
|
}
|
|
10951
|
-
if (
|
|
11715
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
10952
11716
|
return expressionLooksLikeJsonParseHelper(
|
|
10953
11717
|
expression.expression,
|
|
10954
11718
|
sourceFile,
|
|
@@ -10957,7 +11721,7 @@ function expressionLooksLikeJsonParseHelper(expression, sourceFile, namedExpress
|
|
|
10957
11721
|
seenIdentifiers
|
|
10958
11722
|
);
|
|
10959
11723
|
}
|
|
10960
|
-
if (
|
|
11724
|
+
if (ts6.isIdentifier(expression)) {
|
|
10961
11725
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
10962
11726
|
const initializer = namedExpressions.get(expression.text);
|
|
10963
11727
|
if (initializer) {
|
|
@@ -10987,7 +11751,7 @@ function expressionLooksLikeJsonParseHelper(expression, sourceFile, namedExpress
|
|
|
10987
11751
|
}
|
|
10988
11752
|
function expressionLooksLikeStructuredCloneHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
10989
11753
|
if (!expression) return false;
|
|
10990
|
-
if (
|
|
11754
|
+
if (ts6.isIdentifier(expression) && expression.text === "structuredClone") {
|
|
10991
11755
|
return true;
|
|
10992
11756
|
}
|
|
10993
11757
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "structuredClone") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11007,7 +11771,7 @@ function expressionLooksLikeStructuredCloneHelper(expression, sourceFile, namedE
|
|
|
11007
11771
|
)) {
|
|
11008
11772
|
return true;
|
|
11009
11773
|
}
|
|
11010
|
-
if (
|
|
11774
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11011
11775
|
return expressionLooksLikeStructuredCloneHelper(
|
|
11012
11776
|
expression.expression,
|
|
11013
11777
|
sourceFile,
|
|
@@ -11016,7 +11780,7 @@ function expressionLooksLikeStructuredCloneHelper(expression, sourceFile, namedE
|
|
|
11016
11780
|
seenIdentifiers
|
|
11017
11781
|
);
|
|
11018
11782
|
}
|
|
11019
|
-
if (
|
|
11783
|
+
if (ts6.isIdentifier(expression)) {
|
|
11020
11784
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11021
11785
|
const initializer = namedExpressions.get(expression.text);
|
|
11022
11786
|
if (initializer) {
|
|
@@ -11045,7 +11809,7 @@ function expressionLooksLikeStructuredCloneHelper(expression, sourceFile, namedE
|
|
|
11045
11809
|
}
|
|
11046
11810
|
function expressionLooksLikeBrowserGlobalSymbolHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11047
11811
|
if (!expression) return false;
|
|
11048
|
-
if (
|
|
11812
|
+
if (ts6.isIdentifier(expression) && expression.text === "Symbol") {
|
|
11049
11813
|
return true;
|
|
11050
11814
|
}
|
|
11051
11815
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "Symbol") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11065,7 +11829,7 @@ function expressionLooksLikeBrowserGlobalSymbolHelper(expression, sourceFile, na
|
|
|
11065
11829
|
)) {
|
|
11066
11830
|
return true;
|
|
11067
11831
|
}
|
|
11068
|
-
if (
|
|
11832
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11069
11833
|
return expressionLooksLikeBrowserGlobalSymbolHelper(
|
|
11070
11834
|
expression.expression,
|
|
11071
11835
|
sourceFile,
|
|
@@ -11074,7 +11838,7 @@ function expressionLooksLikeBrowserGlobalSymbolHelper(expression, sourceFile, na
|
|
|
11074
11838
|
seenIdentifiers
|
|
11075
11839
|
);
|
|
11076
11840
|
}
|
|
11077
|
-
if (
|
|
11841
|
+
if (ts6.isIdentifier(expression)) {
|
|
11078
11842
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11079
11843
|
const initializer = namedExpressions.get(expression.text);
|
|
11080
11844
|
if (initializer) {
|
|
@@ -11103,7 +11867,7 @@ function expressionLooksLikeBrowserGlobalSymbolHelper(expression, sourceFile, na
|
|
|
11103
11867
|
}
|
|
11104
11868
|
function expressionLooksLikeBrowserGlobalBigIntHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11105
11869
|
if (!expression) return false;
|
|
11106
|
-
if (
|
|
11870
|
+
if (ts6.isIdentifier(expression) && expression.text === "BigInt") {
|
|
11107
11871
|
return true;
|
|
11108
11872
|
}
|
|
11109
11873
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "BigInt") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11123,7 +11887,7 @@ function expressionLooksLikeBrowserGlobalBigIntHelper(expression, sourceFile, na
|
|
|
11123
11887
|
)) {
|
|
11124
11888
|
return true;
|
|
11125
11889
|
}
|
|
11126
|
-
if (
|
|
11890
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11127
11891
|
return expressionLooksLikeBrowserGlobalBigIntHelper(
|
|
11128
11892
|
expression.expression,
|
|
11129
11893
|
sourceFile,
|
|
@@ -11132,7 +11896,7 @@ function expressionLooksLikeBrowserGlobalBigIntHelper(expression, sourceFile, na
|
|
|
11132
11896
|
seenIdentifiers
|
|
11133
11897
|
);
|
|
11134
11898
|
}
|
|
11135
|
-
if (
|
|
11899
|
+
if (ts6.isIdentifier(expression)) {
|
|
11136
11900
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11137
11901
|
const initializer = namedExpressions.get(expression.text);
|
|
11138
11902
|
if (initializer) {
|
|
@@ -11161,7 +11925,7 @@ function expressionLooksLikeBrowserGlobalBigIntHelper(expression, sourceFile, na
|
|
|
11161
11925
|
}
|
|
11162
11926
|
function expressionLooksLikeBrowserGlobalBooleanHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11163
11927
|
if (!expression) return false;
|
|
11164
|
-
if (
|
|
11928
|
+
if (ts6.isIdentifier(expression) && expression.text === "Boolean") {
|
|
11165
11929
|
return true;
|
|
11166
11930
|
}
|
|
11167
11931
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "Boolean") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11181,7 +11945,7 @@ function expressionLooksLikeBrowserGlobalBooleanHelper(expression, sourceFile, n
|
|
|
11181
11945
|
)) {
|
|
11182
11946
|
return true;
|
|
11183
11947
|
}
|
|
11184
|
-
if (
|
|
11948
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11185
11949
|
return expressionLooksLikeBrowserGlobalBooleanHelper(
|
|
11186
11950
|
expression.expression,
|
|
11187
11951
|
sourceFile,
|
|
@@ -11190,7 +11954,7 @@ function expressionLooksLikeBrowserGlobalBooleanHelper(expression, sourceFile, n
|
|
|
11190
11954
|
seenIdentifiers
|
|
11191
11955
|
);
|
|
11192
11956
|
}
|
|
11193
|
-
if (
|
|
11957
|
+
if (ts6.isIdentifier(expression)) {
|
|
11194
11958
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11195
11959
|
const initializer = namedExpressions.get(expression.text);
|
|
11196
11960
|
if (initializer) {
|
|
@@ -11219,7 +11983,7 @@ function expressionLooksLikeBrowserGlobalBooleanHelper(expression, sourceFile, n
|
|
|
11219
11983
|
}
|
|
11220
11984
|
function expressionLooksLikeBrowserGlobalNumberHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11221
11985
|
if (!expression) return false;
|
|
11222
|
-
if (
|
|
11986
|
+
if (ts6.isIdentifier(expression) && expression.text === "Number") {
|
|
11223
11987
|
return true;
|
|
11224
11988
|
}
|
|
11225
11989
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "Number") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11239,7 +12003,7 @@ function expressionLooksLikeBrowserGlobalNumberHelper(expression, sourceFile, na
|
|
|
11239
12003
|
)) {
|
|
11240
12004
|
return true;
|
|
11241
12005
|
}
|
|
11242
|
-
if (
|
|
12006
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11243
12007
|
return expressionLooksLikeBrowserGlobalNumberHelper(
|
|
11244
12008
|
expression.expression,
|
|
11245
12009
|
sourceFile,
|
|
@@ -11248,7 +12012,7 @@ function expressionLooksLikeBrowserGlobalNumberHelper(expression, sourceFile, na
|
|
|
11248
12012
|
seenIdentifiers
|
|
11249
12013
|
);
|
|
11250
12014
|
}
|
|
11251
|
-
if (
|
|
12015
|
+
if (ts6.isIdentifier(expression)) {
|
|
11252
12016
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11253
12017
|
const initializer = namedExpressions.get(expression.text);
|
|
11254
12018
|
if (initializer) {
|
|
@@ -11277,7 +12041,7 @@ function expressionLooksLikeBrowserGlobalNumberHelper(expression, sourceFile, na
|
|
|
11277
12041
|
}
|
|
11278
12042
|
function expressionLooksLikeBrowserGlobalObjectHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11279
12043
|
if (!expression) return false;
|
|
11280
|
-
if (
|
|
12044
|
+
if (ts6.isIdentifier(expression) && expression.text === "Object") {
|
|
11281
12045
|
return true;
|
|
11282
12046
|
}
|
|
11283
12047
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "Object") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11297,7 +12061,7 @@ function expressionLooksLikeBrowserGlobalObjectHelper(expression, sourceFile, na
|
|
|
11297
12061
|
)) {
|
|
11298
12062
|
return true;
|
|
11299
12063
|
}
|
|
11300
|
-
if (
|
|
12064
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11301
12065
|
return expressionLooksLikeBrowserGlobalObjectHelper(
|
|
11302
12066
|
expression.expression,
|
|
11303
12067
|
sourceFile,
|
|
@@ -11306,7 +12070,7 @@ function expressionLooksLikeBrowserGlobalObjectHelper(expression, sourceFile, na
|
|
|
11306
12070
|
seenIdentifiers
|
|
11307
12071
|
);
|
|
11308
12072
|
}
|
|
11309
|
-
if (
|
|
12073
|
+
if (ts6.isIdentifier(expression)) {
|
|
11310
12074
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11311
12075
|
const initializer = namedExpressions.get(expression.text);
|
|
11312
12076
|
if (initializer) {
|
|
@@ -11335,7 +12099,7 @@ function expressionLooksLikeBrowserGlobalObjectHelper(expression, sourceFile, na
|
|
|
11335
12099
|
}
|
|
11336
12100
|
function expressionLooksLikeBrowserGlobalStringHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11337
12101
|
if (!expression) return false;
|
|
11338
|
-
if (
|
|
12102
|
+
if (ts6.isIdentifier(expression) && expression.text === "String") {
|
|
11339
12103
|
return true;
|
|
11340
12104
|
}
|
|
11341
12105
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "String") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11355,7 +12119,7 @@ function expressionLooksLikeBrowserGlobalStringHelper(expression, sourceFile, na
|
|
|
11355
12119
|
)) {
|
|
11356
12120
|
return true;
|
|
11357
12121
|
}
|
|
11358
|
-
if (
|
|
12122
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11359
12123
|
return expressionLooksLikeBrowserGlobalStringHelper(
|
|
11360
12124
|
expression.expression,
|
|
11361
12125
|
sourceFile,
|
|
@@ -11364,7 +12128,7 @@ function expressionLooksLikeBrowserGlobalStringHelper(expression, sourceFile, na
|
|
|
11364
12128
|
seenIdentifiers
|
|
11365
12129
|
);
|
|
11366
12130
|
}
|
|
11367
|
-
if (
|
|
12131
|
+
if (ts6.isIdentifier(expression)) {
|
|
11368
12132
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11369
12133
|
const initializer = namedExpressions.get(expression.text);
|
|
11370
12134
|
if (initializer) {
|
|
@@ -11393,7 +12157,7 @@ function expressionLooksLikeBrowserGlobalStringHelper(expression, sourceFile, na
|
|
|
11393
12157
|
}
|
|
11394
12158
|
function expressionLooksLikeBrowserGlobalBase64Helper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11395
12159
|
if (!expression) return false;
|
|
11396
|
-
if (
|
|
12160
|
+
if (ts6.isIdentifier(expression) && ["atob", "btoa"].includes(expression.text)) {
|
|
11397
12161
|
return true;
|
|
11398
12162
|
}
|
|
11399
12163
|
if (isMemberAccessExpression(expression) && isMemberAccessNamed(expression, "atob", "btoa") && expressionLooksLikeWindowObjectSource(
|
|
@@ -11413,7 +12177,7 @@ function expressionLooksLikeBrowserGlobalBase64Helper(expression, sourceFile, na
|
|
|
11413
12177
|
)) {
|
|
11414
12178
|
return true;
|
|
11415
12179
|
}
|
|
11416
|
-
if (
|
|
12180
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11417
12181
|
return expressionLooksLikeBrowserGlobalBase64Helper(
|
|
11418
12182
|
expression.expression,
|
|
11419
12183
|
sourceFile,
|
|
@@ -11422,7 +12186,7 @@ function expressionLooksLikeBrowserGlobalBase64Helper(expression, sourceFile, na
|
|
|
11422
12186
|
seenIdentifiers
|
|
11423
12187
|
);
|
|
11424
12188
|
}
|
|
11425
|
-
if (
|
|
12189
|
+
if (ts6.isIdentifier(expression)) {
|
|
11426
12190
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11427
12191
|
const initializer = namedExpressions.get(expression.text);
|
|
11428
12192
|
if (initializer) {
|
|
@@ -11451,7 +12215,7 @@ function expressionLooksLikeBrowserGlobalBase64Helper(expression, sourceFile, na
|
|
|
11451
12215
|
}
|
|
11452
12216
|
function expressionLooksLikeBrowserGlobalUriCodecHelper(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11453
12217
|
if (!expression) return false;
|
|
11454
|
-
if (
|
|
12218
|
+
if (ts6.isIdentifier(expression) && [
|
|
11455
12219
|
"decodeURI",
|
|
11456
12220
|
"decodeURIComponent",
|
|
11457
12221
|
"encodeURI",
|
|
@@ -11486,7 +12250,7 @@ function expressionLooksLikeBrowserGlobalUriCodecHelper(expression, sourceFile,
|
|
|
11486
12250
|
)) {
|
|
11487
12251
|
return true;
|
|
11488
12252
|
}
|
|
11489
|
-
if (
|
|
12253
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11490
12254
|
return expressionLooksLikeBrowserGlobalUriCodecHelper(
|
|
11491
12255
|
expression.expression,
|
|
11492
12256
|
sourceFile,
|
|
@@ -11495,7 +12259,7 @@ function expressionLooksLikeBrowserGlobalUriCodecHelper(expression, sourceFile,
|
|
|
11495
12259
|
seenIdentifiers
|
|
11496
12260
|
);
|
|
11497
12261
|
}
|
|
11498
|
-
if (
|
|
12262
|
+
if (ts6.isIdentifier(expression)) {
|
|
11499
12263
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11500
12264
|
const initializer = namedExpressions.get(expression.text);
|
|
11501
12265
|
if (initializer) {
|
|
@@ -11534,7 +12298,7 @@ function expressionLooksLikeLocationUrlSource(expression, sourceFile, namedExpre
|
|
|
11534
12298
|
if (LOCATION_URL_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
11535
12299
|
return true;
|
|
11536
12300
|
}
|
|
11537
|
-
if (
|
|
12301
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11538
12302
|
return expressionLooksLikeLocationUrlSource(
|
|
11539
12303
|
expression.expression,
|
|
11540
12304
|
sourceFile,
|
|
@@ -11543,7 +12307,7 @@ function expressionLooksLikeLocationUrlSource(expression, sourceFile, namedExpre
|
|
|
11543
12307
|
seenIdentifiers
|
|
11544
12308
|
);
|
|
11545
12309
|
}
|
|
11546
|
-
if (
|
|
12310
|
+
if (ts6.isNewExpression(expression) && ts6.isIdentifier(expression.expression) && expression.expression.text === "URL") {
|
|
11547
12311
|
return expressionLooksLikeLocationUrlInput(
|
|
11548
12312
|
expression.arguments?.[0],
|
|
11549
12313
|
sourceFile,
|
|
@@ -11552,7 +12316,7 @@ function expressionLooksLikeLocationUrlSource(expression, sourceFile, namedExpre
|
|
|
11552
12316
|
seenIdentifiers
|
|
11553
12317
|
);
|
|
11554
12318
|
}
|
|
11555
|
-
if (
|
|
12319
|
+
if (ts6.isIdentifier(expression)) {
|
|
11556
12320
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11557
12321
|
const initializer = namedExpressions.get(expression.text);
|
|
11558
12322
|
if (!initializer) return false;
|
|
@@ -11574,7 +12338,7 @@ function expressionLooksLikeLocationUrlInput(expression, sourceFile, namedExpres
|
|
|
11574
12338
|
if (LOCATION_URL_INPUT_REGEX.test(expression.getText(sourceFile))) {
|
|
11575
12339
|
return true;
|
|
11576
12340
|
}
|
|
11577
|
-
if (
|
|
12341
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11578
12342
|
return expressionLooksLikeLocationUrlInput(
|
|
11579
12343
|
expression.expression,
|
|
11580
12344
|
sourceFile,
|
|
@@ -11592,7 +12356,7 @@ function expressionLooksLikeLocationUrlInput(expression, sourceFile, namedExpres
|
|
|
11592
12356
|
)) {
|
|
11593
12357
|
return true;
|
|
11594
12358
|
}
|
|
11595
|
-
if (isCallLikeExpression(expression) &&
|
|
12359
|
+
if (isCallLikeExpression(expression) && ts6.isIdentifier(expression.expression) && expression.expression.text === "String" && expression.arguments.length > 0 && (expressionLooksLikeLocationObjectSource(
|
|
11596
12360
|
expression.arguments[0],
|
|
11597
12361
|
sourceFile,
|
|
11598
12362
|
namedExpressions,
|
|
@@ -11645,7 +12409,7 @@ function expressionLooksLikeLocationUrlInput(expression, sourceFile, namedExpres
|
|
|
11645
12409
|
)) {
|
|
11646
12410
|
return true;
|
|
11647
12411
|
}
|
|
11648
|
-
if (
|
|
12412
|
+
if (ts6.isIdentifier(expression)) {
|
|
11649
12413
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11650
12414
|
const initializer = namedExpressions.get(expression.text);
|
|
11651
12415
|
if (initializer) {
|
|
@@ -11692,7 +12456,7 @@ function expressionLooksLikeRequestObjectSource(expression, sourceFile, namedExp
|
|
|
11692
12456
|
if (REQUEST_OBJECT_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
11693
12457
|
return true;
|
|
11694
12458
|
}
|
|
11695
|
-
if (
|
|
12459
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11696
12460
|
return expressionLooksLikeRequestObjectSource(
|
|
11697
12461
|
expression.expression,
|
|
11698
12462
|
sourceFile,
|
|
@@ -11700,7 +12464,7 @@ function expressionLooksLikeRequestObjectSource(expression, sourceFile, namedExp
|
|
|
11700
12464
|
seenIdentifiers
|
|
11701
12465
|
);
|
|
11702
12466
|
}
|
|
11703
|
-
if (
|
|
12467
|
+
if (ts6.isIdentifier(expression)) {
|
|
11704
12468
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11705
12469
|
const initializer = namedExpressions.get(expression.text);
|
|
11706
12470
|
if (!initializer) return false;
|
|
@@ -11721,7 +12485,7 @@ function expressionLooksLikeNextUrlSource(expression, sourceFile, namedExpressio
|
|
|
11721
12485
|
if (NEXT_URL_SOURCE_REGEX.test(expression.getText(sourceFile))) {
|
|
11722
12486
|
return true;
|
|
11723
12487
|
}
|
|
11724
|
-
if (
|
|
12488
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11725
12489
|
return expressionLooksLikeNextUrlSource(
|
|
11726
12490
|
expression.expression,
|
|
11727
12491
|
sourceFile,
|
|
@@ -11747,7 +12511,7 @@ function expressionLooksLikeNextUrlSource(expression, sourceFile, namedExpressio
|
|
|
11747
12511
|
seenIdentifiers
|
|
11748
12512
|
);
|
|
11749
12513
|
}
|
|
11750
|
-
if (
|
|
12514
|
+
if (ts6.isIdentifier(expression)) {
|
|
11751
12515
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11752
12516
|
const initializer = namedExpressions.get(expression.text);
|
|
11753
12517
|
if (initializer) {
|
|
@@ -11781,7 +12545,7 @@ function expressionLooksLikeOpenRedirectSearchParamsCarrier(expression, sourceFi
|
|
|
11781
12545
|
if (/\b(?:searchParams|(?:request|req)\.nextUrl\.searchParams|url\.searchParams)\b/i.test(text)) {
|
|
11782
12546
|
return true;
|
|
11783
12547
|
}
|
|
11784
|
-
if (
|
|
12548
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11785
12549
|
return expressionLooksLikeOpenRedirectSearchParamsCarrier(
|
|
11786
12550
|
expression.expression,
|
|
11787
12551
|
sourceFile,
|
|
@@ -11790,7 +12554,7 @@ function expressionLooksLikeOpenRedirectSearchParamsCarrier(expression, sourceFi
|
|
|
11790
12554
|
seenIdentifiers
|
|
11791
12555
|
);
|
|
11792
12556
|
}
|
|
11793
|
-
if (
|
|
12557
|
+
if (ts6.isNewExpression(expression) && ts6.isIdentifier(expression.expression) && expression.expression.text === "URLSearchParams") {
|
|
11794
12558
|
return expressionLooksLikeLocationQuerySource(
|
|
11795
12559
|
expression.arguments?.[0],
|
|
11796
12560
|
sourceFile,
|
|
@@ -11799,7 +12563,7 @@ function expressionLooksLikeOpenRedirectSearchParamsCarrier(expression, sourceFi
|
|
|
11799
12563
|
seenIdentifiers
|
|
11800
12564
|
);
|
|
11801
12565
|
}
|
|
11802
|
-
if (isCallLikeExpression(expression) && (
|
|
12566
|
+
if (isCallLikeExpression(expression) && (ts6.isIdentifier(expression.expression) && expression.expression.text === "useSearchParams" || isMemberAccessExpression(expression.expression) && isMemberAccessNamed(expression.expression, "useSearchParams"))) {
|
|
11803
12567
|
return true;
|
|
11804
12568
|
}
|
|
11805
12569
|
if (isPropertyLikeAccessExpression(expression) && isPropertyNamed(expression.name, "searchParams")) {
|
|
@@ -11817,7 +12581,7 @@ function expressionLooksLikeOpenRedirectSearchParamsCarrier(expression, sourceFi
|
|
|
11817
12581
|
seenIdentifiers
|
|
11818
12582
|
);
|
|
11819
12583
|
}
|
|
11820
|
-
if (
|
|
12584
|
+
if (ts6.isIdentifier(expression)) {
|
|
11821
12585
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11822
12586
|
const initializer = namedExpressions.get(expression.text);
|
|
11823
12587
|
if (initializer) {
|
|
@@ -11857,7 +12621,7 @@ function expressionLooksLikeLocationAssignmentTarget(expression, sourceFile, nam
|
|
|
11857
12621
|
if (isLocationAssignmentTarget(expression)) {
|
|
11858
12622
|
return true;
|
|
11859
12623
|
}
|
|
11860
|
-
if (
|
|
12624
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11861
12625
|
return expressionLooksLikeLocationAssignmentTarget(
|
|
11862
12626
|
expression.expression,
|
|
11863
12627
|
sourceFile,
|
|
@@ -11879,7 +12643,7 @@ function expressionLooksLikeLocationAssignmentTarget(expression, sourceFile, nam
|
|
|
11879
12643
|
}
|
|
11880
12644
|
function expressionLooksLikeLocationMutationCall(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11881
12645
|
if (!expression) return false;
|
|
11882
|
-
if (
|
|
12646
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11883
12647
|
return expressionLooksLikeLocationMutationCall(
|
|
11884
12648
|
expression.expression,
|
|
11885
12649
|
sourceFile,
|
|
@@ -11906,7 +12670,7 @@ function expressionLooksLikeLocationMutationCall(expression, sourceFile, namedEx
|
|
|
11906
12670
|
seenIdentifiers
|
|
11907
12671
|
);
|
|
11908
12672
|
}
|
|
11909
|
-
if (
|
|
12673
|
+
if (ts6.isIdentifier(expression)) {
|
|
11910
12674
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11911
12675
|
const initializer = namedExpressions.get(expression.text);
|
|
11912
12676
|
if (initializer) {
|
|
@@ -11945,7 +12709,7 @@ function expressionLooksLikeLocationMutationCall(expression, sourceFile, namedEx
|
|
|
11945
12709
|
}
|
|
11946
12710
|
function expressionLooksLikeWindowOpenCall(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
11947
12711
|
if (!expression) return false;
|
|
11948
|
-
if (
|
|
12712
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
11949
12713
|
return expressionLooksLikeWindowOpenCall(
|
|
11950
12714
|
expression.expression,
|
|
11951
12715
|
sourceFile,
|
|
@@ -11963,10 +12727,10 @@ function expressionLooksLikeWindowOpenCall(expression, sourceFile, namedExpressi
|
|
|
11963
12727
|
seenIdentifiers
|
|
11964
12728
|
);
|
|
11965
12729
|
}
|
|
11966
|
-
if (
|
|
12730
|
+
if (ts6.isIdentifier(expression) && expression.text === "open") {
|
|
11967
12731
|
return true;
|
|
11968
12732
|
}
|
|
11969
|
-
if (
|
|
12733
|
+
if (ts6.isIdentifier(expression)) {
|
|
11970
12734
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
11971
12735
|
const initializer = namedExpressions.get(expression.text);
|
|
11972
12736
|
if (initializer) {
|
|
@@ -12002,7 +12766,7 @@ function expressionLooksLikeWindowOpenCall(expression, sourceFile, namedExpressi
|
|
|
12002
12766
|
}
|
|
12003
12767
|
function expressionLooksLikeHistoryMutationCall(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
12004
12768
|
if (!expression) return false;
|
|
12005
|
-
if (
|
|
12769
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
12006
12770
|
return expressionLooksLikeHistoryMutationCall(
|
|
12007
12771
|
expression.expression,
|
|
12008
12772
|
sourceFile,
|
|
@@ -12029,7 +12793,7 @@ function expressionLooksLikeHistoryMutationCall(expression, sourceFile, namedExp
|
|
|
12029
12793
|
seenIdentifiers
|
|
12030
12794
|
);
|
|
12031
12795
|
}
|
|
12032
|
-
if (
|
|
12796
|
+
if (ts6.isIdentifier(expression)) {
|
|
12033
12797
|
if (seenIdentifiers.has(expression.text)) return false;
|
|
12034
12798
|
const initializer = namedExpressions.get(expression.text);
|
|
12035
12799
|
if (initializer) {
|
|
@@ -12068,7 +12832,7 @@ function expressionLooksLikeHistoryMutationCall(expression, sourceFile, namedExp
|
|
|
12068
12832
|
}
|
|
12069
12833
|
function expressionLooksLikeRouteTransitionCall(expression, sourceFile, namedExpressions, namedPropertyAliases, seenIdentifiers) {
|
|
12070
12834
|
if (!expression) return false;
|
|
12071
|
-
if (
|
|
12835
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
12072
12836
|
return expressionLooksLikeRouteTransitionCall(
|
|
12073
12837
|
expression.expression,
|
|
12074
12838
|
sourceFile,
|
|
@@ -12095,7 +12859,7 @@ function expressionLooksLikeRouteTransitionCall(expression, sourceFile, namedExp
|
|
|
12095
12859
|
seenIdentifiers
|
|
12096
12860
|
);
|
|
12097
12861
|
}
|
|
12098
|
-
if (
|
|
12862
|
+
if (ts6.isIdentifier(expression)) {
|
|
12099
12863
|
if (["redirect", "navigate"].includes(expression.text)) {
|
|
12100
12864
|
return true;
|
|
12101
12865
|
}
|
|
@@ -12141,7 +12905,7 @@ function expressionLooksLikeRouteTransitionCall(expression, sourceFile, namedExp
|
|
|
12141
12905
|
);
|
|
12142
12906
|
}
|
|
12143
12907
|
function getRouteTransitionTargetExpression(node, sourceFile, namedExpressions, namedPropertyAliases) {
|
|
12144
|
-
if (isMemberAccessExpression(node.expression) &&
|
|
12908
|
+
if (isMemberAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "Reflect" && isMemberAccessNamed(node.expression, "apply") && expressionLooksLikeRouteTransitionCall(
|
|
12145
12909
|
node.arguments[0],
|
|
12146
12910
|
sourceFile,
|
|
12147
12911
|
namedExpressions,
|
|
@@ -12186,7 +12950,7 @@ function getRouteTransitionTargetExpression(node, sourceFile, namedExpressions,
|
|
|
12186
12950
|
)) {
|
|
12187
12951
|
return getAliasedApplyArgumentExpression(node.arguments[1], 2, namedExpressions, /* @__PURE__ */ new Set());
|
|
12188
12952
|
}
|
|
12189
|
-
if (isMemberAccessExpression(node.expression) &&
|
|
12953
|
+
if (isMemberAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "Reflect" && isMemberAccessNamed(node.expression, "apply") && expressionLooksLikeHistoryMutationCall(
|
|
12190
12954
|
node.arguments[0],
|
|
12191
12955
|
sourceFile,
|
|
12192
12956
|
namedExpressions,
|
|
@@ -12217,7 +12981,7 @@ function getRouteTransitionTargetExpression(node, sourceFile, namedExpressions,
|
|
|
12217
12981
|
}
|
|
12218
12982
|
function getAliasedApplyArgumentExpression(expression, index, namedExpressions, seenIdentifiers) {
|
|
12219
12983
|
if (!expression) return void 0;
|
|
12220
|
-
if (
|
|
12984
|
+
if (ts6.isParenthesizedExpression(expression) || ts6.isAsExpression(expression) || ts6.isTypeAssertionExpression(expression) || ts6.isNonNullExpression(expression)) {
|
|
12221
12985
|
return getAliasedApplyArgumentExpression(
|
|
12222
12986
|
expression.expression,
|
|
12223
12987
|
index,
|
|
@@ -12225,7 +12989,7 @@ function getAliasedApplyArgumentExpression(expression, index, namedExpressions,
|
|
|
12225
12989
|
seenIdentifiers
|
|
12226
12990
|
);
|
|
12227
12991
|
}
|
|
12228
|
-
if (
|
|
12992
|
+
if (ts6.isIdentifier(expression)) {
|
|
12229
12993
|
if (seenIdentifiers.has(expression.text)) return void 0;
|
|
12230
12994
|
const initializer = namedExpressions.get(expression.text);
|
|
12231
12995
|
if (!initializer) return void 0;
|
|
@@ -12239,12 +13003,12 @@ function getAliasedApplyArgumentExpression(expression, index, namedExpressions,
|
|
|
12239
13003
|
seenIdentifiers.delete(expression.text);
|
|
12240
13004
|
return result;
|
|
12241
13005
|
}
|
|
12242
|
-
if (!
|
|
13006
|
+
if (!ts6.isArrayLiteralExpression(expression)) return void 0;
|
|
12243
13007
|
const argument = expression.elements[index];
|
|
12244
|
-
return
|
|
13008
|
+
return ts6.isExpression(argument) ? argument : void 0;
|
|
12245
13009
|
}
|
|
12246
13010
|
function getLocationMutationTargetExpression(node, sourceFile, namedExpressions, namedPropertyAliases) {
|
|
12247
|
-
if (isMemberAccessExpression(node.expression) &&
|
|
13011
|
+
if (isMemberAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "Reflect" && isMemberAccessNamed(node.expression, "apply") && expressionLooksLikeLocationMutationCall(
|
|
12248
13012
|
node.arguments[0],
|
|
12249
13013
|
sourceFile,
|
|
12250
13014
|
namedExpressions,
|
|
@@ -12283,7 +13047,7 @@ function getLocationMutationTargetExpression(node, sourceFile, namedExpressions,
|
|
|
12283
13047
|
return void 0;
|
|
12284
13048
|
}
|
|
12285
13049
|
function getWindowOpenTargetExpression(node, sourceFile, namedExpressions, namedPropertyAliases) {
|
|
12286
|
-
if (isMemberAccessExpression(node.expression) &&
|
|
13050
|
+
if (isMemberAccessExpression(node.expression) && ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "Reflect" && isMemberAccessNamed(node.expression, "apply") && expressionLooksLikeWindowOpenCall(
|
|
12287
13051
|
node.arguments[0],
|
|
12288
13052
|
sourceFile,
|
|
12289
13053
|
namedExpressions,
|
|
@@ -12422,28 +13186,28 @@ var DYNAMIC_GEOMETRY_STYLE_PROPS = /* @__PURE__ */ new Set([
|
|
|
12422
13186
|
"y"
|
|
12423
13187
|
]);
|
|
12424
13188
|
function getJsxAttributeExpression(initializer) {
|
|
12425
|
-
if (!initializer || !
|
|
13189
|
+
if (!initializer || !ts6.isJsxExpression(initializer)) return null;
|
|
12426
13190
|
return initializer.expression ?? null;
|
|
12427
13191
|
}
|
|
12428
13192
|
function getStylePropertyName(name) {
|
|
12429
|
-
if (
|
|
13193
|
+
if (ts6.isIdentifier(name) || ts6.isStringLiteral(name) || ts6.isNumericLiteral(name)) {
|
|
12430
13194
|
return name.text;
|
|
12431
13195
|
}
|
|
12432
|
-
if (
|
|
13196
|
+
if (ts6.isComputedPropertyName(name)) {
|
|
12433
13197
|
return getExpressionLiteralValue(name.expression);
|
|
12434
13198
|
}
|
|
12435
13199
|
return null;
|
|
12436
13200
|
}
|
|
12437
13201
|
function unwrapStyleExpression(expression) {
|
|
12438
13202
|
let current = expression;
|
|
12439
|
-
while (
|
|
13203
|
+
while (ts6.isParenthesizedExpression(current) || ts6.isAsExpression(current) || ts6.isTypeAssertionExpression(current) || ts6.isNonNullExpression(current) || ts6.isSatisfiesExpression(current)) {
|
|
12440
13204
|
current = current.expression;
|
|
12441
13205
|
}
|
|
12442
13206
|
return current;
|
|
12443
13207
|
}
|
|
12444
13208
|
function isDynamicStyleValue(expression) {
|
|
12445
13209
|
const unwrapped = unwrapStyleExpression(expression);
|
|
12446
|
-
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) {
|
|
12447
13211
|
return false;
|
|
12448
13212
|
}
|
|
12449
13213
|
return true;
|
|
@@ -12452,7 +13216,7 @@ function isAllowedInlineStyleObject(objectLiteral) {
|
|
|
12452
13216
|
let sawGeometryProperty = false;
|
|
12453
13217
|
let sawDynamicGeometryValue = false;
|
|
12454
13218
|
for (const property of objectLiteral.properties) {
|
|
12455
|
-
if (!
|
|
13219
|
+
if (!ts6.isPropertyAssignment(property)) return false;
|
|
12456
13220
|
const propertyName2 = getStylePropertyName(property.name);
|
|
12457
13221
|
if (!propertyName2) return false;
|
|
12458
13222
|
if (propertyName2.startsWith("--d-")) {
|
|
@@ -12481,10 +13245,10 @@ function isAllowedInlineStyleAttribute(attribute, sourceFile, namedExpressions,
|
|
|
12481
13245
|
return resolved ? isAllowedInlineStyleObject(resolved.objectLiteral) : false;
|
|
12482
13246
|
}
|
|
12483
13247
|
function analyzeAstSignals(filePath, code) {
|
|
12484
|
-
const sourceFile =
|
|
13248
|
+
const sourceFile = ts6.createSourceFile(
|
|
12485
13249
|
filePath,
|
|
12486
13250
|
code,
|
|
12487
|
-
|
|
13251
|
+
ts6.ScriptTarget.Latest,
|
|
12488
13252
|
true,
|
|
12489
13253
|
getScriptKind(filePath)
|
|
12490
13254
|
);
|
|
@@ -12569,7 +13333,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12569
13333
|
let navigationLandmarkCount = 0;
|
|
12570
13334
|
let unlabeledNavigationLandmarkCount = 0;
|
|
12571
13335
|
const walk = (node) => {
|
|
12572
|
-
if (
|
|
13336
|
+
if (ts6.isJsxAttribute(node)) {
|
|
12573
13337
|
if (isPropertyNamed(node.name, "style") && node.initializer) {
|
|
12574
13338
|
if (!isAllowedInlineStyleAttribute(
|
|
12575
13339
|
node,
|
|
@@ -12583,7 +13347,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12583
13347
|
if (isPropertyNamed(node.name, "dangerouslySetInnerHTML") && !isSafeJsonLdDangerouslySetInnerHtml(node)) {
|
|
12584
13348
|
signals.dangerousHtmlCount += 1;
|
|
12585
13349
|
}
|
|
12586
|
-
if (isPropertyNamed(node.name, "href", "to") && node.initializer &&
|
|
13350
|
+
if (isPropertyNamed(node.name, "href", "to") && node.initializer && ts6.isJsxExpression(node.initializer) && expressionContainsOpenRedirectSource(
|
|
12587
13351
|
node.initializer.expression,
|
|
12588
13352
|
sourceFile,
|
|
12589
13353
|
namedExpressionInitializers,
|
|
@@ -12601,10 +13365,10 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12601
13365
|
signals.authProviderNonceMissingCount += 1;
|
|
12602
13366
|
}
|
|
12603
13367
|
}
|
|
12604
|
-
if (
|
|
13368
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && ts6.isPropertyAccessExpression(node.left) && isPropertyNamed(node.left.name, "innerHTML", "outerHTML")) {
|
|
12605
13369
|
signals.rawHtmlInjectionCount += 1;
|
|
12606
13370
|
}
|
|
12607
|
-
if (
|
|
13371
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && expressionLooksLikeLocationAssignmentTarget(
|
|
12608
13372
|
node.left,
|
|
12609
13373
|
sourceFile,
|
|
12610
13374
|
namedExpressionInitializers,
|
|
@@ -12618,7 +13382,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12618
13382
|
)) {
|
|
12619
13383
|
signals.authOpenRedirectSignalCount += 1;
|
|
12620
13384
|
}
|
|
12621
|
-
if (
|
|
13385
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && expressionLooksLikeLocationAssignmentTarget(
|
|
12622
13386
|
node.left,
|
|
12623
13387
|
sourceFile,
|
|
12624
13388
|
namedExpressionInitializers,
|
|
@@ -12627,7 +13391,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12627
13391
|
) && isInsecureTransportUrl(getExpressionLiteralValue(node.right))) {
|
|
12628
13392
|
signals.insecureTransportEndpointCount += 1;
|
|
12629
13393
|
}
|
|
12630
|
-
if (
|
|
13394
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && expressionLooksLikeLocationAssignmentTarget(
|
|
12631
13395
|
node.left,
|
|
12632
13396
|
sourceFile,
|
|
12633
13397
|
namedExpressionInitializers,
|
|
@@ -12645,7 +13409,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12645
13409
|
signals.authProviderNonceMissingCount += 1;
|
|
12646
13410
|
}
|
|
12647
13411
|
}
|
|
12648
|
-
if (
|
|
13412
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && expressionLooksLikeLocationAssignmentTarget(
|
|
12649
13413
|
node.left,
|
|
12650
13414
|
sourceFile,
|
|
12651
13415
|
namedExpressionInitializers,
|
|
@@ -12659,36 +13423,36 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12659
13423
|
)) {
|
|
12660
13424
|
signals.authOpenRedirectSignalCount += 1;
|
|
12661
13425
|
}
|
|
12662
|
-
if (
|
|
13426
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && ts6.isPropertyAccessExpression(node.left) && isPropertyNamed(node.left.name, "onmessage")) {
|
|
12663
13427
|
const handler = resolveFunctionLikeHandler(node.right, namedFunctionDeclarations);
|
|
12664
13428
|
if (handler && !functionLikeReferencesOrigin(handler)) {
|
|
12665
13429
|
signals.messageListenerWithoutOriginCheckCount += 1;
|
|
12666
13430
|
}
|
|
12667
13431
|
}
|
|
12668
|
-
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)) {
|
|
12669
13433
|
signals.authStorageWriteCount += 1;
|
|
12670
13434
|
}
|
|
12671
|
-
if (
|
|
13435
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && ts6.isElementAccessExpression(node.left) && isBrowserStorageObject(node.left.expression) && isAuthStorageKeyLiteral(node.left.argumentExpression)) {
|
|
12672
13436
|
signals.authStorageWriteCount += 1;
|
|
12673
13437
|
}
|
|
12674
|
-
if (
|
|
13438
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && isCookiePropertyAccess(node.left) && hasAuthCredentialText(node.right, sourceFile)) {
|
|
12675
13439
|
signals.authCookieWriteCount += 1;
|
|
12676
13440
|
}
|
|
12677
|
-
if (
|
|
13441
|
+
if (ts6.isBinaryExpression(node) && node.operatorToken.kind === ts6.SyntaxKind.EqualsToken && isAuthorizationHeaderAccess(node.left)) {
|
|
12678
13442
|
if (isHeaderClearValue(node.right)) {
|
|
12679
13443
|
signals.authHeaderClearCount += 1;
|
|
12680
13444
|
} else {
|
|
12681
13445
|
signals.authHeaderWriteCount += 1;
|
|
12682
13446
|
}
|
|
12683
13447
|
}
|
|
12684
|
-
if (
|
|
13448
|
+
if (ts6.isPropertyAssignment(node) && isAuthorizationHeaderName(node.name)) {
|
|
12685
13449
|
if (isHeaderClearValue(node.initializer)) {
|
|
12686
13450
|
signals.authHeaderClearCount += 1;
|
|
12687
13451
|
} else {
|
|
12688
13452
|
signals.authHeaderWriteCount += 1;
|
|
12689
13453
|
}
|
|
12690
13454
|
}
|
|
12691
|
-
if (
|
|
13455
|
+
if (ts6.isDeleteExpression(node) && isAuthorizationHeaderAccess(node.expression)) {
|
|
12692
13456
|
signals.authHeaderClearCount += 1;
|
|
12693
13457
|
}
|
|
12694
13458
|
if (isCallLikeExpression(node)) {
|
|
@@ -12719,10 +13483,10 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12719
13483
|
namedPropertyAliases
|
|
12720
13484
|
);
|
|
12721
13485
|
const windowOpenTargetLiteral = getExpressionLiteralValue(windowOpenTargetExpression);
|
|
12722
|
-
if (
|
|
13486
|
+
if (ts6.isIdentifier(node.expression) && node.expression.text === "eval") {
|
|
12723
13487
|
signals.dynamicEvalCount += 1;
|
|
12724
13488
|
}
|
|
12725
|
-
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") {
|
|
12726
13490
|
signals.dynamicEvalCount += 1;
|
|
12727
13491
|
}
|
|
12728
13492
|
if ((isFetchLikeCall(node) || isAxiosLikeCall(node)) && isInsecureTransportUrl(firstArgumentLiteral)) {
|
|
@@ -12804,7 +13568,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12804
13568
|
signals.authProviderNonceMissingCount += 1;
|
|
12805
13569
|
}
|
|
12806
13570
|
}
|
|
12807
|
-
if (
|
|
13571
|
+
if (ts6.isPropertyAccessExpression(node.expression) && isPropertyNamed(node.expression.name, "postMessage") && secondArgumentLiteral === "*") {
|
|
12808
13572
|
signals.wildcardPostMessageCount += 1;
|
|
12809
13573
|
}
|
|
12810
13574
|
if (isAddEventListenerCall(node) && firstArgumentLiteral === "message") {
|
|
@@ -12813,7 +13577,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12813
13577
|
signals.messageListenerWithoutOriginCheckCount += 1;
|
|
12814
13578
|
}
|
|
12815
13579
|
}
|
|
12816
|
-
if (
|
|
13580
|
+
if (ts6.isPropertyAccessExpression(node.expression) && isPropertyNamed(node.expression.name, "setHeader", "append", "set") && isSetCookieHeaderName(node.arguments[0])) {
|
|
12817
13581
|
const cookieStrings = collectCookieHeaderStrings(node.arguments[1]);
|
|
12818
13582
|
const authCookieStrings = cookieStrings.filter(cookieHeaderStringLooksAuthLike);
|
|
12819
13583
|
if (authCookieStrings.length > 0) {
|
|
@@ -12831,13 +13595,13 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12831
13595
|
}
|
|
12832
13596
|
}
|
|
12833
13597
|
}
|
|
12834
|
-
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") {
|
|
12835
13599
|
const featureLiteral = getExpressionLiteralValue(node.arguments[2])?.toLowerCase() ?? "";
|
|
12836
13600
|
if (!featureLiteral.includes("noopener") || !featureLiteral.includes("noreferrer")) {
|
|
12837
13601
|
signals.windowOpenWithoutNoopenerCount += 1;
|
|
12838
13602
|
}
|
|
12839
13603
|
}
|
|
12840
|
-
if (
|
|
13604
|
+
if (ts6.isPropertyAccessExpression(node.expression)) {
|
|
12841
13605
|
if (isPropertyNamed(node.expression.name, "insertAdjacentHTML")) {
|
|
12842
13606
|
signals.rawHtmlInjectionCount += 1;
|
|
12843
13607
|
}
|
|
@@ -12846,7 +13610,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12846
13610
|
}
|
|
12847
13611
|
if (isCookieMutationSetCall(node)) {
|
|
12848
13612
|
const firstArgument = node.arguments[0];
|
|
12849
|
-
const isObjectConfigCall =
|
|
13613
|
+
const isObjectConfigCall = ts6.isObjectLiteralExpression(firstArgument);
|
|
12850
13614
|
const isAuthCookieWrite = isObjectConfigCall ? objectLiteralLooksLikeAuthCookieConfig(firstArgument, sourceFile) : expressionLooksLikeAuthCookieName(firstArgument, sourceFile);
|
|
12851
13615
|
if (isAuthCookieWrite) {
|
|
12852
13616
|
signals.authCookieWriteCount += 1;
|
|
@@ -12866,7 +13630,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12866
13630
|
signals.authHeaderWriteCount += 1;
|
|
12867
13631
|
}
|
|
12868
13632
|
}
|
|
12869
|
-
if (
|
|
13633
|
+
if (ts6.isIdentifier(node.expression.expression) && node.expression.expression.text === "document" && isPropertyNamed(node.expression.name, "write")) {
|
|
12870
13634
|
signals.rawHtmlInjectionCount += 1;
|
|
12871
13635
|
}
|
|
12872
13636
|
if (isPropertyNamed(node.expression.name, "eval")) {
|
|
@@ -12874,16 +13638,16 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12874
13638
|
}
|
|
12875
13639
|
}
|
|
12876
13640
|
}
|
|
12877
|
-
if (
|
|
13641
|
+
if (ts6.isNewExpression(node) && isRealtimeTransportConstructor(node) && isInsecureTransportUrl(getExpressionLiteralValue(node.arguments?.[0]))) {
|
|
12878
13642
|
signals.insecureTransportEndpointCount += 1;
|
|
12879
13643
|
}
|
|
12880
|
-
if (
|
|
13644
|
+
if (ts6.isNewExpression(node) && ts6.isIdentifier(node.expression) && node.expression.text === "Function") {
|
|
12881
13645
|
signals.dynamicEvalCount += 1;
|
|
12882
13646
|
}
|
|
12883
|
-
if (
|
|
13647
|
+
if (ts6.isNewExpression(node) && ts6.isIdentifier(node.expression) && ["WebSocket", "EventSource"].includes(node.expression.text) && isInsecureTransportUrl(getExpressionLiteralValue(node.arguments?.[0]))) {
|
|
12884
13648
|
signals.insecureTransportEndpointCount += 1;
|
|
12885
13649
|
}
|
|
12886
|
-
if (
|
|
13650
|
+
if (ts6.isJsxSelfClosingElement(node)) {
|
|
12887
13651
|
const tagName = getJsxTagName(node);
|
|
12888
13652
|
if (hasMainLandmarkSignal(node.attributes, tagName)) {
|
|
12889
13653
|
signals.mainLandmarkCount += 1;
|
|
@@ -12976,7 +13740,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
12976
13740
|
signals.formControlWithoutLabelCount += 1;
|
|
12977
13741
|
}
|
|
12978
13742
|
}
|
|
12979
|
-
if (
|
|
13743
|
+
if (ts6.isJsxElement(node)) {
|
|
12980
13744
|
const tagName = getJsxTagName(node.openingElement);
|
|
12981
13745
|
const textContent = getJsxTextContent(node).replace(/\s+/g, " ").trim();
|
|
12982
13746
|
if (hasMainLandmarkSignal(node.openingElement.attributes, tagName)) {
|
|
@@ -13092,7 +13856,7 @@ function analyzeAstSignals(filePath, code) {
|
|
|
13092
13856
|
signals.formControlWithoutLabelCount += 1;
|
|
13093
13857
|
}
|
|
13094
13858
|
}
|
|
13095
|
-
|
|
13859
|
+
ts6.forEachChild(node, walk);
|
|
13096
13860
|
};
|
|
13097
13861
|
walk(sourceFile);
|
|
13098
13862
|
signals.unlabeledNavigationLandmarkCount = navigationLandmarkCount > 1 ? unlabeledNavigationLandmarkCount : 0;
|
|
@@ -14846,11 +15610,11 @@ function critiqueSource({
|
|
|
14846
15610
|
};
|
|
14847
15611
|
}
|
|
14848
15612
|
function resolveProjectFilePath(projectRoot, filePath) {
|
|
14849
|
-
const root =
|
|
14850
|
-
const candidatePath =
|
|
14851
|
-
const resolvedPath =
|
|
14852
|
-
const relativePath =
|
|
14853
|
-
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)) {
|
|
14854
15618
|
throw new Error(`Path escapes the project root: ${filePath}`);
|
|
14855
15619
|
}
|
|
14856
15620
|
return resolvedPath;
|
|
@@ -14858,7 +15622,7 @@ function resolveProjectFilePath(projectRoot, filePath) {
|
|
|
14858
15622
|
async function critiqueFile(filePath, projectRoot) {
|
|
14859
15623
|
const resolvedPath = resolveProjectFilePath(projectRoot, filePath);
|
|
14860
15624
|
const code = await readFile(resolvedPath, "utf-8");
|
|
14861
|
-
const treatmentsCss = readTextIfExists(
|
|
15625
|
+
const treatmentsCss = readTextIfExists(join6(projectRoot, "src", "styles", "treatments.css"));
|
|
14862
15626
|
const reviewPack = loadReviewPack(projectRoot);
|
|
14863
15627
|
const packManifest = loadPackManifest(projectRoot);
|
|
14864
15628
|
const adoptionMode = readProjectAdoptionMode(projectRoot);
|
|
@@ -14888,19 +15652,33 @@ export {
|
|
|
14888
15652
|
buildProjectHealthRepairPlan,
|
|
14889
15653
|
collectMissingPackManifestFiles,
|
|
14890
15654
|
collectProjectSourceFiles,
|
|
15655
|
+
collectSourceImports,
|
|
14891
15656
|
createContractAssertions,
|
|
14892
15657
|
createEvidenceBundle,
|
|
15658
|
+
createProjectSourceProgram,
|
|
15659
|
+
createSourceInventory,
|
|
14893
15660
|
createUnavailableScanReport,
|
|
14894
15661
|
critiqueFile,
|
|
14895
15662
|
critiqueSource,
|
|
14896
15663
|
deriveVerificationDiagnostic,
|
|
14897
15664
|
emptyRuntimeAudit,
|
|
14898
15665
|
extractRouteHintsFromEssence,
|
|
15666
|
+
extractSourceStringLiterals,
|
|
15667
|
+
getProjectSourceFile,
|
|
15668
|
+
isPathInsideProject,
|
|
15669
|
+
isSupportedSourceExtension,
|
|
14899
15670
|
listKnownInteractions,
|
|
15671
|
+
normalizeSourcePath,
|
|
14900
15672
|
probePublishedSite,
|
|
14901
15673
|
resolveGitHubScanInput,
|
|
14902
15674
|
resolveGraphAnchorForFinding,
|
|
15675
|
+
resolveSourceImport,
|
|
15676
|
+
resolveSourceSymbolOrigin,
|
|
14903
15677
|
scanProject,
|
|
15678
|
+
sourceKindFromPath,
|
|
15679
|
+
sourceLanguageFromPath,
|
|
15680
|
+
sourceLocationForNode,
|
|
15681
|
+
sourceScriptKindFromPath,
|
|
14904
15682
|
verifyInteractionsInSource
|
|
14905
15683
|
};
|
|
14906
15684
|
//# sourceMappingURL=index.js.map
|