react-doctor 0.9.13 → 0.9.14-dev.922616f
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-CNFcGNYm.js +81 -0
- package/dist/{ci-DqnZCnrL.js → ci-CbTOIIel.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-DqUidb1f.js → design-CPav17ye.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-CrpeIbra.js → exit-gracefully-De_DePvj.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-BEYYtsCl.js → handle-error-B3GWdtbq.js} +6 -5
- package/dist/index.d.ts +8511 -8509
- package/dist/index.js +61698 -60577
- package/dist/{inspect-BjMaC5WV.js → inspect-vT3G27FR.js} +38 -27
- package/dist/{install-DxLmASQ5.js → install-C-_xdS80.js} +10 -9
- package/dist/{install-doctor-script-4EWviJL8.js → install-doctor-script-BFv3Iiwe.js} +17 -8
- package/dist/{install-github-workflow-BPznUbbo.js → install-github-workflow-C-rhKOiP.js} +10 -10
- package/dist/{install-react-doctor-Baq9hjoF.js → install-react-doctor-BvU99j_I.js} +15 -11
- package/dist/is-cache-globally-disabled-CoHiYz2i.js +10 -0
- package/dist/{jsx-runtime-DvynQ_wu.js → jsx-runtime-CiJj554e.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-DSB6i3kk.js → print-branded-header-DJMuy9Hr.js} +4 -4
- package/dist/project-analysis-worker.js +466 -481
- package/dist/{prompt-runtime-scan-url-BibDt9O1.js → prompt-runtime-scan-url-1YpMskOr.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-DfWpkle4.js → read-object-file-CWvQd5ls.js} +4 -4
- package/dist/{record-metric-Cckscwg_.js → record-metric-DSQY-qOh.js} +57476 -57240
- package/dist/{report-error-C1YnoRNl.js → report-error-C1g5jtl7.js} +9 -8
- package/dist/{report-workflow-result-IdGRoBFN.js → report-workflow-result-it0G879R.js} +24 -11
- package/dist/{resolve-scope-Bb6fljxd.js → resolve-scope-DmsEUxUn.js} +7 -7
- package/dist/{rules-BcFekwN4.js → rules-BXkqekjc.js} +8 -7
- package/dist/{run-scan-app-CKHynQx8.js → run-scan-app-wCfH8LdA.js} +30 -23
- package/dist/{runtime-scan-7Y_mbqEa.js → runtime-scan-CXmDoQ2W.js} +16 -15
- package/dist/{sanitize-runtime-url-DzyBLbi3.js → sanitize-runtime-url-kA6U9dQF.js} +5 -5
- package/dist/{scan-DQCwBx6p.js → scan-Dd-VVq_7.js} +10 -9
- package/dist/{semver-DFtnEmN-.js → semver-BZIuy1gP.js} +3 -3
- package/dist/{should-fail-scan-gate-BYPsKIde.js → should-fail-scan-gate-YK9VAFNu.js} +1339 -1283
- package/dist/{should-skip-prompts-CKkbB3rC.js → should-skip-prompts-SdC04R_e.js} +4 -4
- package/dist/{should-use-tui-Crfoao-l.js → should-use-tui-D2fEl9q2.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-DKJyjz9o.js → telemetry-runtime-DOCJCTsL.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-CMkUAGmw.js → version-WpL8zILr.js} +5 -4
- package/dist/{why-By3I6_Ex.js → why-CnQMoK2D.js} +4 -4
- package/dist/{with-run-span-DxFGyW7k.js → with-run-span-B0SMAP_Z.js} +7 -6
- package/package.json +9 -7
- package/dist/build-section-divider-DELfSn3p.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) {
|
|
@@ -44073,7 +44069,11 @@ const FRAMEWORK_PATTERNS = [
|
|
|
44073
44069
|
enablers: ["sanity", "@sanity/cli"],
|
|
44074
44070
|
enablerPrefixes: ["@sanity/"],
|
|
44075
44071
|
entryPatterns: [],
|
|
44076
|
-
alwaysUsed: [
|
|
44072
|
+
alwaysUsed: [
|
|
44073
|
+
"sanity.config.{ts,js}",
|
|
44074
|
+
"sanity.cli.{ts,js}",
|
|
44075
|
+
"sanity.blueprint.{ts,js}"
|
|
44076
|
+
]
|
|
44077
44077
|
},
|
|
44078
44078
|
{
|
|
44079
44079
|
enablers: ["astro"],
|
|
@@ -44534,20 +44534,8 @@ const isConfigFile = (filePath) => {
|
|
|
44534
44534
|
return KNOWN_CONFIG_PREFIXES.some((prefix) => fileName.startsWith(prefix));
|
|
44535
44535
|
};
|
|
44536
44536
|
//#endregion
|
|
44537
|
-
//#region ../core/src/project-info/constants.ts
|
|
44538
|
-
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch$2(), 1);
|
|
44539
|
-
const GIT_CHECK_ATTR_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
44540
|
-
new Map(Object.entries({
|
|
44541
|
-
Security: "An attacker can read user data, act as your users, or run code you never shipped.",
|
|
44542
|
-
Bugs: "Real users hit crashes, wrong output, or state that silently corrupts.",
|
|
44543
|
-
Performance: "Users feel extra latency and wasted renders on every interaction.",
|
|
44544
|
-
Accessibility: "Users on screen readers, keyboards, or assistive tech get locked out.",
|
|
44545
|
-
Maintainability: "Every future change gets slower and riskier to make."
|
|
44546
|
-
}));
|
|
44547
|
-
const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
|
|
44548
|
-
process.env.REACT_DOCTOR_CORE_VERSION;
|
|
44549
|
-
//#endregion
|
|
44550
44537
|
//#region ../core/src/utils/message-from-unknown.ts
|
|
44538
|
+
var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch$2(), 1);
|
|
44551
44539
|
const messageFromUnknown = (error) => error instanceof Error ? error.message : String(error);
|
|
44552
44540
|
//#endregion
|
|
44553
44541
|
//#region ../core/src/utils/match-glob-pattern.ts
|
|
@@ -45445,18 +45433,18 @@ const collectDynamicBuildImports = (sourceFile, typeChecker) => {
|
|
|
45445
45433
|
const globNamespaceSymbols = /* @__PURE__ */ new Set();
|
|
45446
45434
|
const pathNamespaceSymbols = /* @__PURE__ */ new Set();
|
|
45447
45435
|
for (const statement of sourceFile.statements) {
|
|
45448
|
-
if (!
|
|
45436
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier) || !statement.importClause) continue;
|
|
45449
45437
|
const moduleName = statement.moduleSpecifier.text;
|
|
45450
45438
|
const namedBindings = statement.importClause.namedBindings;
|
|
45451
|
-
if (moduleName === "glob" && namedBindings &&
|
|
45439
|
+
if (moduleName === "glob" && namedBindings && typescriptBinding.isNamespaceImport(namedBindings)) {
|
|
45452
45440
|
const globNamespaceSymbol = typeChecker.getSymbolAtLocation(namedBindings.name);
|
|
45453
45441
|
if (globNamespaceSymbol) globNamespaceSymbols.add(globNamespaceSymbol);
|
|
45454
45442
|
}
|
|
45455
|
-
if (moduleName === "path" && namedBindings &&
|
|
45443
|
+
if (moduleName === "path" && namedBindings && typescriptBinding.isNamespaceImport(namedBindings)) {
|
|
45456
45444
|
const pathNamespaceSymbol = typeChecker.getSymbolAtLocation(namedBindings.name);
|
|
45457
45445
|
if (pathNamespaceSymbol) pathNamespaceSymbols.add(pathNamespaceSymbol);
|
|
45458
45446
|
}
|
|
45459
|
-
if (moduleName !== "tsup" || !namedBindings || !
|
|
45447
|
+
if (moduleName !== "tsup" || !namedBindings || !typescriptBinding.isNamedImports(namedBindings)) continue;
|
|
45460
45448
|
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") {
|
|
45461
45449
|
const buildSymbol = typeChecker.getSymbolAtLocation(importSpecifier.name);
|
|
45462
45450
|
if (buildSymbol) buildSymbols.add(buildSymbol);
|
|
@@ -45469,18 +45457,18 @@ const collectDynamicBuildImports = (sourceFile, typeChecker) => {
|
|
|
45469
45457
|
};
|
|
45470
45458
|
};
|
|
45471
45459
|
const extractGlobPattern = (expression, imports, scriptDirectory, typeChecker) => {
|
|
45472
|
-
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;
|
|
45473
45461
|
const patternExpression = expression.arguments[0];
|
|
45474
|
-
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;
|
|
45475
45463
|
const relativeGlobPattern = patternExpression.arguments[1].text;
|
|
45476
45464
|
if (!relativeGlobPattern.includes("*")) return void 0;
|
|
45477
45465
|
return toPosixPath(resolve(scriptDirectory, relativeGlobPattern));
|
|
45478
45466
|
};
|
|
45479
45467
|
const extractExcludedPathSubstring = (callback) => {
|
|
45480
|
-
if (callback.parameters.length !== 1 || !
|
|
45468
|
+
if (callback.parameters.length !== 1 || !typescriptBinding.isIdentifier(callback.parameters[0].name)) return;
|
|
45481
45469
|
const filePathName = callback.parameters[0].name.text;
|
|
45482
|
-
const returnedExpression =
|
|
45483
|
-
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;
|
|
45484
45472
|
return toPosixPath(returnedExpression.operand.arguments[0].text);
|
|
45485
45473
|
};
|
|
45486
45474
|
const extractFileCollection = (initializer, imports, scriptDirectory, typeChecker) => {
|
|
@@ -45489,7 +45477,7 @@ const extractFileCollection = (initializer, imports, scriptDirectory, typeChecke
|
|
|
45489
45477
|
excludedPathSubstrings: [],
|
|
45490
45478
|
globPattern: directGlobPattern
|
|
45491
45479
|
};
|
|
45492
|
-
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;
|
|
45493
45481
|
const globPattern = extractGlobPattern(initializer.expression.expression, imports, scriptDirectory, typeChecker);
|
|
45494
45482
|
const excludedPathSubstring = extractExcludedPathSubstring(initializer.arguments[0]);
|
|
45495
45483
|
if (!globPattern || excludedPathSubstring === void 0) return void 0;
|
|
@@ -45498,36 +45486,36 @@ const extractFileCollection = (initializer, imports, scriptDirectory, typeChecke
|
|
|
45498
45486
|
globPattern
|
|
45499
45487
|
};
|
|
45500
45488
|
};
|
|
45501
|
-
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);
|
|
45502
45490
|
const hasMatchingOutputEntryPath = (callback, filePathName, outputEntryName, imports, typeChecker) => {
|
|
45503
|
-
if (!
|
|
45491
|
+
if (!typescriptBinding.isBlock(callback.body)) return false;
|
|
45504
45492
|
const initializersByName = /* @__PURE__ */ new Map();
|
|
45505
45493
|
for (const statement of callback.body.statements) {
|
|
45506
|
-
if (!
|
|
45507
|
-
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);
|
|
45508
45496
|
}
|
|
45509
45497
|
const outputEntryInitializer = initializersByName.get(outputEntryName);
|
|
45510
45498
|
if (!outputEntryInitializer || !isPathNamespaceCall(outputEntryInitializer, "join", imports, typeChecker)) return false;
|
|
45511
45499
|
const outputFilenameExpression = outputEntryInitializer.arguments.at(-1);
|
|
45512
|
-
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;
|
|
45513
45501
|
const basenameSourceName = outputFilenameExpression.left.arguments[0].text;
|
|
45514
45502
|
if (basenameSourceName === filePathName) return true;
|
|
45515
45503
|
const basenameSourceInitializer = initializersByName.get(basenameSourceName);
|
|
45516
|
-
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);
|
|
45517
45505
|
};
|
|
45518
45506
|
const findBuildInvocation = (callback, filePathName, imports, typeChecker) => {
|
|
45519
45507
|
let buildInvocation;
|
|
45520
45508
|
const visitNode = (node) => {
|
|
45521
|
-
if (
|
|
45522
|
-
const hasMatchingEntry = node.arguments[0].properties.some((property) =>
|
|
45523
|
-
const outDirectoryProperty = node.arguments[0].properties.find((property) =>
|
|
45524
|
-
const hasCommonJsFormat = node.arguments[0].properties.some((property) =>
|
|
45525
|
-
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 = {
|
|
45526
45514
|
end: node.parent.end,
|
|
45527
45515
|
outputEntryName: outDirectoryProperty.initializer.arguments[0].text
|
|
45528
45516
|
};
|
|
45529
45517
|
}
|
|
45530
|
-
if (!buildInvocation)
|
|
45518
|
+
if (!buildInvocation) typescriptBinding.forEachChild(node, visitNode);
|
|
45531
45519
|
};
|
|
45532
45520
|
visitNode(callback.body);
|
|
45533
45521
|
return buildInvocation;
|
|
@@ -45536,19 +45524,19 @@ const collectImportedNamespaceExportNames = (callback, buildInvocation, typeChec
|
|
|
45536
45524
|
const importedNamespaceDeclarationEndBySymbol = /* @__PURE__ */ new Map();
|
|
45537
45525
|
const exportNames = /* @__PURE__ */ new Set();
|
|
45538
45526
|
const collectNamespaceNames = (node) => {
|
|
45539
|
-
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) {
|
|
45540
45528
|
const namespaceSymbol = typeChecker.getSymbolAtLocation(node.name);
|
|
45541
45529
|
if (namespaceSymbol) importedNamespaceDeclarationEndBySymbol.set(namespaceSymbol, node.end);
|
|
45542
45530
|
}
|
|
45543
|
-
|
|
45531
|
+
typescriptBinding.forEachChild(node, collectNamespaceNames);
|
|
45544
45532
|
};
|
|
45545
45533
|
collectNamespaceNames(callback.body);
|
|
45546
45534
|
const collectExportNames = (node) => {
|
|
45547
|
-
const namespaceSymbol = (
|
|
45535
|
+
const namespaceSymbol = (typescriptBinding.isPropertyAccessExpression(node) || typescriptBinding.isElementAccessExpression(node)) && typescriptBinding.isIdentifier(node.expression) ? typeChecker.getSymbolAtLocation(node.expression) : void 0;
|
|
45548
45536
|
const namespaceDeclarationEnd = namespaceSymbol ? importedNamespaceDeclarationEndBySymbol.get(namespaceSymbol) : void 0;
|
|
45549
|
-
if (
|
|
45550
|
-
else if (
|
|
45551
|
-
|
|
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);
|
|
45552
45540
|
};
|
|
45553
45541
|
collectExportNames(callback.body);
|
|
45554
45542
|
return exportNames;
|
|
@@ -45564,14 +45552,14 @@ const collectScriptConsumedExportKeys = (scriptPath, packageDirectory) => {
|
|
|
45564
45552
|
noLib: true,
|
|
45565
45553
|
noResolve: true
|
|
45566
45554
|
};
|
|
45567
|
-
const sourceFile =
|
|
45568
|
-
const compilerHost =
|
|
45555
|
+
const sourceFile = typescriptBinding.createSourceFile(scriptPath, source, typescriptBinding.ScriptTarget.Latest, true);
|
|
45556
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
45569
45557
|
const scriptIdentity = getFileIdentityKey(scriptPath);
|
|
45570
45558
|
const isScriptPath = (candidatePath) => getFileIdentityKey(candidatePath) === scriptIdentity;
|
|
45571
45559
|
compilerHost.fileExists = isScriptPath;
|
|
45572
45560
|
compilerHost.getSourceFile = (candidatePath) => isScriptPath(candidatePath) ? sourceFile : void 0;
|
|
45573
45561
|
compilerHost.readFile = (candidatePath) => isScriptPath(candidatePath) ? source : void 0;
|
|
45574
|
-
const program =
|
|
45562
|
+
const program = typescriptBinding.createProgram({
|
|
45575
45563
|
rootNames: [scriptPath],
|
|
45576
45564
|
options: compilerOptions,
|
|
45577
45565
|
host: compilerHost
|
|
@@ -45583,22 +45571,22 @@ const collectScriptConsumedExportKeys = (scriptPath, packageDirectory) => {
|
|
|
45583
45571
|
if (imports.buildSymbols.size === 0 || imports.globNamespaceSymbols.size === 0 || imports.pathNamespaceSymbols.size === 0) return /* @__PURE__ */ new Set();
|
|
45584
45572
|
const collectionsBySymbol = /* @__PURE__ */ new Map();
|
|
45585
45573
|
const visitCollection = (node) => {
|
|
45586
|
-
if (
|
|
45574
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer) {
|
|
45587
45575
|
const collection = extractFileCollection(node.initializer, imports, dirname(scriptPath), typeChecker);
|
|
45588
45576
|
const collectionSymbol = typeChecker.getSymbolAtLocation(node.name);
|
|
45589
45577
|
if (collection && collectionSymbol) collectionsBySymbol.set(collectionSymbol, collection);
|
|
45590
45578
|
}
|
|
45591
|
-
|
|
45579
|
+
typescriptBinding.forEachChild(node, visitCollection);
|
|
45592
45580
|
};
|
|
45593
45581
|
visitCollection(boundSourceFile);
|
|
45594
45582
|
const consumedExportKeys = /* @__PURE__ */ new Set();
|
|
45595
45583
|
const packageManifestIdentity = getFileIdentityKey(resolve(packageDirectory, "package.json"));
|
|
45596
45584
|
const visitMapCall = (node) => {
|
|
45597
|
-
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]))) {
|
|
45598
45586
|
const collectionSymbol = typeChecker.getSymbolAtLocation(node.expression.expression);
|
|
45599
45587
|
const collection = collectionSymbol ? collectionsBySymbol.get(collectionSymbol) : void 0;
|
|
45600
45588
|
const callback = node.arguments[0];
|
|
45601
|
-
if (collection && callback.parameters.length === 1 &&
|
|
45589
|
+
if (collection && callback.parameters.length === 1 && typescriptBinding.isIdentifier(callback.parameters[0].name)) {
|
|
45602
45590
|
const buildInvocation = findBuildInvocation(callback, callback.parameters[0].name.text, imports, typeChecker);
|
|
45603
45591
|
if (!buildInvocation) return;
|
|
45604
45592
|
const exportNames = collectImportedNamespaceExportNames(callback, buildInvocation, typeChecker);
|
|
@@ -45617,7 +45605,7 @@ const collectScriptConsumedExportKeys = (scriptPath, packageDirectory) => {
|
|
|
45617
45605
|
}
|
|
45618
45606
|
}
|
|
45619
45607
|
}
|
|
45620
|
-
|
|
45608
|
+
typescriptBinding.forEachChild(node, visitMapCall);
|
|
45621
45609
|
};
|
|
45622
45610
|
visitMapCall(boundSourceFile);
|
|
45623
45611
|
return consumedExportKeys;
|
|
@@ -45661,7 +45649,7 @@ const readPackageMetadata = (packageDirectory) => {
|
|
|
45661
45649
|
return;
|
|
45662
45650
|
}
|
|
45663
45651
|
};
|
|
45664
|
-
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");
|
|
45665
45653
|
const collectReferencedNextraThemeConfigPaths = (packageDirectory) => {
|
|
45666
45654
|
const referencedPaths = /* @__PURE__ */ new Set();
|
|
45667
45655
|
for (const configFilename of NEXT_CONFIG_FILENAMES) {
|
|
@@ -45673,16 +45661,16 @@ const collectReferencedNextraThemeConfigPaths = (packageDirectory) => {
|
|
|
45673
45661
|
} catch {
|
|
45674
45662
|
continue;
|
|
45675
45663
|
}
|
|
45676
|
-
const sourceFile =
|
|
45664
|
+
const sourceFile = typescriptBinding.createSourceFile(configPath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
45677
45665
|
if (!hasNextraImport(sourceFile)) continue;
|
|
45678
45666
|
const visitNode = (node) => {
|
|
45679
|
-
if (
|
|
45680
|
-
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(".")) {
|
|
45681
45669
|
const resolvedThemeConfigPath = resolveEntryWithExtensions(resolve(dirname(configPath), node.initializer.text));
|
|
45682
45670
|
if (resolvedThemeConfigPath) referencedPaths.add(toPosixPath(toFilesystemIdentityPath(resolve(resolvedThemeConfigPath))));
|
|
45683
45671
|
}
|
|
45684
45672
|
}
|
|
45685
|
-
|
|
45673
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
45686
45674
|
};
|
|
45687
45675
|
visitNode(sourceFile);
|
|
45688
45676
|
}
|
|
@@ -46135,7 +46123,7 @@ const collectStaticModulePackageNames = (sourceText) => {
|
|
|
46135
46123
|
//#region ../core/src/project-analysis/utils/matches-package-import-reference.ts
|
|
46136
46124
|
const collectPackageImportNames = (content) => {
|
|
46137
46125
|
const packageNames = collectStaticModulePackageNames(content);
|
|
46138
|
-
const sourceFile =
|
|
46126
|
+
const sourceFile = typescriptBinding.createSourceFile("package-reference.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
46139
46127
|
for (const typeReferenceDirective of sourceFile.typeReferenceDirectives) {
|
|
46140
46128
|
const packageName = extractPackageName(typeReferenceDirective.fileName);
|
|
46141
46129
|
if (packageName) packageNames.add(packageName);
|
|
@@ -46145,8 +46133,8 @@ const collectPackageImportNames = (content) => {
|
|
|
46145
46133
|
//#endregion
|
|
46146
46134
|
//#region ../core/src/project-analysis/utils/get-object-literal-element-name.ts
|
|
46147
46135
|
const getObjectLiteralElementName = (property) => {
|
|
46148
|
-
if (!
|
|
46149
|
-
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;
|
|
46150
46138
|
};
|
|
46151
46139
|
//#endregion
|
|
46152
46140
|
//#region ../core/src/project-analysis/utils/collect-config-plugin-map-package-names.ts
|
|
@@ -46154,23 +46142,23 @@ const collectConfigPluginMapPackageNames = (expression) => {
|
|
|
46154
46142
|
const packageNames = /* @__PURE__ */ new Set();
|
|
46155
46143
|
const collectExpression = (currentExpression) => {
|
|
46156
46144
|
const unwrappedExpression = unwrapTypescriptExpression(currentExpression);
|
|
46157
|
-
if (
|
|
46145
|
+
if (typescriptBinding.isConditionalExpression(unwrappedExpression)) {
|
|
46158
46146
|
collectExpression(unwrappedExpression.whenTrue);
|
|
46159
46147
|
collectExpression(unwrappedExpression.whenFalse);
|
|
46160
46148
|
return;
|
|
46161
46149
|
}
|
|
46162
|
-
if (
|
|
46163
|
-
|
|
46164
|
-
|
|
46165
|
-
|
|
46150
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && [
|
|
46151
|
+
typescriptBinding.SyntaxKind.AmpersandAmpersandToken,
|
|
46152
|
+
typescriptBinding.SyntaxKind.BarBarToken,
|
|
46153
|
+
typescriptBinding.SyntaxKind.QuestionQuestionToken
|
|
46166
46154
|
].includes(unwrappedExpression.operatorToken.kind)) {
|
|
46167
46155
|
collectExpression(unwrappedExpression.left);
|
|
46168
46156
|
collectExpression(unwrappedExpression.right);
|
|
46169
46157
|
return;
|
|
46170
46158
|
}
|
|
46171
|
-
if (!
|
|
46159
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
46172
46160
|
for (const property of unwrappedExpression.properties) {
|
|
46173
|
-
if (
|
|
46161
|
+
if (typescriptBinding.isSpreadAssignment(property)) {
|
|
46174
46162
|
collectExpression(property.expression);
|
|
46175
46163
|
continue;
|
|
46176
46164
|
}
|
|
@@ -46193,16 +46181,16 @@ const STRUCTURED_TEXT_EXTENSIONS = new Set([
|
|
|
46193
46181
|
const BABEL_CONFIG_FILE_PATTERN = /(?:^|[/\\])(?:babel\.config\.[^/\\]+|\.babelrc(?:\.[^/\\]+)?)$/;
|
|
46194
46182
|
const BABEL_MODULE_PREFIX = "module:";
|
|
46195
46183
|
const isBabelPluginOrPresetSpecifier = (node) => {
|
|
46196
|
-
const parent =
|
|
46184
|
+
const parent = typescriptBinding.isArrayLiteralExpression(node.parent) ? node.parent : void 0;
|
|
46197
46185
|
if (!parent) return false;
|
|
46198
|
-
const property = (parent.elements[0] === node &&
|
|
46186
|
+
const property = (parent.elements[0] === node && typescriptBinding.isArrayLiteralExpression(parent.parent) ? parent.parent : parent).parent;
|
|
46199
46187
|
let ancestor = property;
|
|
46200
|
-
while (ancestor && !
|
|
46188
|
+
while (ancestor && !typescriptBinding.isSourceFile(ancestor)) {
|
|
46201
46189
|
const parentNode = ancestor.parent;
|
|
46202
|
-
if (
|
|
46190
|
+
if (typescriptBinding.isObjectLiteralExpression(ancestor) && typescriptBinding.isArrayLiteralExpression(parentNode) && parentNode.elements[0] !== ancestor && typescriptBinding.isStringLiteralLike(parentNode.elements[0])) return false;
|
|
46203
46191
|
ancestor = parentNode;
|
|
46204
46192
|
}
|
|
46205
|
-
return
|
|
46193
|
+
return typescriptBinding.isPropertyAssignment(property) && (getObjectLiteralElementName(property) === "plugins" || getObjectLiteralElementName(property) === "presets");
|
|
46206
46194
|
};
|
|
46207
46195
|
const collectStructuredTextPackageReferences = (content) => {
|
|
46208
46196
|
const uncommentedContent = content.split("\n").map(stripCoffeeScriptComment).join("\n");
|
|
@@ -46215,16 +46203,16 @@ const collectStructuredTextPackageReferences = (content) => {
|
|
|
46215
46203
|
};
|
|
46216
46204
|
const collectPackageConfigReferences = (filePath, content) => {
|
|
46217
46205
|
if (STRUCTURED_TEXT_EXTENSIONS.has(extname(filePath))) return collectStructuredTextPackageReferences(content);
|
|
46218
|
-
const sourceFile =
|
|
46206
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
46219
46207
|
const packageNames = /* @__PURE__ */ new Set();
|
|
46220
46208
|
const visit = (node) => {
|
|
46221
|
-
if (
|
|
46222
|
-
if (
|
|
46209
|
+
if (typescriptBinding.isPropertyAssignment(node) && getObjectLiteralElementName(node) === "plugins") for (const packageName of collectConfigPluginMapPackageNames(node.initializer)) packageNames.add(packageName);
|
|
46210
|
+
if (typescriptBinding.isStringLiteralLike(node)) {
|
|
46223
46211
|
const packageName = extractPackageName(BABEL_CONFIG_FILE_PATTERN.test(filePath) && node.text.startsWith(BABEL_MODULE_PREFIX) && isBabelPluginOrPresetSpecifier(node) ? node.text.slice(7) : node.text);
|
|
46224
46212
|
if (packageName) packageNames.add(packageName);
|
|
46225
46213
|
return;
|
|
46226
46214
|
}
|
|
46227
|
-
|
|
46215
|
+
typescriptBinding.forEachChild(node, visit);
|
|
46228
46216
|
};
|
|
46229
46217
|
visit(sourceFile);
|
|
46230
46218
|
return packageNames;
|
|
@@ -48452,21 +48440,21 @@ const extractPreviewRegistryNamesFromMdx = (sourceText) => {
|
|
|
48452
48440
|
//#endregion
|
|
48453
48441
|
//#region ../core/src/project-analysis/utils/are-source-files-structurally-equivalent.ts
|
|
48454
48442
|
const buildSourceStructure = (filePath, sourceText) => {
|
|
48455
|
-
const sourceFile =
|
|
48443
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, filePath.endsWith("x") ? typescriptBinding.ScriptKind.TSX : typescriptBinding.ScriptKind.TS);
|
|
48456
48444
|
const structure = [];
|
|
48457
48445
|
const visitNode = (node, normalizeClassNames = false) => {
|
|
48458
48446
|
structure.push(String(node.kind));
|
|
48459
|
-
if (
|
|
48460
|
-
else if (
|
|
48461
|
-
else if (
|
|
48462
|
-
else if (
|
|
48463
|
-
else if (
|
|
48464
|
-
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)) {
|
|
48465
48453
|
visitNode(node.name);
|
|
48466
48454
|
visitNode(node.initializer, true);
|
|
48467
48455
|
return;
|
|
48468
48456
|
}
|
|
48469
|
-
|
|
48457
|
+
typescriptBinding.forEachChild(node, (childNode) => visitNode(childNode));
|
|
48470
48458
|
};
|
|
48471
48459
|
visitNode(sourceFile);
|
|
48472
48460
|
return structure.join("\0");
|
|
@@ -48480,8 +48468,8 @@ const buildScriptAnalysisKey = (scriptFile) => `${scriptFile.workingDirectory}\0
|
|
|
48480
48468
|
const resolveBuildReference = (reference, workingDirectory, projectRoot) => reference.startsWith("/") ? resolve(projectRoot, reference.replace(/^\/+/, "")) : resolve(workingDirectory, reference);
|
|
48481
48469
|
const getPropertyName$1 = (expression) => {
|
|
48482
48470
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48483
|
-
if (
|
|
48484
|
-
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;
|
|
48485
48473
|
};
|
|
48486
48474
|
const resolveImportedScriptPath = (specifier, scriptFile, projectRoot) => {
|
|
48487
48475
|
const importedPath = specifier.startsWith(".") ? resolve(dirname(scriptFile.filePath), specifier) : specifier.startsWith("@/registry/") ? resolve(scriptFile.workingDirectory, "src/registry", specifier.slice(11)) : void 0;
|
|
@@ -48498,20 +48486,20 @@ const collectWebpackEntrySpecifiers = (filePath) => {
|
|
|
48498
48486
|
} catch {
|
|
48499
48487
|
return [];
|
|
48500
48488
|
}
|
|
48501
|
-
const sourceFile =
|
|
48489
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
48502
48490
|
const specifiers = /* @__PURE__ */ new Set();
|
|
48503
48491
|
const collectStringLiterals = (node) => {
|
|
48504
|
-
if (
|
|
48492
|
+
if (typescriptBinding.isStringLiteralLike(node) && node.text.startsWith(".")) {
|
|
48505
48493
|
specifiers.add(node.text);
|
|
48506
48494
|
return;
|
|
48507
48495
|
}
|
|
48508
|
-
|
|
48496
|
+
typescriptBinding.forEachChild(node, collectStringLiterals);
|
|
48509
48497
|
};
|
|
48510
48498
|
const visitNode = (node) => {
|
|
48511
|
-
if (
|
|
48512
|
-
if (
|
|
48513
|
-
if (
|
|
48514
|
-
|
|
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);
|
|
48515
48503
|
};
|
|
48516
48504
|
visitNode(sourceFile);
|
|
48517
48505
|
return [...specifiers];
|
|
@@ -48678,23 +48666,23 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48678
48666
|
} catch {
|
|
48679
48667
|
continue;
|
|
48680
48668
|
}
|
|
48681
|
-
const sourceFile =
|
|
48669
|
+
const sourceFile = typescriptBinding.createSourceFile(scriptFile.filePath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
48682
48670
|
const localFunctions = /* @__PURE__ */ new Map();
|
|
48683
48671
|
const defaultExportExpressions = [];
|
|
48684
48672
|
for (const statement of sourceFile.statements) {
|
|
48685
|
-
if (
|
|
48673
|
+
if (typescriptBinding.isFunctionDeclaration(statement) && statement.body) {
|
|
48686
48674
|
if (statement.name) localFunctions.set(statement.name.text, statement.body);
|
|
48687
|
-
if (statement.modifiers?.some((modifier) => modifier.kind ===
|
|
48675
|
+
if (statement.modifiers?.some((modifier) => modifier.kind === typescriptBinding.SyntaxKind.DefaultKeyword)) localFunctions.set("default", statement.body);
|
|
48688
48676
|
}
|
|
48689
|
-
if (
|
|
48690
|
-
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);
|
|
48691
48679
|
}
|
|
48692
|
-
if (
|
|
48680
|
+
if (typescriptBinding.isExportAssignment(statement) && !statement.isExportEquals) defaultExportExpressions.push(statement.expression);
|
|
48693
48681
|
}
|
|
48694
48682
|
for (const defaultExportExpression of defaultExportExpressions) {
|
|
48695
48683
|
const unwrappedDefaultExport = unwrapTypescriptExpression(defaultExportExpression);
|
|
48696
|
-
if (
|
|
48697
|
-
else if (
|
|
48684
|
+
if (typescriptBinding.isArrowFunction(unwrappedDefaultExport) || typescriptBinding.isFunctionExpression(unwrappedDefaultExport)) localFunctions.set("default", unwrappedDefaultExport.body);
|
|
48685
|
+
else if (typescriptBinding.isIdentifier(unwrappedDefaultExport)) {
|
|
48698
48686
|
const defaultFunctionBody = localFunctions.get(unwrappedDefaultExport.text);
|
|
48699
48687
|
if (defaultFunctionBody) localFunctions.set("default", defaultFunctionBody);
|
|
48700
48688
|
}
|
|
@@ -48708,7 +48696,7 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48708
48696
|
});
|
|
48709
48697
|
}
|
|
48710
48698
|
for (const analysis of analyses.values()) for (const statement of analysis.sourceFile.statements) {
|
|
48711
|
-
if (!
|
|
48699
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
48712
48700
|
const importClause = statement.importClause;
|
|
48713
48701
|
if (!importClause || importClause.isTypeOnly) continue;
|
|
48714
48702
|
const importedFilePath = resolveImportedScriptPath(statement.moduleSpecifier.text, analysis.scriptFile, projectRoot);
|
|
@@ -48722,7 +48710,7 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48722
48710
|
analysisKey: importedAnalysisKey,
|
|
48723
48711
|
exportName: "default"
|
|
48724
48712
|
});
|
|
48725
|
-
if (!importClause.namedBindings || !
|
|
48713
|
+
if (!importClause.namedBindings || !typescriptBinding.isNamedImports(importClause.namedBindings)) continue;
|
|
48726
48714
|
for (const element of importClause.namedBindings.elements) {
|
|
48727
48715
|
if (element.isTypeOnly) continue;
|
|
48728
48716
|
analysis.importedFunctions.set(element.name.text, {
|
|
@@ -48744,11 +48732,11 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48744
48732
|
const visitLiveNode = (analysis, rootNode) => {
|
|
48745
48733
|
const visitNode = (node) => {
|
|
48746
48734
|
analysis.liveNodes.add(node);
|
|
48747
|
-
if (node !== rootNode && (
|
|
48748
|
-
if (
|
|
48735
|
+
if (node !== rootNode && (typescriptBinding.isFunctionDeclaration(node) || typescriptBinding.isFunctionExpression(node) || typescriptBinding.isArrowFunction(node) || typescriptBinding.isMethodDeclaration(node))) return;
|
|
48736
|
+
if (typescriptBinding.isCallExpression(node)) {
|
|
48749
48737
|
const calledExpression = unwrapTypescriptExpression(node.expression);
|
|
48750
|
-
if (
|
|
48751
|
-
if (
|
|
48738
|
+
if (typescriptBinding.isFunctionExpression(calledExpression) || typescriptBinding.isArrowFunction(calledExpression)) queueFunctionBody(analysis, calledExpression.body);
|
|
48739
|
+
if (typescriptBinding.isIdentifier(calledExpression)) {
|
|
48752
48740
|
const localFunctionBody = analysis.localFunctions.get(calledExpression.text);
|
|
48753
48741
|
if (localFunctionBody) queueFunctionBody(analysis, localFunctionBody);
|
|
48754
48742
|
const importedFunction = analysis.importedFunctions.get(calledExpression.text);
|
|
@@ -48758,10 +48746,10 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48758
48746
|
}
|
|
48759
48747
|
for (const argument of node.arguments) {
|
|
48760
48748
|
const unwrappedArgument = unwrapTypescriptExpression(argument);
|
|
48761
|
-
if (
|
|
48749
|
+
if (typescriptBinding.isFunctionExpression(unwrappedArgument) || typescriptBinding.isArrowFunction(unwrappedArgument)) queueFunctionBody(analysis, unwrappedArgument.body);
|
|
48762
48750
|
}
|
|
48763
48751
|
}
|
|
48764
|
-
|
|
48752
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48765
48753
|
};
|
|
48766
48754
|
visitNode(rootNode);
|
|
48767
48755
|
};
|
|
@@ -48786,18 +48774,18 @@ const findVariableDeclaration = (sourceFile, identifierName, usePosition) => {
|
|
|
48786
48774
|
let closestDeclaration;
|
|
48787
48775
|
const visitNode = (node) => {
|
|
48788
48776
|
if (node.getStart(sourceFile) >= usePosition) return;
|
|
48789
|
-
if (
|
|
48777
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name)) {
|
|
48790
48778
|
if (node.name.text === identifierName) closestDeclaration = node;
|
|
48791
48779
|
}
|
|
48792
|
-
|
|
48780
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48793
48781
|
};
|
|
48794
48782
|
visitNode(sourceFile);
|
|
48795
48783
|
return closestDeclaration;
|
|
48796
48784
|
};
|
|
48797
48785
|
const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
48798
48786
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48799
|
-
if (
|
|
48800
|
-
if (
|
|
48787
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) return resolveBuildReference(unwrappedExpression.text, analysis.scriptFile.workingDirectory, projectRoot);
|
|
48788
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) {
|
|
48801
48789
|
if (unwrappedExpression.text === "__dirname") return dirname(analysis.scriptFile.filePath);
|
|
48802
48790
|
if (seenIdentifiers.has(unwrappedExpression.text)) return void 0;
|
|
48803
48791
|
const declaration = findVariableDeclaration(analysis.sourceFile, unwrappedExpression.text, unwrappedExpression.getStart(analysis.sourceFile));
|
|
@@ -48806,8 +48794,8 @@ const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifie
|
|
|
48806
48794
|
nextSeenIdentifiers.add(unwrappedExpression.text);
|
|
48807
48795
|
return evaluatePathExpression(declaration.initializer, analysis, projectRoot, nextSeenIdentifiers);
|
|
48808
48796
|
}
|
|
48809
|
-
if (!
|
|
48810
|
-
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;
|
|
48811
48799
|
const pathMethodName = getPropertyName$1(unwrappedExpression.expression);
|
|
48812
48800
|
if (pathMethodName !== "join" && pathMethodName !== "resolve") return void 0;
|
|
48813
48801
|
const [baseExpression, ...segmentExpressions] = unwrappedExpression.arguments;
|
|
@@ -48817,7 +48805,7 @@ const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifie
|
|
|
48817
48805
|
const pathSegments = [];
|
|
48818
48806
|
for (const segmentExpression of segmentExpressions) {
|
|
48819
48807
|
const unwrappedSegment = unwrapTypescriptExpression(segmentExpression);
|
|
48820
|
-
if (!
|
|
48808
|
+
if (!typescriptBinding.isStringLiteralLike(unwrappedSegment)) return void 0;
|
|
48821
48809
|
pathSegments.push(unwrappedSegment.text);
|
|
48822
48810
|
}
|
|
48823
48811
|
const rootRelativeSegment = pathSegments.find((pathSegment) => pathSegment.startsWith("/"));
|
|
@@ -48831,48 +48819,48 @@ const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifie
|
|
|
48831
48819
|
const expressionContainsIdentifier = (expression, identifierName) => {
|
|
48832
48820
|
let containsIdentifier = false;
|
|
48833
48821
|
const visitNode = (node) => {
|
|
48834
|
-
if (
|
|
48822
|
+
if (typescriptBinding.isIdentifier(node) && node.text === identifierName) {
|
|
48835
48823
|
containsIdentifier = true;
|
|
48836
48824
|
return;
|
|
48837
48825
|
}
|
|
48838
|
-
if (!containsIdentifier)
|
|
48826
|
+
if (!containsIdentifier) typescriptBinding.forEachChild(node, visitNode);
|
|
48839
48827
|
};
|
|
48840
48828
|
visitNode(expression);
|
|
48841
48829
|
return containsIdentifier;
|
|
48842
48830
|
};
|
|
48843
48831
|
const isConditionallyExecuted = (node, boundary) => {
|
|
48844
|
-
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;
|
|
48845
48833
|
return false;
|
|
48846
48834
|
};
|
|
48847
48835
|
const analyzeDirectoryConsumer = (body, helperName, parameterName) => {
|
|
48848
48836
|
const directoryEntryCollectionNames = /* @__PURE__ */ new Set();
|
|
48849
48837
|
let unconditionallyConsumesEntries = false;
|
|
48850
48838
|
let recursivelyTraverses = false;
|
|
48851
|
-
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;
|
|
48852
48840
|
const visitNode = (node) => {
|
|
48853
|
-
if (
|
|
48854
|
-
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)) {
|
|
48855
48843
|
const collectionExpression = unwrapTypescriptExpression(node.expression);
|
|
48856
|
-
if (isDirectoryRead(collectionExpression) ||
|
|
48844
|
+
if (isDirectoryRead(collectionExpression) || typescriptBinding.isIdentifier(collectionExpression) && directoryEntryCollectionNames.has(collectionExpression.text)) {
|
|
48857
48845
|
const loopVariable = node.initializer.declarations[0]?.name;
|
|
48858
|
-
if (loopVariable &&
|
|
48846
|
+
if (loopVariable && typescriptBinding.isIdentifier(loopVariable)) {
|
|
48859
48847
|
const entryDependentNames = new Set([loopVariable.text]);
|
|
48860
48848
|
const visitLoop = (loopNode) => {
|
|
48861
|
-
if (
|
|
48862
|
-
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)) {
|
|
48863
48851
|
if (getPropertyName$1(loopNode.expression)?.match(/^(?:copyFile|readFile)(?:Sync)?$/) && loopNode.arguments.some((argument) => [...entryDependentNames].some((identifierName) => expressionContainsIdentifier(argument, identifierName)))) {
|
|
48864
48852
|
if (!isConditionallyExecuted(loopNode, node.statement)) unconditionallyConsumesEntries = true;
|
|
48865
48853
|
}
|
|
48866
48854
|
const calledExpression = unwrapTypescriptExpression(loopNode.expression);
|
|
48867
|
-
if (
|
|
48855
|
+
if (typescriptBinding.isIdentifier(calledExpression) && calledExpression.text === helperName && loopNode.arguments.some((argument) => [...entryDependentNames].some((identifierName) => expressionContainsIdentifier(argument, identifierName)))) recursivelyTraverses = true;
|
|
48868
48856
|
}
|
|
48869
|
-
|
|
48857
|
+
typescriptBinding.forEachChild(loopNode, visitLoop);
|
|
48870
48858
|
};
|
|
48871
48859
|
visitLoop(node.statement);
|
|
48872
48860
|
}
|
|
48873
48861
|
}
|
|
48874
48862
|
}
|
|
48875
|
-
|
|
48863
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48876
48864
|
};
|
|
48877
48865
|
visitNode(body);
|
|
48878
48866
|
return {
|
|
@@ -48882,11 +48870,11 @@ const analyzeDirectoryConsumer = (body, helperName, parameterName) => {
|
|
|
48882
48870
|
};
|
|
48883
48871
|
const collectRecursiveInputDirectories = (analysis, projectRoot, consumedFiles) => {
|
|
48884
48872
|
for (const node of analysis.liveNodes) {
|
|
48885
|
-
if (!
|
|
48873
|
+
if (!typescriptBinding.isCallExpression(node) || !typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.expression))) continue;
|
|
48886
48874
|
const helperName = unwrapTypescriptExpression(node.expression).getText();
|
|
48887
48875
|
const helperBody = analysis.localFunctions.get(helperName);
|
|
48888
|
-
const helperDeclaration = [...analysis.sourceFile.statements].find((statement) =>
|
|
48889
|
-
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;
|
|
48890
48878
|
const directoryConsumption = analyzeDirectoryConsumer(helperBody, helperName, helperDeclaration.parameters[0].name.text);
|
|
48891
48879
|
if (!directoryConsumption.consumesAllEntries) continue;
|
|
48892
48880
|
const directoryArgument = node.arguments[0];
|
|
@@ -48897,9 +48885,9 @@ const collectRecursiveInputDirectories = (analysis, projectRoot, consumedFiles)
|
|
|
48897
48885
|
};
|
|
48898
48886
|
const evaluateCopySourceExpression = (expression, loopVariableName, loopVariableValue) => {
|
|
48899
48887
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48900
|
-
if (
|
|
48901
|
-
if (
|
|
48902
|
-
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)) {
|
|
48903
48891
|
let resolvedTemplate = unwrappedExpression.head.text;
|
|
48904
48892
|
for (const templateSpan of unwrappedExpression.templateSpans) {
|
|
48905
48893
|
const resolvedExpression = evaluateCopySourceExpression(templateSpan.expression, loopVariableName, loopVariableValue);
|
|
@@ -48908,7 +48896,7 @@ const evaluateCopySourceExpression = (expression, loopVariableName, loopVariable
|
|
|
48908
48896
|
}
|
|
48909
48897
|
return resolvedTemplate;
|
|
48910
48898
|
}
|
|
48911
|
-
if (
|
|
48899
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.PlusToken) {
|
|
48912
48900
|
const leftValue = evaluateCopySourceExpression(unwrappedExpression.left, loopVariableName, loopVariableValue);
|
|
48913
48901
|
const rightValue = evaluateCopySourceExpression(unwrappedExpression.right, loopVariableName, loopVariableValue);
|
|
48914
48902
|
return leftValue === void 0 || rightValue === void 0 ? void 0 : `${leftValue}${rightValue}`;
|
|
@@ -48916,25 +48904,25 @@ const evaluateCopySourceExpression = (expression, loopVariableName, loopVariable
|
|
|
48916
48904
|
};
|
|
48917
48905
|
const collectCopiedSourceFiles = (analysis, projectRoot, consumedFiles) => {
|
|
48918
48906
|
for (const node of analysis.liveNodes) {
|
|
48919
|
-
if (!
|
|
48920
|
-
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;
|
|
48921
48909
|
const loopVariableName = node.initializer.declarations[0].name.text;
|
|
48922
48910
|
const arrayIdentifier = unwrapTypescriptExpression(node.expression);
|
|
48923
|
-
if (!
|
|
48911
|
+
if (!typescriptBinding.isIdentifier(arrayIdentifier)) continue;
|
|
48924
48912
|
const arrayDeclaration = findVariableDeclaration(analysis.sourceFile, arrayIdentifier.text, node.getStart(analysis.sourceFile));
|
|
48925
|
-
if (!arrayDeclaration?.initializer || !
|
|
48913
|
+
if (!arrayDeclaration?.initializer || !typescriptBinding.isArrayLiteralExpression(arrayDeclaration.initializer)) continue;
|
|
48926
48914
|
const values = arrayDeclaration.initializer.elements.flatMap((element) => {
|
|
48927
48915
|
const unwrappedElement = unwrapTypescriptExpression(element);
|
|
48928
|
-
return
|
|
48916
|
+
return typescriptBinding.isStringLiteralLike(unwrappedElement) ? [unwrappedElement.text] : [];
|
|
48929
48917
|
});
|
|
48930
48918
|
const visitLoopBody = (loopNode) => {
|
|
48931
|
-
if (
|
|
48919
|
+
if (typescriptBinding.isCallExpression(loopNode) && getPropertyName$1(loopNode.expression)?.match(/^copyFile(?:Sync)?$/) && loopNode.arguments[0]) for (const value of values) {
|
|
48932
48920
|
const sourceReference = evaluateCopySourceExpression(loopNode.arguments[0], loopVariableName, value);
|
|
48933
48921
|
if (!sourceReference) continue;
|
|
48934
48922
|
const sourcePath = resolveBuildReference(sourceReference, analysis.scriptFile.workingDirectory, projectRoot);
|
|
48935
48923
|
if (isPathInsideDirectoryOrEqual(sourcePath, projectRoot) && existsSync(sourcePath) && statSync(sourcePath).isFile() && SOURCE_FILE_EXTENSION_PATTERN.test(sourcePath)) consumedFiles.add(sourcePath);
|
|
48936
48924
|
}
|
|
48937
|
-
|
|
48925
|
+
typescriptBinding.forEachChild(loopNode, visitLoopBody);
|
|
48938
48926
|
};
|
|
48939
48927
|
visitLoopBody(node.statement);
|
|
48940
48928
|
}
|
|
@@ -48943,56 +48931,56 @@ const expressionContainsString = (expression, value) => {
|
|
|
48943
48931
|
let containsString = false;
|
|
48944
48932
|
const visitNode = (node) => {
|
|
48945
48933
|
if (containsString) return;
|
|
48946
|
-
if (
|
|
48934
|
+
if (typescriptBinding.isStringLiteralLike(node) && node.text === value) {
|
|
48947
48935
|
containsString = true;
|
|
48948
48936
|
return;
|
|
48949
48937
|
}
|
|
48950
|
-
|
|
48938
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48951
48939
|
};
|
|
48952
48940
|
visitNode(expression);
|
|
48953
48941
|
return containsString;
|
|
48954
48942
|
};
|
|
48955
48943
|
const collectObjectPathReferences = (expression, fileReferences) => {
|
|
48956
48944
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48957
|
-
if (
|
|
48945
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) {
|
|
48958
48946
|
fileReferences.add(unwrappedExpression.text);
|
|
48959
48947
|
return;
|
|
48960
48948
|
}
|
|
48961
|
-
if (
|
|
48949
|
+
if (typescriptBinding.isArrayLiteralExpression(unwrappedExpression)) {
|
|
48962
48950
|
for (const element of unwrappedExpression.elements) collectObjectPathReferences(element, fileReferences);
|
|
48963
48951
|
return;
|
|
48964
48952
|
}
|
|
48965
|
-
if (!
|
|
48953
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
48966
48954
|
for (const property of unwrappedExpression.properties) {
|
|
48967
|
-
if (!
|
|
48968
|
-
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);
|
|
48969
48957
|
}
|
|
48970
48958
|
};
|
|
48971
48959
|
const findStyleRegistryFanoutSources = (analysis, analyses) => {
|
|
48972
48960
|
for (const node of analysis.liveNodes) {
|
|
48973
|
-
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;
|
|
48974
48962
|
const styleVariableName = node.initializer.declarations[0].name.text;
|
|
48975
48963
|
const styleCollectionExpression = unwrapTypescriptExpression(node.expression);
|
|
48976
|
-
if (!
|
|
48964
|
+
if (!typescriptBinding.isIdentifier(styleCollectionExpression)) continue;
|
|
48977
48965
|
const stylesImport = analysis.importedFunctions.get(styleCollectionExpression.text);
|
|
48978
48966
|
const stylesAnalysis = stylesImport ? analyses.get(stylesImport.analysisKey) : void 0;
|
|
48979
48967
|
if (!stylesAnalysis) continue;
|
|
48980
48968
|
let registryAnalysis;
|
|
48981
48969
|
const visitStyleLoop = (loopNode) => {
|
|
48982
|
-
if (registryAnalysis || !
|
|
48983
|
-
if (!registryAnalysis)
|
|
48970
|
+
if (registryAnalysis || !typescriptBinding.isForOfStatement(loopNode)) {
|
|
48971
|
+
if (!registryAnalysis) typescriptBinding.forEachChild(loopNode, visitStyleLoop);
|
|
48984
48972
|
return;
|
|
48985
48973
|
}
|
|
48986
|
-
if (!
|
|
48987
|
-
|
|
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);
|
|
48988
48976
|
return;
|
|
48989
48977
|
}
|
|
48990
48978
|
const registryItemName = loopNode.initializer.declarations[0].name.text;
|
|
48991
48979
|
const registryCollectionExpression = unwrapTypescriptExpression(loopNode.expression);
|
|
48992
|
-
if (!
|
|
48980
|
+
if (!typescriptBinding.isIdentifier(registryCollectionExpression)) return;
|
|
48993
48981
|
const normalizedLoopBodyText = loopNode.statement.getText(analysis.sourceFile).replace(/\s/g, "");
|
|
48994
48982
|
if (!normalizedLoopBodyText.includes(`src/registry/\${${styleVariableName}.name}/`) || !normalizedLoopBodyText.includes(`${registryItemName}.files`) || !/\$\{[A-Za-z_$][\w$]*\.path\}/.test(normalizedLoopBodyText)) {
|
|
48995
|
-
|
|
48983
|
+
typescriptBinding.forEachChild(loopNode, visitStyleLoop);
|
|
48996
48984
|
return;
|
|
48997
48985
|
}
|
|
48998
48986
|
const registryImport = analysis.importedFunctions.get(registryCollectionExpression.text);
|
|
@@ -49009,10 +48997,10 @@ const collectRegistryFileReferences = (registryAnalysis, analyses) => {
|
|
|
49009
48997
|
const registryFileReferences = /* @__PURE__ */ new Set();
|
|
49010
48998
|
const collectRegistryModule = (moduleAnalysis) => {
|
|
49011
48999
|
const visitNode = (node) => {
|
|
49012
|
-
if (
|
|
49013
|
-
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);
|
|
49014
49002
|
}
|
|
49015
|
-
|
|
49003
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49016
49004
|
};
|
|
49017
49005
|
visitNode(moduleAnalysis.sourceFile);
|
|
49018
49006
|
};
|
|
@@ -49026,11 +49014,11 @@ const collectRegistryFileReferences = (registryAnalysis, analyses) => {
|
|
|
49026
49014
|
const collectRegistryStyleNames = (stylesAnalysis) => {
|
|
49027
49015
|
const styleNames = /* @__PURE__ */ new Set();
|
|
49028
49016
|
const visitNode = (node) => {
|
|
49029
|
-
if (
|
|
49017
|
+
if (typescriptBinding.isPropertyAssignment(node) && (typescriptBinding.isIdentifier(node.name) || typescriptBinding.isStringLiteralLike(node.name)) && node.name.text === "name") {
|
|
49030
49018
|
const styleNameExpression = unwrapTypescriptExpression(node.initializer);
|
|
49031
|
-
if (
|
|
49019
|
+
if (typescriptBinding.isStringLiteralLike(styleNameExpression)) styleNames.add(styleNameExpression.text);
|
|
49032
49020
|
}
|
|
49033
|
-
|
|
49021
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49034
49022
|
};
|
|
49035
49023
|
visitNode(stylesAnalysis.sourceFile);
|
|
49036
49024
|
return styleNames;
|
|
@@ -49044,7 +49032,7 @@ const collectResolvedRegistryFiles = (registryFileReferences, styleNames, regist
|
|
|
49044
49032
|
const collectRegistryMetadataConsumedFiles = (analyses, projectRoot, consumedFiles) => {
|
|
49045
49033
|
for (const analysis of analyses.values()) {
|
|
49046
49034
|
if (!basename(analysis.scriptFile.filePath).includes("registry")) continue;
|
|
49047
|
-
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;
|
|
49048
49036
|
const registryImport = analysis.importedFunctions.get("registry");
|
|
49049
49037
|
const stylesImport = analysis.importedFunctions.get("styles");
|
|
49050
49038
|
const registryAnalysis = registryImport ? analyses.get(registryImport.analysisKey) : void 0;
|
|
@@ -49065,7 +49053,7 @@ const nodeContainsNode = (rootNode, targetNode) => {
|
|
|
49065
49053
|
containsNode = true;
|
|
49066
49054
|
return;
|
|
49067
49055
|
}
|
|
49068
|
-
if (!containsNode)
|
|
49056
|
+
if (!containsNode) typescriptBinding.forEachChild(node, visitNode);
|
|
49069
49057
|
};
|
|
49070
49058
|
visitNode(rootNode);
|
|
49071
49059
|
return containsNode;
|
|
@@ -49074,11 +49062,11 @@ const findAssignedVariableName = (analysis, targetNode) => {
|
|
|
49074
49062
|
let variableName;
|
|
49075
49063
|
let smallestInitializerWidth = Number.POSITIVE_INFINITY;
|
|
49076
49064
|
const visitNode = (node) => {
|
|
49077
|
-
if (
|
|
49065
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer && nodeContainsNode(node.initializer, targetNode) && node.initializer.end - node.initializer.pos < smallestInitializerWidth) {
|
|
49078
49066
|
variableName = node.name.text;
|
|
49079
49067
|
smallestInitializerWidth = node.initializer.end - node.initializer.pos;
|
|
49080
49068
|
}
|
|
49081
|
-
|
|
49069
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49082
49070
|
};
|
|
49083
49071
|
visitNode(analysis.sourceFile);
|
|
49084
49072
|
return variableName;
|
|
@@ -49086,29 +49074,29 @@ const findAssignedVariableName = (analysis, targetNode) => {
|
|
|
49086
49074
|
const recursivelyReadsManifestWildcards = (analysis, readCall) => {
|
|
49087
49075
|
const registryVariableName = findAssignedVariableName(analysis, readCall);
|
|
49088
49076
|
if (!registryVariableName) return false;
|
|
49089
|
-
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");
|
|
49090
49078
|
const sourceBaseDeclaration = findVariableDeclaration(analysis.sourceFile, "sourceBase", analysis.sourceFile.end);
|
|
49091
49079
|
if (hasDirectRecursiveRead && sourceBaseDeclaration?.initializer && sourceBaseDeclaration.initializer.getText(analysis.sourceFile).includes(registryVariableName) && sourceBaseDeclaration.initializer.getText(analysis.sourceFile).includes("split")) return true;
|
|
49092
49080
|
const collectionNames = new Set([registryVariableName]);
|
|
49093
|
-
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))) {
|
|
49094
49082
|
const propertyAccess = unwrapTypescriptExpression(node.initializer);
|
|
49095
|
-
if (
|
|
49083
|
+
if (typescriptBinding.isPropertyAccessExpression(propertyAccess) && typescriptBinding.isIdentifier(propertyAccess.expression) && collectionNames.has(propertyAccess.expression.text)) collectionNames.add(node.name.text);
|
|
49096
49084
|
}
|
|
49097
49085
|
for (const node of analysis.liveNodes) {
|
|
49098
|
-
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;
|
|
49099
49087
|
const collectionExpression = unwrapTypescriptExpression(node.expression);
|
|
49100
|
-
if (!
|
|
49088
|
+
if (!typescriptBinding.isIdentifier(collectionExpression) || !collectionNames.has(collectionExpression.text)) continue;
|
|
49101
49089
|
const componentName = node.initializer.declarations[0].name.text;
|
|
49102
49090
|
let hasRecursiveFileLoop = false;
|
|
49103
49091
|
const visitOuterLoop = (outerNode) => {
|
|
49104
|
-
if (
|
|
49092
|
+
if (typescriptBinding.isForOfStatement(outerNode) && typescriptBinding.isPropertyAccessExpression(unwrapTypescriptExpression(outerNode.expression))) {
|
|
49105
49093
|
const filesExpression = unwrapTypescriptExpression(outerNode.expression);
|
|
49106
|
-
if (
|
|
49094
|
+
if (typescriptBinding.isPropertyAccessExpression(filesExpression) && typescriptBinding.isIdentifier(filesExpression.expression) && filesExpression.expression.text === componentName && filesExpression.name.text === "files") {
|
|
49107
49095
|
const innerLoopText = outerNode.statement.getText(analysis.sourceFile);
|
|
49108
49096
|
if (/\.includes\(\s*["']\*["']\s*\)/.test(innerLoopText) && /\.split\(\s*["']\*["']\s*\)/.test(innerLoopText) && /\bwalk\s*\(\s*sourceBase\s*,\s*sourceBase\s*\)/.test(innerLoopText)) hasRecursiveFileLoop = true;
|
|
49109
49097
|
}
|
|
49110
49098
|
}
|
|
49111
|
-
if (!hasRecursiveFileLoop)
|
|
49099
|
+
if (!hasRecursiveFileLoop) typescriptBinding.forEachChild(outerNode, visitOuterLoop);
|
|
49112
49100
|
};
|
|
49113
49101
|
visitOuterLoop(node.statement);
|
|
49114
49102
|
if (hasRecursiveFileLoop) return true;
|
|
@@ -49117,7 +49105,7 @@ const recursivelyReadsManifestWildcards = (analysis, readCall) => {
|
|
|
49117
49105
|
};
|
|
49118
49106
|
const collectReferencedManifestFiles = (analysis, projectRoot, consumedFiles) => {
|
|
49119
49107
|
for (const node of analysis.liveNodes) {
|
|
49120
|
-
if (!
|
|
49108
|
+
if (!typescriptBinding.isCallExpression(node) || !getPropertyName$1(node.expression)?.match(/^readFile(?:Sync)?$/) || !node.arguments[0]) continue;
|
|
49121
49109
|
const manifestPath = evaluatePathExpression(node.arguments[0], analysis, projectRoot);
|
|
49122
49110
|
if (!manifestPath || basename(manifestPath) !== "registry.json") continue;
|
|
49123
49111
|
if (!isPathInsideDirectoryOrEqual(manifestPath, projectRoot)) continue;
|
|
@@ -49308,46 +49296,46 @@ const collectParcelHtmlEntryPaths = (rootDirectory) => {
|
|
|
49308
49296
|
} catch {
|
|
49309
49297
|
continue;
|
|
49310
49298
|
}
|
|
49311
|
-
const sourceFile =
|
|
49299
|
+
const sourceFile = typescriptBinding.createSourceFile(scriptPath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49312
49300
|
const parcelConstructorNames = /* @__PURE__ */ new Set();
|
|
49313
49301
|
const variableInitializers = /* @__PURE__ */ new Map();
|
|
49314
49302
|
for (const statement of sourceFile.statements) {
|
|
49315
|
-
if (
|
|
49303
|
+
if (typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteralLike(statement.moduleSpecifier) && statement.moduleSpecifier.text === "parcel-bundler") {
|
|
49316
49304
|
const importClause = statement.importClause;
|
|
49317
49305
|
if (importClause?.name) parcelConstructorNames.add(importClause.name.text);
|
|
49318
49306
|
}
|
|
49319
|
-
if (!
|
|
49307
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
49320
49308
|
for (const declaration of statement.declarationList.declarations) {
|
|
49321
|
-
if (!
|
|
49309
|
+
if (!typescriptBinding.isIdentifier(declaration.name) || !declaration.initializer) continue;
|
|
49322
49310
|
variableInitializers.set(declaration.name.text, declaration.initializer);
|
|
49323
|
-
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);
|
|
49324
49312
|
}
|
|
49325
49313
|
}
|
|
49326
49314
|
if (parcelConstructorNames.size === 0) continue;
|
|
49327
49315
|
const evaluateEntryExpression = (expression, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
49328
|
-
if (
|
|
49329
|
-
if (
|
|
49330
|
-
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)) {
|
|
49331
49319
|
if (visitedIdentifiers.has(expression.text)) return [];
|
|
49332
49320
|
const initializer = variableInitializers.get(expression.text);
|
|
49333
49321
|
if (!initializer) return [];
|
|
49334
49322
|
return evaluateEntryExpression(initializer, new Set(visitedIdentifiers).add(expression.text));
|
|
49335
49323
|
}
|
|
49336
|
-
if (
|
|
49337
|
-
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] : []);
|
|
49338
49326
|
return [resolve(dirname(scriptPath), ...pathSegments)];
|
|
49339
49327
|
}
|
|
49340
49328
|
return [];
|
|
49341
49329
|
};
|
|
49342
49330
|
const visitNode = (node) => {
|
|
49343
|
-
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])) {
|
|
49344
49332
|
const entryPattern = isAbsolute(entrySpecifier) ? entrySpecifier : resolve(dirname(scriptPath), entrySpecifier);
|
|
49345
49333
|
for (const htmlEntryPath of import_out.default.sync(entryPattern.replaceAll("\\", "/"), {
|
|
49346
49334
|
absolute: true,
|
|
49347
49335
|
onlyFiles: true
|
|
49348
49336
|
})) if (/\.html?$/i.test(htmlEntryPath)) htmlEntryPaths.add(htmlEntryPath);
|
|
49349
49337
|
}
|
|
49350
|
-
|
|
49338
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49351
49339
|
};
|
|
49352
49340
|
visitNode(sourceFile);
|
|
49353
49341
|
}
|
|
@@ -49393,22 +49381,22 @@ const isConsumedStringLiteral = (node) => {
|
|
|
49393
49381
|
let currentNode = node;
|
|
49394
49382
|
while (currentNode.parent) {
|
|
49395
49383
|
const parentNode = currentNode.parent;
|
|
49396
|
-
if (
|
|
49397
|
-
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;
|
|
49398
49386
|
currentNode = parentNode;
|
|
49399
49387
|
}
|
|
49400
49388
|
return false;
|
|
49401
49389
|
};
|
|
49402
49390
|
const matchesExecutableNodeModulesPackageReference = (content, packageName) => {
|
|
49403
|
-
const sourceFile =
|
|
49391
|
+
const sourceFile = typescriptBinding.createSourceFile("node-modules-reference.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49404
49392
|
let isMatched = false;
|
|
49405
49393
|
const visit = (node) => {
|
|
49406
49394
|
if (isMatched) return;
|
|
49407
|
-
if (
|
|
49395
|
+
if (typescriptBinding.isStringLiteralLike(node) && isConsumedStringLiteral(node) && matchesNodeModulesPackageReference(node.text, packageName)) {
|
|
49408
49396
|
isMatched = true;
|
|
49409
49397
|
return;
|
|
49410
49398
|
}
|
|
49411
|
-
|
|
49399
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49412
49400
|
};
|
|
49413
49401
|
visit(sourceFile);
|
|
49414
49402
|
return isMatched;
|
|
@@ -49468,14 +49456,14 @@ const collectTwoslashPackageNames = (sourceText) => {
|
|
|
49468
49456
|
const packageNames = /* @__PURE__ */ new Set();
|
|
49469
49457
|
for (const source of sources) try {
|
|
49470
49458
|
for (const packageName of collectStaticModulePackageNames(source)) packageNames.add(packageName);
|
|
49471
|
-
const sourceFile =
|
|
49459
|
+
const sourceFile = typescriptBinding.createSourceFile("twoslash-source.js", source, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.JS);
|
|
49472
49460
|
const visitNode = (node) => {
|
|
49473
|
-
for (const tag of
|
|
49474
|
-
if (!
|
|
49461
|
+
for (const tag of typescriptBinding.getJSDocTags(node)) {
|
|
49462
|
+
if (!typescriptBinding.isJSDocImportTag(tag) || !typescriptBinding.isStringLiteralLike(tag.moduleSpecifier)) continue;
|
|
49475
49463
|
const packageName = extractPackageName(tag.moduleSpecifier.text);
|
|
49476
49464
|
if (packageName) packageNames.add(packageName);
|
|
49477
49465
|
}
|
|
49478
|
-
|
|
49466
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49479
49467
|
};
|
|
49480
49468
|
visitNode(sourceFile);
|
|
49481
49469
|
} catch {
|
|
@@ -49529,27 +49517,27 @@ const KARMA_BROWSER_PACKAGES = new Map([
|
|
|
49529
49517
|
["Safari", ["karma-safari-launcher"]]
|
|
49530
49518
|
]);
|
|
49531
49519
|
const collectExpressionStrings = (expression, identifierStrings, strings) => {
|
|
49532
|
-
if (
|
|
49520
|
+
if (typescriptBinding.isStringLiteralLike(expression)) {
|
|
49533
49521
|
strings.add(expression.text);
|
|
49534
49522
|
return;
|
|
49535
49523
|
}
|
|
49536
|
-
if (
|
|
49524
|
+
if (typescriptBinding.isIdentifier(expression)) {
|
|
49537
49525
|
for (const value of identifierStrings.get(expression.text) ?? []) strings.add(value);
|
|
49538
49526
|
return;
|
|
49539
49527
|
}
|
|
49540
|
-
if (
|
|
49541
|
-
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);
|
|
49542
49530
|
else collectExpressionStrings(element, identifierStrings, strings);
|
|
49543
49531
|
return;
|
|
49544
49532
|
}
|
|
49545
|
-
if (
|
|
49533
|
+
if (typescriptBinding.isConditionalExpression(expression)) {
|
|
49546
49534
|
collectExpressionStrings(expression.whenTrue, identifierStrings, strings);
|
|
49547
49535
|
collectExpressionStrings(expression.whenFalse, identifierStrings, strings);
|
|
49548
49536
|
return;
|
|
49549
49537
|
}
|
|
49550
|
-
if (
|
|
49551
|
-
for (const property of expression.properties) if (
|
|
49552
|
-
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);
|
|
49553
49541
|
}
|
|
49554
49542
|
};
|
|
49555
49543
|
const collectIdentifierStrings = (sourceFile) => {
|
|
@@ -49560,21 +49548,21 @@ const collectIdentifierStrings = (sourceFile) => {
|
|
|
49560
49548
|
identifierStrings.set(identifierName, strings);
|
|
49561
49549
|
};
|
|
49562
49550
|
const visit = (node) => {
|
|
49563
|
-
if (
|
|
49564
|
-
if (
|
|
49565
|
-
|
|
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);
|
|
49566
49554
|
};
|
|
49567
49555
|
visit(sourceFile);
|
|
49568
49556
|
return identifierStrings;
|
|
49569
49557
|
};
|
|
49570
49558
|
const collectPropertyStrings = (property, identifierStrings) => {
|
|
49571
49559
|
const strings = /* @__PURE__ */ new Set();
|
|
49572
|
-
if (
|
|
49573
|
-
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);
|
|
49574
49562
|
return strings;
|
|
49575
49563
|
};
|
|
49576
49564
|
const extractKarmaConfigPackageReferences = (content, declaredPackageNames) => {
|
|
49577
|
-
const sourceFile =
|
|
49565
|
+
const sourceFile = typescriptBinding.createSourceFile("karma.config.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49578
49566
|
const identifierStrings = collectIdentifierStrings(sourceFile);
|
|
49579
49567
|
const referencedPackages = /* @__PURE__ */ new Set();
|
|
49580
49568
|
const propertyPackageMaps = new Map([
|
|
@@ -49584,12 +49572,12 @@ const extractKarmaConfigPackageReferences = (content, declaredPackageNames) => {
|
|
|
49584
49572
|
["browsers", KARMA_BROWSER_PACKAGES]
|
|
49585
49573
|
]);
|
|
49586
49574
|
const visit = (node) => {
|
|
49587
|
-
if (
|
|
49575
|
+
if (typescriptBinding.isObjectLiteralExpression(node)) for (const property of node.properties) {
|
|
49588
49576
|
const packageMap = propertyPackageMaps.get(getObjectLiteralElementName(property) ?? "");
|
|
49589
49577
|
if (!packageMap) continue;
|
|
49590
49578
|
for (const token of collectPropertyStrings(property, identifierStrings)) for (const packageName of packageMap.get(token) ?? []) if (declaredPackageNames.has(packageName)) referencedPackages.add(packageName);
|
|
49591
49579
|
}
|
|
49592
|
-
|
|
49580
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49593
49581
|
};
|
|
49594
49582
|
visit(sourceFile);
|
|
49595
49583
|
return [...referencedPackages];
|
|
@@ -49606,23 +49594,23 @@ const hasExpoReactServerFunctions = (rootDirectory) => {
|
|
|
49606
49594
|
//#endregion
|
|
49607
49595
|
//#region ../core/src/project-analysis/utils/has-antfu-eslint-react-config.ts
|
|
49608
49596
|
const hasReactEnabled = (expression) => {
|
|
49609
|
-
if (!
|
|
49610
|
-
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)));
|
|
49611
49599
|
};
|
|
49612
49600
|
const hasAntfuEslintReactConfig = (content) => {
|
|
49613
49601
|
const virtualFilePath = "eslint.config.ts";
|
|
49614
|
-
const sourceFile =
|
|
49602
|
+
const sourceFile = typescriptBinding.createSourceFile(virtualFilePath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49615
49603
|
const compilerOptions = {
|
|
49616
49604
|
allowJs: true,
|
|
49617
49605
|
noLib: true,
|
|
49618
49606
|
noResolve: true,
|
|
49619
|
-
target:
|
|
49607
|
+
target: typescriptBinding.ScriptTarget.Latest
|
|
49620
49608
|
};
|
|
49621
|
-
const compilerHost =
|
|
49609
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
49622
49610
|
compilerHost.fileExists = (candidatePath) => candidatePath === virtualFilePath;
|
|
49623
49611
|
compilerHost.getSourceFile = (candidatePath) => candidatePath === virtualFilePath ? sourceFile : void 0;
|
|
49624
49612
|
compilerHost.readFile = (candidatePath) => candidatePath === virtualFilePath ? content : void 0;
|
|
49625
|
-
const program =
|
|
49613
|
+
const program = typescriptBinding.createProgram({
|
|
49626
49614
|
rootNames: [virtualFilePath],
|
|
49627
49615
|
options: compilerOptions,
|
|
49628
49616
|
host: compilerHost
|
|
@@ -49632,24 +49620,24 @@ const hasAntfuEslintReactConfig = (content) => {
|
|
|
49632
49620
|
const typeChecker = program.getTypeChecker();
|
|
49633
49621
|
const antfuFactorySymbols = /* @__PURE__ */ new Set();
|
|
49634
49622
|
for (const statement of boundSourceFile.statements) {
|
|
49635
|
-
if (!
|
|
49623
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteralLike(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "@antfu/eslint-config" || !statement.importClause?.name) continue;
|
|
49636
49624
|
const factorySymbol = typeChecker.getSymbolAtLocation(statement.importClause.name);
|
|
49637
49625
|
if (factorySymbol) antfuFactorySymbols.add(factorySymbol);
|
|
49638
49626
|
}
|
|
49639
49627
|
let isReactEnabled = false;
|
|
49640
49628
|
const visit = (node) => {
|
|
49641
49629
|
if (isReactEnabled) return;
|
|
49642
|
-
if (
|
|
49643
|
-
if (
|
|
49630
|
+
if (typescriptBinding.isFunctionLike(node)) return;
|
|
49631
|
+
if (typescriptBinding.isCallExpression(node) && node.arguments[0] && hasReactEnabled(node.arguments[0])) {
|
|
49644
49632
|
const factorySymbol = typeChecker.getSymbolAtLocation(node.expression);
|
|
49645
49633
|
if (factorySymbol && antfuFactorySymbols.has(factorySymbol)) {
|
|
49646
49634
|
isReactEnabled = true;
|
|
49647
49635
|
return;
|
|
49648
49636
|
}
|
|
49649
49637
|
}
|
|
49650
|
-
|
|
49638
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49651
49639
|
};
|
|
49652
|
-
for (const statement of boundSourceFile.statements) if (
|
|
49640
|
+
for (const statement of boundSourceFile.statements) if (typescriptBinding.isExportAssignment(statement)) visit(statement.expression);
|
|
49653
49641
|
return isReactEnabled;
|
|
49654
49642
|
};
|
|
49655
49643
|
//#endregion
|
|
@@ -51056,13 +51044,6 @@ const buildPlatformSiblingIndex = (graph, additionalPlatformSuffixesForFile = ()
|
|
|
51056
51044
|
return siblingIndex;
|
|
51057
51045
|
};
|
|
51058
51046
|
//#endregion
|
|
51059
|
-
//#region ../core/src/project-info/fs-utils.ts
|
|
51060
|
-
const isPlainObject = (value) => {
|
|
51061
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
51062
|
-
const prototype = Object.getPrototypeOf(value);
|
|
51063
|
-
return prototype === null || prototype === Object.prototype;
|
|
51064
|
-
};
|
|
51065
|
-
//#endregion
|
|
51066
51047
|
//#region ../core/src/utils/fail-open-read-json.ts
|
|
51067
51048
|
const failOpenReadJson = (filePath, fallback) => {
|
|
51068
51049
|
try {
|
|
@@ -51102,32 +51083,32 @@ const SUPPORTED_GLOBAL_VALUES = new Set([
|
|
|
51102
51083
|
"writeable"
|
|
51103
51084
|
]);
|
|
51104
51085
|
const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
|
|
51105
|
-
if (
|
|
51106
|
-
const name =
|
|
51107
|
-
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;
|
|
51108
51089
|
}) ?? null;
|
|
51109
|
-
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)));
|
|
51110
51091
|
const getStaticPropertyAssignment = (objectExpression, propertyName) => {
|
|
51111
51092
|
const property = getStaticProperty(objectExpression, propertyName);
|
|
51112
|
-
return property &&
|
|
51093
|
+
return property && typescriptBinding.isPropertyAssignment(property) ? property : null;
|
|
51113
51094
|
};
|
|
51114
51095
|
const getRequireModuleSpecifier = (expression) => {
|
|
51115
51096
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
51116
|
-
if (
|
|
51117
|
-
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;
|
|
51118
51099
|
const moduleSpecifier = unwrappedExpression.arguments[0];
|
|
51119
|
-
return moduleSpecifier &&
|
|
51100
|
+
return moduleSpecifier && typescriptBinding.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
51120
51101
|
};
|
|
51121
51102
|
const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
|
|
51122
51103
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
51123
|
-
return
|
|
51104
|
+
return typescriptBinding.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
|
|
51124
51105
|
};
|
|
51125
|
-
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");
|
|
51126
51107
|
const isTopLevelExpression = (node) => {
|
|
51127
51108
|
let ancestor = node.parent;
|
|
51128
|
-
while (ancestor && !
|
|
51129
|
-
if (
|
|
51130
|
-
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;
|
|
51131
51112
|
ancestor = ancestor.parent;
|
|
51132
51113
|
}
|
|
51133
51114
|
return false;
|
|
@@ -51135,21 +51116,21 @@ const isTopLevelExpression = (node) => {
|
|
|
51135
51116
|
const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
|
|
51136
51117
|
let ancestor = node.parent;
|
|
51137
51118
|
let didFindConfigProperty = false;
|
|
51138
|
-
while (ancestor && !
|
|
51139
|
-
if (!didFindConfigProperty && !
|
|
51140
|
-
if (
|
|
51141
|
-
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;
|
|
51142
51123
|
if (didFindConfigProperty || !isConfigProperty) return false;
|
|
51143
|
-
if (!
|
|
51124
|
+
if (!typescriptBinding.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(typescriptBinding.isSpreadAssignment)) return false;
|
|
51144
51125
|
didFindConfigProperty = true;
|
|
51145
51126
|
ancestor = ancestor.parent;
|
|
51146
51127
|
continue;
|
|
51147
51128
|
}
|
|
51148
51129
|
if (didFindConfigProperty) {
|
|
51149
|
-
if (
|
|
51130
|
+
if (typescriptBinding.isExportAssignment(ancestor)) return true;
|
|
51150
51131
|
if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
|
|
51151
|
-
if (propertyName === "plugins" &&
|
|
51152
|
-
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;
|
|
51153
51134
|
}
|
|
51154
51135
|
ancestor = ancestor.parent;
|
|
51155
51136
|
}
|
|
@@ -51159,21 +51140,21 @@ const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory
|
|
|
51159
51140
|
const optionsExpression = callExpression.arguments[0];
|
|
51160
51141
|
if (!optionsExpression) return null;
|
|
51161
51142
|
const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
|
|
51162
|
-
if (!
|
|
51163
|
-
if (unwrappedOptions.properties.some(
|
|
51143
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedOptions)) return null;
|
|
51144
|
+
if (unwrappedOptions.properties.some(typescriptBinding.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
|
|
51164
51145
|
if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
|
|
51165
51146
|
const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
|
|
51166
51147
|
if (!eslintrcProperty) return null;
|
|
51167
51148
|
const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
|
|
51168
|
-
if (!
|
|
51169
|
-
if (eslintrcExpression.properties.some(
|
|
51149
|
+
if (!typescriptBinding.isObjectLiteralExpression(eslintrcExpression)) return null;
|
|
51150
|
+
if (eslintrcExpression.properties.some(typescriptBinding.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
|
|
51170
51151
|
const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
|
|
51171
|
-
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !==
|
|
51152
|
+
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== typescriptBinding.SyntaxKind.TrueKeyword) return null;
|
|
51172
51153
|
const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
|
|
51173
51154
|
if (!filepathProperty) return path$1.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
|
|
51174
|
-
if (!
|
|
51155
|
+
if (!typescriptBinding.isPropertyAssignment(filepathProperty)) return null;
|
|
51175
51156
|
const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
|
|
51176
|
-
return
|
|
51157
|
+
return typescriptBinding.isStringLiteralLike(filepathExpression) ? path$1.resolve(packageDirectory, filepathExpression.text) : null;
|
|
51177
51158
|
};
|
|
51178
51159
|
const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
51179
51160
|
let sourceText;
|
|
@@ -51185,12 +51166,16 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51185
51166
|
globalsPaths: []
|
|
51186
51167
|
};
|
|
51187
51168
|
}
|
|
51188
|
-
|
|
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);
|
|
51189
51174
|
const autoImportBindings = /* @__PURE__ */ new Map();
|
|
51190
51175
|
const esbuildBindings = /* @__PURE__ */ new Set();
|
|
51191
51176
|
const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
|
|
51192
51177
|
for (const statement of sourceFile.statements) {
|
|
51193
|
-
if (
|
|
51178
|
+
if (typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteralLike(statement.moduleSpecifier)) {
|
|
51194
51179
|
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
51195
51180
|
if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
51196
51181
|
const defaultBinding = statement.importClause?.name;
|
|
@@ -51200,23 +51185,23 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51200
51185
|
const defaultBinding = statement.importClause?.name;
|
|
51201
51186
|
if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
|
|
51202
51187
|
const namedBindings = statement.importClause?.namedBindings;
|
|
51203
|
-
if (namedBindings &&
|
|
51188
|
+
if (namedBindings && typescriptBinding.isNamedImports(namedBindings)) {
|
|
51204
51189
|
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
|
|
51205
51190
|
}
|
|
51206
|
-
if (namedBindings &&
|
|
51191
|
+
if (namedBindings && typescriptBinding.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
|
|
51207
51192
|
}
|
|
51208
51193
|
}
|
|
51209
|
-
if (!
|
|
51194
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
51210
51195
|
for (const declaration of statement.declarationList.declarations) {
|
|
51211
51196
|
if (!declaration.initializer) continue;
|
|
51212
|
-
const declarationName =
|
|
51197
|
+
const declarationName = typescriptBinding.isIdentifier(declaration.name) ? declaration.name.text : null;
|
|
51213
51198
|
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
51214
51199
|
if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
|
|
51215
51200
|
if (moduleSpecifier === "esbuild") {
|
|
51216
51201
|
if (declarationName) esbuildNamespaceBindings.add(declarationName);
|
|
51217
|
-
if (
|
|
51202
|
+
if (typescriptBinding.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
|
|
51218
51203
|
const importedName = bindingElement.propertyName ?? bindingElement.name;
|
|
51219
|
-
if (
|
|
51204
|
+
if (typescriptBinding.isIdentifier(importedName) && importedName.text === "build" && typescriptBinding.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
|
|
51220
51205
|
}
|
|
51221
51206
|
}
|
|
51222
51207
|
if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
|
|
@@ -51226,8 +51211,8 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51226
51211
|
let didFindActiveAutoImport = false;
|
|
51227
51212
|
let didFindUnsafeActiveAutoImport = false;
|
|
51228
51213
|
const visit = (node) => {
|
|
51229
|
-
if (
|
|
51230
|
-
const moduleSpecifier =
|
|
51214
|
+
if (typescriptBinding.isCallExpression(node)) {
|
|
51215
|
+
const moduleSpecifier = typescriptBinding.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
|
|
51231
51216
|
if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
51232
51217
|
if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
|
|
51233
51218
|
didFindActiveAutoImport = true;
|
|
@@ -51237,7 +51222,7 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51237
51222
|
}
|
|
51238
51223
|
}
|
|
51239
51224
|
}
|
|
51240
|
-
|
|
51225
|
+
typescriptBinding.forEachChild(node, visit);
|
|
51241
51226
|
};
|
|
51242
51227
|
visit(sourceFile);
|
|
51243
51228
|
return {
|
|
@@ -51318,7 +51303,7 @@ const GENERATED_AUTO_IMPORT_MARKER = "Generated by unplugin-auto-import";
|
|
|
51318
51303
|
const AUTO_IMPORT_SOURCE_BINDING_PATTERN = /\bconst\s+([A-Za-z_$][\w$]*)\s*:\s*typeof\s+import\(["']([^"']+)["']\)\[["']([^"']+)["']\]/g;
|
|
51319
51304
|
const isNonReferenceIdentifier = (identifier) => {
|
|
51320
51305
|
const parent = identifier.parent;
|
|
51321
|
-
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;
|
|
51322
51307
|
};
|
|
51323
51308
|
const collectUnboundGlobalNames = (filePath, candidateGlobalNames) => {
|
|
51324
51309
|
let source;
|
|
@@ -51327,19 +51312,19 @@ const collectUnboundGlobalNames = (filePath, candidateGlobalNames) => {
|
|
|
51327
51312
|
} catch {
|
|
51328
51313
|
return /* @__PURE__ */ new Set();
|
|
51329
51314
|
}
|
|
51330
|
-
const sourceFile =
|
|
51315
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, source, typescriptBinding.ScriptTarget.Latest, true);
|
|
51331
51316
|
const compilerOptions = {
|
|
51332
51317
|
allowJs: true,
|
|
51333
|
-
jsx:
|
|
51318
|
+
jsx: typescriptBinding.JsxEmit.Preserve,
|
|
51334
51319
|
noLib: true,
|
|
51335
51320
|
noResolve: true,
|
|
51336
|
-
target:
|
|
51321
|
+
target: typescriptBinding.ScriptTarget.Latest
|
|
51337
51322
|
};
|
|
51338
|
-
const compilerHost =
|
|
51323
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
51339
51324
|
compilerHost.fileExists = (candidatePath) => candidatePath === filePath;
|
|
51340
51325
|
compilerHost.getSourceFile = (candidatePath) => candidatePath === filePath ? sourceFile : void 0;
|
|
51341
51326
|
compilerHost.readFile = (candidatePath) => candidatePath === filePath ? source : void 0;
|
|
51342
|
-
const program =
|
|
51327
|
+
const program = typescriptBinding.createProgram({
|
|
51343
51328
|
rootNames: [filePath],
|
|
51344
51329
|
options: compilerOptions,
|
|
51345
51330
|
host: compilerHost
|
|
@@ -51349,10 +51334,10 @@ const collectUnboundGlobalNames = (filePath, candidateGlobalNames) => {
|
|
|
51349
51334
|
if (!boundSourceFile) return /* @__PURE__ */ new Set();
|
|
51350
51335
|
const unboundGlobalNames = /* @__PURE__ */ new Set();
|
|
51351
51336
|
const visitNode = (node) => {
|
|
51352
|
-
if (
|
|
51353
|
-
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);
|
|
51354
51339
|
}
|
|
51355
|
-
|
|
51340
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
51356
51341
|
};
|
|
51357
51342
|
visitNode(boundSourceFile);
|
|
51358
51343
|
return unboundGlobalNames;
|
|
@@ -51525,7 +51510,7 @@ const hasUnparseableCompilerConfig = (packageRootDirectory) => {
|
|
|
51525
51510
|
return configNames.some((configName) => {
|
|
51526
51511
|
const configPath = join(packageRootDirectory, configName);
|
|
51527
51512
|
try {
|
|
51528
|
-
return
|
|
51513
|
+
return typescriptBinding.parseConfigFileTextToJson(configPath, readFileSync(configPath, "utf8")).error !== void 0;
|
|
51529
51514
|
} catch {
|
|
51530
51515
|
return true;
|
|
51531
51516
|
}
|
|
@@ -51898,4 +51883,4 @@ startProjectAnalysisWorker();
|
|
|
51898
51883
|
export {};
|
|
51899
51884
|
|
|
51900
51885
|
//# sourceMappingURL=project-analysis-worker.js.map
|
|
51901
|
-
//# debugId=
|
|
51886
|
+
//# debugId=81139e97-fbde-59ee-9b65-cb0499a5510a
|