react-doctor 0.9.13-dev.ff7dd67 → 0.9.14-dev.499a020
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_react-doctor_require-typescript-DXQDYeWK.js +16 -0
- package/dist/{active-run-trace-dlIZeEvb.js → active-run-trace-Dewycxda.js} +3 -3
- package/dist/{active-scan-abort-registry-DwG6tSPy.js → active-scan-abort-registry-CCTgal0O.js} +3 -3
- package/dist/build-section-divider-BsKw6rbA.js +81 -0
- package/dist/{ci-ByM_SFTq.js → ci-Y7ntr_X7.js} +14 -13
- package/dist/cli.js +31 -30
- package/dist/constants-CW_854PH.js +1035 -0
- package/dist/constants-DNh19qg9.js +23 -0
- package/dist/{design-2hjOmtV1.js → design-CZbXwzWh.js} +4 -4
- package/dist/{devtools-CC2PAZ85.js → devtools-D20sefkm.js} +3 -3
- package/dist/duplicate-jsx-worker.d.ts +1 -0
- package/dist/duplicate-jsx-worker.js +636 -0
- package/dist/{exit-gracefully-niPFXq9Y.js → exit-gracefully-Bq8kCmar.js} +7 -7
- package/dist/fs-utils-C88IbqFa.js +45 -0
- package/dist/{get-east-asian-width-Bv2TD3Xj.js → get-east-asian-width-DRPy7dqz.js} +4 -4
- package/dist/{handle-error-D-4lexec.js → handle-error-DkZtH4y1.js} +6 -5
- package/dist/index.d.ts +8511 -8509
- package/dist/index.js +61693 -60580
- package/dist/{inspect-BrctG7ql.js → inspect-4R70DaBp.js} +38 -27
- package/dist/{install-CcFc56OK.js → install-DSOkcCn6.js} +10 -9
- package/dist/{install-doctor-script-Coa2ErCg.js → install-doctor-script-k5jxcUWB.js} +17 -8
- package/dist/{install-github-workflow-DlfdrYkQ.js → install-github-workflow-Dh3nS6ms.js} +10 -10
- package/dist/{install-react-doctor-BWxqZMX-.js → install-react-doctor-NmiRJQtp.js} +15 -11
- package/dist/is-cache-globally-disabled-CoHiYz2i.js +10 -0
- package/dist/{jsx-runtime-Njm7vAoN.js → jsx-runtime-B1PPqZBs.js} +11 -10
- package/dist/oxlint-worker.d.ts +1 -0
- package/dist/oxlint-worker.js +225 -0
- package/dist/{path-format-DnHpmJwG.js → path-format-By20mo8A.js} +3 -3
- package/dist/{print-branded-header-DFkeG4BS.js → print-branded-header-ydu9MCpt.js} +4 -4
- package/dist/project-analysis-worker.js +461 -480
- package/dist/{prompt-runtime-scan-url-BenBNq25.js → prompt-runtime-scan-url-BEFbrKze.js} +6 -6
- package/dist/react-compiler-detection-worker.d.ts +1 -0
- package/dist/react-compiler-detection-worker.js +1029 -0
- package/dist/{read-object-file-CqMtxcfF.js → read-object-file-f9AWbDOo.js} +4 -4
- package/dist/{record-metric-Bkorhx43.js → record-metric-BeiisdDK.js} +12998 -12770
- package/dist/{report-error-DPjmfRi9.js → report-error-CwReeGgL.js} +9 -8
- package/dist/{report-workflow-result-CBL6CrLY.js → report-workflow-result-CRhHHcHp.js} +24 -11
- package/dist/{resolve-scope-BFloAClV.js → resolve-scope-DsrT6gaf.js} +7 -7
- package/dist/{rules-BKNy9YIl.js → rules-Bhk46JNb.js} +8 -7
- package/dist/{run-scan-app-Bc70ozp-.js → run-scan-app-B_r_jHg-.js} +30 -23
- package/dist/{runtime-scan-ODrdp5mV.js → runtime-scan-B6v3G55b.js} +13 -12
- package/dist/{sanitize-runtime-url-BYOmPSdm.js → sanitize-runtime-url-CVRMHksi.js} +4 -4
- package/dist/{scan-BfcGHHkI.js → scan-BJsk-x4c.js} +10 -9
- package/dist/{semver-DFtnEmN-.js → semver-BZIuy1gP.js} +3 -3
- package/dist/{should-fail-scan-gate-CCPDoHaM.js → should-fail-scan-gate-B8cvpr6W.js} +1339 -1283
- package/dist/{should-skip-prompts-D-ClPHHR.js → should-skip-prompts-CupUff2k.js} +4 -4
- package/dist/{should-use-tui-BaCVIPPN.js → should-use-tui-t0DIGfJ0.js} +4 -4
- package/dist/start-scan-preamble-D0QepYZ_.js +68 -0
- package/dist/start-scan-preamble-DVhXIPc0.d.ts +1 -0
- package/dist/start-scan-preamble.d.ts +1 -0
- package/dist/start-scan-preamble.js +4 -0
- package/dist/{telemetry-runtime-BGWa_GB9.js → telemetry-runtime-DfK-XYFO.js} +154 -5
- package/dist/{unref-stdin-SK3WfwxS.js → unref-stdin-D-NZBFpg.js} +3 -3
- package/dist/unwrap-typescript-expression-CrEPQUWz.js +14 -0
- package/dist/{version-DN1N-oZy.js → version-DpQFTCI_.js} +5 -4
- package/dist/{why-CyioXUF2.js → why-DA3u09OY.js} +4 -4
- package/dist/{with-run-span-GsCWW2_X.js → with-run-span-DP84SJbD.js} +7 -6
- package/package.json +9 -7
- package/dist/build-section-divider-BRuN44fL.js +0 -216
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="81139e97-fbde-59ee-9b65-cb0499a5510a")}catch(e){}}();
|
|
3
3
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-ChKA3wi6.js";
|
|
4
|
-
import { n as require_picomatch$2, t as require_semver } from "./semver-
|
|
4
|
+
import { n as require_picomatch$2, t as require_semver } from "./semver-BZIuy1gP.js";
|
|
5
|
+
import { t as typescriptBinding } from "./_react-doctor_require-typescript-DXQDYeWK.js";
|
|
6
|
+
import { t as unwrapTypescriptExpression } from "./unwrap-typescript-expression-CrEPQUWz.js";
|
|
7
|
+
import { a as MAX_GLOB_PATTERN_LENGTH_CHARS, c as GIT_CHECK_ATTR_MAX_BUFFER_BYTES } from "./constants-DNh19qg9.js";
|
|
8
|
+
import { n as isPlainObject } from "./fs-utils-C88IbqFa.js";
|
|
5
9
|
import { builtinModules } from "node:module";
|
|
6
|
-
import { spawnSync } from "node:child_process";
|
|
7
|
-
import * as path$1 from "node:path";
|
|
8
|
-
import path, { basename, dirname, extname, isAbsolute, join, parse, posix, relative, resolve, sep } from "node:path";
|
|
9
10
|
import * as fs$1 from "node:fs";
|
|
10
11
|
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
11
|
-
import
|
|
12
|
+
import * as path$1 from "node:path";
|
|
13
|
+
import path, { basename, dirname, extname, isAbsolute, join, parse, posix, relative, resolve, sep } from "node:path";
|
|
14
|
+
import { spawnSync } from "node:child_process";
|
|
15
|
+
import { devNull } from "node:os";
|
|
12
16
|
import { parseSync } from "oxc-parser";
|
|
17
|
+
import { readFile } from "node:fs/promises";
|
|
13
18
|
import { ResolverFactory } from "oxc-resolver";
|
|
14
|
-
import { devNull } from "node:os";
|
|
15
19
|
import { parseJSONC, parseTOML, parseYAML } from "confbox";
|
|
16
|
-
import { readFile } from "node:fs/promises";
|
|
17
20
|
import { parse as parse$1 } from "@astrojs/compiler/sync";
|
|
18
21
|
//#region ../core/src/project-analysis/constants.ts
|
|
19
22
|
const DEFAULT_EXTENSIONS = [
|
|
@@ -13380,19 +13383,19 @@ const collectStylesheetImportSpecifiers = (content) => {
|
|
|
13380
13383
|
const extractJitiLoadReferences = (sourceText) => {
|
|
13381
13384
|
if (!sourceText.includes("jiti")) return [];
|
|
13382
13385
|
const virtualFilePath = "react-doctor-jiti-source.tsx";
|
|
13383
|
-
const sourceFile =
|
|
13386
|
+
const sourceFile = typescriptBinding.createSourceFile(virtualFilePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TSX);
|
|
13384
13387
|
const compilerOptions = {
|
|
13385
13388
|
allowJs: true,
|
|
13386
|
-
jsx:
|
|
13389
|
+
jsx: typescriptBinding.JsxEmit.Preserve,
|
|
13387
13390
|
noLib: true,
|
|
13388
13391
|
noResolve: true,
|
|
13389
|
-
target:
|
|
13392
|
+
target: typescriptBinding.ScriptTarget.Latest
|
|
13390
13393
|
};
|
|
13391
|
-
const compilerHost =
|
|
13394
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
13392
13395
|
compilerHost.fileExists = (candidatePath) => candidatePath === virtualFilePath;
|
|
13393
13396
|
compilerHost.getSourceFile = (candidatePath) => candidatePath === virtualFilePath ? sourceFile : void 0;
|
|
13394
13397
|
compilerHost.readFile = (candidatePath) => candidatePath === virtualFilePath ? sourceText : void 0;
|
|
13395
|
-
const program =
|
|
13398
|
+
const program = typescriptBinding.createProgram({
|
|
13396
13399
|
rootNames: [virtualFilePath],
|
|
13397
13400
|
options: compilerOptions,
|
|
13398
13401
|
host: compilerHost
|
|
@@ -13407,60 +13410,60 @@ const extractJitiLoadReferences = (sourceText) => {
|
|
|
13407
13410
|
const factorySymbols = /* @__PURE__ */ new Set();
|
|
13408
13411
|
const moduleSymbols = /* @__PURE__ */ new Set();
|
|
13409
13412
|
const loaderSymbols = /* @__PURE__ */ new Set();
|
|
13410
|
-
const isRequireJitiCall = (expression) =>
|
|
13413
|
+
const isRequireJitiCall = (expression) => typescriptBinding.isCallExpression(expression) && typescriptBinding.isIdentifier(expression.expression) && expression.expression.text === "require" && typeChecker.getSymbolAtLocation(expression.expression) === void 0 && expression.arguments.length === 1 && typescriptBinding.isStringLiteralLike(expression.arguments[0]) && expression.arguments[0].text === "jiti";
|
|
13411
13414
|
for (const statement of boundSourceFile.statements) {
|
|
13412
|
-
if (
|
|
13415
|
+
if (typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === "jiti") {
|
|
13413
13416
|
const importClause = statement.importClause;
|
|
13414
13417
|
if (!importClause) continue;
|
|
13415
13418
|
if (importClause.name) {
|
|
13416
13419
|
const defaultImportSymbol = typeChecker.getSymbolAtLocation(importClause.name);
|
|
13417
13420
|
if (defaultImportSymbol) factorySymbols.add(defaultImportSymbol);
|
|
13418
13421
|
}
|
|
13419
|
-
if (importClause.namedBindings &&
|
|
13422
|
+
if (importClause.namedBindings && typescriptBinding.isNamespaceImport(importClause.namedBindings)) {
|
|
13420
13423
|
const moduleSymbol = typeChecker.getSymbolAtLocation(importClause.namedBindings.name);
|
|
13421
13424
|
if (moduleSymbol) moduleSymbols.add(moduleSymbol);
|
|
13422
13425
|
}
|
|
13423
|
-
if (importClause.namedBindings &&
|
|
13426
|
+
if (importClause.namedBindings && typescriptBinding.isNamedImports(importClause.namedBindings)) for (const importSpecifier of importClause.namedBindings.elements) {
|
|
13424
13427
|
if ((importSpecifier.propertyName?.text ?? importSpecifier.name.text) !== "createJiti") continue;
|
|
13425
13428
|
const factorySymbol = typeChecker.getSymbolAtLocation(importSpecifier.name);
|
|
13426
13429
|
if (factorySymbol) factorySymbols.add(factorySymbol);
|
|
13427
13430
|
}
|
|
13428
13431
|
continue;
|
|
13429
13432
|
}
|
|
13430
|
-
if (!
|
|
13433
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
13431
13434
|
for (const declaration of statement.declarationList.declarations) {
|
|
13432
13435
|
if (!declaration.initializer || !isRequireJitiCall(declaration.initializer)) continue;
|
|
13433
|
-
if (
|
|
13436
|
+
if (typescriptBinding.isIdentifier(declaration.name)) {
|
|
13434
13437
|
const moduleSymbol = typeChecker.getSymbolAtLocation(declaration.name);
|
|
13435
13438
|
if (moduleSymbol) moduleSymbols.add(moduleSymbol);
|
|
13436
13439
|
continue;
|
|
13437
13440
|
}
|
|
13438
|
-
if (!
|
|
13441
|
+
if (!typescriptBinding.isObjectBindingPattern(declaration.name)) continue;
|
|
13439
13442
|
for (const bindingElement of declaration.name.elements) {
|
|
13440
13443
|
const importedName = bindingElement.propertyName ?? bindingElement.name;
|
|
13441
|
-
if (!
|
|
13442
|
-
if (!
|
|
13444
|
+
if (!typescriptBinding.isIdentifier(importedName) || importedName.text !== "createJiti") continue;
|
|
13445
|
+
if (!typescriptBinding.isIdentifier(bindingElement.name)) continue;
|
|
13443
13446
|
const factorySymbol = typeChecker.getSymbolAtLocation(bindingElement.name);
|
|
13444
13447
|
if (factorySymbol) factorySymbols.add(factorySymbol);
|
|
13445
13448
|
}
|
|
13446
13449
|
}
|
|
13447
13450
|
}
|
|
13448
|
-
const isRequireJitiFactoryCall = (expression) =>
|
|
13451
|
+
const isRequireJitiFactoryCall = (expression) => typescriptBinding.isCallExpression(expression) && isRequireJitiCall(expression.expression);
|
|
13449
13452
|
const isFactoryExpression = (expression) => {
|
|
13450
13453
|
const factorySymbol = typeChecker.getSymbolAtLocation(expression);
|
|
13451
13454
|
if (factorySymbol && factorySymbols.has(factorySymbol)) return true;
|
|
13452
|
-
if (!
|
|
13455
|
+
if (!typescriptBinding.isPropertyAccessExpression(expression) || expression.name.text !== "createJiti") return false;
|
|
13453
13456
|
const moduleSymbol = typeChecker.getSymbolAtLocation(expression.expression);
|
|
13454
13457
|
return moduleSymbol !== void 0 && moduleSymbols.has(moduleSymbol);
|
|
13455
13458
|
};
|
|
13456
13459
|
const collectLoaderBindings = (node) => {
|
|
13457
|
-
if (
|
|
13460
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer && typescriptBinding.isCallExpression(node.initializer)) {
|
|
13458
13461
|
if (isRequireJitiFactoryCall(node.initializer) || isFactoryExpression(node.initializer.expression)) {
|
|
13459
13462
|
const loaderSymbol = typeChecker.getSymbolAtLocation(node.name);
|
|
13460
13463
|
if (loaderSymbol) loaderSymbols.add(loaderSymbol);
|
|
13461
13464
|
}
|
|
13462
13465
|
}
|
|
13463
|
-
|
|
13466
|
+
typescriptBinding.forEachChild(node, collectLoaderBindings);
|
|
13464
13467
|
};
|
|
13465
13468
|
collectLoaderBindings(boundSourceFile);
|
|
13466
13469
|
const references = [];
|
|
@@ -13468,25 +13471,25 @@ const extractJitiLoadReferences = (sourceText) => {
|
|
|
13468
13471
|
const firstArgument = callExpression.arguments[0];
|
|
13469
13472
|
const position = boundSourceFile.getLineAndCharacterOfPosition(callExpression.getStart());
|
|
13470
13473
|
references.push({
|
|
13471
|
-
path: firstArgument &&
|
|
13474
|
+
path: firstArgument && typescriptBinding.isStringLiteralLike(firstArgument) ? firstArgument.text : void 0,
|
|
13472
13475
|
line: position.line + 1,
|
|
13473
13476
|
column: position.character
|
|
13474
13477
|
});
|
|
13475
13478
|
};
|
|
13476
13479
|
const visitLoaderCalls = (node) => {
|
|
13477
|
-
if (
|
|
13480
|
+
if (typescriptBinding.isCallExpression(node)) {
|
|
13478
13481
|
const calleeSymbol = typeChecker.getSymbolAtLocation(node.expression);
|
|
13479
13482
|
if (calleeSymbol && loaderSymbols.has(calleeSymbol)) recordLoaderCall(node);
|
|
13480
|
-
else if (
|
|
13483
|
+
else if (typescriptBinding.isCallExpression(node.expression)) {
|
|
13481
13484
|
if (isRequireJitiFactoryCall(node.expression) || isFactoryExpression(node.expression.expression)) recordLoaderCall(node);
|
|
13482
|
-
} else if (
|
|
13485
|
+
} else if (typescriptBinding.isPropertyAccessExpression(node.expression) && node.expression.name.text === "import") {
|
|
13483
13486
|
const loaderExpression = node.expression.expression;
|
|
13484
13487
|
const loaderSymbol = typeChecker.getSymbolAtLocation(loaderExpression);
|
|
13485
|
-
const isInlineFactory =
|
|
13488
|
+
const isInlineFactory = typescriptBinding.isCallExpression(loaderExpression) && isFactoryExpression(loaderExpression.expression);
|
|
13486
13489
|
if (loaderSymbol && loaderSymbols.has(loaderSymbol) || isInlineFactory) recordLoaderCall(node);
|
|
13487
13490
|
}
|
|
13488
13491
|
}
|
|
13489
|
-
|
|
13492
|
+
typescriptBinding.forEachChild(node, visitLoaderCalls);
|
|
13490
13493
|
};
|
|
13491
13494
|
visitLoaderCalls(boundSourceFile);
|
|
13492
13495
|
return references;
|
|
@@ -36057,10 +36060,10 @@ const extractMarkdownModuleStatements = (sourceText) => {
|
|
|
36057
36060
|
//#endregion
|
|
36058
36061
|
//#region ../core/src/project-analysis/collect/parse.ts
|
|
36059
36062
|
const extractRecoveryImports = (filePath, sourceText) => {
|
|
36060
|
-
const sourceFile =
|
|
36063
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, filePath.endsWith("x") ? typescriptBinding.ScriptKind.TSX : typescriptBinding.ScriptKind.TS);
|
|
36061
36064
|
const imports = [];
|
|
36062
36065
|
for (const statement of sourceFile.statements) {
|
|
36063
|
-
if (!
|
|
36066
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
36064
36067
|
const importedNames = [];
|
|
36065
36068
|
const importClause = statement.importClause;
|
|
36066
36069
|
if (importClause?.name) importedNames.push({
|
|
@@ -36070,14 +36073,14 @@ const extractRecoveryImports = (filePath, sourceText) => {
|
|
|
36070
36073
|
isDefault: true,
|
|
36071
36074
|
isTypeOnly: importClause.isTypeOnly
|
|
36072
36075
|
});
|
|
36073
|
-
if (importClause?.namedBindings &&
|
|
36076
|
+
if (importClause?.namedBindings && typescriptBinding.isNamespaceImport(importClause.namedBindings)) importedNames.push({
|
|
36074
36077
|
name: "*",
|
|
36075
36078
|
alias: importClause.namedBindings.name.text,
|
|
36076
36079
|
isNamespace: true,
|
|
36077
36080
|
isDefault: false,
|
|
36078
36081
|
isTypeOnly: importClause.isTypeOnly
|
|
36079
36082
|
});
|
|
36080
|
-
if (importClause?.namedBindings &&
|
|
36083
|
+
if (importClause?.namedBindings && typescriptBinding.isNamedImports(importClause.namedBindings)) for (const element of importClause.namedBindings.elements) importedNames.push({
|
|
36081
36084
|
name: element.propertyName?.text ?? element.name.text,
|
|
36082
36085
|
alias: element.name.text,
|
|
36083
36086
|
isNamespace: false,
|
|
@@ -36102,18 +36105,18 @@ const restoreMaskedSourceRange = (maskedSource, sourceSection, startOffset) => {
|
|
|
36102
36105
|
for (let characterIndex = 0; characterIndex < sourceSection.length; characterIndex++) maskedSource[startOffset + characterIndex] = sourceSection[characterIndex];
|
|
36103
36106
|
};
|
|
36104
36107
|
const maskSelectedExportKeywords = (sourceText, shouldMaskStatement) => {
|
|
36105
|
-
const sourceFile =
|
|
36108
|
+
const sourceFile = typescriptBinding.createSourceFile("embedded-component.tsx", sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TSX);
|
|
36106
36109
|
const maskedSource = sourceText.split("");
|
|
36107
36110
|
for (const statement of sourceFile.statements) {
|
|
36108
|
-
if (!shouldMaskStatement(statement) || !
|
|
36109
|
-
const exportModifier =
|
|
36111
|
+
if (!shouldMaskStatement(statement) || !typescriptBinding.canHaveModifiers(statement)) continue;
|
|
36112
|
+
const exportModifier = typescriptBinding.getModifiers(statement)?.find((modifier) => modifier.kind === typescriptBinding.SyntaxKind.ExportKeyword);
|
|
36110
36113
|
if (!exportModifier) continue;
|
|
36111
36114
|
for (let characterIndex = exportModifier.getStart(sourceFile); characterIndex < exportModifier.end; characterIndex++) maskedSource[characterIndex] = " ";
|
|
36112
36115
|
}
|
|
36113
36116
|
return maskedSource.join("");
|
|
36114
36117
|
};
|
|
36115
|
-
const maskAstroPropsExports = (sourceText) => maskSelectedExportKeywords(sourceText, (statement) => (
|
|
36116
|
-
const maskSvelteInstancePropExports = (sourceText) => maskSelectedExportKeywords(sourceText, (statement) =>
|
|
36118
|
+
const maskAstroPropsExports = (sourceText) => maskSelectedExportKeywords(sourceText, (statement) => (typescriptBinding.isInterfaceDeclaration(statement) || typescriptBinding.isTypeAliasDeclaration(statement)) && statement.name.text === "Props");
|
|
36119
|
+
const maskSvelteInstancePropExports = (sourceText) => maskSelectedExportKeywords(sourceText, (statement) => typescriptBinding.isVariableStatement(statement) && (statement.declarationList.flags & typescriptBinding.NodeFlags.Let) !== 0);
|
|
36117
36120
|
const extractAstroSources = (sourceText) => {
|
|
36118
36121
|
const maskedSource = createWhitespaceMask(sourceText);
|
|
36119
36122
|
let astroRoot;
|
|
@@ -38057,13 +38060,6 @@ const discoverMobileEntryPoints = (directory) => {
|
|
|
38057
38060
|
}
|
|
38058
38061
|
};
|
|
38059
38062
|
//#endregion
|
|
38060
|
-
//#region ../core/src/utils/unwrap-typescript-expression.ts
|
|
38061
|
-
const unwrapTypescriptExpression = (expression) => {
|
|
38062
|
-
let currentExpression = expression;
|
|
38063
|
-
while (ts.isParenthesizedExpression(currentExpression) || ts.isAsExpression(currentExpression) || ts.isSatisfiesExpression(currentExpression) || ts.isNonNullExpression(currentExpression) || ts.isTypeAssertionExpression(currentExpression)) currentExpression = currentExpression.expression;
|
|
38064
|
-
return currentExpression;
|
|
38065
|
-
};
|
|
38066
|
-
//#endregion
|
|
38067
38063
|
//#region ../core/src/project-analysis/collect/expo-config-plugin-entries.ts
|
|
38068
38064
|
const EXPO_CONFIG_FILE_GLOBS = ["app.config.{ts,mts,cts,js,mjs,cjs}", "app.json"];
|
|
38069
38065
|
const NESTED_EXPO_CONFIG_FILE_GLOBS = [
|
|
@@ -38107,52 +38103,52 @@ const addExpoPluginEntry = (entries, packageNamePlugins, rootDirectory, configDi
|
|
|
38107
38103
|
entries.add(resolvedPath);
|
|
38108
38104
|
};
|
|
38109
38105
|
const getPropertyName$4 = (name) => {
|
|
38110
|
-
if (
|
|
38106
|
+
if (typescriptBinding.isIdentifier(name) || typescriptBinding.isStringLiteral(name) || typescriptBinding.isNumericLiteral(name)) return name.text;
|
|
38111
38107
|
};
|
|
38112
38108
|
const collectExpoPluginPathsFromArray = (array, entries, packageNamePlugins, rootDirectory, configDirectory) => {
|
|
38113
38109
|
for (const element of array.elements) {
|
|
38114
|
-
if (
|
|
38110
|
+
if (typescriptBinding.isStringLiteral(element) || typescriptBinding.isNoSubstitutionTemplateLiteral(element)) {
|
|
38115
38111
|
addExpoPluginEntry(entries, packageNamePlugins, rootDirectory, configDirectory, element.text);
|
|
38116
38112
|
continue;
|
|
38117
38113
|
}
|
|
38118
|
-
if (
|
|
38114
|
+
if (typescriptBinding.isArrayLiteralExpression(element)) {
|
|
38119
38115
|
const [pluginName] = element.elements;
|
|
38120
|
-
if (pluginName && (
|
|
38116
|
+
if (pluginName && (typescriptBinding.isStringLiteral(pluginName) || typescriptBinding.isNoSubstitutionTemplateLiteral(pluginName))) addExpoPluginEntry(entries, packageNamePlugins, rootDirectory, configDirectory, pluginName.text);
|
|
38121
38117
|
}
|
|
38122
38118
|
}
|
|
38123
38119
|
};
|
|
38124
38120
|
const collectExpoPluginPathsFromConfigObject = (objectLiteral, entries, packageNamePlugins, rootDirectory, configDirectory) => {
|
|
38125
38121
|
for (const property of objectLiteral.properties) {
|
|
38126
|
-
if (!
|
|
38122
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
38127
38123
|
const propertyName = getPropertyName$4(property.name);
|
|
38128
|
-
if (propertyName === "plugins" &&
|
|
38129
|
-
if (propertyName === "expo" &&
|
|
38124
|
+
if (propertyName === "plugins" && typescriptBinding.isArrayLiteralExpression(property.initializer)) collectExpoPluginPathsFromArray(property.initializer, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38125
|
+
if (propertyName === "expo" && typescriptBinding.isObjectLiteralExpression(property.initializer)) collectExpoPluginPathsFromConfigObject(property.initializer, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38130
38126
|
}
|
|
38131
38127
|
};
|
|
38132
38128
|
const collectReturnedExpoConfigPluginPaths = (body, entries, packageNamePlugins, rootDirectory, configDirectory) => {
|
|
38133
|
-
if (!
|
|
38129
|
+
if (!typescriptBinding.isBlock(body)) {
|
|
38134
38130
|
const expression = unwrapTypescriptExpression(body);
|
|
38135
|
-
if (
|
|
38131
|
+
if (typescriptBinding.isObjectLiteralExpression(expression)) collectExpoPluginPathsFromConfigObject(expression, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38136
38132
|
return;
|
|
38137
38133
|
}
|
|
38138
38134
|
const visit = (node) => {
|
|
38139
|
-
if (
|
|
38140
|
-
if (
|
|
38135
|
+
if (typescriptBinding.isFunctionDeclaration(node) || typescriptBinding.isFunctionExpression(node) || typescriptBinding.isArrowFunction(node)) return;
|
|
38136
|
+
if (typescriptBinding.isReturnStatement(node) && node.expression) {
|
|
38141
38137
|
const expression = unwrapTypescriptExpression(node.expression);
|
|
38142
|
-
if (
|
|
38138
|
+
if (typescriptBinding.isObjectLiteralExpression(expression)) collectExpoPluginPathsFromConfigObject(expression, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38143
38139
|
return;
|
|
38144
38140
|
}
|
|
38145
|
-
|
|
38141
|
+
typescriptBinding.forEachChild(node, visit);
|
|
38146
38142
|
};
|
|
38147
38143
|
visit(body);
|
|
38148
38144
|
};
|
|
38149
38145
|
const collectExpoPluginPathsFromConfigExpression = (expression, entries, packageNamePlugins, rootDirectory, configDirectory, bindings, seenIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
38150
38146
|
const configExpression = unwrapTypescriptExpression(expression);
|
|
38151
|
-
if (
|
|
38147
|
+
if (typescriptBinding.isObjectLiteralExpression(configExpression)) {
|
|
38152
38148
|
collectExpoPluginPathsFromConfigObject(configExpression, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38153
38149
|
return;
|
|
38154
38150
|
}
|
|
38155
|
-
if (
|
|
38151
|
+
if (typescriptBinding.isIdentifier(configExpression)) {
|
|
38156
38152
|
if (seenIdentifiers.has(configExpression.text)) return;
|
|
38157
38153
|
seenIdentifiers.add(configExpression.text);
|
|
38158
38154
|
const boundExpression = bindings.expressions.get(configExpression.text);
|
|
@@ -38164,23 +38160,23 @@ const collectExpoPluginPathsFromConfigExpression = (expression, entries, package
|
|
|
38164
38160
|
if (boundFunction?.body) collectReturnedExpoConfigPluginPaths(boundFunction.body, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38165
38161
|
return;
|
|
38166
38162
|
}
|
|
38167
|
-
if (
|
|
38163
|
+
if (typescriptBinding.isArrowFunction(configExpression)) {
|
|
38168
38164
|
collectReturnedExpoConfigPluginPaths(configExpression.body, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38169
38165
|
return;
|
|
38170
38166
|
}
|
|
38171
|
-
if (
|
|
38167
|
+
if (typescriptBinding.isFunctionExpression(configExpression) && configExpression.body) collectReturnedExpoConfigPluginPaths(configExpression.body, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38172
38168
|
};
|
|
38173
|
-
const hasDefaultExportModifier = (node) => Boolean(
|
|
38174
|
-
const isModuleExportsAssignmentTarget = (node) =>
|
|
38169
|
+
const hasDefaultExportModifier = (node) => Boolean(typescriptBinding.canHaveModifiers(node) && typescriptBinding.getModifiers(node)?.some((modifier) => modifier.kind === typescriptBinding.SyntaxKind.DefaultKeyword));
|
|
38170
|
+
const isModuleExportsAssignmentTarget = (node) => typescriptBinding.isPropertyAccessExpression(node) && typescriptBinding.isIdentifier(node.expression) && node.expression.text === "module" && node.name.text === "exports";
|
|
38175
38171
|
const collectStaticConfigBindings = (sourceFile) => {
|
|
38176
38172
|
const expressions = /* @__PURE__ */ new Map();
|
|
38177
38173
|
const functions = /* @__PURE__ */ new Map();
|
|
38178
38174
|
for (const statement of sourceFile.statements) {
|
|
38179
|
-
if (
|
|
38180
|
-
for (const declaration of statement.declarationList.declarations) if (
|
|
38175
|
+
if (typescriptBinding.isVariableStatement(statement)) {
|
|
38176
|
+
for (const declaration of statement.declarationList.declarations) if (typescriptBinding.isIdentifier(declaration.name) && declaration.initializer) expressions.set(declaration.name.text, declaration.initializer);
|
|
38181
38177
|
continue;
|
|
38182
38178
|
}
|
|
38183
|
-
if (
|
|
38179
|
+
if (typescriptBinding.isFunctionDeclaration(statement) && statement.name) functions.set(statement.name.text, statement);
|
|
38184
38180
|
}
|
|
38185
38181
|
return {
|
|
38186
38182
|
expressions,
|
|
@@ -38189,23 +38185,23 @@ const collectStaticConfigBindings = (sourceFile) => {
|
|
|
38189
38185
|
};
|
|
38190
38186
|
const collectExpoPluginPathsFromAppConfig = (configPath, entries, packageNamePlugins, rootDirectory) => {
|
|
38191
38187
|
const extension = extname(configPath);
|
|
38192
|
-
const sourceFile =
|
|
38188
|
+
const sourceFile = typescriptBinding.createSourceFile(configPath, readFileSync(configPath, "utf8"), typescriptBinding.ScriptTarget.Latest, true, extension === ".ts" || extension === ".mts" || extension === ".cts" ? typescriptBinding.ScriptKind.TS : typescriptBinding.ScriptKind.JS);
|
|
38193
38189
|
const configDirectory = dirname(configPath);
|
|
38194
38190
|
const bindings = collectStaticConfigBindings(sourceFile);
|
|
38195
38191
|
const visit = (node) => {
|
|
38196
|
-
if (
|
|
38192
|
+
if (typescriptBinding.isExportAssignment(node)) {
|
|
38197
38193
|
collectExpoPluginPathsFromConfigExpression(node.expression, entries, packageNamePlugins, rootDirectory, configDirectory, bindings);
|
|
38198
38194
|
return;
|
|
38199
38195
|
}
|
|
38200
|
-
if (
|
|
38196
|
+
if (typescriptBinding.isFunctionDeclaration(node) && hasDefaultExportModifier(node) && node.body) {
|
|
38201
38197
|
collectReturnedExpoConfigPluginPaths(node.body, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38202
38198
|
return;
|
|
38203
38199
|
}
|
|
38204
|
-
if (
|
|
38200
|
+
if (typescriptBinding.isBinaryExpression(node) && node.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken && isModuleExportsAssignmentTarget(node.left)) {
|
|
38205
38201
|
collectExpoPluginPathsFromConfigExpression(node.right, entries, packageNamePlugins, rootDirectory, configDirectory, bindings);
|
|
38206
38202
|
return;
|
|
38207
38203
|
}
|
|
38208
|
-
|
|
38204
|
+
typescriptBinding.forEachChild(node, visit);
|
|
38209
38205
|
};
|
|
38210
38206
|
visit(sourceFile);
|
|
38211
38207
|
};
|
|
@@ -38885,23 +38881,23 @@ const resolveGeneratedOutputs = (patterns, configDirectory) => {
|
|
|
38885
38881
|
};
|
|
38886
38882
|
const extractVitePluginConfigContents = (content) => {
|
|
38887
38883
|
const pluginConfigContents = [];
|
|
38888
|
-
const sourceFile =
|
|
38889
|
-
const pluginName = sourceFile.statements.find((statement) =>
|
|
38884
|
+
const sourceFile = typescriptBinding.createSourceFile("vite.config.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
38885
|
+
const pluginName = sourceFile.statements.find((statement) => typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === "vite-plugin-graphql-codegen" && statement.importClause?.name !== void 0)?.importClause?.name?.text;
|
|
38890
38886
|
if (!pluginName) return [];
|
|
38891
|
-
const exportAssignment = sourceFile.statements.find((statement) =>
|
|
38887
|
+
const exportAssignment = sourceFile.statements.find((statement) => typescriptBinding.isExportAssignment(statement) && !statement.isExportEquals);
|
|
38892
38888
|
if (!exportAssignment) return [];
|
|
38893
38889
|
const topLevelVariableInitializers = /* @__PURE__ */ new Map();
|
|
38894
38890
|
for (const statement of sourceFile.statements) {
|
|
38895
|
-
if (!
|
|
38896
|
-
for (const declaration of statement.declarationList.declarations) if (
|
|
38891
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
38892
|
+
for (const declaration of statement.declarationList.declarations) if (typescriptBinding.isIdentifier(declaration.name) && declaration.initializer) topLevelVariableInitializers.set(declaration.name.text, declaration.initializer);
|
|
38897
38893
|
}
|
|
38898
38894
|
const unwrapExpression = (expression) => {
|
|
38899
|
-
if (
|
|
38895
|
+
if (typescriptBinding.isParenthesizedExpression(expression) || typescriptBinding.isAsExpression(expression) || typescriptBinding.isSatisfiesExpression(expression)) return unwrapExpression(expression.expression);
|
|
38900
38896
|
return expression;
|
|
38901
38897
|
};
|
|
38902
38898
|
const collectPluginExpression = (expression, variableInitializers, isPluginNameShadowed, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
38903
38899
|
const unwrappedExpression = unwrapExpression(expression);
|
|
38904
|
-
if (
|
|
38900
|
+
if (typescriptBinding.isCallExpression(unwrappedExpression) && typescriptBinding.isIdentifier(unwrappedExpression.expression) && unwrappedExpression.expression.text === pluginName) {
|
|
38905
38901
|
const configArgument = unwrappedExpression.arguments[0];
|
|
38906
38902
|
if (configArgument && !isPluginNameShadowed) {
|
|
38907
38903
|
const bindingStatements = [...variableInitializers.entries()].map(([variableName, initializer]) => `const ${variableName} = (${initializer.getText(sourceFile)});`).join("\n");
|
|
@@ -38909,54 +38905,54 @@ const extractVitePluginConfigContents = (content) => {
|
|
|
38909
38905
|
}
|
|
38910
38906
|
return;
|
|
38911
38907
|
}
|
|
38912
|
-
if (
|
|
38908
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression) && !visitedIdentifiers.has(unwrappedExpression.text)) {
|
|
38913
38909
|
const initializer = variableInitializers.get(unwrappedExpression.text);
|
|
38914
38910
|
if (!initializer) return;
|
|
38915
38911
|
collectPluginExpression(initializer, variableInitializers, isPluginNameShadowed, new Set(visitedIdentifiers).add(unwrappedExpression.text));
|
|
38916
38912
|
return;
|
|
38917
38913
|
}
|
|
38918
|
-
if (
|
|
38919
|
-
for (const element of unwrappedExpression.elements) collectPluginExpression(
|
|
38914
|
+
if (typescriptBinding.isArrayLiteralExpression(unwrappedExpression)) {
|
|
38915
|
+
for (const element of unwrappedExpression.elements) collectPluginExpression(typescriptBinding.isSpreadElement(element) ? element.expression : element, variableInitializers, isPluginNameShadowed, visitedIdentifiers);
|
|
38920
38916
|
return;
|
|
38921
38917
|
}
|
|
38922
|
-
if (
|
|
38918
|
+
if (typescriptBinding.isConditionalExpression(unwrappedExpression)) {
|
|
38923
38919
|
collectPluginExpression(unwrappedExpression.whenTrue, variableInitializers, isPluginNameShadowed, visitedIdentifiers);
|
|
38924
38920
|
collectPluginExpression(unwrappedExpression.whenFalse, variableInitializers, isPluginNameShadowed, visitedIdentifiers);
|
|
38925
38921
|
return;
|
|
38926
38922
|
}
|
|
38927
|
-
if (
|
|
38923
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && (unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.AmpersandAmpersandToken || unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.BarBarToken || unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.QuestionQuestionToken)) {
|
|
38928
38924
|
collectPluginExpression(unwrappedExpression.left, variableInitializers, isPluginNameShadowed, visitedIdentifiers);
|
|
38929
38925
|
collectPluginExpression(unwrappedExpression.right, variableInitializers, isPluginNameShadowed, visitedIdentifiers);
|
|
38930
38926
|
}
|
|
38931
38927
|
};
|
|
38932
38928
|
const collectConfigPlugins = (expression, variableInitializers, isPluginNameShadowed, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
38933
38929
|
const unwrappedExpression = unwrapExpression(expression);
|
|
38934
|
-
if (
|
|
38930
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression) && !visitedIdentifiers.has(unwrappedExpression.text)) {
|
|
38935
38931
|
const initializer = variableInitializers.get(unwrappedExpression.text);
|
|
38936
38932
|
if (!initializer) return;
|
|
38937
38933
|
collectConfigPlugins(initializer, variableInitializers, isPluginNameShadowed, new Set(visitedIdentifiers).add(unwrappedExpression.text));
|
|
38938
38934
|
return;
|
|
38939
38935
|
}
|
|
38940
|
-
if (
|
|
38936
|
+
if (typescriptBinding.isCallExpression(unwrappedExpression)) {
|
|
38941
38937
|
const calledExpression = unwrapExpression(unwrappedExpression.expression);
|
|
38942
|
-
if (!
|
|
38938
|
+
if (!typescriptBinding.isIdentifier(calledExpression) || calledExpression.text !== "defineConfig") return;
|
|
38943
38939
|
const configArgument = unwrappedExpression.arguments[0];
|
|
38944
38940
|
if (!configArgument) return;
|
|
38945
38941
|
const unwrappedArgument = unwrapExpression(configArgument);
|
|
38946
|
-
if (
|
|
38947
|
-
let callbackPluginNameShadowed = isPluginNameShadowed || unwrappedArgument.parameters.some((parameter) =>
|
|
38948
|
-
if (!
|
|
38942
|
+
if (typescriptBinding.isArrowFunction(unwrappedArgument) || typescriptBinding.isFunctionExpression(unwrappedArgument)) {
|
|
38943
|
+
let callbackPluginNameShadowed = isPluginNameShadowed || unwrappedArgument.parameters.some((parameter) => typescriptBinding.isIdentifier(parameter.name) && parameter.name.text === pluginName);
|
|
38944
|
+
if (!typescriptBinding.isBlock(unwrappedArgument.body)) {
|
|
38949
38945
|
collectConfigPlugins(unwrappedArgument.body, variableInitializers, callbackPluginNameShadowed);
|
|
38950
38946
|
return;
|
|
38951
38947
|
}
|
|
38952
38948
|
const callbackVariableInitializers = new Map(variableInitializers);
|
|
38953
38949
|
for (const statement of unwrappedArgument.body.statements) {
|
|
38954
|
-
if (
|
|
38955
|
-
if (!
|
|
38950
|
+
if (typescriptBinding.isVariableStatement(statement)) for (const declaration of statement.declarationList.declarations) {
|
|
38951
|
+
if (!typescriptBinding.isIdentifier(declaration.name)) continue;
|
|
38956
38952
|
if (declaration.name.text === pluginName) callbackPluginNameShadowed = true;
|
|
38957
38953
|
if (declaration.initializer) callbackVariableInitializers.set(declaration.name.text, declaration.initializer);
|
|
38958
38954
|
}
|
|
38959
|
-
if (
|
|
38955
|
+
if (typescriptBinding.isReturnStatement(statement) && statement.expression) {
|
|
38960
38956
|
collectConfigPlugins(statement.expression, callbackVariableInitializers, callbackPluginNameShadowed);
|
|
38961
38957
|
return;
|
|
38962
38958
|
}
|
|
@@ -38966,10 +38962,10 @@ const extractVitePluginConfigContents = (content) => {
|
|
|
38966
38962
|
collectConfigPlugins(unwrappedArgument, variableInitializers, isPluginNameShadowed);
|
|
38967
38963
|
return;
|
|
38968
38964
|
}
|
|
38969
|
-
if (!
|
|
38965
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
38970
38966
|
for (const property of unwrappedExpression.properties) {
|
|
38971
|
-
if (
|
|
38972
|
-
if (
|
|
38967
|
+
if (typescriptBinding.isPropertyAssignment(property) && (typescriptBinding.isIdentifier(property.name) && property.name.text === "plugins" || typescriptBinding.isStringLiteral(property.name) && property.name.text === "plugins")) collectPluginExpression(property.initializer, variableInitializers, isPluginNameShadowed);
|
|
38968
|
+
if (typescriptBinding.isShorthandPropertyAssignment(property) && property.name.text === "plugins") collectPluginExpression(property.name, variableInitializers, isPluginNameShadowed);
|
|
38973
38969
|
}
|
|
38974
38970
|
};
|
|
38975
38971
|
collectConfigPlugins(exportAssignment.expression, topLevelVariableInitializers, false);
|
|
@@ -39093,24 +39089,24 @@ const TARO_ARRAY_SELECTION_METHODS = new Set([
|
|
|
39093
39089
|
"splice"
|
|
39094
39090
|
]);
|
|
39095
39091
|
const getPropertyName$2 = (propertyName) => {
|
|
39096
|
-
if (
|
|
39092
|
+
if (typescriptBinding.isIdentifier(propertyName) || typescriptBinding.isStringLiteral(propertyName) || typescriptBinding.isNoSubstitutionTemplateLiteral(propertyName)) return propertyName.text;
|
|
39097
39093
|
};
|
|
39098
39094
|
const unwrapConfigExpression = (expression) => {
|
|
39099
|
-
if (
|
|
39100
|
-
if (
|
|
39095
|
+
if (typescriptBinding.isParenthesizedExpression(expression) || typescriptBinding.isAsExpression(expression) || typescriptBinding.isSatisfiesExpression(expression)) return unwrapConfigExpression(expression.expression);
|
|
39096
|
+
if (typescriptBinding.isCallExpression(expression)) {
|
|
39101
39097
|
const [configArgument] = expression.arguments;
|
|
39102
39098
|
return configArgument ? unwrapConfigExpression(configArgument) : expression;
|
|
39103
39099
|
}
|
|
39104
39100
|
return expression;
|
|
39105
39101
|
};
|
|
39106
39102
|
const unwrapArrayExpression = (expression) => {
|
|
39107
|
-
if (
|
|
39103
|
+
if (typescriptBinding.isParenthesizedExpression(expression) || typescriptBinding.isAsExpression(expression) || typescriptBinding.isSatisfiesExpression(expression)) return unwrapArrayExpression(expression.expression);
|
|
39108
39104
|
return expression;
|
|
39109
39105
|
};
|
|
39110
39106
|
const getPropertyInitializer = (objectLiteral, propertyNames) => {
|
|
39111
39107
|
for (const property of objectLiteral.properties) {
|
|
39112
|
-
if (
|
|
39113
|
-
if (!
|
|
39108
|
+
if (typescriptBinding.isShorthandPropertyAssignment(property) && propertyNames.has(property.name.text)) return property.name;
|
|
39109
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
39114
39110
|
const propertyName = getPropertyName$2(property.name);
|
|
39115
39111
|
if (propertyName && propertyNames.has(propertyName)) return property.initializer;
|
|
39116
39112
|
}
|
|
@@ -39118,16 +39114,16 @@ const getPropertyInitializer = (objectLiteral, propertyNames) => {
|
|
|
39118
39114
|
const collectArrayElements = (expression, variableInitializers, pushedElements, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
39119
39115
|
if (!expression) return [];
|
|
39120
39116
|
const unwrappedExpression = unwrapArrayExpression(expression);
|
|
39121
|
-
if (
|
|
39122
|
-
if (
|
|
39123
|
-
if (
|
|
39124
|
-
if (
|
|
39117
|
+
if (typescriptBinding.isArrayLiteralExpression(unwrappedExpression)) return [...unwrappedExpression.elements];
|
|
39118
|
+
if (typescriptBinding.isConditionalExpression(unwrappedExpression)) return [...collectArrayElements(unwrappedExpression.whenTrue, variableInitializers, pushedElements, visitedIdentifiers), ...collectArrayElements(unwrappedExpression.whenFalse, variableInitializers, pushedElements, visitedIdentifiers)];
|
|
39119
|
+
if (typescriptBinding.isCallExpression(unwrappedExpression) && typescriptBinding.isPropertyAccessExpression(unwrappedExpression.expression) && TARO_ARRAY_SELECTION_METHODS.has(unwrappedExpression.expression.name.text)) return collectArrayElements(unwrappedExpression.expression.expression, variableInitializers, pushedElements, visitedIdentifiers);
|
|
39120
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression) && !visitedIdentifiers.has(unwrappedExpression.text)) {
|
|
39125
39121
|
const nextVisitedIdentifiers = new Set(visitedIdentifiers).add(unwrappedExpression.text);
|
|
39126
39122
|
return [...collectArrayElements(variableInitializers.get(unwrappedExpression.text), variableInitializers, pushedElements, nextVisitedIdentifiers), ...pushedElements.get(unwrappedExpression.text) ?? []];
|
|
39127
39123
|
}
|
|
39128
39124
|
return [];
|
|
39129
39125
|
};
|
|
39130
|
-
const collectPagePaths = (expression, variableInitializers, pushedElements) => collectArrayElements(expression, variableInitializers, pushedElements).flatMap((element) =>
|
|
39126
|
+
const collectPagePaths = (expression, variableInitializers, pushedElements) => collectArrayElements(expression, variableInitializers, pushedElements).flatMap((element) => typescriptBinding.isStringLiteral(element) || typescriptBinding.isNoSubstitutionTemplateLiteral(element) ? [element.text] : []);
|
|
39131
39127
|
const resolvePageEntries = (configDirectory, pagePaths) => pagePaths.flatMap((pagePath) => {
|
|
39132
39128
|
const resolvedEntry = resolveEntryWithExtensions(resolve(configDirectory, pagePath));
|
|
39133
39129
|
return resolvedEntry ? [resolvedEntry] : [];
|
|
@@ -39136,9 +39132,9 @@ const collectConfigPageEntries = (configDirectory, configObject, variableInitial
|
|
|
39136
39132
|
const entries = resolvePageEntries(configDirectory, collectPagePaths(getPropertyInitializer(configObject, new Set(["pages"])), variableInitializers, pushedElements));
|
|
39137
39133
|
const subPackagesExpression = getPropertyInitializer(configObject, new Set(["subPackages", "subpackages"]));
|
|
39138
39134
|
for (const subPackageElement of collectArrayElements(subPackagesExpression, variableInitializers, pushedElements)) {
|
|
39139
|
-
if (!
|
|
39135
|
+
if (!typescriptBinding.isObjectLiteralExpression(subPackageElement)) continue;
|
|
39140
39136
|
const rootExpression = getPropertyInitializer(subPackageElement, new Set(["root"]));
|
|
39141
|
-
if (!rootExpression || !
|
|
39137
|
+
if (!rootExpression || !typescriptBinding.isStringLiteral(rootExpression) && !typescriptBinding.isNoSubstitutionTemplateLiteral(rootExpression)) continue;
|
|
39142
39138
|
const subPackagePages = collectPagePaths(getPropertyInitializer(subPackageElement, new Set(["pages"])), variableInitializers, pushedElements).map((pagePath) => `${rootExpression.text}/${pagePath}`);
|
|
39143
39139
|
entries.push(...resolvePageEntries(configDirectory, subPackagePages));
|
|
39144
39140
|
}
|
|
@@ -39147,56 +39143,56 @@ const collectConfigPageEntries = (configDirectory, configObject, variableInitial
|
|
|
39147
39143
|
const collectVariableInitializers = (sourceFile) => {
|
|
39148
39144
|
const variableInitializers = /* @__PURE__ */ new Map();
|
|
39149
39145
|
for (const statement of sourceFile.statements) {
|
|
39150
|
-
if (!
|
|
39151
|
-
for (const declaration of statement.declarationList.declarations) if (
|
|
39146
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
39147
|
+
for (const declaration of statement.declarationList.declarations) if (typescriptBinding.isIdentifier(declaration.name) && declaration.initializer) variableInitializers.set(declaration.name.text, declaration.initializer);
|
|
39152
39148
|
}
|
|
39153
39149
|
return variableInitializers;
|
|
39154
39150
|
};
|
|
39155
39151
|
const collectShadowedBindingNames = (bindingName, topLevelVariableNames) => {
|
|
39156
|
-
if (
|
|
39157
|
-
return bindingName.elements.flatMap((bindingElement) =>
|
|
39152
|
+
if (typescriptBinding.isIdentifier(bindingName)) return topLevelVariableNames.has(bindingName.text) ? [bindingName.text] : [];
|
|
39153
|
+
return bindingName.elements.flatMap((bindingElement) => typescriptBinding.isBindingElement(bindingElement) ? collectShadowedBindingNames(bindingElement.name, topLevelVariableNames) : []);
|
|
39158
39154
|
};
|
|
39159
39155
|
const collectPushedElements = (sourceFile, topLevelVariableNames) => {
|
|
39160
39156
|
const pushedElements = /* @__PURE__ */ new Map();
|
|
39161
39157
|
const visitNode = (node, shadowedNames) => {
|
|
39162
|
-
if (
|
|
39158
|
+
if (typescriptBinding.isFunctionDeclaration(node) || typescriptBinding.isFunctionExpression(node) || typescriptBinding.isArrowFunction(node) || typescriptBinding.isMethodDeclaration(node) || typescriptBinding.isGetAccessorDeclaration(node) || typescriptBinding.isSetAccessorDeclaration(node) || typescriptBinding.isConstructorDeclaration(node)) return;
|
|
39163
39159
|
let nextShadowedNames = shadowedNames;
|
|
39164
39160
|
const shadowBindingNames = (bindingNames) => {
|
|
39165
39161
|
const newlyShadowedNames = bindingNames.flatMap((bindingName) => collectShadowedBindingNames(bindingName, topLevelVariableNames));
|
|
39166
39162
|
if (newlyShadowedNames.length > 0) nextShadowedNames = new Set([...nextShadowedNames, ...newlyShadowedNames]);
|
|
39167
39163
|
};
|
|
39168
|
-
if (
|
|
39169
|
-
if (!
|
|
39164
|
+
if (typescriptBinding.isBlock(node)) shadowBindingNames(node.statements.flatMap((statement) => {
|
|
39165
|
+
if (!typescriptBinding.isVariableStatement(statement) || !(statement.declarationList.flags & typescriptBinding.NodeFlags.BlockScoped)) return [];
|
|
39170
39166
|
return statement.declarationList.declarations.map((declaration) => declaration.name);
|
|
39171
39167
|
}));
|
|
39172
|
-
if (
|
|
39173
|
-
if (
|
|
39168
|
+
if (typescriptBinding.isCatchClause(node) && node.variableDeclaration) shadowBindingNames([node.variableDeclaration.name]);
|
|
39169
|
+
if (typescriptBinding.isForStatement(node) || typescriptBinding.isForInStatement(node) || typescriptBinding.isForOfStatement(node)) {
|
|
39174
39170
|
const initializer = node.initializer;
|
|
39175
|
-
if (initializer &&
|
|
39171
|
+
if (initializer && typescriptBinding.isVariableDeclarationList(initializer) && initializer.flags & typescriptBinding.NodeFlags.BlockScoped) shadowBindingNames(initializer.declarations.map((declaration) => declaration.name));
|
|
39176
39172
|
}
|
|
39177
|
-
if (
|
|
39173
|
+
if (typescriptBinding.isCallExpression(node) && typescriptBinding.isPropertyAccessExpression(node.expression) && node.expression.name.text === "push" && typescriptBinding.isIdentifier(node.expression.expression) && topLevelVariableNames.has(node.expression.expression.text) && !nextShadowedNames.has(node.expression.expression.text)) {
|
|
39178
39174
|
const identifier = node.expression.expression.text;
|
|
39179
39175
|
const existingElements = pushedElements.get(identifier) ?? [];
|
|
39180
39176
|
existingElements.push(...node.arguments);
|
|
39181
39177
|
pushedElements.set(identifier, existingElements);
|
|
39182
39178
|
}
|
|
39183
|
-
|
|
39179
|
+
typescriptBinding.forEachChild(node, (childNode) => visitNode(childNode, nextShadowedNames));
|
|
39184
39180
|
};
|
|
39185
39181
|
visitNode(sourceFile, /* @__PURE__ */ new Set());
|
|
39186
39182
|
return pushedElements;
|
|
39187
39183
|
};
|
|
39188
39184
|
const extractConfigObject = (sourceFile, variableInitializers) => {
|
|
39189
39185
|
for (const statement of sourceFile.statements) {
|
|
39190
|
-
if (!
|
|
39186
|
+
if (!typescriptBinding.isExportAssignment(statement) || statement.isExportEquals) continue;
|
|
39191
39187
|
let expression = unwrapConfigExpression(statement.expression);
|
|
39192
39188
|
const visitedIdentifiers = /* @__PURE__ */ new Set();
|
|
39193
|
-
while (
|
|
39189
|
+
while (typescriptBinding.isIdentifier(expression) && !visitedIdentifiers.has(expression.text)) {
|
|
39194
39190
|
visitedIdentifiers.add(expression.text);
|
|
39195
39191
|
const initializer = variableInitializers.get(expression.text);
|
|
39196
39192
|
if (!initializer) break;
|
|
39197
39193
|
expression = unwrapConfigExpression(initializer);
|
|
39198
39194
|
}
|
|
39199
|
-
if (
|
|
39195
|
+
if (typescriptBinding.isObjectLiteralExpression(expression)) return expression;
|
|
39200
39196
|
}
|
|
39201
39197
|
};
|
|
39202
39198
|
const extractTaroPageEntries = (directory, dependencies) => {
|
|
@@ -39209,7 +39205,7 @@ const extractTaroPageEntries = (directory, dependencies) => {
|
|
|
39209
39205
|
});
|
|
39210
39206
|
for (const configPath of configPaths) try {
|
|
39211
39207
|
const sourceText = readFileSync(configPath, "utf8");
|
|
39212
|
-
const sourceFile =
|
|
39208
|
+
const sourceFile = typescriptBinding.createSourceFile(configPath, sourceText, typescriptBinding.ScriptTarget.Latest, true);
|
|
39213
39209
|
const variableInitializers = collectVariableInitializers(sourceFile);
|
|
39214
39210
|
const pushedElements = collectPushedElements(sourceFile, new Set(variableInitializers.keys()));
|
|
39215
39211
|
const configObject = extractConfigObject(sourceFile, variableInitializers);
|
|
@@ -39680,20 +39676,20 @@ const extractJestModuleNameMapperAliases = (content, configDirectory) => {
|
|
|
39680
39676
|
const extractWebpackModuleDirectories = (content, configDirectory) => {
|
|
39681
39677
|
const moduleDirectories = [];
|
|
39682
39678
|
const moduleDirectoryNames = [];
|
|
39683
|
-
const sourceFile =
|
|
39679
|
+
const sourceFile = typescriptBinding.createSourceFile("webpack.config.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
39684
39680
|
const variableInitializers = /* @__PURE__ */ new Map();
|
|
39685
39681
|
for (const statement of sourceFile.statements) {
|
|
39686
|
-
if (!
|
|
39687
|
-
for (const declaration of statement.declarationList.declarations) if (
|
|
39682
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
39683
|
+
for (const declaration of statement.declarationList.declarations) if (typescriptBinding.isIdentifier(declaration.name) && declaration.initializer) variableInitializers.set(declaration.name.text, declaration.initializer);
|
|
39688
39684
|
}
|
|
39689
39685
|
const unwrapExpression = (expression) => {
|
|
39690
|
-
if (
|
|
39686
|
+
if (typescriptBinding.isParenthesizedExpression(expression) || typescriptBinding.isAsExpression(expression) || typescriptBinding.isSatisfiesExpression(expression)) return unwrapExpression(expression.expression);
|
|
39691
39687
|
return expression;
|
|
39692
39688
|
};
|
|
39693
39689
|
const resolveObjectExpression = (expression, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
39694
39690
|
const unwrappedExpression = unwrapExpression(expression);
|
|
39695
|
-
if (
|
|
39696
|
-
if (
|
|
39691
|
+
if (typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return unwrappedExpression;
|
|
39692
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression) && !visitedIdentifiers.has(unwrappedExpression.text)) {
|
|
39697
39693
|
const initializer = variableInitializers.get(unwrappedExpression.text);
|
|
39698
39694
|
if (!initializer) return void 0;
|
|
39699
39695
|
return resolveObjectExpression(initializer, new Set(visitedIdentifiers).add(unwrappedExpression.text));
|
|
@@ -39701,82 +39697,82 @@ const extractWebpackModuleDirectories = (content, configDirectory) => {
|
|
|
39701
39697
|
};
|
|
39702
39698
|
const collectModules = (resolveObject) => {
|
|
39703
39699
|
for (const property of resolveObject.properties) {
|
|
39704
|
-
if (!
|
|
39705
|
-
const propertyName =
|
|
39700
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
39701
|
+
const propertyName = typescriptBinding.isIdentifier(property.name) || typescriptBinding.isStringLiteral(property.name) ? property.name.text : void 0;
|
|
39706
39702
|
if (propertyName !== "modules" && propertyName !== "modulesDirectories") continue;
|
|
39707
|
-
if (!
|
|
39703
|
+
if (!typescriptBinding.isArrayLiteralExpression(property.initializer)) continue;
|
|
39708
39704
|
for (const element of property.initializer.elements) {
|
|
39709
|
-
if (
|
|
39705
|
+
if (typescriptBinding.isStringLiteral(element) || typescriptBinding.isNoSubstitutionTemplateLiteral(element)) {
|
|
39710
39706
|
if (element.text === "node_modules") continue;
|
|
39711
39707
|
if (element.text.startsWith(".") || element.text.includes("/")) moduleDirectories.push(resolveConfigPathValue(element.text, configDirectory));
|
|
39712
39708
|
else moduleDirectoryNames.push(element.text);
|
|
39713
39709
|
continue;
|
|
39714
39710
|
}
|
|
39715
|
-
if (!
|
|
39711
|
+
if (!typescriptBinding.isCallExpression(element)) continue;
|
|
39716
39712
|
const calledExpression = element.expression;
|
|
39717
|
-
if (!
|
|
39718
|
-
const pathSegments = element.arguments.slice(1).flatMap((argument) =>
|
|
39713
|
+
if (!typescriptBinding.isPropertyAccessExpression(calledExpression) || !typescriptBinding.isIdentifier(calledExpression.expression) || calledExpression.expression.text !== "path" || calledExpression.name.text !== "resolve" && calledExpression.name.text !== "join") continue;
|
|
39714
|
+
const pathSegments = element.arguments.slice(1).flatMap((argument) => typescriptBinding.isStringLiteral(argument) || typescriptBinding.isNoSubstitutionTemplateLiteral(argument) ? [argument.text] : []);
|
|
39719
39715
|
if (pathSegments.length > 0) moduleDirectories.push(resolve(configDirectory, ...pathSegments));
|
|
39720
39716
|
}
|
|
39721
39717
|
}
|
|
39722
39718
|
};
|
|
39723
39719
|
const collectConfigExpression = (expression, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
39724
39720
|
const unwrappedExpression = unwrapExpression(expression);
|
|
39725
|
-
if (
|
|
39721
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken) {
|
|
39726
39722
|
collectConfigExpression(unwrappedExpression.right, visitedIdentifiers);
|
|
39727
39723
|
return;
|
|
39728
39724
|
}
|
|
39729
|
-
if (
|
|
39725
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) {
|
|
39730
39726
|
if (visitedIdentifiers.has(unwrappedExpression.text)) return;
|
|
39731
39727
|
const initializer = variableInitializers.get(unwrappedExpression.text);
|
|
39732
39728
|
if (!initializer) return;
|
|
39733
39729
|
collectConfigExpression(initializer, new Set(visitedIdentifiers).add(unwrappedExpression.text));
|
|
39734
39730
|
return;
|
|
39735
39731
|
}
|
|
39736
|
-
if (
|
|
39737
|
-
for (const element of unwrappedExpression.elements) if (
|
|
39732
|
+
if (typescriptBinding.isArrayLiteralExpression(unwrappedExpression)) {
|
|
39733
|
+
for (const element of unwrappedExpression.elements) if (typescriptBinding.isSpreadElement(element)) collectConfigExpression(element.expression, visitedIdentifiers);
|
|
39738
39734
|
else collectConfigExpression(element, visitedIdentifiers);
|
|
39739
39735
|
return;
|
|
39740
39736
|
}
|
|
39741
|
-
if (
|
|
39737
|
+
if (typescriptBinding.isConditionalExpression(unwrappedExpression)) {
|
|
39742
39738
|
collectConfigExpression(unwrappedExpression.whenTrue, visitedIdentifiers);
|
|
39743
39739
|
collectConfigExpression(unwrappedExpression.whenFalse, visitedIdentifiers);
|
|
39744
39740
|
return;
|
|
39745
39741
|
}
|
|
39746
|
-
if (
|
|
39747
|
-
if (!
|
|
39742
|
+
if (typescriptBinding.isArrowFunction(unwrappedExpression) || typescriptBinding.isFunctionExpression(unwrappedExpression)) {
|
|
39743
|
+
if (!typescriptBinding.isBlock(unwrappedExpression.body)) {
|
|
39748
39744
|
collectConfigExpression(unwrappedExpression.body, visitedIdentifiers);
|
|
39749
39745
|
return;
|
|
39750
39746
|
}
|
|
39751
|
-
for (const statement of unwrappedExpression.body.statements) if (
|
|
39747
|
+
for (const statement of unwrappedExpression.body.statements) if (typescriptBinding.isReturnStatement(statement) && statement.expression) collectConfigExpression(statement.expression, visitedIdentifiers);
|
|
39752
39748
|
return;
|
|
39753
39749
|
}
|
|
39754
|
-
if (!
|
|
39750
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
39755
39751
|
for (const property of unwrappedExpression.properties) {
|
|
39756
|
-
if (
|
|
39752
|
+
if (typescriptBinding.isSpreadAssignment(property)) {
|
|
39757
39753
|
collectConfigExpression(property.expression, visitedIdentifiers);
|
|
39758
39754
|
continue;
|
|
39759
39755
|
}
|
|
39760
|
-
if (
|
|
39756
|
+
if (typescriptBinding.isShorthandPropertyAssignment(property) && property.name.text === "resolve") {
|
|
39761
39757
|
const resolveObject = resolveObjectExpression(property.name);
|
|
39762
39758
|
if (resolveObject) collectModules(resolveObject);
|
|
39763
39759
|
continue;
|
|
39764
39760
|
}
|
|
39765
|
-
if (!
|
|
39766
|
-
if ((
|
|
39761
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
39762
|
+
if ((typescriptBinding.isIdentifier(property.name) || typescriptBinding.isStringLiteral(property.name) ? property.name.text : void 0) !== "resolve") continue;
|
|
39767
39763
|
const resolveObject = resolveObjectExpression(property.initializer);
|
|
39768
39764
|
if (resolveObject) collectModules(resolveObject);
|
|
39769
39765
|
}
|
|
39770
39766
|
};
|
|
39771
|
-
const isModuleExports = (expression) =>
|
|
39767
|
+
const isModuleExports = (expression) => typescriptBinding.isPropertyAccessExpression(expression) && typescriptBinding.isIdentifier(expression.expression) && expression.expression.text === "module" && expression.name.text === "exports";
|
|
39772
39768
|
const collectModuleExportsAssignment = (expression) => {
|
|
39773
|
-
if (
|
|
39769
|
+
if (typescriptBinding.isBinaryExpression(expression) && expression.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken) if (isModuleExports(expression.left)) collectConfigExpression(expression.right);
|
|
39774
39770
|
else collectModuleExportsAssignment(expression.right);
|
|
39775
39771
|
};
|
|
39776
39772
|
for (const statement of sourceFile.statements) {
|
|
39777
|
-
if (
|
|
39778
|
-
if (
|
|
39779
|
-
if (
|
|
39773
|
+
if (typescriptBinding.isExportAssignment(statement) && !statement.isExportEquals) collectConfigExpression(statement.expression);
|
|
39774
|
+
if (typescriptBinding.isExpressionStatement(statement)) collectModuleExportsAssignment(statement.expression);
|
|
39775
|
+
if (typescriptBinding.isVariableStatement(statement)) {
|
|
39780
39776
|
for (const declaration of statement.declarationList.declarations) if (declaration.initializer) collectModuleExportsAssignment(declaration.initializer);
|
|
39781
39777
|
}
|
|
39782
39778
|
}
|
|
@@ -40540,20 +40536,20 @@ const extractImportSpecifiers = (sourceText) => {
|
|
|
40540
40536
|
};
|
|
40541
40537
|
const extractStylelintPluginSpecifiers = (sourceText) => {
|
|
40542
40538
|
const specifiers = [];
|
|
40543
|
-
const sourceFile =
|
|
40539
|
+
const sourceFile = typescriptBinding.createSourceFile("stylelint.config.mjs", sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
40544
40540
|
const collectStringLiterals = (node) => {
|
|
40545
|
-
if (
|
|
40541
|
+
if (typescriptBinding.isStringLiteralLike(node)) {
|
|
40546
40542
|
specifiers.push(node.text);
|
|
40547
40543
|
return;
|
|
40548
40544
|
}
|
|
40549
|
-
|
|
40545
|
+
typescriptBinding.forEachChild(node, collectStringLiterals);
|
|
40550
40546
|
};
|
|
40551
40547
|
const visitNode = (node) => {
|
|
40552
|
-
if (
|
|
40548
|
+
if (typescriptBinding.isPropertyAssignment(node) && (typescriptBinding.isIdentifier(node.name) || typescriptBinding.isStringLiteralLike(node.name)) && node.name.text === "plugins") {
|
|
40553
40549
|
collectStringLiterals(node.initializer);
|
|
40554
40550
|
return;
|
|
40555
40551
|
}
|
|
40556
|
-
|
|
40552
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
40557
40553
|
};
|
|
40558
40554
|
visitNode(sourceFile);
|
|
40559
40555
|
return specifiers;
|
|
@@ -41012,17 +41008,17 @@ const isPathInsideDirectoryOrEqual = (candidatePath, directoryPath) => {
|
|
|
41012
41008
|
//#region ../core/src/project-analysis/collect/static-globby-entries.ts
|
|
41013
41009
|
const getCalledName = (expression) => {
|
|
41014
41010
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41015
|
-
if (
|
|
41016
|
-
if (
|
|
41011
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) return unwrappedExpression.text;
|
|
41012
|
+
if (typescriptBinding.isPropertyAccessExpression(unwrappedExpression)) return unwrappedExpression.name.text;
|
|
41017
41013
|
};
|
|
41018
41014
|
const isImportMetaUrl = (expression) => {
|
|
41019
41015
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41020
|
-
return
|
|
41016
|
+
return typescriptBinding.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "url" && typescriptBinding.isMetaProperty(unwrappedExpression.expression) && unwrappedExpression.expression.keywordToken === typescriptBinding.SyntaxKind.ImportKeyword;
|
|
41021
41017
|
};
|
|
41022
41018
|
const evaluateDirectoryExpression = (expression, context, seenIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
41023
41019
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41024
|
-
if (
|
|
41025
|
-
if (
|
|
41020
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) return resolve(dirname(context.entryFilePath), unwrappedExpression.text);
|
|
41021
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) {
|
|
41026
41022
|
if (unwrappedExpression.text === "__dirname") return dirname(context.entryFilePath);
|
|
41027
41023
|
if (seenIdentifiers.has(unwrappedExpression.text)) return void 0;
|
|
41028
41024
|
const initializer = context.variableDeclarations.get(unwrappedExpression.text);
|
|
@@ -41031,10 +41027,10 @@ const evaluateDirectoryExpression = (expression, context, seenIdentifiers = /* @
|
|
|
41031
41027
|
nextSeenIdentifiers.add(unwrappedExpression.text);
|
|
41032
41028
|
return evaluateDirectoryExpression(initializer, context, nextSeenIdentifiers);
|
|
41033
41029
|
}
|
|
41034
|
-
if (
|
|
41035
|
-
if (!
|
|
41030
|
+
if (typescriptBinding.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "dirname" && typescriptBinding.isMetaProperty(unwrappedExpression.expression) && unwrappedExpression.expression.keywordToken === typescriptBinding.SyntaxKind.ImportKeyword) return dirname(context.entryFilePath);
|
|
41031
|
+
if (!typescriptBinding.isCallExpression(unwrappedExpression)) return void 0;
|
|
41036
41032
|
const calledName = getCalledName(unwrappedExpression.expression);
|
|
41037
|
-
if (calledName === "cwd" &&
|
|
41033
|
+
if (calledName === "cwd" && typescriptBinding.isPropertyAccessExpression(unwrappedExpression.expression) && typescriptBinding.isIdentifier(unwrappedExpression.expression.expression) && unwrappedExpression.expression.expression.text === "process") return context.projectRoot;
|
|
41038
41034
|
if (calledName === "fileURLToPath" && unwrappedExpression.arguments[0] && isImportMetaUrl(unwrappedExpression.arguments[0])) return context.entryFilePath;
|
|
41039
41035
|
if (calledName === "dirname" && unwrappedExpression.arguments[0]) {
|
|
41040
41036
|
const evaluatedPath = evaluateDirectoryExpression(unwrappedExpression.arguments[0], context, seenIdentifiers);
|
|
@@ -41048,19 +41044,19 @@ const evaluateDirectoryExpression = (expression, context, seenIdentifiers = /* @
|
|
|
41048
41044
|
const pathSegments = [];
|
|
41049
41045
|
for (const segmentExpression of segmentExpressions) {
|
|
41050
41046
|
const unwrappedSegment = unwrapTypescriptExpression(segmentExpression);
|
|
41051
|
-
if (!
|
|
41047
|
+
if (!typescriptBinding.isStringLiteralLike(unwrappedSegment)) return void 0;
|
|
41052
41048
|
pathSegments.push(unwrappedSegment.text);
|
|
41053
41049
|
}
|
|
41054
41050
|
return calledName === "join" ? join(baseDirectory, ...pathSegments) : resolve(baseDirectory, ...pathSegments);
|
|
41055
41051
|
};
|
|
41056
41052
|
const collectStaticPatterns = (expression) => {
|
|
41057
41053
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41058
|
-
if (
|
|
41059
|
-
if (!
|
|
41054
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) return [unwrappedExpression.text];
|
|
41055
|
+
if (!typescriptBinding.isArrayLiteralExpression(unwrappedExpression)) return [];
|
|
41060
41056
|
const patterns = [];
|
|
41061
41057
|
for (const element of unwrappedExpression.elements) {
|
|
41062
41058
|
const unwrappedElement = unwrapTypescriptExpression(element);
|
|
41063
|
-
if (!
|
|
41059
|
+
if (!typescriptBinding.isStringLiteralLike(unwrappedElement)) return [];
|
|
41064
41060
|
patterns.push(unwrappedElement.text);
|
|
41065
41061
|
}
|
|
41066
41062
|
return patterns;
|
|
@@ -41068,16 +41064,16 @@ const collectStaticPatterns = (expression) => {
|
|
|
41068
41064
|
const findCwdExpression = (expression) => {
|
|
41069
41065
|
if (!expression) return void 0;
|
|
41070
41066
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41071
|
-
if (!
|
|
41067
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return void 0;
|
|
41072
41068
|
for (const property of unwrappedExpression.properties) {
|
|
41073
|
-
if (!
|
|
41074
|
-
if ((
|
|
41069
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
41070
|
+
if ((typescriptBinding.isIdentifier(property.name) || typescriptBinding.isStringLiteralLike(property.name) ? property.name.text : void 0) === "cwd") return property.initializer;
|
|
41075
41071
|
}
|
|
41076
41072
|
};
|
|
41077
41073
|
const collectGlobbyLocalNames = (sourceFile) => {
|
|
41078
41074
|
const localNames = /* @__PURE__ */ new Set();
|
|
41079
41075
|
for (const statement of sourceFile.statements) {
|
|
41080
|
-
if (!
|
|
41076
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "globby" || !statement.importClause?.namedBindings || !typescriptBinding.isNamedImports(statement.importClause.namedBindings)) continue;
|
|
41081
41077
|
for (const element of statement.importClause.namedBindings.elements) {
|
|
41082
41078
|
const importedName = element.propertyName?.text ?? element.name.text;
|
|
41083
41079
|
if (importedName === "globby" || importedName === "globbySync") localNames.add(element.name.text);
|
|
@@ -41088,8 +41084,8 @@ const collectGlobbyLocalNames = (sourceFile) => {
|
|
|
41088
41084
|
const collectVariableDeclarations = (sourceFile) => {
|
|
41089
41085
|
const declarations = /* @__PURE__ */ new Map();
|
|
41090
41086
|
const visitNode = (node) => {
|
|
41091
|
-
if (
|
|
41092
|
-
|
|
41087
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer) declarations.set(node.name.text, node.initializer);
|
|
41088
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
41093
41089
|
};
|
|
41094
41090
|
visitNode(sourceFile);
|
|
41095
41091
|
return declarations;
|
|
@@ -41103,7 +41099,7 @@ const extractGlobbyEntriesFromFile = (entryFilePath, projectRoot) => {
|
|
|
41103
41099
|
return [];
|
|
41104
41100
|
}
|
|
41105
41101
|
if (!sourceText.includes("globby")) return [];
|
|
41106
|
-
const sourceFile =
|
|
41102
|
+
const sourceFile = typescriptBinding.createSourceFile(entryFilePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TSX);
|
|
41107
41103
|
const globbyLocalNames = collectGlobbyLocalNames(sourceFile);
|
|
41108
41104
|
if (globbyLocalNames.size === 0) return [];
|
|
41109
41105
|
const context = {
|
|
@@ -41114,7 +41110,7 @@ const extractGlobbyEntriesFromFile = (entryFilePath, projectRoot) => {
|
|
|
41114
41110
|
};
|
|
41115
41111
|
const entries = /* @__PURE__ */ new Set();
|
|
41116
41112
|
const visitNode = (node) => {
|
|
41117
|
-
if (
|
|
41113
|
+
if (typescriptBinding.isCallExpression(node) && typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.expression)) && globbyLocalNames.has(unwrapTypescriptExpression(node.expression).getText()) && node.arguments[0]) {
|
|
41118
41114
|
const patterns = collectStaticPatterns(node.arguments[0]);
|
|
41119
41115
|
const cwdExpression = findCwdExpression(node.arguments[1]);
|
|
41120
41116
|
const workingDirectory = cwdExpression ? evaluateDirectoryExpression(cwdExpression, context) : dirname(entryFilePath);
|
|
@@ -41127,7 +41123,7 @@ const extractGlobbyEntriesFromFile = (entryFilePath, projectRoot) => {
|
|
|
41127
41123
|
})) if (isPathInsideDirectoryOrEqual(filePath, projectRoot) && DEFAULT_EXTENSIONS.some((extension) => filePath.endsWith(extension))) entries.add(filePath);
|
|
41128
41124
|
}
|
|
41129
41125
|
}
|
|
41130
|
-
|
|
41126
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
41131
41127
|
};
|
|
41132
41128
|
visitNode(sourceFile);
|
|
41133
41129
|
return [...entries];
|
|
@@ -41635,7 +41631,7 @@ const extractReactEmailTemplateEntries = (directory) => {
|
|
|
41635
41631
|
//#endregion
|
|
41636
41632
|
//#region ../core/src/project-analysis/utils/parse-typescript-config.ts
|
|
41637
41633
|
const parseTypeScriptConfig = (configPath, source) => {
|
|
41638
|
-
const parsedConfig =
|
|
41634
|
+
const parsedConfig = typescriptBinding.parseConfigFileTextToJson(configPath, source);
|
|
41639
41635
|
return parsedConfig.error ? void 0 : parsedConfig.config;
|
|
41640
41636
|
};
|
|
41641
41637
|
//#endregion
|
|
@@ -42693,9 +42689,9 @@ const collectWebpackConfigModules = (configPath) => {
|
|
|
42693
42689
|
if (visitedModulePaths.has(modulePath)) continue;
|
|
42694
42690
|
visitedModulePaths.add(modulePath);
|
|
42695
42691
|
configModulePaths.push(modulePath);
|
|
42696
|
-
const sourceFile =
|
|
42692
|
+
const sourceFile = typescriptBinding.createSourceFile(modulePath, readFileSync(modulePath, "utf-8"), typescriptBinding.ScriptTarget.Latest, true);
|
|
42697
42693
|
for (const statement of sourceFile.statements) {
|
|
42698
|
-
if (!
|
|
42694
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
42699
42695
|
const specifier = statement.moduleSpecifier.text;
|
|
42700
42696
|
if (!specifier.startsWith(".")) continue;
|
|
42701
42697
|
const importedModulePath = resolveEntryWithExtensions(resolve(dirname(modulePath), specifier));
|
|
@@ -42708,7 +42704,7 @@ const extractComputedWebpackEntries = (configPath, projectDirectory) => {
|
|
|
42708
42704
|
const entries = [];
|
|
42709
42705
|
for (const modulePath of collectWebpackConfigModules(configPath)) {
|
|
42710
42706
|
const sourceText = readFileSync(modulePath, "utf-8");
|
|
42711
|
-
const sourceFile =
|
|
42707
|
+
const sourceFile = typescriptBinding.createSourceFile(modulePath, sourceText, typescriptBinding.ScriptTarget.Latest, true);
|
|
42712
42708
|
const program = parseOxcProgram(modulePath, sourceText);
|
|
42713
42709
|
if (program) visitOxcAstWithBindings(program, (node, bindingNames) => {
|
|
42714
42710
|
if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") return false;
|
|
@@ -42720,30 +42716,30 @@ const extractComputedWebpackEntries = (configPath, projectDirectory) => {
|
|
|
42720
42716
|
});
|
|
42721
42717
|
const objectInitializers = /* @__PURE__ */ new Map();
|
|
42722
42718
|
for (const statement of sourceFile.statements) {
|
|
42723
|
-
if (!
|
|
42724
|
-
for (const declaration of statement.declarationList.declarations) if (
|
|
42719
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
42720
|
+
for (const declaration of statement.declarationList.declarations) if (typescriptBinding.isIdentifier(declaration.name) && declaration.initializer && typescriptBinding.isObjectLiteralExpression(declaration.initializer)) objectInitializers.set(declaration.name.text, declaration.initializer);
|
|
42725
42721
|
}
|
|
42726
42722
|
const exportedObjects = sourceFile.statements.flatMap((statement) => {
|
|
42727
42723
|
let exportedExpression;
|
|
42728
|
-
if (
|
|
42729
|
-
else if (
|
|
42724
|
+
if (typescriptBinding.isExportAssignment(statement)) exportedExpression = statement.expression;
|
|
42725
|
+
else if (typescriptBinding.isExpressionStatement(statement) && typescriptBinding.isBinaryExpression(statement.expression) && statement.expression.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken && typescriptBinding.isPropertyAccessExpression(statement.expression.left) && typescriptBinding.isIdentifier(statement.expression.left.expression) && statement.expression.left.expression.text === "module" && statement.expression.left.name.text === "exports") exportedExpression = statement.expression.right;
|
|
42730
42726
|
if (!exportedExpression) return [];
|
|
42731
|
-
if (
|
|
42732
|
-
if (
|
|
42727
|
+
if (typescriptBinding.isObjectLiteralExpression(exportedExpression)) return [exportedExpression];
|
|
42728
|
+
if (typescriptBinding.isIdentifier(exportedExpression)) {
|
|
42733
42729
|
const objectInitializer = objectInitializers.get(exportedExpression.text);
|
|
42734
42730
|
return objectInitializer ? [objectInitializer] : [];
|
|
42735
42731
|
}
|
|
42736
42732
|
return [];
|
|
42737
42733
|
});
|
|
42738
42734
|
for (const exportedObject of exportedObjects) {
|
|
42739
|
-
const entryProperty = exportedObject.properties.find((property) =>
|
|
42735
|
+
const entryProperty = exportedObject.properties.find((property) => typescriptBinding.isPropertyAssignment(property) && (typescriptBinding.isIdentifier(property.name) && property.name.text === "entry" || typescriptBinding.isStringLiteral(property.name) && property.name.text === "entry"));
|
|
42740
42736
|
const pathSegments = [];
|
|
42741
|
-
if (entryProperty &&
|
|
42742
|
-
for (const argument of entryProperty.initializer.arguments) if (
|
|
42737
|
+
if (entryProperty && typescriptBinding.isCallExpression(entryProperty.initializer)) {
|
|
42738
|
+
for (const argument of entryProperty.initializer.arguments) if (typescriptBinding.isStringLiteral(argument) || typescriptBinding.isNoSubstitutionTemplateLiteral(argument)) pathSegments.push(argument.text);
|
|
42743
42739
|
}
|
|
42744
|
-
const entryCallExpression = entryProperty &&
|
|
42745
|
-
const entryPathObjectName = entryCallExpression &&
|
|
42746
|
-
const entryPathMethodName = entryCallExpression &&
|
|
42740
|
+
const entryCallExpression = entryProperty && typescriptBinding.isCallExpression(entryProperty.initializer) ? entryProperty.initializer : void 0;
|
|
42741
|
+
const entryPathObjectName = entryCallExpression && typescriptBinding.isPropertyAccessExpression(entryCallExpression.expression) && typescriptBinding.isIdentifier(entryCallExpression.expression.expression) ? entryCallExpression.expression.expression.text : void 0;
|
|
42742
|
+
const entryPathMethodName = entryCallExpression && typescriptBinding.isPropertyAccessExpression(entryCallExpression.expression) ? entryCallExpression.expression.name.text : void 0;
|
|
42747
42743
|
if (!entryProperty || !entryCallExpression || !entryPathObjectName || !entryPathMethodName || !/path/i.test(entryPathObjectName) || pathSegments.length !== entryCallExpression.arguments.length) continue;
|
|
42748
42744
|
const candidatePaths = entryPathObjectName === "path" && (entryPathMethodName === "join" || entryPathMethodName === "resolve") ? [resolve(dirname(modulePath), ...pathSegments)] : [resolve(projectDirectory, entryPathMethodName, ...pathSegments), resolve(projectDirectory, "src", entryPathMethodName, ...pathSegments)];
|
|
42749
42745
|
for (const candidatePath of candidatePaths) {
|
|
@@ -44538,20 +44534,8 @@ const isConfigFile = (filePath) => {
|
|
|
44538
44534
|
return KNOWN_CONFIG_PREFIXES.some((prefix) => fileName.startsWith(prefix));
|
|
44539
44535
|
};
|
|
44540
44536
|
//#endregion
|
|
44541
|
-
//#region ../core/src/project-info/constants.ts
|
|
44542
|
-
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch$2(), 1);
|
|
44543
|
-
const GIT_CHECK_ATTR_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
44544
|
-
new Map(Object.entries({
|
|
44545
|
-
Security: "An attacker can read user data, act as your users, or run code you never shipped.",
|
|
44546
|
-
Bugs: "Real users hit crashes, wrong output, or state that silently corrupts.",
|
|
44547
|
-
Performance: "Users feel extra latency and wasted renders on every interaction.",
|
|
44548
|
-
Accessibility: "Users on screen readers, keyboards, or assistive tech get locked out.",
|
|
44549
|
-
Maintainability: "Every future change gets slower and riskier to make."
|
|
44550
|
-
}));
|
|
44551
|
-
const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
|
|
44552
|
-
process.env.REACT_DOCTOR_CORE_VERSION;
|
|
44553
|
-
//#endregion
|
|
44554
44537
|
//#region ../core/src/utils/message-from-unknown.ts
|
|
44538
|
+
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch$2(), 1);
|
|
44555
44539
|
const messageFromUnknown = (error) => error instanceof Error ? error.message : String(error);
|
|
44556
44540
|
//#endregion
|
|
44557
44541
|
//#region ../core/src/utils/match-glob-pattern.ts
|
|
@@ -45449,18 +45433,18 @@ const collectDynamicBuildImports = (sourceFile, typeChecker) => {
|
|
|
45449
45433
|
const globNamespaceSymbols = /* @__PURE__ */ new Set();
|
|
45450
45434
|
const pathNamespaceSymbols = /* @__PURE__ */ new Set();
|
|
45451
45435
|
for (const statement of sourceFile.statements) {
|
|
45452
|
-
if (!
|
|
45436
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier) || !statement.importClause) continue;
|
|
45453
45437
|
const moduleName = statement.moduleSpecifier.text;
|
|
45454
45438
|
const namedBindings = statement.importClause.namedBindings;
|
|
45455
|
-
if (moduleName === "glob" && namedBindings &&
|
|
45439
|
+
if (moduleName === "glob" && namedBindings && typescriptBinding.isNamespaceImport(namedBindings)) {
|
|
45456
45440
|
const globNamespaceSymbol = typeChecker.getSymbolAtLocation(namedBindings.name);
|
|
45457
45441
|
if (globNamespaceSymbol) globNamespaceSymbols.add(globNamespaceSymbol);
|
|
45458
45442
|
}
|
|
45459
|
-
if (moduleName === "path" && namedBindings &&
|
|
45443
|
+
if (moduleName === "path" && namedBindings && typescriptBinding.isNamespaceImport(namedBindings)) {
|
|
45460
45444
|
const pathNamespaceSymbol = typeChecker.getSymbolAtLocation(namedBindings.name);
|
|
45461
45445
|
if (pathNamespaceSymbol) pathNamespaceSymbols.add(pathNamespaceSymbol);
|
|
45462
45446
|
}
|
|
45463
|
-
if (moduleName !== "tsup" || !namedBindings || !
|
|
45447
|
+
if (moduleName !== "tsup" || !namedBindings || !typescriptBinding.isNamedImports(namedBindings)) continue;
|
|
45464
45448
|
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") {
|
|
45465
45449
|
const buildSymbol = typeChecker.getSymbolAtLocation(importSpecifier.name);
|
|
45466
45450
|
if (buildSymbol) buildSymbols.add(buildSymbol);
|
|
@@ -45473,18 +45457,18 @@ const collectDynamicBuildImports = (sourceFile, typeChecker) => {
|
|
|
45473
45457
|
};
|
|
45474
45458
|
};
|
|
45475
45459
|
const extractGlobPattern = (expression, imports, scriptDirectory, typeChecker) => {
|
|
45476
|
-
if (!
|
|
45460
|
+
if (!typescriptBinding.isCallExpression(expression) || !typescriptBinding.isPropertyAccessExpression(expression.expression) || expression.expression.name.text !== "sync" || !typescriptBinding.isIdentifier(expression.expression.expression) || !hasMatchingSymbol(expression.expression.expression, imports.globNamespaceSymbols, typeChecker) || expression.arguments.length !== 1) return;
|
|
45477
45461
|
const patternExpression = expression.arguments[0];
|
|
45478
|
-
if (!
|
|
45462
|
+
if (!typescriptBinding.isCallExpression(patternExpression) || !typescriptBinding.isPropertyAccessExpression(patternExpression.expression) || patternExpression.expression.name.text !== "join" || !typescriptBinding.isIdentifier(patternExpression.expression.expression) || !hasMatchingSymbol(patternExpression.expression.expression, imports.pathNamespaceSymbols, typeChecker) || patternExpression.arguments.length !== 2 || !typescriptBinding.isIdentifier(patternExpression.arguments[0]) || patternExpression.arguments[0].text !== "__dirname" || !typescriptBinding.isStringLiteral(patternExpression.arguments[1]) && !typescriptBinding.isNoSubstitutionTemplateLiteral(patternExpression.arguments[1])) return;
|
|
45479
45463
|
const relativeGlobPattern = patternExpression.arguments[1].text;
|
|
45480
45464
|
if (!relativeGlobPattern.includes("*")) return void 0;
|
|
45481
45465
|
return toPosixPath(resolve(scriptDirectory, relativeGlobPattern));
|
|
45482
45466
|
};
|
|
45483
45467
|
const extractExcludedPathSubstring = (callback) => {
|
|
45484
|
-
if (callback.parameters.length !== 1 || !
|
|
45468
|
+
if (callback.parameters.length !== 1 || !typescriptBinding.isIdentifier(callback.parameters[0].name)) return;
|
|
45485
45469
|
const filePathName = callback.parameters[0].name.text;
|
|
45486
|
-
const returnedExpression =
|
|
45487
|
-
if (!returnedExpression || !
|
|
45470
|
+
const returnedExpression = typescriptBinding.isBlock(callback.body) ? callback.body.statements.length === 1 && typescriptBinding.isReturnStatement(callback.body.statements[0]) ? callback.body.statements[0].expression : void 0 : callback.body;
|
|
45471
|
+
if (!returnedExpression || !typescriptBinding.isPrefixUnaryExpression(returnedExpression) || returnedExpression.operator !== typescriptBinding.SyntaxKind.ExclamationToken || !typescriptBinding.isCallExpression(returnedExpression.operand) || !typescriptBinding.isPropertyAccessExpression(returnedExpression.operand.expression) || returnedExpression.operand.expression.name.text !== "includes" || !typescriptBinding.isIdentifier(returnedExpression.operand.expression.expression) || returnedExpression.operand.expression.expression.text !== filePathName || returnedExpression.operand.arguments.length !== 1 || !typescriptBinding.isStringLiteral(returnedExpression.operand.arguments[0]) && !typescriptBinding.isNoSubstitutionTemplateLiteral(returnedExpression.operand.arguments[0])) return;
|
|
45488
45472
|
return toPosixPath(returnedExpression.operand.arguments[0].text);
|
|
45489
45473
|
};
|
|
45490
45474
|
const extractFileCollection = (initializer, imports, scriptDirectory, typeChecker) => {
|
|
@@ -45493,7 +45477,7 @@ const extractFileCollection = (initializer, imports, scriptDirectory, typeChecke
|
|
|
45493
45477
|
excludedPathSubstrings: [],
|
|
45494
45478
|
globPattern: directGlobPattern
|
|
45495
45479
|
};
|
|
45496
|
-
if (!
|
|
45480
|
+
if (!typescriptBinding.isCallExpression(initializer) || !typescriptBinding.isPropertyAccessExpression(initializer.expression) || initializer.expression.name.text !== "filter" || initializer.arguments.length !== 1 || !typescriptBinding.isArrowFunction(initializer.arguments[0]) && !typescriptBinding.isFunctionExpression(initializer.arguments[0])) return;
|
|
45497
45481
|
const globPattern = extractGlobPattern(initializer.expression.expression, imports, scriptDirectory, typeChecker);
|
|
45498
45482
|
const excludedPathSubstring = extractExcludedPathSubstring(initializer.arguments[0]);
|
|
45499
45483
|
if (!globPattern || excludedPathSubstring === void 0) return void 0;
|
|
@@ -45502,36 +45486,36 @@ const extractFileCollection = (initializer, imports, scriptDirectory, typeChecke
|
|
|
45502
45486
|
globPattern
|
|
45503
45487
|
};
|
|
45504
45488
|
};
|
|
45505
|
-
const isPathNamespaceCall = (expression, methodName, imports, typeChecker) =>
|
|
45489
|
+
const isPathNamespaceCall = (expression, methodName, imports, typeChecker) => typescriptBinding.isCallExpression(expression) && typescriptBinding.isPropertyAccessExpression(expression.expression) && expression.expression.name.text === methodName && typescriptBinding.isIdentifier(expression.expression.expression) && hasMatchingSymbol(expression.expression.expression, imports.pathNamespaceSymbols, typeChecker);
|
|
45506
45490
|
const hasMatchingOutputEntryPath = (callback, filePathName, outputEntryName, imports, typeChecker) => {
|
|
45507
|
-
if (!
|
|
45491
|
+
if (!typescriptBinding.isBlock(callback.body)) return false;
|
|
45508
45492
|
const initializersByName = /* @__PURE__ */ new Map();
|
|
45509
45493
|
for (const statement of callback.body.statements) {
|
|
45510
|
-
if (!
|
|
45511
|
-
for (const declaration of statement.declarationList.declarations) if (
|
|
45494
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
45495
|
+
for (const declaration of statement.declarationList.declarations) if (typescriptBinding.isIdentifier(declaration.name) && declaration.initializer) initializersByName.set(declaration.name.text, declaration.initializer);
|
|
45512
45496
|
}
|
|
45513
45497
|
const outputEntryInitializer = initializersByName.get(outputEntryName);
|
|
45514
45498
|
if (!outputEntryInitializer || !isPathNamespaceCall(outputEntryInitializer, "join", imports, typeChecker)) return false;
|
|
45515
45499
|
const outputFilenameExpression = outputEntryInitializer.arguments.at(-1);
|
|
45516
|
-
if (!outputFilenameExpression || !
|
|
45500
|
+
if (!outputFilenameExpression || !typescriptBinding.isBinaryExpression(outputFilenameExpression) || outputFilenameExpression.operatorToken.kind !== typescriptBinding.SyntaxKind.PlusToken || !typescriptBinding.isStringLiteralLike(outputFilenameExpression.right) || outputFilenameExpression.right.text !== ".js" || !isPathNamespaceCall(outputFilenameExpression.left, "basename", imports, typeChecker) || outputFilenameExpression.left.arguments.length !== 2 || !typescriptBinding.isIdentifier(outputFilenameExpression.left.arguments[0]) || !typescriptBinding.isStringLiteralLike(outputFilenameExpression.left.arguments[1]) || outputFilenameExpression.left.arguments[1].text !== ".tsx") return false;
|
|
45517
45501
|
const basenameSourceName = outputFilenameExpression.left.arguments[0].text;
|
|
45518
45502
|
if (basenameSourceName === filePathName) return true;
|
|
45519
45503
|
const basenameSourceInitializer = initializersByName.get(basenameSourceName);
|
|
45520
|
-
return Boolean(basenameSourceInitializer && isPathNamespaceCall(basenameSourceInitializer, "relative", imports, typeChecker) && basenameSourceInitializer.arguments.length === 2 &&
|
|
45504
|
+
return Boolean(basenameSourceInitializer && isPathNamespaceCall(basenameSourceInitializer, "relative", imports, typeChecker) && basenameSourceInitializer.arguments.length === 2 && typescriptBinding.isIdentifier(basenameSourceInitializer.arguments[1]) && basenameSourceInitializer.arguments[1].text === filePathName);
|
|
45521
45505
|
};
|
|
45522
45506
|
const findBuildInvocation = (callback, filePathName, imports, typeChecker) => {
|
|
45523
45507
|
let buildInvocation;
|
|
45524
45508
|
const visitNode = (node) => {
|
|
45525
|
-
if (
|
|
45526
|
-
const hasMatchingEntry = node.arguments[0].properties.some((property) =>
|
|
45527
|
-
const outDirectoryProperty = node.arguments[0].properties.find((property) =>
|
|
45528
|
-
const hasCommonJsFormat = node.arguments[0].properties.some((property) =>
|
|
45529
|
-
if (hasMatchingEntry && hasCommonJsFormat && outDirectoryProperty &&
|
|
45509
|
+
if (typescriptBinding.isCallExpression(node) && typescriptBinding.isAwaitExpression(node.parent) && typescriptBinding.isIdentifier(node.expression) && hasMatchingSymbol(node.expression, imports.buildSymbols, typeChecker) && node.arguments.length === 1 && typescriptBinding.isObjectLiteralExpression(node.arguments[0])) {
|
|
45510
|
+
const hasMatchingEntry = node.arguments[0].properties.some((property) => typescriptBinding.isPropertyAssignment(property) && (typescriptBinding.isIdentifier(property.name) && property.name.text === "entry" || typescriptBinding.isStringLiteral(property.name) && property.name.text === "entry") && typescriptBinding.isArrayLiteralExpression(property.initializer) && property.initializer.elements.length === 1 && typescriptBinding.isIdentifier(property.initializer.elements[0]) && property.initializer.elements[0].text === filePathName);
|
|
45511
|
+
const outDirectoryProperty = node.arguments[0].properties.find((property) => typescriptBinding.isPropertyAssignment(property) && (typescriptBinding.isIdentifier(property.name) && property.name.text === "outDir" || typescriptBinding.isStringLiteral(property.name) && property.name.text === "outDir"));
|
|
45512
|
+
const hasCommonJsFormat = node.arguments[0].properties.some((property) => typescriptBinding.isPropertyAssignment(property) && (typescriptBinding.isIdentifier(property.name) && property.name.text === "format" || typescriptBinding.isStringLiteral(property.name) && property.name.text === "format") && typescriptBinding.isStringLiteralLike(property.initializer) && property.initializer.text === "cjs");
|
|
45513
|
+
if (hasMatchingEntry && hasCommonJsFormat && outDirectoryProperty && typescriptBinding.isPropertyAssignment(outDirectoryProperty) && typescriptBinding.isCallExpression(outDirectoryProperty.initializer) && typescriptBinding.isPropertyAccessExpression(outDirectoryProperty.initializer.expression) && outDirectoryProperty.initializer.expression.name.text === "dirname" && typescriptBinding.isIdentifier(outDirectoryProperty.initializer.expression.expression) && hasMatchingSymbol(outDirectoryProperty.initializer.expression.expression, imports.pathNamespaceSymbols, typeChecker) && outDirectoryProperty.initializer.arguments.length === 1 && typescriptBinding.isIdentifier(outDirectoryProperty.initializer.arguments[0]) && hasMatchingOutputEntryPath(callback, filePathName, outDirectoryProperty.initializer.arguments[0].text, imports, typeChecker)) buildInvocation = {
|
|
45530
45514
|
end: node.parent.end,
|
|
45531
45515
|
outputEntryName: outDirectoryProperty.initializer.arguments[0].text
|
|
45532
45516
|
};
|
|
45533
45517
|
}
|
|
45534
|
-
if (!buildInvocation)
|
|
45518
|
+
if (!buildInvocation) typescriptBinding.forEachChild(node, visitNode);
|
|
45535
45519
|
};
|
|
45536
45520
|
visitNode(callback.body);
|
|
45537
45521
|
return buildInvocation;
|
|
@@ -45540,19 +45524,19 @@ const collectImportedNamespaceExportNames = (callback, buildInvocation, typeChec
|
|
|
45540
45524
|
const importedNamespaceDeclarationEndBySymbol = /* @__PURE__ */ new Map();
|
|
45541
45525
|
const exportNames = /* @__PURE__ */ new Set();
|
|
45542
45526
|
const collectNamespaceNames = (node) => {
|
|
45543
|
-
if (
|
|
45527
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer && typescriptBinding.isAwaitExpression(node.initializer) && node.initializer.pos >= buildInvocation.end && typescriptBinding.isCallExpression(node.initializer.expression) && node.initializer.expression.expression.kind === typescriptBinding.SyntaxKind.ImportKeyword && node.initializer.expression.arguments.length === 1 && typescriptBinding.isIdentifier(node.initializer.expression.arguments[0]) && node.initializer.expression.arguments[0].text === buildInvocation.outputEntryName) {
|
|
45544
45528
|
const namespaceSymbol = typeChecker.getSymbolAtLocation(node.name);
|
|
45545
45529
|
if (namespaceSymbol) importedNamespaceDeclarationEndBySymbol.set(namespaceSymbol, node.end);
|
|
45546
45530
|
}
|
|
45547
|
-
|
|
45531
|
+
typescriptBinding.forEachChild(node, collectNamespaceNames);
|
|
45548
45532
|
};
|
|
45549
45533
|
collectNamespaceNames(callback.body);
|
|
45550
45534
|
const collectExportNames = (node) => {
|
|
45551
|
-
const namespaceSymbol = (
|
|
45535
|
+
const namespaceSymbol = (typescriptBinding.isPropertyAccessExpression(node) || typescriptBinding.isElementAccessExpression(node)) && typescriptBinding.isIdentifier(node.expression) ? typeChecker.getSymbolAtLocation(node.expression) : void 0;
|
|
45552
45536
|
const namespaceDeclarationEnd = namespaceSymbol ? importedNamespaceDeclarationEndBySymbol.get(namespaceSymbol) : void 0;
|
|
45553
|
-
if (
|
|
45554
|
-
else if (
|
|
45555
|
-
|
|
45537
|
+
if (typescriptBinding.isPropertyAccessExpression(node) && namespaceDeclarationEnd !== void 0 && node.pos >= namespaceDeclarationEnd) exportNames.add(node.name.text);
|
|
45538
|
+
else if (typescriptBinding.isElementAccessExpression(node) && namespaceDeclarationEnd !== void 0 && node.pos >= namespaceDeclarationEnd && node.argumentExpression && typescriptBinding.isStringLiteral(node.argumentExpression)) exportNames.add(node.argumentExpression.text);
|
|
45539
|
+
typescriptBinding.forEachChild(node, collectExportNames);
|
|
45556
45540
|
};
|
|
45557
45541
|
collectExportNames(callback.body);
|
|
45558
45542
|
return exportNames;
|
|
@@ -45568,14 +45552,14 @@ const collectScriptConsumedExportKeys = (scriptPath, packageDirectory) => {
|
|
|
45568
45552
|
noLib: true,
|
|
45569
45553
|
noResolve: true
|
|
45570
45554
|
};
|
|
45571
|
-
const sourceFile =
|
|
45572
|
-
const compilerHost =
|
|
45555
|
+
const sourceFile = typescriptBinding.createSourceFile(scriptPath, source, typescriptBinding.ScriptTarget.Latest, true);
|
|
45556
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
45573
45557
|
const scriptIdentity = getFileIdentityKey(scriptPath);
|
|
45574
45558
|
const isScriptPath = (candidatePath) => getFileIdentityKey(candidatePath) === scriptIdentity;
|
|
45575
45559
|
compilerHost.fileExists = isScriptPath;
|
|
45576
45560
|
compilerHost.getSourceFile = (candidatePath) => isScriptPath(candidatePath) ? sourceFile : void 0;
|
|
45577
45561
|
compilerHost.readFile = (candidatePath) => isScriptPath(candidatePath) ? source : void 0;
|
|
45578
|
-
const program =
|
|
45562
|
+
const program = typescriptBinding.createProgram({
|
|
45579
45563
|
rootNames: [scriptPath],
|
|
45580
45564
|
options: compilerOptions,
|
|
45581
45565
|
host: compilerHost
|
|
@@ -45587,22 +45571,22 @@ const collectScriptConsumedExportKeys = (scriptPath, packageDirectory) => {
|
|
|
45587
45571
|
if (imports.buildSymbols.size === 0 || imports.globNamespaceSymbols.size === 0 || imports.pathNamespaceSymbols.size === 0) return /* @__PURE__ */ new Set();
|
|
45588
45572
|
const collectionsBySymbol = /* @__PURE__ */ new Map();
|
|
45589
45573
|
const visitCollection = (node) => {
|
|
45590
|
-
if (
|
|
45574
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer) {
|
|
45591
45575
|
const collection = extractFileCollection(node.initializer, imports, dirname(scriptPath), typeChecker);
|
|
45592
45576
|
const collectionSymbol = typeChecker.getSymbolAtLocation(node.name);
|
|
45593
45577
|
if (collection && collectionSymbol) collectionsBySymbol.set(collectionSymbol, collection);
|
|
45594
45578
|
}
|
|
45595
|
-
|
|
45579
|
+
typescriptBinding.forEachChild(node, visitCollection);
|
|
45596
45580
|
};
|
|
45597
45581
|
visitCollection(boundSourceFile);
|
|
45598
45582
|
const consumedExportKeys = /* @__PURE__ */ new Set();
|
|
45599
45583
|
const packageManifestIdentity = getFileIdentityKey(resolve(packageDirectory, "package.json"));
|
|
45600
45584
|
const visitMapCall = (node) => {
|
|
45601
|
-
if (
|
|
45585
|
+
if (typescriptBinding.isCallExpression(node) && typescriptBinding.isPropertyAccessExpression(node.expression) && node.expression.name.text === "map" && typescriptBinding.isIdentifier(node.expression.expression) && node.arguments.length === 1 && (typescriptBinding.isArrowFunction(node.arguments[0]) || typescriptBinding.isFunctionExpression(node.arguments[0]))) {
|
|
45602
45586
|
const collectionSymbol = typeChecker.getSymbolAtLocation(node.expression.expression);
|
|
45603
45587
|
const collection = collectionSymbol ? collectionsBySymbol.get(collectionSymbol) : void 0;
|
|
45604
45588
|
const callback = node.arguments[0];
|
|
45605
|
-
if (collection && callback.parameters.length === 1 &&
|
|
45589
|
+
if (collection && callback.parameters.length === 1 && typescriptBinding.isIdentifier(callback.parameters[0].name)) {
|
|
45606
45590
|
const buildInvocation = findBuildInvocation(callback, callback.parameters[0].name.text, imports, typeChecker);
|
|
45607
45591
|
if (!buildInvocation) return;
|
|
45608
45592
|
const exportNames = collectImportedNamespaceExportNames(callback, buildInvocation, typeChecker);
|
|
@@ -45621,7 +45605,7 @@ const collectScriptConsumedExportKeys = (scriptPath, packageDirectory) => {
|
|
|
45621
45605
|
}
|
|
45622
45606
|
}
|
|
45623
45607
|
}
|
|
45624
|
-
|
|
45608
|
+
typescriptBinding.forEachChild(node, visitMapCall);
|
|
45625
45609
|
};
|
|
45626
45610
|
visitMapCall(boundSourceFile);
|
|
45627
45611
|
return consumedExportKeys;
|
|
@@ -45665,7 +45649,7 @@ const readPackageMetadata = (packageDirectory) => {
|
|
|
45665
45649
|
return;
|
|
45666
45650
|
}
|
|
45667
45651
|
};
|
|
45668
|
-
const hasNextraImport = (sourceFile) => sourceFile.statements.some((statement) =>
|
|
45652
|
+
const hasNextraImport = (sourceFile) => sourceFile.statements.some((statement) => typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === "nextra");
|
|
45669
45653
|
const collectReferencedNextraThemeConfigPaths = (packageDirectory) => {
|
|
45670
45654
|
const referencedPaths = /* @__PURE__ */ new Set();
|
|
45671
45655
|
for (const configFilename of NEXT_CONFIG_FILENAMES) {
|
|
@@ -45677,16 +45661,16 @@ const collectReferencedNextraThemeConfigPaths = (packageDirectory) => {
|
|
|
45677
45661
|
} catch {
|
|
45678
45662
|
continue;
|
|
45679
45663
|
}
|
|
45680
|
-
const sourceFile =
|
|
45664
|
+
const sourceFile = typescriptBinding.createSourceFile(configPath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
45681
45665
|
if (!hasNextraImport(sourceFile)) continue;
|
|
45682
45666
|
const visitNode = (node) => {
|
|
45683
|
-
if (
|
|
45684
|
-
if ((
|
|
45667
|
+
if (typescriptBinding.isPropertyAssignment(node)) {
|
|
45668
|
+
if ((typescriptBinding.isIdentifier(node.name) || typescriptBinding.isStringLiteral(node.name) ? node.name.text : void 0) === "themeConfig" && (typescriptBinding.isStringLiteral(node.initializer) || typescriptBinding.isNoSubstitutionTemplateLiteral(node.initializer)) && node.initializer.text.startsWith(".")) {
|
|
45685
45669
|
const resolvedThemeConfigPath = resolveEntryWithExtensions(resolve(dirname(configPath), node.initializer.text));
|
|
45686
45670
|
if (resolvedThemeConfigPath) referencedPaths.add(toPosixPath(toFilesystemIdentityPath(resolve(resolvedThemeConfigPath))));
|
|
45687
45671
|
}
|
|
45688
45672
|
}
|
|
45689
|
-
|
|
45673
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
45690
45674
|
};
|
|
45691
45675
|
visitNode(sourceFile);
|
|
45692
45676
|
}
|
|
@@ -46139,7 +46123,7 @@ const collectStaticModulePackageNames = (sourceText) => {
|
|
|
46139
46123
|
//#region ../core/src/project-analysis/utils/matches-package-import-reference.ts
|
|
46140
46124
|
const collectPackageImportNames = (content) => {
|
|
46141
46125
|
const packageNames = collectStaticModulePackageNames(content);
|
|
46142
|
-
const sourceFile =
|
|
46126
|
+
const sourceFile = typescriptBinding.createSourceFile("package-reference.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
46143
46127
|
for (const typeReferenceDirective of sourceFile.typeReferenceDirectives) {
|
|
46144
46128
|
const packageName = extractPackageName(typeReferenceDirective.fileName);
|
|
46145
46129
|
if (packageName) packageNames.add(packageName);
|
|
@@ -46149,8 +46133,8 @@ const collectPackageImportNames = (content) => {
|
|
|
46149
46133
|
//#endregion
|
|
46150
46134
|
//#region ../core/src/project-analysis/utils/get-object-literal-element-name.ts
|
|
46151
46135
|
const getObjectLiteralElementName = (property) => {
|
|
46152
|
-
if (!
|
|
46153
|
-
return
|
|
46136
|
+
if (!typescriptBinding.isPropertyAssignment(property) && !typescriptBinding.isShorthandPropertyAssignment(property)) return;
|
|
46137
|
+
return typescriptBinding.isIdentifier(property.name) || typescriptBinding.isStringLiteral(property.name) ? property.name.text : void 0;
|
|
46154
46138
|
};
|
|
46155
46139
|
//#endregion
|
|
46156
46140
|
//#region ../core/src/project-analysis/utils/collect-config-plugin-map-package-names.ts
|
|
@@ -46158,23 +46142,23 @@ const collectConfigPluginMapPackageNames = (expression) => {
|
|
|
46158
46142
|
const packageNames = /* @__PURE__ */ new Set();
|
|
46159
46143
|
const collectExpression = (currentExpression) => {
|
|
46160
46144
|
const unwrappedExpression = unwrapTypescriptExpression(currentExpression);
|
|
46161
|
-
if (
|
|
46145
|
+
if (typescriptBinding.isConditionalExpression(unwrappedExpression)) {
|
|
46162
46146
|
collectExpression(unwrappedExpression.whenTrue);
|
|
46163
46147
|
collectExpression(unwrappedExpression.whenFalse);
|
|
46164
46148
|
return;
|
|
46165
46149
|
}
|
|
46166
|
-
if (
|
|
46167
|
-
|
|
46168
|
-
|
|
46169
|
-
|
|
46150
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && [
|
|
46151
|
+
typescriptBinding.SyntaxKind.AmpersandAmpersandToken,
|
|
46152
|
+
typescriptBinding.SyntaxKind.BarBarToken,
|
|
46153
|
+
typescriptBinding.SyntaxKind.QuestionQuestionToken
|
|
46170
46154
|
].includes(unwrappedExpression.operatorToken.kind)) {
|
|
46171
46155
|
collectExpression(unwrappedExpression.left);
|
|
46172
46156
|
collectExpression(unwrappedExpression.right);
|
|
46173
46157
|
return;
|
|
46174
46158
|
}
|
|
46175
|
-
if (!
|
|
46159
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
46176
46160
|
for (const property of unwrappedExpression.properties) {
|
|
46177
|
-
if (
|
|
46161
|
+
if (typescriptBinding.isSpreadAssignment(property)) {
|
|
46178
46162
|
collectExpression(property.expression);
|
|
46179
46163
|
continue;
|
|
46180
46164
|
}
|
|
@@ -46197,16 +46181,16 @@ const STRUCTURED_TEXT_EXTENSIONS = new Set([
|
|
|
46197
46181
|
const BABEL_CONFIG_FILE_PATTERN = /(?:^|[/\\])(?:babel\.config\.[^/\\]+|\.babelrc(?:\.[^/\\]+)?)$/;
|
|
46198
46182
|
const BABEL_MODULE_PREFIX = "module:";
|
|
46199
46183
|
const isBabelPluginOrPresetSpecifier = (node) => {
|
|
46200
|
-
const parent =
|
|
46184
|
+
const parent = typescriptBinding.isArrayLiteralExpression(node.parent) ? node.parent : void 0;
|
|
46201
46185
|
if (!parent) return false;
|
|
46202
|
-
const property = (parent.elements[0] === node &&
|
|
46186
|
+
const property = (parent.elements[0] === node && typescriptBinding.isArrayLiteralExpression(parent.parent) ? parent.parent : parent).parent;
|
|
46203
46187
|
let ancestor = property;
|
|
46204
|
-
while (ancestor && !
|
|
46188
|
+
while (ancestor && !typescriptBinding.isSourceFile(ancestor)) {
|
|
46205
46189
|
const parentNode = ancestor.parent;
|
|
46206
|
-
if (
|
|
46190
|
+
if (typescriptBinding.isObjectLiteralExpression(ancestor) && typescriptBinding.isArrayLiteralExpression(parentNode) && parentNode.elements[0] !== ancestor && typescriptBinding.isStringLiteralLike(parentNode.elements[0])) return false;
|
|
46207
46191
|
ancestor = parentNode;
|
|
46208
46192
|
}
|
|
46209
|
-
return
|
|
46193
|
+
return typescriptBinding.isPropertyAssignment(property) && (getObjectLiteralElementName(property) === "plugins" || getObjectLiteralElementName(property) === "presets");
|
|
46210
46194
|
};
|
|
46211
46195
|
const collectStructuredTextPackageReferences = (content) => {
|
|
46212
46196
|
const uncommentedContent = content.split("\n").map(stripCoffeeScriptComment).join("\n");
|
|
@@ -46219,16 +46203,16 @@ const collectStructuredTextPackageReferences = (content) => {
|
|
|
46219
46203
|
};
|
|
46220
46204
|
const collectPackageConfigReferences = (filePath, content) => {
|
|
46221
46205
|
if (STRUCTURED_TEXT_EXTENSIONS.has(extname(filePath))) return collectStructuredTextPackageReferences(content);
|
|
46222
|
-
const sourceFile =
|
|
46206
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
46223
46207
|
const packageNames = /* @__PURE__ */ new Set();
|
|
46224
46208
|
const visit = (node) => {
|
|
46225
|
-
if (
|
|
46226
|
-
if (
|
|
46209
|
+
if (typescriptBinding.isPropertyAssignment(node) && getObjectLiteralElementName(node) === "plugins") for (const packageName of collectConfigPluginMapPackageNames(node.initializer)) packageNames.add(packageName);
|
|
46210
|
+
if (typescriptBinding.isStringLiteralLike(node)) {
|
|
46227
46211
|
const packageName = extractPackageName(BABEL_CONFIG_FILE_PATTERN.test(filePath) && node.text.startsWith(BABEL_MODULE_PREFIX) && isBabelPluginOrPresetSpecifier(node) ? node.text.slice(7) : node.text);
|
|
46228
46212
|
if (packageName) packageNames.add(packageName);
|
|
46229
46213
|
return;
|
|
46230
46214
|
}
|
|
46231
|
-
|
|
46215
|
+
typescriptBinding.forEachChild(node, visit);
|
|
46232
46216
|
};
|
|
46233
46217
|
visit(sourceFile);
|
|
46234
46218
|
return packageNames;
|
|
@@ -48456,21 +48440,21 @@ const extractPreviewRegistryNamesFromMdx = (sourceText) => {
|
|
|
48456
48440
|
//#endregion
|
|
48457
48441
|
//#region ../core/src/project-analysis/utils/are-source-files-structurally-equivalent.ts
|
|
48458
48442
|
const buildSourceStructure = (filePath, sourceText) => {
|
|
48459
|
-
const sourceFile =
|
|
48443
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, filePath.endsWith("x") ? typescriptBinding.ScriptKind.TSX : typescriptBinding.ScriptKind.TS);
|
|
48460
48444
|
const structure = [];
|
|
48461
48445
|
const visitNode = (node, normalizeClassNames = false) => {
|
|
48462
48446
|
structure.push(String(node.kind));
|
|
48463
|
-
if (
|
|
48464
|
-
else if (
|
|
48465
|
-
else if (
|
|
48466
|
-
else if (
|
|
48467
|
-
else if (
|
|
48468
|
-
if (
|
|
48447
|
+
if (typescriptBinding.isIdentifier(node)) structure.push(node.text);
|
|
48448
|
+
else if (typescriptBinding.isStringLiteralLike(node)) structure.push(normalizeClassNames ? node.text.trim().split(/\s+/).sort().join(" ") : node.text);
|
|
48449
|
+
else if (typescriptBinding.isNumericLiteral(node)) structure.push(node.text);
|
|
48450
|
+
else if (typescriptBinding.isTemplateLiteralToken(node) || typescriptBinding.isRegularExpressionLiteral(node) || typescriptBinding.isBigIntLiteral(node)) structure.push(node.text);
|
|
48451
|
+
else if (typescriptBinding.isJsxText(node)) structure.push(node.text.replace(/\s+/g, " ").trim());
|
|
48452
|
+
if (typescriptBinding.isJsxAttribute(node) && typescriptBinding.isIdentifier(node.name) && node.name.text === "className" && node.initializer && typescriptBinding.isStringLiteral(node.initializer)) {
|
|
48469
48453
|
visitNode(node.name);
|
|
48470
48454
|
visitNode(node.initializer, true);
|
|
48471
48455
|
return;
|
|
48472
48456
|
}
|
|
48473
|
-
|
|
48457
|
+
typescriptBinding.forEachChild(node, (childNode) => visitNode(childNode));
|
|
48474
48458
|
};
|
|
48475
48459
|
visitNode(sourceFile);
|
|
48476
48460
|
return structure.join("\0");
|
|
@@ -48484,8 +48468,8 @@ const buildScriptAnalysisKey = (scriptFile) => `${scriptFile.workingDirectory}\0
|
|
|
48484
48468
|
const resolveBuildReference = (reference, workingDirectory, projectRoot) => reference.startsWith("/") ? resolve(projectRoot, reference.replace(/^\/+/, "")) : resolve(workingDirectory, reference);
|
|
48485
48469
|
const getPropertyName$1 = (expression) => {
|
|
48486
48470
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48487
|
-
if (
|
|
48488
|
-
if (
|
|
48471
|
+
if (typescriptBinding.isPropertyAccessExpression(unwrappedExpression)) return unwrappedExpression.name.text;
|
|
48472
|
+
if (typescriptBinding.isElementAccessExpression(unwrappedExpression) && unwrappedExpression.argumentExpression && typescriptBinding.isStringLiteralLike(unwrappedExpression.argumentExpression)) return unwrappedExpression.argumentExpression.text;
|
|
48489
48473
|
};
|
|
48490
48474
|
const resolveImportedScriptPath = (specifier, scriptFile, projectRoot) => {
|
|
48491
48475
|
const importedPath = specifier.startsWith(".") ? resolve(dirname(scriptFile.filePath), specifier) : specifier.startsWith("@/registry/") ? resolve(scriptFile.workingDirectory, "src/registry", specifier.slice(11)) : void 0;
|
|
@@ -48502,20 +48486,20 @@ const collectWebpackEntrySpecifiers = (filePath) => {
|
|
|
48502
48486
|
} catch {
|
|
48503
48487
|
return [];
|
|
48504
48488
|
}
|
|
48505
|
-
const sourceFile =
|
|
48489
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
48506
48490
|
const specifiers = /* @__PURE__ */ new Set();
|
|
48507
48491
|
const collectStringLiterals = (node) => {
|
|
48508
|
-
if (
|
|
48492
|
+
if (typescriptBinding.isStringLiteralLike(node) && node.text.startsWith(".")) {
|
|
48509
48493
|
specifiers.add(node.text);
|
|
48510
48494
|
return;
|
|
48511
48495
|
}
|
|
48512
|
-
|
|
48496
|
+
typescriptBinding.forEachChild(node, collectStringLiterals);
|
|
48513
48497
|
};
|
|
48514
48498
|
const visitNode = (node) => {
|
|
48515
|
-
if (
|
|
48516
|
-
if (
|
|
48517
|
-
if (
|
|
48518
|
-
|
|
48499
|
+
if (typescriptBinding.isPropertyAssignment(node) && (typescriptBinding.isIdentifier(node.name) && node.name.text === "entry" || typescriptBinding.isStringLiteralLike(node.name) && node.name.text === "entry")) collectStringLiterals(node.initializer);
|
|
48500
|
+
if (typescriptBinding.isBinaryExpression(node) && node.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken && typescriptBinding.isPropertyAccessExpression(node.left) && node.left.name.text === "entry") collectStringLiterals(node.right);
|
|
48501
|
+
if (typescriptBinding.isCallExpression(node) && typescriptBinding.isPropertyAccessExpression(node.expression) && node.expression.name.text === "concat" && node.getText(sourceFile).includes(".entry")) collectStringLiterals(node);
|
|
48502
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48519
48503
|
};
|
|
48520
48504
|
visitNode(sourceFile);
|
|
48521
48505
|
return [...specifiers];
|
|
@@ -48682,23 +48666,23 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48682
48666
|
} catch {
|
|
48683
48667
|
continue;
|
|
48684
48668
|
}
|
|
48685
|
-
const sourceFile =
|
|
48669
|
+
const sourceFile = typescriptBinding.createSourceFile(scriptFile.filePath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
48686
48670
|
const localFunctions = /* @__PURE__ */ new Map();
|
|
48687
48671
|
const defaultExportExpressions = [];
|
|
48688
48672
|
for (const statement of sourceFile.statements) {
|
|
48689
|
-
if (
|
|
48673
|
+
if (typescriptBinding.isFunctionDeclaration(statement) && statement.body) {
|
|
48690
48674
|
if (statement.name) localFunctions.set(statement.name.text, statement.body);
|
|
48691
|
-
if (statement.modifiers?.some((modifier) => modifier.kind ===
|
|
48675
|
+
if (statement.modifiers?.some((modifier) => modifier.kind === typescriptBinding.SyntaxKind.DefaultKeyword)) localFunctions.set("default", statement.body);
|
|
48692
48676
|
}
|
|
48693
|
-
if (
|
|
48694
|
-
for (const declaration of statement.declarationList.declarations) if (
|
|
48677
|
+
if (typescriptBinding.isVariableStatement(statement)) {
|
|
48678
|
+
for (const declaration of statement.declarationList.declarations) if (typescriptBinding.isIdentifier(declaration.name) && declaration.initializer && (typescriptBinding.isArrowFunction(declaration.initializer) || typescriptBinding.isFunctionExpression(declaration.initializer))) localFunctions.set(declaration.name.text, declaration.initializer.body);
|
|
48695
48679
|
}
|
|
48696
|
-
if (
|
|
48680
|
+
if (typescriptBinding.isExportAssignment(statement) && !statement.isExportEquals) defaultExportExpressions.push(statement.expression);
|
|
48697
48681
|
}
|
|
48698
48682
|
for (const defaultExportExpression of defaultExportExpressions) {
|
|
48699
48683
|
const unwrappedDefaultExport = unwrapTypescriptExpression(defaultExportExpression);
|
|
48700
|
-
if (
|
|
48701
|
-
else if (
|
|
48684
|
+
if (typescriptBinding.isArrowFunction(unwrappedDefaultExport) || typescriptBinding.isFunctionExpression(unwrappedDefaultExport)) localFunctions.set("default", unwrappedDefaultExport.body);
|
|
48685
|
+
else if (typescriptBinding.isIdentifier(unwrappedDefaultExport)) {
|
|
48702
48686
|
const defaultFunctionBody = localFunctions.get(unwrappedDefaultExport.text);
|
|
48703
48687
|
if (defaultFunctionBody) localFunctions.set("default", defaultFunctionBody);
|
|
48704
48688
|
}
|
|
@@ -48712,7 +48696,7 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48712
48696
|
});
|
|
48713
48697
|
}
|
|
48714
48698
|
for (const analysis of analyses.values()) for (const statement of analysis.sourceFile.statements) {
|
|
48715
|
-
if (!
|
|
48699
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
48716
48700
|
const importClause = statement.importClause;
|
|
48717
48701
|
if (!importClause || importClause.isTypeOnly) continue;
|
|
48718
48702
|
const importedFilePath = resolveImportedScriptPath(statement.moduleSpecifier.text, analysis.scriptFile, projectRoot);
|
|
@@ -48726,7 +48710,7 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48726
48710
|
analysisKey: importedAnalysisKey,
|
|
48727
48711
|
exportName: "default"
|
|
48728
48712
|
});
|
|
48729
|
-
if (!importClause.namedBindings || !
|
|
48713
|
+
if (!importClause.namedBindings || !typescriptBinding.isNamedImports(importClause.namedBindings)) continue;
|
|
48730
48714
|
for (const element of importClause.namedBindings.elements) {
|
|
48731
48715
|
if (element.isTypeOnly) continue;
|
|
48732
48716
|
analysis.importedFunctions.set(element.name.text, {
|
|
@@ -48748,11 +48732,11 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48748
48732
|
const visitLiveNode = (analysis, rootNode) => {
|
|
48749
48733
|
const visitNode = (node) => {
|
|
48750
48734
|
analysis.liveNodes.add(node);
|
|
48751
|
-
if (node !== rootNode && (
|
|
48752
|
-
if (
|
|
48735
|
+
if (node !== rootNode && (typescriptBinding.isFunctionDeclaration(node) || typescriptBinding.isFunctionExpression(node) || typescriptBinding.isArrowFunction(node) || typescriptBinding.isMethodDeclaration(node))) return;
|
|
48736
|
+
if (typescriptBinding.isCallExpression(node)) {
|
|
48753
48737
|
const calledExpression = unwrapTypescriptExpression(node.expression);
|
|
48754
|
-
if (
|
|
48755
|
-
if (
|
|
48738
|
+
if (typescriptBinding.isFunctionExpression(calledExpression) || typescriptBinding.isArrowFunction(calledExpression)) queueFunctionBody(analysis, calledExpression.body);
|
|
48739
|
+
if (typescriptBinding.isIdentifier(calledExpression)) {
|
|
48756
48740
|
const localFunctionBody = analysis.localFunctions.get(calledExpression.text);
|
|
48757
48741
|
if (localFunctionBody) queueFunctionBody(analysis, localFunctionBody);
|
|
48758
48742
|
const importedFunction = analysis.importedFunctions.get(calledExpression.text);
|
|
@@ -48762,10 +48746,10 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48762
48746
|
}
|
|
48763
48747
|
for (const argument of node.arguments) {
|
|
48764
48748
|
const unwrappedArgument = unwrapTypescriptExpression(argument);
|
|
48765
|
-
if (
|
|
48749
|
+
if (typescriptBinding.isFunctionExpression(unwrappedArgument) || typescriptBinding.isArrowFunction(unwrappedArgument)) queueFunctionBody(analysis, unwrappedArgument.body);
|
|
48766
48750
|
}
|
|
48767
48751
|
}
|
|
48768
|
-
|
|
48752
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48769
48753
|
};
|
|
48770
48754
|
visitNode(rootNode);
|
|
48771
48755
|
};
|
|
@@ -48790,18 +48774,18 @@ const findVariableDeclaration = (sourceFile, identifierName, usePosition) => {
|
|
|
48790
48774
|
let closestDeclaration;
|
|
48791
48775
|
const visitNode = (node) => {
|
|
48792
48776
|
if (node.getStart(sourceFile) >= usePosition) return;
|
|
48793
|
-
if (
|
|
48777
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name)) {
|
|
48794
48778
|
if (node.name.text === identifierName) closestDeclaration = node;
|
|
48795
48779
|
}
|
|
48796
|
-
|
|
48780
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48797
48781
|
};
|
|
48798
48782
|
visitNode(sourceFile);
|
|
48799
48783
|
return closestDeclaration;
|
|
48800
48784
|
};
|
|
48801
48785
|
const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
48802
48786
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48803
|
-
if (
|
|
48804
|
-
if (
|
|
48787
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) return resolveBuildReference(unwrappedExpression.text, analysis.scriptFile.workingDirectory, projectRoot);
|
|
48788
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) {
|
|
48805
48789
|
if (unwrappedExpression.text === "__dirname") return dirname(analysis.scriptFile.filePath);
|
|
48806
48790
|
if (seenIdentifiers.has(unwrappedExpression.text)) return void 0;
|
|
48807
48791
|
const declaration = findVariableDeclaration(analysis.sourceFile, unwrappedExpression.text, unwrappedExpression.getStart(analysis.sourceFile));
|
|
@@ -48810,8 +48794,8 @@ const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifie
|
|
|
48810
48794
|
nextSeenIdentifiers.add(unwrappedExpression.text);
|
|
48811
48795
|
return evaluatePathExpression(declaration.initializer, analysis, projectRoot, nextSeenIdentifiers);
|
|
48812
48796
|
}
|
|
48813
|
-
if (!
|
|
48814
|
-
if (
|
|
48797
|
+
if (!typescriptBinding.isCallExpression(unwrappedExpression)) return void 0;
|
|
48798
|
+
if (typescriptBinding.isPropertyAccessExpression(unwrappedExpression.expression) && typescriptBinding.isIdentifier(unwrappedExpression.expression.expression) && unwrappedExpression.expression.expression.text === "process" && unwrappedExpression.expression.name.text === "cwd") return analysis.scriptFile.workingDirectory;
|
|
48815
48799
|
const pathMethodName = getPropertyName$1(unwrappedExpression.expression);
|
|
48816
48800
|
if (pathMethodName !== "join" && pathMethodName !== "resolve") return void 0;
|
|
48817
48801
|
const [baseExpression, ...segmentExpressions] = unwrappedExpression.arguments;
|
|
@@ -48821,7 +48805,7 @@ const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifie
|
|
|
48821
48805
|
const pathSegments = [];
|
|
48822
48806
|
for (const segmentExpression of segmentExpressions) {
|
|
48823
48807
|
const unwrappedSegment = unwrapTypescriptExpression(segmentExpression);
|
|
48824
|
-
if (!
|
|
48808
|
+
if (!typescriptBinding.isStringLiteralLike(unwrappedSegment)) return void 0;
|
|
48825
48809
|
pathSegments.push(unwrappedSegment.text);
|
|
48826
48810
|
}
|
|
48827
48811
|
const rootRelativeSegment = pathSegments.find((pathSegment) => pathSegment.startsWith("/"));
|
|
@@ -48835,48 +48819,48 @@ const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifie
|
|
|
48835
48819
|
const expressionContainsIdentifier = (expression, identifierName) => {
|
|
48836
48820
|
let containsIdentifier = false;
|
|
48837
48821
|
const visitNode = (node) => {
|
|
48838
|
-
if (
|
|
48822
|
+
if (typescriptBinding.isIdentifier(node) && node.text === identifierName) {
|
|
48839
48823
|
containsIdentifier = true;
|
|
48840
48824
|
return;
|
|
48841
48825
|
}
|
|
48842
|
-
if (!containsIdentifier)
|
|
48826
|
+
if (!containsIdentifier) typescriptBinding.forEachChild(node, visitNode);
|
|
48843
48827
|
};
|
|
48844
48828
|
visitNode(expression);
|
|
48845
48829
|
return containsIdentifier;
|
|
48846
48830
|
};
|
|
48847
48831
|
const isConditionallyExecuted = (node, boundary) => {
|
|
48848
|
-
for (let ancestor = node.parent; ancestor && ancestor !== boundary; ancestor = ancestor.parent) if (
|
|
48832
|
+
for (let ancestor = node.parent; ancestor && ancestor !== boundary; ancestor = ancestor.parent) if (typescriptBinding.isIfStatement(ancestor) || typescriptBinding.isConditionalExpression(ancestor) || typescriptBinding.isSwitchStatement(ancestor)) return true;
|
|
48849
48833
|
return false;
|
|
48850
48834
|
};
|
|
48851
48835
|
const analyzeDirectoryConsumer = (body, helperName, parameterName) => {
|
|
48852
48836
|
const directoryEntryCollectionNames = /* @__PURE__ */ new Set();
|
|
48853
48837
|
let unconditionallyConsumesEntries = false;
|
|
48854
48838
|
let recursivelyTraverses = false;
|
|
48855
|
-
const isDirectoryRead = (node) =>
|
|
48839
|
+
const isDirectoryRead = (node) => typescriptBinding.isCallExpression(node) && getPropertyName$1(node.expression) === "readdirSync" && node.arguments[0] !== void 0 && typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.arguments[0])) && unwrapTypescriptExpression(node.arguments[0]).getText() === parameterName;
|
|
48856
48840
|
const visitNode = (node) => {
|
|
48857
|
-
if (
|
|
48858
|
-
if (
|
|
48841
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer && isDirectoryRead(unwrapTypescriptExpression(node.initializer))) directoryEntryCollectionNames.add(node.name.text);
|
|
48842
|
+
if (typescriptBinding.isForOfStatement(node) && typescriptBinding.isVariableDeclarationList(node.initializer)) {
|
|
48859
48843
|
const collectionExpression = unwrapTypescriptExpression(node.expression);
|
|
48860
|
-
if (isDirectoryRead(collectionExpression) ||
|
|
48844
|
+
if (isDirectoryRead(collectionExpression) || typescriptBinding.isIdentifier(collectionExpression) && directoryEntryCollectionNames.has(collectionExpression.text)) {
|
|
48861
48845
|
const loopVariable = node.initializer.declarations[0]?.name;
|
|
48862
|
-
if (loopVariable &&
|
|
48846
|
+
if (loopVariable && typescriptBinding.isIdentifier(loopVariable)) {
|
|
48863
48847
|
const entryDependentNames = new Set([loopVariable.text]);
|
|
48864
48848
|
const visitLoop = (loopNode) => {
|
|
48865
|
-
if (
|
|
48866
|
-
if (
|
|
48849
|
+
if (typescriptBinding.isVariableDeclaration(loopNode) && typescriptBinding.isIdentifier(loopNode.name) && loopNode.initializer && [...entryDependentNames].some((identifierName) => expressionContainsIdentifier(loopNode.initializer, identifierName))) entryDependentNames.add(loopNode.name.text);
|
|
48850
|
+
if (typescriptBinding.isCallExpression(loopNode)) {
|
|
48867
48851
|
if (getPropertyName$1(loopNode.expression)?.match(/^(?:copyFile|readFile)(?:Sync)?$/) && loopNode.arguments.some((argument) => [...entryDependentNames].some((identifierName) => expressionContainsIdentifier(argument, identifierName)))) {
|
|
48868
48852
|
if (!isConditionallyExecuted(loopNode, node.statement)) unconditionallyConsumesEntries = true;
|
|
48869
48853
|
}
|
|
48870
48854
|
const calledExpression = unwrapTypescriptExpression(loopNode.expression);
|
|
48871
|
-
if (
|
|
48855
|
+
if (typescriptBinding.isIdentifier(calledExpression) && calledExpression.text === helperName && loopNode.arguments.some((argument) => [...entryDependentNames].some((identifierName) => expressionContainsIdentifier(argument, identifierName)))) recursivelyTraverses = true;
|
|
48872
48856
|
}
|
|
48873
|
-
|
|
48857
|
+
typescriptBinding.forEachChild(loopNode, visitLoop);
|
|
48874
48858
|
};
|
|
48875
48859
|
visitLoop(node.statement);
|
|
48876
48860
|
}
|
|
48877
48861
|
}
|
|
48878
48862
|
}
|
|
48879
|
-
|
|
48863
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48880
48864
|
};
|
|
48881
48865
|
visitNode(body);
|
|
48882
48866
|
return {
|
|
@@ -48886,11 +48870,11 @@ const analyzeDirectoryConsumer = (body, helperName, parameterName) => {
|
|
|
48886
48870
|
};
|
|
48887
48871
|
const collectRecursiveInputDirectories = (analysis, projectRoot, consumedFiles) => {
|
|
48888
48872
|
for (const node of analysis.liveNodes) {
|
|
48889
|
-
if (!
|
|
48873
|
+
if (!typescriptBinding.isCallExpression(node) || !typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.expression))) continue;
|
|
48890
48874
|
const helperName = unwrapTypescriptExpression(node.expression).getText();
|
|
48891
48875
|
const helperBody = analysis.localFunctions.get(helperName);
|
|
48892
|
-
const helperDeclaration = [...analysis.sourceFile.statements].find((statement) =>
|
|
48893
|
-
if (!helperBody || !helperDeclaration || !
|
|
48876
|
+
const helperDeclaration = [...analysis.sourceFile.statements].find((statement) => typescriptBinding.isFunctionDeclaration(statement) && statement.name?.text === helperName);
|
|
48877
|
+
if (!helperBody || !helperDeclaration || !typescriptBinding.isFunctionDeclaration(helperDeclaration) || !helperDeclaration.parameters[0] || !typescriptBinding.isIdentifier(helperDeclaration.parameters[0].name)) continue;
|
|
48894
48878
|
const directoryConsumption = analyzeDirectoryConsumer(helperBody, helperName, helperDeclaration.parameters[0].name.text);
|
|
48895
48879
|
if (!directoryConsumption.consumesAllEntries) continue;
|
|
48896
48880
|
const directoryArgument = node.arguments[0];
|
|
@@ -48901,9 +48885,9 @@ const collectRecursiveInputDirectories = (analysis, projectRoot, consumedFiles)
|
|
|
48901
48885
|
};
|
|
48902
48886
|
const evaluateCopySourceExpression = (expression, loopVariableName, loopVariableValue) => {
|
|
48903
48887
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48904
|
-
if (
|
|
48905
|
-
if (
|
|
48906
|
-
if (
|
|
48888
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) return unwrappedExpression.text === loopVariableName ? loopVariableValue : void 0;
|
|
48889
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) return unwrappedExpression.text;
|
|
48890
|
+
if (typescriptBinding.isTemplateExpression(unwrappedExpression)) {
|
|
48907
48891
|
let resolvedTemplate = unwrappedExpression.head.text;
|
|
48908
48892
|
for (const templateSpan of unwrappedExpression.templateSpans) {
|
|
48909
48893
|
const resolvedExpression = evaluateCopySourceExpression(templateSpan.expression, loopVariableName, loopVariableValue);
|
|
@@ -48912,7 +48896,7 @@ const evaluateCopySourceExpression = (expression, loopVariableName, loopVariable
|
|
|
48912
48896
|
}
|
|
48913
48897
|
return resolvedTemplate;
|
|
48914
48898
|
}
|
|
48915
|
-
if (
|
|
48899
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.PlusToken) {
|
|
48916
48900
|
const leftValue = evaluateCopySourceExpression(unwrappedExpression.left, loopVariableName, loopVariableValue);
|
|
48917
48901
|
const rightValue = evaluateCopySourceExpression(unwrappedExpression.right, loopVariableName, loopVariableValue);
|
|
48918
48902
|
return leftValue === void 0 || rightValue === void 0 ? void 0 : `${leftValue}${rightValue}`;
|
|
@@ -48920,25 +48904,25 @@ const evaluateCopySourceExpression = (expression, loopVariableName, loopVariable
|
|
|
48920
48904
|
};
|
|
48921
48905
|
const collectCopiedSourceFiles = (analysis, projectRoot, consumedFiles) => {
|
|
48922
48906
|
for (const node of analysis.liveNodes) {
|
|
48923
|
-
if (!
|
|
48924
|
-
if (!
|
|
48907
|
+
if (!typescriptBinding.isForOfStatement(node) || !analysis.liveNodes.has(node.statement)) continue;
|
|
48908
|
+
if (!typescriptBinding.isVariableDeclarationList(node.initializer) || node.initializer.declarations.length !== 1 || !typescriptBinding.isIdentifier(node.initializer.declarations[0].name) || !typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.expression))) continue;
|
|
48925
48909
|
const loopVariableName = node.initializer.declarations[0].name.text;
|
|
48926
48910
|
const arrayIdentifier = unwrapTypescriptExpression(node.expression);
|
|
48927
|
-
if (!
|
|
48911
|
+
if (!typescriptBinding.isIdentifier(arrayIdentifier)) continue;
|
|
48928
48912
|
const arrayDeclaration = findVariableDeclaration(analysis.sourceFile, arrayIdentifier.text, node.getStart(analysis.sourceFile));
|
|
48929
|
-
if (!arrayDeclaration?.initializer || !
|
|
48913
|
+
if (!arrayDeclaration?.initializer || !typescriptBinding.isArrayLiteralExpression(arrayDeclaration.initializer)) continue;
|
|
48930
48914
|
const values = arrayDeclaration.initializer.elements.flatMap((element) => {
|
|
48931
48915
|
const unwrappedElement = unwrapTypescriptExpression(element);
|
|
48932
|
-
return
|
|
48916
|
+
return typescriptBinding.isStringLiteralLike(unwrappedElement) ? [unwrappedElement.text] : [];
|
|
48933
48917
|
});
|
|
48934
48918
|
const visitLoopBody = (loopNode) => {
|
|
48935
|
-
if (
|
|
48919
|
+
if (typescriptBinding.isCallExpression(loopNode) && getPropertyName$1(loopNode.expression)?.match(/^copyFile(?:Sync)?$/) && loopNode.arguments[0]) for (const value of values) {
|
|
48936
48920
|
const sourceReference = evaluateCopySourceExpression(loopNode.arguments[0], loopVariableName, value);
|
|
48937
48921
|
if (!sourceReference) continue;
|
|
48938
48922
|
const sourcePath = resolveBuildReference(sourceReference, analysis.scriptFile.workingDirectory, projectRoot);
|
|
48939
48923
|
if (isPathInsideDirectoryOrEqual(sourcePath, projectRoot) && existsSync(sourcePath) && statSync(sourcePath).isFile() && SOURCE_FILE_EXTENSION_PATTERN.test(sourcePath)) consumedFiles.add(sourcePath);
|
|
48940
48924
|
}
|
|
48941
|
-
|
|
48925
|
+
typescriptBinding.forEachChild(loopNode, visitLoopBody);
|
|
48942
48926
|
};
|
|
48943
48927
|
visitLoopBody(node.statement);
|
|
48944
48928
|
}
|
|
@@ -48947,56 +48931,56 @@ const expressionContainsString = (expression, value) => {
|
|
|
48947
48931
|
let containsString = false;
|
|
48948
48932
|
const visitNode = (node) => {
|
|
48949
48933
|
if (containsString) return;
|
|
48950
|
-
if (
|
|
48934
|
+
if (typescriptBinding.isStringLiteralLike(node) && node.text === value) {
|
|
48951
48935
|
containsString = true;
|
|
48952
48936
|
return;
|
|
48953
48937
|
}
|
|
48954
|
-
|
|
48938
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48955
48939
|
};
|
|
48956
48940
|
visitNode(expression);
|
|
48957
48941
|
return containsString;
|
|
48958
48942
|
};
|
|
48959
48943
|
const collectObjectPathReferences = (expression, fileReferences) => {
|
|
48960
48944
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48961
|
-
if (
|
|
48945
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) {
|
|
48962
48946
|
fileReferences.add(unwrappedExpression.text);
|
|
48963
48947
|
return;
|
|
48964
48948
|
}
|
|
48965
|
-
if (
|
|
48949
|
+
if (typescriptBinding.isArrayLiteralExpression(unwrappedExpression)) {
|
|
48966
48950
|
for (const element of unwrappedExpression.elements) collectObjectPathReferences(element, fileReferences);
|
|
48967
48951
|
return;
|
|
48968
48952
|
}
|
|
48969
|
-
if (!
|
|
48953
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
48970
48954
|
for (const property of unwrappedExpression.properties) {
|
|
48971
|
-
if (!
|
|
48972
|
-
if ((
|
|
48955
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
48956
|
+
if ((typescriptBinding.isIdentifier(property.name) || typescriptBinding.isStringLiteralLike(property.name) ? property.name.text : void 0) === "path") collectObjectPathReferences(property.initializer, fileReferences);
|
|
48973
48957
|
}
|
|
48974
48958
|
};
|
|
48975
48959
|
const findStyleRegistryFanoutSources = (analysis, analyses) => {
|
|
48976
48960
|
for (const node of analysis.liveNodes) {
|
|
48977
|
-
if (!
|
|
48961
|
+
if (!typescriptBinding.isForOfStatement(node) || !typescriptBinding.isVariableDeclarationList(node.initializer) || node.initializer.declarations.length !== 1 || !typescriptBinding.isIdentifier(node.initializer.declarations[0].name) || !typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.expression))) continue;
|
|
48978
48962
|
const styleVariableName = node.initializer.declarations[0].name.text;
|
|
48979
48963
|
const styleCollectionExpression = unwrapTypescriptExpression(node.expression);
|
|
48980
|
-
if (!
|
|
48964
|
+
if (!typescriptBinding.isIdentifier(styleCollectionExpression)) continue;
|
|
48981
48965
|
const stylesImport = analysis.importedFunctions.get(styleCollectionExpression.text);
|
|
48982
48966
|
const stylesAnalysis = stylesImport ? analyses.get(stylesImport.analysisKey) : void 0;
|
|
48983
48967
|
if (!stylesAnalysis) continue;
|
|
48984
48968
|
let registryAnalysis;
|
|
48985
48969
|
const visitStyleLoop = (loopNode) => {
|
|
48986
|
-
if (registryAnalysis || !
|
|
48987
|
-
if (!registryAnalysis)
|
|
48970
|
+
if (registryAnalysis || !typescriptBinding.isForOfStatement(loopNode)) {
|
|
48971
|
+
if (!registryAnalysis) typescriptBinding.forEachChild(loopNode, visitStyleLoop);
|
|
48988
48972
|
return;
|
|
48989
48973
|
}
|
|
48990
|
-
if (!
|
|
48991
|
-
|
|
48974
|
+
if (!typescriptBinding.isVariableDeclarationList(loopNode.initializer) || loopNode.initializer.declarations.length !== 1 || !typescriptBinding.isIdentifier(loopNode.initializer.declarations[0].name) || !typescriptBinding.isIdentifier(unwrapTypescriptExpression(loopNode.expression))) {
|
|
48975
|
+
typescriptBinding.forEachChild(loopNode, visitStyleLoop);
|
|
48992
48976
|
return;
|
|
48993
48977
|
}
|
|
48994
48978
|
const registryItemName = loopNode.initializer.declarations[0].name.text;
|
|
48995
48979
|
const registryCollectionExpression = unwrapTypescriptExpression(loopNode.expression);
|
|
48996
|
-
if (!
|
|
48980
|
+
if (!typescriptBinding.isIdentifier(registryCollectionExpression)) return;
|
|
48997
48981
|
const normalizedLoopBodyText = loopNode.statement.getText(analysis.sourceFile).replace(/\s/g, "");
|
|
48998
48982
|
if (!normalizedLoopBodyText.includes(`src/registry/\${${styleVariableName}.name}/`) || !normalizedLoopBodyText.includes(`${registryItemName}.files`) || !/\$\{[A-Za-z_$][\w$]*\.path\}/.test(normalizedLoopBodyText)) {
|
|
48999
|
-
|
|
48983
|
+
typescriptBinding.forEachChild(loopNode, visitStyleLoop);
|
|
49000
48984
|
return;
|
|
49001
48985
|
}
|
|
49002
48986
|
const registryImport = analysis.importedFunctions.get(registryCollectionExpression.text);
|
|
@@ -49013,10 +48997,10 @@ const collectRegistryFileReferences = (registryAnalysis, analyses) => {
|
|
|
49013
48997
|
const registryFileReferences = /* @__PURE__ */ new Set();
|
|
49014
48998
|
const collectRegistryModule = (moduleAnalysis) => {
|
|
49015
48999
|
const visitNode = (node) => {
|
|
49016
|
-
if (
|
|
49017
|
-
if ((
|
|
49000
|
+
if (typescriptBinding.isPropertyAssignment(node)) {
|
|
49001
|
+
if ((typescriptBinding.isIdentifier(node.name) || typescriptBinding.isStringLiteralLike(node.name) ? node.name.text : void 0) === "files") collectObjectPathReferences(node.initializer, registryFileReferences);
|
|
49018
49002
|
}
|
|
49019
|
-
|
|
49003
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49020
49004
|
};
|
|
49021
49005
|
visitNode(moduleAnalysis.sourceFile);
|
|
49022
49006
|
};
|
|
@@ -49030,11 +49014,11 @@ const collectRegistryFileReferences = (registryAnalysis, analyses) => {
|
|
|
49030
49014
|
const collectRegistryStyleNames = (stylesAnalysis) => {
|
|
49031
49015
|
const styleNames = /* @__PURE__ */ new Set();
|
|
49032
49016
|
const visitNode = (node) => {
|
|
49033
|
-
if (
|
|
49017
|
+
if (typescriptBinding.isPropertyAssignment(node) && (typescriptBinding.isIdentifier(node.name) || typescriptBinding.isStringLiteralLike(node.name)) && node.name.text === "name") {
|
|
49034
49018
|
const styleNameExpression = unwrapTypescriptExpression(node.initializer);
|
|
49035
|
-
if (
|
|
49019
|
+
if (typescriptBinding.isStringLiteralLike(styleNameExpression)) styleNames.add(styleNameExpression.text);
|
|
49036
49020
|
}
|
|
49037
|
-
|
|
49021
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49038
49022
|
};
|
|
49039
49023
|
visitNode(stylesAnalysis.sourceFile);
|
|
49040
49024
|
return styleNames;
|
|
@@ -49048,7 +49032,7 @@ const collectResolvedRegistryFiles = (registryFileReferences, styleNames, regist
|
|
|
49048
49032
|
const collectRegistryMetadataConsumedFiles = (analyses, projectRoot, consumedFiles) => {
|
|
49049
49033
|
for (const analysis of analyses.values()) {
|
|
49050
49034
|
if (!basename(analysis.scriptFile.filePath).includes("registry")) continue;
|
|
49051
|
-
if (![...analysis.liveNodes].some((node) =>
|
|
49035
|
+
if (![...analysis.liveNodes].some((node) => typescriptBinding.isCallExpression(node) && getPropertyName$1(node.expression)?.match(/^readFile(?:Sync)?$/) && node.arguments[0] !== void 0 && expressionContainsString(node.arguments[0], "src/registry"))) continue;
|
|
49052
49036
|
const registryImport = analysis.importedFunctions.get("registry");
|
|
49053
49037
|
const stylesImport = analysis.importedFunctions.get("styles");
|
|
49054
49038
|
const registryAnalysis = registryImport ? analyses.get(registryImport.analysisKey) : void 0;
|
|
@@ -49069,7 +49053,7 @@ const nodeContainsNode = (rootNode, targetNode) => {
|
|
|
49069
49053
|
containsNode = true;
|
|
49070
49054
|
return;
|
|
49071
49055
|
}
|
|
49072
|
-
if (!containsNode)
|
|
49056
|
+
if (!containsNode) typescriptBinding.forEachChild(node, visitNode);
|
|
49073
49057
|
};
|
|
49074
49058
|
visitNode(rootNode);
|
|
49075
49059
|
return containsNode;
|
|
@@ -49078,11 +49062,11 @@ const findAssignedVariableName = (analysis, targetNode) => {
|
|
|
49078
49062
|
let variableName;
|
|
49079
49063
|
let smallestInitializerWidth = Number.POSITIVE_INFINITY;
|
|
49080
49064
|
const visitNode = (node) => {
|
|
49081
|
-
if (
|
|
49065
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer && nodeContainsNode(node.initializer, targetNode) && node.initializer.end - node.initializer.pos < smallestInitializerWidth) {
|
|
49082
49066
|
variableName = node.name.text;
|
|
49083
49067
|
smallestInitializerWidth = node.initializer.end - node.initializer.pos;
|
|
49084
49068
|
}
|
|
49085
|
-
|
|
49069
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49086
49070
|
};
|
|
49087
49071
|
visitNode(analysis.sourceFile);
|
|
49088
49072
|
return variableName;
|
|
@@ -49090,29 +49074,29 @@ const findAssignedVariableName = (analysis, targetNode) => {
|
|
|
49090
49074
|
const recursivelyReadsManifestWildcards = (analysis, readCall) => {
|
|
49091
49075
|
const registryVariableName = findAssignedVariableName(analysis, readCall);
|
|
49092
49076
|
if (!registryVariableName) return false;
|
|
49093
|
-
const hasDirectRecursiveRead = [...analysis.liveNodes].some((node) =>
|
|
49077
|
+
const hasDirectRecursiveRead = [...analysis.liveNodes].some((node) => typescriptBinding.isCallExpression(node) && typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.expression)) && unwrapTypescriptExpression(node.expression).getText() === "walk" && node.arguments.length >= 1 && typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.arguments[0])) && unwrapTypescriptExpression(node.arguments[0]).getText() === "sourceBase");
|
|
49094
49078
|
const sourceBaseDeclaration = findVariableDeclaration(analysis.sourceFile, "sourceBase", analysis.sourceFile.end);
|
|
49095
49079
|
if (hasDirectRecursiveRead && sourceBaseDeclaration?.initializer && sourceBaseDeclaration.initializer.getText(analysis.sourceFile).includes(registryVariableName) && sourceBaseDeclaration.initializer.getText(analysis.sourceFile).includes("split")) return true;
|
|
49096
49080
|
const collectionNames = new Set([registryVariableName]);
|
|
49097
|
-
for (const node of analysis.liveNodes) if (
|
|
49081
|
+
for (const node of analysis.liveNodes) if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer && typescriptBinding.isPropertyAccessExpression(unwrapTypescriptExpression(node.initializer))) {
|
|
49098
49082
|
const propertyAccess = unwrapTypescriptExpression(node.initializer);
|
|
49099
|
-
if (
|
|
49083
|
+
if (typescriptBinding.isPropertyAccessExpression(propertyAccess) && typescriptBinding.isIdentifier(propertyAccess.expression) && collectionNames.has(propertyAccess.expression.text)) collectionNames.add(node.name.text);
|
|
49100
49084
|
}
|
|
49101
49085
|
for (const node of analysis.liveNodes) {
|
|
49102
|
-
if (!
|
|
49086
|
+
if (!typescriptBinding.isForOfStatement(node) || !typescriptBinding.isVariableDeclarationList(node.initializer) || node.initializer.declarations.length !== 1 || !typescriptBinding.isIdentifier(node.initializer.declarations[0].name) || !typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.expression))) continue;
|
|
49103
49087
|
const collectionExpression = unwrapTypescriptExpression(node.expression);
|
|
49104
|
-
if (!
|
|
49088
|
+
if (!typescriptBinding.isIdentifier(collectionExpression) || !collectionNames.has(collectionExpression.text)) continue;
|
|
49105
49089
|
const componentName = node.initializer.declarations[0].name.text;
|
|
49106
49090
|
let hasRecursiveFileLoop = false;
|
|
49107
49091
|
const visitOuterLoop = (outerNode) => {
|
|
49108
|
-
if (
|
|
49092
|
+
if (typescriptBinding.isForOfStatement(outerNode) && typescriptBinding.isPropertyAccessExpression(unwrapTypescriptExpression(outerNode.expression))) {
|
|
49109
49093
|
const filesExpression = unwrapTypescriptExpression(outerNode.expression);
|
|
49110
|
-
if (
|
|
49094
|
+
if (typescriptBinding.isPropertyAccessExpression(filesExpression) && typescriptBinding.isIdentifier(filesExpression.expression) && filesExpression.expression.text === componentName && filesExpression.name.text === "files") {
|
|
49111
49095
|
const innerLoopText = outerNode.statement.getText(analysis.sourceFile);
|
|
49112
49096
|
if (/\.includes\(\s*["']\*["']\s*\)/.test(innerLoopText) && /\.split\(\s*["']\*["']\s*\)/.test(innerLoopText) && /\bwalk\s*\(\s*sourceBase\s*,\s*sourceBase\s*\)/.test(innerLoopText)) hasRecursiveFileLoop = true;
|
|
49113
49097
|
}
|
|
49114
49098
|
}
|
|
49115
|
-
if (!hasRecursiveFileLoop)
|
|
49099
|
+
if (!hasRecursiveFileLoop) typescriptBinding.forEachChild(outerNode, visitOuterLoop);
|
|
49116
49100
|
};
|
|
49117
49101
|
visitOuterLoop(node.statement);
|
|
49118
49102
|
if (hasRecursiveFileLoop) return true;
|
|
@@ -49121,7 +49105,7 @@ const recursivelyReadsManifestWildcards = (analysis, readCall) => {
|
|
|
49121
49105
|
};
|
|
49122
49106
|
const collectReferencedManifestFiles = (analysis, projectRoot, consumedFiles) => {
|
|
49123
49107
|
for (const node of analysis.liveNodes) {
|
|
49124
|
-
if (!
|
|
49108
|
+
if (!typescriptBinding.isCallExpression(node) || !getPropertyName$1(node.expression)?.match(/^readFile(?:Sync)?$/) || !node.arguments[0]) continue;
|
|
49125
49109
|
const manifestPath = evaluatePathExpression(node.arguments[0], analysis, projectRoot);
|
|
49126
49110
|
if (!manifestPath || basename(manifestPath) !== "registry.json") continue;
|
|
49127
49111
|
if (!isPathInsideDirectoryOrEqual(manifestPath, projectRoot)) continue;
|
|
@@ -49312,46 +49296,46 @@ const collectParcelHtmlEntryPaths = (rootDirectory) => {
|
|
|
49312
49296
|
} catch {
|
|
49313
49297
|
continue;
|
|
49314
49298
|
}
|
|
49315
|
-
const sourceFile =
|
|
49299
|
+
const sourceFile = typescriptBinding.createSourceFile(scriptPath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49316
49300
|
const parcelConstructorNames = /* @__PURE__ */ new Set();
|
|
49317
49301
|
const variableInitializers = /* @__PURE__ */ new Map();
|
|
49318
49302
|
for (const statement of sourceFile.statements) {
|
|
49319
|
-
if (
|
|
49303
|
+
if (typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteralLike(statement.moduleSpecifier) && statement.moduleSpecifier.text === "parcel-bundler") {
|
|
49320
49304
|
const importClause = statement.importClause;
|
|
49321
49305
|
if (importClause?.name) parcelConstructorNames.add(importClause.name.text);
|
|
49322
49306
|
}
|
|
49323
|
-
if (!
|
|
49307
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
49324
49308
|
for (const declaration of statement.declarationList.declarations) {
|
|
49325
|
-
if (!
|
|
49309
|
+
if (!typescriptBinding.isIdentifier(declaration.name) || !declaration.initializer) continue;
|
|
49326
49310
|
variableInitializers.set(declaration.name.text, declaration.initializer);
|
|
49327
|
-
if (
|
|
49311
|
+
if (typescriptBinding.isCallExpression(declaration.initializer) && typescriptBinding.isIdentifier(declaration.initializer.expression) && declaration.initializer.expression.text === "require" && declaration.initializer.arguments.length === 1 && typescriptBinding.isStringLiteralLike(declaration.initializer.arguments[0]) && declaration.initializer.arguments[0].text === "parcel-bundler") parcelConstructorNames.add(declaration.name.text);
|
|
49328
49312
|
}
|
|
49329
49313
|
}
|
|
49330
49314
|
if (parcelConstructorNames.size === 0) continue;
|
|
49331
49315
|
const evaluateEntryExpression = (expression, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
49332
|
-
if (
|
|
49333
|
-
if (
|
|
49334
|
-
if (
|
|
49316
|
+
if (typescriptBinding.isStringLiteralLike(expression)) return [expression.text];
|
|
49317
|
+
if (typescriptBinding.isArrayLiteralExpression(expression)) return expression.elements.flatMap((element) => typescriptBinding.isExpression(element) ? evaluateEntryExpression(element, visitedIdentifiers) : []);
|
|
49318
|
+
if (typescriptBinding.isIdentifier(expression)) {
|
|
49335
49319
|
if (visitedIdentifiers.has(expression.text)) return [];
|
|
49336
49320
|
const initializer = variableInitializers.get(expression.text);
|
|
49337
49321
|
if (!initializer) return [];
|
|
49338
49322
|
return evaluateEntryExpression(initializer, new Set(visitedIdentifiers).add(expression.text));
|
|
49339
49323
|
}
|
|
49340
|
-
if (
|
|
49341
|
-
const pathSegments = expression.arguments.slice(1).flatMap((argument) =>
|
|
49324
|
+
if (typescriptBinding.isCallExpression(expression) && typescriptBinding.isPropertyAccessExpression(expression.expression) && (expression.expression.name.text === "join" || expression.expression.name.text === "resolve") && expression.arguments.length > 1 && typescriptBinding.isIdentifier(expression.arguments[0]) && expression.arguments[0].text === "__dirname" && expression.arguments.slice(1).every(typescriptBinding.isStringLiteralLike)) {
|
|
49325
|
+
const pathSegments = expression.arguments.slice(1).flatMap((argument) => typescriptBinding.isStringLiteralLike(argument) ? [argument.text] : []);
|
|
49342
49326
|
return [resolve(dirname(scriptPath), ...pathSegments)];
|
|
49343
49327
|
}
|
|
49344
49328
|
return [];
|
|
49345
49329
|
};
|
|
49346
49330
|
const visitNode = (node) => {
|
|
49347
|
-
if (
|
|
49331
|
+
if (typescriptBinding.isNewExpression(node) && typescriptBinding.isIdentifier(node.expression) && parcelConstructorNames.has(node.expression.text) && node.arguments?.[0]) for (const entrySpecifier of evaluateEntryExpression(node.arguments[0])) {
|
|
49348
49332
|
const entryPattern = isAbsolute(entrySpecifier) ? entrySpecifier : resolve(dirname(scriptPath), entrySpecifier);
|
|
49349
49333
|
for (const htmlEntryPath of import_out.default.sync(entryPattern.replaceAll("\\", "/"), {
|
|
49350
49334
|
absolute: true,
|
|
49351
49335
|
onlyFiles: true
|
|
49352
49336
|
})) if (/\.html?$/i.test(htmlEntryPath)) htmlEntryPaths.add(htmlEntryPath);
|
|
49353
49337
|
}
|
|
49354
|
-
|
|
49338
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49355
49339
|
};
|
|
49356
49340
|
visitNode(sourceFile);
|
|
49357
49341
|
}
|
|
@@ -49397,22 +49381,22 @@ const isConsumedStringLiteral = (node) => {
|
|
|
49397
49381
|
let currentNode = node;
|
|
49398
49382
|
while (currentNode.parent) {
|
|
49399
49383
|
const parentNode = currentNode.parent;
|
|
49400
|
-
if (
|
|
49401
|
-
if (
|
|
49384
|
+
if (typescriptBinding.isCallExpression(parentNode) || typescriptBinding.isNewExpression(parentNode) || typescriptBinding.isPropertyAssignment(parentNode) || typescriptBinding.isExportAssignment(parentNode) || typescriptBinding.isReturnStatement(parentNode)) return true;
|
|
49385
|
+
if (typescriptBinding.isVariableDeclaration(parentNode) || typescriptBinding.isExpressionStatement(parentNode) || typescriptBinding.isSourceFile(parentNode)) return false;
|
|
49402
49386
|
currentNode = parentNode;
|
|
49403
49387
|
}
|
|
49404
49388
|
return false;
|
|
49405
49389
|
};
|
|
49406
49390
|
const matchesExecutableNodeModulesPackageReference = (content, packageName) => {
|
|
49407
|
-
const sourceFile =
|
|
49391
|
+
const sourceFile = typescriptBinding.createSourceFile("node-modules-reference.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49408
49392
|
let isMatched = false;
|
|
49409
49393
|
const visit = (node) => {
|
|
49410
49394
|
if (isMatched) return;
|
|
49411
|
-
if (
|
|
49395
|
+
if (typescriptBinding.isStringLiteralLike(node) && isConsumedStringLiteral(node) && matchesNodeModulesPackageReference(node.text, packageName)) {
|
|
49412
49396
|
isMatched = true;
|
|
49413
49397
|
return;
|
|
49414
49398
|
}
|
|
49415
|
-
|
|
49399
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49416
49400
|
};
|
|
49417
49401
|
visit(sourceFile);
|
|
49418
49402
|
return isMatched;
|
|
@@ -49472,14 +49456,14 @@ const collectTwoslashPackageNames = (sourceText) => {
|
|
|
49472
49456
|
const packageNames = /* @__PURE__ */ new Set();
|
|
49473
49457
|
for (const source of sources) try {
|
|
49474
49458
|
for (const packageName of collectStaticModulePackageNames(source)) packageNames.add(packageName);
|
|
49475
|
-
const sourceFile =
|
|
49459
|
+
const sourceFile = typescriptBinding.createSourceFile("twoslash-source.js", source, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.JS);
|
|
49476
49460
|
const visitNode = (node) => {
|
|
49477
|
-
for (const tag of
|
|
49478
|
-
if (!
|
|
49461
|
+
for (const tag of typescriptBinding.getJSDocTags(node)) {
|
|
49462
|
+
if (!typescriptBinding.isJSDocImportTag(tag) || !typescriptBinding.isStringLiteralLike(tag.moduleSpecifier)) continue;
|
|
49479
49463
|
const packageName = extractPackageName(tag.moduleSpecifier.text);
|
|
49480
49464
|
if (packageName) packageNames.add(packageName);
|
|
49481
49465
|
}
|
|
49482
|
-
|
|
49466
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49483
49467
|
};
|
|
49484
49468
|
visitNode(sourceFile);
|
|
49485
49469
|
} catch {
|
|
@@ -49533,27 +49517,27 @@ const KARMA_BROWSER_PACKAGES = new Map([
|
|
|
49533
49517
|
["Safari", ["karma-safari-launcher"]]
|
|
49534
49518
|
]);
|
|
49535
49519
|
const collectExpressionStrings = (expression, identifierStrings, strings) => {
|
|
49536
|
-
if (
|
|
49520
|
+
if (typescriptBinding.isStringLiteralLike(expression)) {
|
|
49537
49521
|
strings.add(expression.text);
|
|
49538
49522
|
return;
|
|
49539
49523
|
}
|
|
49540
|
-
if (
|
|
49524
|
+
if (typescriptBinding.isIdentifier(expression)) {
|
|
49541
49525
|
for (const value of identifierStrings.get(expression.text) ?? []) strings.add(value);
|
|
49542
49526
|
return;
|
|
49543
49527
|
}
|
|
49544
|
-
if (
|
|
49545
|
-
for (const element of expression.elements) if (
|
|
49528
|
+
if (typescriptBinding.isArrayLiteralExpression(expression)) {
|
|
49529
|
+
for (const element of expression.elements) if (typescriptBinding.isSpreadElement(element)) collectExpressionStrings(element.expression, identifierStrings, strings);
|
|
49546
49530
|
else collectExpressionStrings(element, identifierStrings, strings);
|
|
49547
49531
|
return;
|
|
49548
49532
|
}
|
|
49549
|
-
if (
|
|
49533
|
+
if (typescriptBinding.isConditionalExpression(expression)) {
|
|
49550
49534
|
collectExpressionStrings(expression.whenTrue, identifierStrings, strings);
|
|
49551
49535
|
collectExpressionStrings(expression.whenFalse, identifierStrings, strings);
|
|
49552
49536
|
return;
|
|
49553
49537
|
}
|
|
49554
|
-
if (
|
|
49555
|
-
for (const property of expression.properties) if (
|
|
49556
|
-
else if (
|
|
49538
|
+
if (typescriptBinding.isObjectLiteralExpression(expression)) {
|
|
49539
|
+
for (const property of expression.properties) if (typescriptBinding.isPropertyAssignment(property)) collectExpressionStrings(property.initializer, identifierStrings, strings);
|
|
49540
|
+
else if (typescriptBinding.isShorthandPropertyAssignment(property)) for (const value of identifierStrings.get(property.name.text) ?? []) strings.add(value);
|
|
49557
49541
|
}
|
|
49558
49542
|
};
|
|
49559
49543
|
const collectIdentifierStrings = (sourceFile) => {
|
|
@@ -49564,21 +49548,21 @@ const collectIdentifierStrings = (sourceFile) => {
|
|
|
49564
49548
|
identifierStrings.set(identifierName, strings);
|
|
49565
49549
|
};
|
|
49566
49550
|
const visit = (node) => {
|
|
49567
|
-
if (
|
|
49568
|
-
if (
|
|
49569
|
-
|
|
49551
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer) addExpression(node.name.text, node.initializer);
|
|
49552
|
+
if (typescriptBinding.isBinaryExpression(node) && node.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken && typescriptBinding.isIdentifier(node.left)) addExpression(node.left.text, node.right);
|
|
49553
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49570
49554
|
};
|
|
49571
49555
|
visit(sourceFile);
|
|
49572
49556
|
return identifierStrings;
|
|
49573
49557
|
};
|
|
49574
49558
|
const collectPropertyStrings = (property, identifierStrings) => {
|
|
49575
49559
|
const strings = /* @__PURE__ */ new Set();
|
|
49576
|
-
if (
|
|
49577
|
-
else if (
|
|
49560
|
+
if (typescriptBinding.isPropertyAssignment(property)) collectExpressionStrings(property.initializer, identifierStrings, strings);
|
|
49561
|
+
else if (typescriptBinding.isShorthandPropertyAssignment(property)) for (const value of identifierStrings.get(property.name.text) ?? []) strings.add(value);
|
|
49578
49562
|
return strings;
|
|
49579
49563
|
};
|
|
49580
49564
|
const extractKarmaConfigPackageReferences = (content, declaredPackageNames) => {
|
|
49581
|
-
const sourceFile =
|
|
49565
|
+
const sourceFile = typescriptBinding.createSourceFile("karma.config.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49582
49566
|
const identifierStrings = collectIdentifierStrings(sourceFile);
|
|
49583
49567
|
const referencedPackages = /* @__PURE__ */ new Set();
|
|
49584
49568
|
const propertyPackageMaps = new Map([
|
|
@@ -49588,12 +49572,12 @@ const extractKarmaConfigPackageReferences = (content, declaredPackageNames) => {
|
|
|
49588
49572
|
["browsers", KARMA_BROWSER_PACKAGES]
|
|
49589
49573
|
]);
|
|
49590
49574
|
const visit = (node) => {
|
|
49591
|
-
if (
|
|
49575
|
+
if (typescriptBinding.isObjectLiteralExpression(node)) for (const property of node.properties) {
|
|
49592
49576
|
const packageMap = propertyPackageMaps.get(getObjectLiteralElementName(property) ?? "");
|
|
49593
49577
|
if (!packageMap) continue;
|
|
49594
49578
|
for (const token of collectPropertyStrings(property, identifierStrings)) for (const packageName of packageMap.get(token) ?? []) if (declaredPackageNames.has(packageName)) referencedPackages.add(packageName);
|
|
49595
49579
|
}
|
|
49596
|
-
|
|
49580
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49597
49581
|
};
|
|
49598
49582
|
visit(sourceFile);
|
|
49599
49583
|
return [...referencedPackages];
|
|
@@ -49610,23 +49594,23 @@ const hasExpoReactServerFunctions = (rootDirectory) => {
|
|
|
49610
49594
|
//#endregion
|
|
49611
49595
|
//#region ../core/src/project-analysis/utils/has-antfu-eslint-react-config.ts
|
|
49612
49596
|
const hasReactEnabled = (expression) => {
|
|
49613
|
-
if (!
|
|
49614
|
-
return expression.properties.some((property) =>
|
|
49597
|
+
if (!typescriptBinding.isObjectLiteralExpression(expression)) return false;
|
|
49598
|
+
return expression.properties.some((property) => typescriptBinding.isPropertyAssignment(property) && (typescriptBinding.isIdentifier(property.name) && property.name.text === "react" || typescriptBinding.isStringLiteralLike(property.name) && property.name.text === "react") && (property.initializer.kind === typescriptBinding.SyntaxKind.TrueKeyword || typescriptBinding.isObjectLiteralExpression(property.initializer)));
|
|
49615
49599
|
};
|
|
49616
49600
|
const hasAntfuEslintReactConfig = (content) => {
|
|
49617
49601
|
const virtualFilePath = "eslint.config.ts";
|
|
49618
|
-
const sourceFile =
|
|
49602
|
+
const sourceFile = typescriptBinding.createSourceFile(virtualFilePath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49619
49603
|
const compilerOptions = {
|
|
49620
49604
|
allowJs: true,
|
|
49621
49605
|
noLib: true,
|
|
49622
49606
|
noResolve: true,
|
|
49623
|
-
target:
|
|
49607
|
+
target: typescriptBinding.ScriptTarget.Latest
|
|
49624
49608
|
};
|
|
49625
|
-
const compilerHost =
|
|
49609
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
49626
49610
|
compilerHost.fileExists = (candidatePath) => candidatePath === virtualFilePath;
|
|
49627
49611
|
compilerHost.getSourceFile = (candidatePath) => candidatePath === virtualFilePath ? sourceFile : void 0;
|
|
49628
49612
|
compilerHost.readFile = (candidatePath) => candidatePath === virtualFilePath ? content : void 0;
|
|
49629
|
-
const program =
|
|
49613
|
+
const program = typescriptBinding.createProgram({
|
|
49630
49614
|
rootNames: [virtualFilePath],
|
|
49631
49615
|
options: compilerOptions,
|
|
49632
49616
|
host: compilerHost
|
|
@@ -49636,24 +49620,24 @@ const hasAntfuEslintReactConfig = (content) => {
|
|
|
49636
49620
|
const typeChecker = program.getTypeChecker();
|
|
49637
49621
|
const antfuFactorySymbols = /* @__PURE__ */ new Set();
|
|
49638
49622
|
for (const statement of boundSourceFile.statements) {
|
|
49639
|
-
if (!
|
|
49623
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteralLike(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "@antfu/eslint-config" || !statement.importClause?.name) continue;
|
|
49640
49624
|
const factorySymbol = typeChecker.getSymbolAtLocation(statement.importClause.name);
|
|
49641
49625
|
if (factorySymbol) antfuFactorySymbols.add(factorySymbol);
|
|
49642
49626
|
}
|
|
49643
49627
|
let isReactEnabled = false;
|
|
49644
49628
|
const visit = (node) => {
|
|
49645
49629
|
if (isReactEnabled) return;
|
|
49646
|
-
if (
|
|
49647
|
-
if (
|
|
49630
|
+
if (typescriptBinding.isFunctionLike(node)) return;
|
|
49631
|
+
if (typescriptBinding.isCallExpression(node) && node.arguments[0] && hasReactEnabled(node.arguments[0])) {
|
|
49648
49632
|
const factorySymbol = typeChecker.getSymbolAtLocation(node.expression);
|
|
49649
49633
|
if (factorySymbol && antfuFactorySymbols.has(factorySymbol)) {
|
|
49650
49634
|
isReactEnabled = true;
|
|
49651
49635
|
return;
|
|
49652
49636
|
}
|
|
49653
49637
|
}
|
|
49654
|
-
|
|
49638
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49655
49639
|
};
|
|
49656
|
-
for (const statement of boundSourceFile.statements) if (
|
|
49640
|
+
for (const statement of boundSourceFile.statements) if (typescriptBinding.isExportAssignment(statement)) visit(statement.expression);
|
|
49657
49641
|
return isReactEnabled;
|
|
49658
49642
|
};
|
|
49659
49643
|
//#endregion
|
|
@@ -51060,13 +51044,6 @@ const buildPlatformSiblingIndex = (graph, additionalPlatformSuffixesForFile = ()
|
|
|
51060
51044
|
return siblingIndex;
|
|
51061
51045
|
};
|
|
51062
51046
|
//#endregion
|
|
51063
|
-
//#region ../core/src/project-info/fs-utils.ts
|
|
51064
|
-
const isPlainObject = (value) => {
|
|
51065
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
51066
|
-
const prototype = Object.getPrototypeOf(value);
|
|
51067
|
-
return prototype === null || prototype === Object.prototype;
|
|
51068
|
-
};
|
|
51069
|
-
//#endregion
|
|
51070
51047
|
//#region ../core/src/utils/fail-open-read-json.ts
|
|
51071
51048
|
const failOpenReadJson = (filePath, fallback) => {
|
|
51072
51049
|
try {
|
|
@@ -51106,32 +51083,32 @@ const SUPPORTED_GLOBAL_VALUES = new Set([
|
|
|
51106
51083
|
"writeable"
|
|
51107
51084
|
]);
|
|
51108
51085
|
const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
|
|
51109
|
-
if (
|
|
51110
|
-
const name =
|
|
51111
|
-
return (
|
|
51086
|
+
if (typescriptBinding.isSpreadAssignment(property)) return false;
|
|
51087
|
+
const name = typescriptBinding.isComputedPropertyName(property.name) ? unwrapTypescriptExpression(property.name.expression) : property.name;
|
|
51088
|
+
return (typescriptBinding.isIdentifier(name) || typescriptBinding.isStringLiteralLike(name)) && name.text === propertyName;
|
|
51112
51089
|
}) ?? null;
|
|
51113
|
-
const hasNonLiteralComputedProperty = (objectExpression) => objectExpression.properties.some((property) => !
|
|
51090
|
+
const hasNonLiteralComputedProperty = (objectExpression) => objectExpression.properties.some((property) => !typescriptBinding.isSpreadAssignment(property) && typescriptBinding.isComputedPropertyName(property.name) && !typescriptBinding.isStringLiteralLike(unwrapTypescriptExpression(property.name.expression)));
|
|
51114
51091
|
const getStaticPropertyAssignment = (objectExpression, propertyName) => {
|
|
51115
51092
|
const property = getStaticProperty(objectExpression, propertyName);
|
|
51116
|
-
return property &&
|
|
51093
|
+
return property && typescriptBinding.isPropertyAssignment(property) ? property : null;
|
|
51117
51094
|
};
|
|
51118
51095
|
const getRequireModuleSpecifier = (expression) => {
|
|
51119
51096
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
51120
|
-
if (
|
|
51121
|
-
if (!
|
|
51097
|
+
if (typescriptBinding.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "default") return getRequireModuleSpecifier(unwrappedExpression.expression);
|
|
51098
|
+
if (!typescriptBinding.isCallExpression(unwrappedExpression) || !typescriptBinding.isIdentifier(unwrappedExpression.expression) || unwrappedExpression.expression.text !== "require" || unwrappedExpression.arguments.length !== 1) return null;
|
|
51122
51099
|
const moduleSpecifier = unwrappedExpression.arguments[0];
|
|
51123
|
-
return moduleSpecifier &&
|
|
51100
|
+
return moduleSpecifier && typescriptBinding.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
51124
51101
|
};
|
|
51125
51102
|
const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
|
|
51126
51103
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
51127
|
-
return
|
|
51104
|
+
return typescriptBinding.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
|
|
51128
51105
|
};
|
|
51129
|
-
const isCommonJsExportAssignment = (node, sourceFile) =>
|
|
51106
|
+
const isCommonJsExportAssignment = (node, sourceFile) => typescriptBinding.isBinaryExpression(node) && node.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
|
|
51130
51107
|
const isTopLevelExpression = (node) => {
|
|
51131
51108
|
let ancestor = node.parent;
|
|
51132
|
-
while (ancestor && !
|
|
51133
|
-
if (
|
|
51134
|
-
if (!
|
|
51109
|
+
while (ancestor && !typescriptBinding.isSourceFile(ancestor)) {
|
|
51110
|
+
if (typescriptBinding.isExpressionStatement(ancestor)) return typescriptBinding.isSourceFile(ancestor.parent);
|
|
51111
|
+
if (!typescriptBinding.isParenthesizedExpression(ancestor) && !typescriptBinding.isAsExpression(ancestor) && !typescriptBinding.isSatisfiesExpression(ancestor) && !typescriptBinding.isNonNullExpression(ancestor) && !typescriptBinding.isTypeAssertionExpression(ancestor) && !typescriptBinding.isAwaitExpression(ancestor)) return false;
|
|
51135
51112
|
ancestor = ancestor.parent;
|
|
51136
51113
|
}
|
|
51137
51114
|
return false;
|
|
@@ -51139,21 +51116,21 @@ const isTopLevelExpression = (node) => {
|
|
|
51139
51116
|
const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
|
|
51140
51117
|
let ancestor = node.parent;
|
|
51141
51118
|
let didFindConfigProperty = false;
|
|
51142
|
-
while (ancestor && !
|
|
51143
|
-
if (!didFindConfigProperty && !
|
|
51144
|
-
if (
|
|
51145
|
-
const isConfigProperty = (
|
|
51119
|
+
while (ancestor && !typescriptBinding.isSourceFile(ancestor)) {
|
|
51120
|
+
if (!didFindConfigProperty && !typescriptBinding.isArrayLiteralExpression(ancestor) && !typescriptBinding.isParenthesizedExpression(ancestor) && !typescriptBinding.isAsExpression(ancestor) && !typescriptBinding.isSatisfiesExpression(ancestor) && !typescriptBinding.isNonNullExpression(ancestor) && !typescriptBinding.isTypeAssertionExpression(ancestor) && !typescriptBinding.isPropertyAssignment(ancestor)) return false;
|
|
51121
|
+
if (typescriptBinding.isPropertyAssignment(ancestor)) {
|
|
51122
|
+
const isConfigProperty = (typescriptBinding.isIdentifier(ancestor.name) || typescriptBinding.isStringLiteralLike(ancestor.name)) && ancestor.name.text === propertyName;
|
|
51146
51123
|
if (didFindConfigProperty || !isConfigProperty) return false;
|
|
51147
|
-
if (!
|
|
51124
|
+
if (!typescriptBinding.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(typescriptBinding.isSpreadAssignment)) return false;
|
|
51148
51125
|
didFindConfigProperty = true;
|
|
51149
51126
|
ancestor = ancestor.parent;
|
|
51150
51127
|
continue;
|
|
51151
51128
|
}
|
|
51152
51129
|
if (didFindConfigProperty) {
|
|
51153
|
-
if (
|
|
51130
|
+
if (typescriptBinding.isExportAssignment(ancestor)) return true;
|
|
51154
51131
|
if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
|
|
51155
|
-
if (propertyName === "plugins" &&
|
|
51156
|
-
if (!(
|
|
51132
|
+
if (propertyName === "plugins" && typescriptBinding.isCallExpression(ancestor) && (typescriptBinding.isIdentifier(ancestor.expression) ? esbuildBindings.has(ancestor.expression.text) : typescriptBinding.isPropertyAccessExpression(ancestor.expression) && ancestor.expression.name.text === "build" && (typescriptBinding.isIdentifier(ancestor.expression.expression) && esbuildNamespaceBindings.has(ancestor.expression.expression.text) || getRequireModuleSpecifier(ancestor.expression.expression) === "esbuild"))) return isTopLevelExpression(ancestor);
|
|
51133
|
+
if (!(typescriptBinding.isObjectLiteralExpression(ancestor) || typescriptBinding.isParenthesizedExpression(ancestor) || typescriptBinding.isAsExpression(ancestor) || typescriptBinding.isSatisfiesExpression(ancestor) || typescriptBinding.isNonNullExpression(ancestor) || typescriptBinding.isTypeAssertionExpression(ancestor) || typescriptBinding.isCallExpression(ancestor) && typescriptBinding.isIdentifier(ancestor.expression) && ancestor.expression.text === "defineConfig")) return false;
|
|
51157
51134
|
}
|
|
51158
51135
|
ancestor = ancestor.parent;
|
|
51159
51136
|
}
|
|
@@ -51163,21 +51140,21 @@ const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory
|
|
|
51163
51140
|
const optionsExpression = callExpression.arguments[0];
|
|
51164
51141
|
if (!optionsExpression) return null;
|
|
51165
51142
|
const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
|
|
51166
|
-
if (!
|
|
51167
|
-
if (unwrappedOptions.properties.some(
|
|
51143
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedOptions)) return null;
|
|
51144
|
+
if (unwrappedOptions.properties.some(typescriptBinding.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
|
|
51168
51145
|
if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
|
|
51169
51146
|
const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
|
|
51170
51147
|
if (!eslintrcProperty) return null;
|
|
51171
51148
|
const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
|
|
51172
|
-
if (!
|
|
51173
|
-
if (eslintrcExpression.properties.some(
|
|
51149
|
+
if (!typescriptBinding.isObjectLiteralExpression(eslintrcExpression)) return null;
|
|
51150
|
+
if (eslintrcExpression.properties.some(typescriptBinding.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
|
|
51174
51151
|
const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
|
|
51175
|
-
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !==
|
|
51152
|
+
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== typescriptBinding.SyntaxKind.TrueKeyword) return null;
|
|
51176
51153
|
const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
|
|
51177
51154
|
if (!filepathProperty) return path$1.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
|
|
51178
|
-
if (!
|
|
51155
|
+
if (!typescriptBinding.isPropertyAssignment(filepathProperty)) return null;
|
|
51179
51156
|
const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
|
|
51180
|
-
return
|
|
51157
|
+
return typescriptBinding.isStringLiteralLike(filepathExpression) ? path$1.resolve(packageDirectory, filepathExpression.text) : null;
|
|
51181
51158
|
};
|
|
51182
51159
|
const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
51183
51160
|
let sourceText;
|
|
@@ -51189,12 +51166,16 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51189
51166
|
globalsPaths: []
|
|
51190
51167
|
};
|
|
51191
51168
|
}
|
|
51192
|
-
|
|
51169
|
+
if (!sourceText.includes("unplugin-auto-import") && !sourceText.includes("\\")) return {
|
|
51170
|
+
didFindActiveAutoImport: false,
|
|
51171
|
+
globalsPaths: []
|
|
51172
|
+
};
|
|
51173
|
+
const sourceFile = typescriptBinding.createSourceFile(configPath, sourceText, typescriptBinding.ScriptTarget.Latest, true);
|
|
51193
51174
|
const autoImportBindings = /* @__PURE__ */ new Map();
|
|
51194
51175
|
const esbuildBindings = /* @__PURE__ */ new Set();
|
|
51195
51176
|
const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
|
|
51196
51177
|
for (const statement of sourceFile.statements) {
|
|
51197
|
-
if (
|
|
51178
|
+
if (typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteralLike(statement.moduleSpecifier)) {
|
|
51198
51179
|
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
51199
51180
|
if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
51200
51181
|
const defaultBinding = statement.importClause?.name;
|
|
@@ -51204,23 +51185,23 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51204
51185
|
const defaultBinding = statement.importClause?.name;
|
|
51205
51186
|
if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
|
|
51206
51187
|
const namedBindings = statement.importClause?.namedBindings;
|
|
51207
|
-
if (namedBindings &&
|
|
51188
|
+
if (namedBindings && typescriptBinding.isNamedImports(namedBindings)) {
|
|
51208
51189
|
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
|
|
51209
51190
|
}
|
|
51210
|
-
if (namedBindings &&
|
|
51191
|
+
if (namedBindings && typescriptBinding.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
|
|
51211
51192
|
}
|
|
51212
51193
|
}
|
|
51213
|
-
if (!
|
|
51194
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
51214
51195
|
for (const declaration of statement.declarationList.declarations) {
|
|
51215
51196
|
if (!declaration.initializer) continue;
|
|
51216
|
-
const declarationName =
|
|
51197
|
+
const declarationName = typescriptBinding.isIdentifier(declaration.name) ? declaration.name.text : null;
|
|
51217
51198
|
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
51218
51199
|
if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
|
|
51219
51200
|
if (moduleSpecifier === "esbuild") {
|
|
51220
51201
|
if (declarationName) esbuildNamespaceBindings.add(declarationName);
|
|
51221
|
-
if (
|
|
51202
|
+
if (typescriptBinding.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
|
|
51222
51203
|
const importedName = bindingElement.propertyName ?? bindingElement.name;
|
|
51223
|
-
if (
|
|
51204
|
+
if (typescriptBinding.isIdentifier(importedName) && importedName.text === "build" && typescriptBinding.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
|
|
51224
51205
|
}
|
|
51225
51206
|
}
|
|
51226
51207
|
if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
|
|
@@ -51230,8 +51211,8 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51230
51211
|
let didFindActiveAutoImport = false;
|
|
51231
51212
|
let didFindUnsafeActiveAutoImport = false;
|
|
51232
51213
|
const visit = (node) => {
|
|
51233
|
-
if (
|
|
51234
|
-
const moduleSpecifier =
|
|
51214
|
+
if (typescriptBinding.isCallExpression(node)) {
|
|
51215
|
+
const moduleSpecifier = typescriptBinding.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
|
|
51235
51216
|
if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
51236
51217
|
if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
|
|
51237
51218
|
didFindActiveAutoImport = true;
|
|
@@ -51241,7 +51222,7 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51241
51222
|
}
|
|
51242
51223
|
}
|
|
51243
51224
|
}
|
|
51244
|
-
|
|
51225
|
+
typescriptBinding.forEachChild(node, visit);
|
|
51245
51226
|
};
|
|
51246
51227
|
visit(sourceFile);
|
|
51247
51228
|
return {
|
|
@@ -51322,7 +51303,7 @@ const GENERATED_AUTO_IMPORT_MARKER = "Generated by unplugin-auto-import";
|
|
|
51322
51303
|
const AUTO_IMPORT_SOURCE_BINDING_PATTERN = /\bconst\s+([A-Za-z_$][\w$]*)\s*:\s*typeof\s+import\(["']([^"']+)["']\)\[["']([^"']+)["']\]/g;
|
|
51323
51304
|
const isNonReferenceIdentifier = (identifier) => {
|
|
51324
51305
|
const parent = identifier.parent;
|
|
51325
|
-
return (
|
|
51306
|
+
return (typescriptBinding.isVariableDeclaration(parent) || typescriptBinding.isParameter(parent) || typescriptBinding.isFunctionDeclaration(parent) || typescriptBinding.isFunctionExpression(parent) || typescriptBinding.isClassDeclaration(parent) || typescriptBinding.isClassExpression(parent) || typescriptBinding.isImportClause(parent) || typescriptBinding.isImportSpecifier(parent) || typescriptBinding.isNamespaceImport(parent) || typescriptBinding.isBindingElement(parent)) && parent.name === identifier || typescriptBinding.isImportSpecifier(parent) && parent.propertyName === identifier || typescriptBinding.isBindingElement(parent) && parent.propertyName === identifier || typescriptBinding.isJsxAttribute(parent) && parent.name === identifier || (typescriptBinding.isPropertyAccessExpression(parent) || typescriptBinding.isPropertyAssignment(parent) || typescriptBinding.isPropertyDeclaration(parent) || typescriptBinding.isMethodDeclaration(parent) || typescriptBinding.isMethodSignature(parent) || typescriptBinding.isPropertySignature(parent)) && parent.name === identifier || typescriptBinding.isQualifiedName(parent) && parent.right === identifier;
|
|
51326
51307
|
};
|
|
51327
51308
|
const collectUnboundGlobalNames = (filePath, candidateGlobalNames) => {
|
|
51328
51309
|
let source;
|
|
@@ -51331,19 +51312,19 @@ const collectUnboundGlobalNames = (filePath, candidateGlobalNames) => {
|
|
|
51331
51312
|
} catch {
|
|
51332
51313
|
return /* @__PURE__ */ new Set();
|
|
51333
51314
|
}
|
|
51334
|
-
const sourceFile =
|
|
51315
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, source, typescriptBinding.ScriptTarget.Latest, true);
|
|
51335
51316
|
const compilerOptions = {
|
|
51336
51317
|
allowJs: true,
|
|
51337
|
-
jsx:
|
|
51318
|
+
jsx: typescriptBinding.JsxEmit.Preserve,
|
|
51338
51319
|
noLib: true,
|
|
51339
51320
|
noResolve: true,
|
|
51340
|
-
target:
|
|
51321
|
+
target: typescriptBinding.ScriptTarget.Latest
|
|
51341
51322
|
};
|
|
51342
|
-
const compilerHost =
|
|
51323
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
51343
51324
|
compilerHost.fileExists = (candidatePath) => candidatePath === filePath;
|
|
51344
51325
|
compilerHost.getSourceFile = (candidatePath) => candidatePath === filePath ? sourceFile : void 0;
|
|
51345
51326
|
compilerHost.readFile = (candidatePath) => candidatePath === filePath ? source : void 0;
|
|
51346
|
-
const program =
|
|
51327
|
+
const program = typescriptBinding.createProgram({
|
|
51347
51328
|
rootNames: [filePath],
|
|
51348
51329
|
options: compilerOptions,
|
|
51349
51330
|
host: compilerHost
|
|
@@ -51353,10 +51334,10 @@ const collectUnboundGlobalNames = (filePath, candidateGlobalNames) => {
|
|
|
51353
51334
|
if (!boundSourceFile) return /* @__PURE__ */ new Set();
|
|
51354
51335
|
const unboundGlobalNames = /* @__PURE__ */ new Set();
|
|
51355
51336
|
const visitNode = (node) => {
|
|
51356
|
-
if (
|
|
51357
|
-
if (!(
|
|
51337
|
+
if (typescriptBinding.isIdentifier(node) && candidateGlobalNames.has(node.text) && !isNonReferenceIdentifier(node)) {
|
|
51338
|
+
if (!(typescriptBinding.isShorthandPropertyAssignment(node.parent) ? typeChecker.getShorthandAssignmentValueSymbol(node.parent) : typeChecker.getSymbolAtLocation(node))) unboundGlobalNames.add(node.text);
|
|
51358
51339
|
}
|
|
51359
|
-
|
|
51340
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
51360
51341
|
};
|
|
51361
51342
|
visitNode(boundSourceFile);
|
|
51362
51343
|
return unboundGlobalNames;
|
|
@@ -51529,7 +51510,7 @@ const hasUnparseableCompilerConfig = (packageRootDirectory) => {
|
|
|
51529
51510
|
return configNames.some((configName) => {
|
|
51530
51511
|
const configPath = join(packageRootDirectory, configName);
|
|
51531
51512
|
try {
|
|
51532
|
-
return
|
|
51513
|
+
return typescriptBinding.parseConfigFileTextToJson(configPath, readFileSync(configPath, "utf8")).error !== void 0;
|
|
51533
51514
|
} catch {
|
|
51534
51515
|
return true;
|
|
51535
51516
|
}
|
|
@@ -51902,4 +51883,4 @@ startProjectAnalysisWorker();
|
|
|
51902
51883
|
export {};
|
|
51903
51884
|
|
|
51904
51885
|
//# sourceMappingURL=project-analysis-worker.js.map
|
|
51905
|
-
//# debugId=
|
|
51886
|
+
//# debugId=81139e97-fbde-59ee-9b65-cb0499a5510a
|