react-doctor 0.9.14 → 0.9.15-dev.3242a81
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-B72ASBUh.js → active-scan-abort-registry-CCTgal0O.js} +3 -3
- package/dist/{build-section-divider-8DpL5BjN.js → build-section-divider-B-Bbahk_.js} +5 -4
- package/dist/{ci-DH_jkNS4.js → ci-D_GhoEkY.js} +14 -13
- package/dist/cli.js +32 -29
- package/dist/constants-DJ3RtEMu.js +1035 -0
- package/dist/{constants-CKOk_Fa9.js → constants-DNh19qg9.js} +3 -3
- package/dist/{design-DR72z3tB.js → design-B8EMFKlN.js} +4 -4
- package/dist/{devtools-DOdrAPkZ.js → devtools-D20sefkm.js} +3 -3
- package/dist/duplicate-jsx-worker.js +62 -62
- package/dist/{exit-gracefully-BP0lJPao.js → exit-gracefully-BTVhlyoR.js} +7 -7
- package/dist/fs-utils-C88IbqFa.js +45 -0
- package/dist/{get-east-asian-width-CM5BOEC-.js → get-east-asian-width-DRPy7dqz.js} +4 -4
- package/dist/{handle-error-BO7AUOeO.js → handle-error-JId9eFQ_.js} +6 -5
- package/dist/index.d.ts +8511 -8509
- package/dist/index.js +12732 -12337
- package/dist/{inspect-CtwjUwiF.js → inspect-ClJlUcd6.js} +28 -21
- package/dist/{install-DAwHDunN.js → install-bAES9fz_.js} +10 -9
- package/dist/{install-doctor-script-DousNjwa.js → install-doctor-script-ByhqWGm4.js} +17 -8
- package/dist/{install-github-workflow-DNfyCbSd.js → install-github-workflow-CMVYSVGv.js} +10 -10
- package/dist/{install-react-doctor-CofgPrzS.js → install-react-doctor-D7cj-Foc.js} +15 -11
- package/dist/is-cache-globally-disabled-De19063F.js +10 -0
- package/dist/{jsx-runtime-Dv_yWxfg.js → jsx-runtime-BSGXwXUT.js} +11 -10
- package/dist/oxlint-worker.js +95 -5
- package/dist/{path-format-DnHpmJwG.js → path-format-By20mo8A.js} +3 -3
- package/dist/{print-branded-header-CFoO5ZHN.js → print-branded-header-ToEzN9wS.js} +4 -4
- package/dist/project-analysis-worker.js +459 -461
- package/dist/{prompt-runtime-scan-url-9tmVyRA2.js → prompt-runtime-scan-url-B-N-pmnA.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-C8gGTrwo.js → read-object-file-BwnK2YRI.js} +4 -4
- package/dist/{record-metric-DMuxA69u.js → record-metric-DUV0U_Gf.js} +12587 -13128
- package/dist/{report-error-DynYEdrW.js → report-error-Df6kpdn5.js} +7 -6
- package/dist/{report-workflow-result-C0nwk5Eq.js → report-workflow-result-CDjrtaab.js} +24 -11
- package/dist/{resolve-scope-CtDh9FtN.js → resolve-scope-BQLYQkzz.js} +7 -7
- package/dist/{rules-Dtp6I51W.js → rules-BvI82y2z.js} +8 -7
- package/dist/{run-scan-app-DTjrGFyP.js → run-scan-app-DUzpuqlt.js} +12 -11
- package/dist/{runtime-scan-DylzMW6d.js → runtime-scan-CxErJEVf.js} +13 -12
- package/dist/{sanitize-runtime-url-CtosBgav.js → sanitize-runtime-url-BjEqBgwG.js} +4 -4
- package/dist/{scan-i9quJrxG.js → scan-Cuyc4IC8.js} +10 -9
- package/dist/{semver-DlmXks31.js → semver-BZIuy1gP.js} +3 -3
- package/dist/{should-fail-scan-gate-uW8_hnTc.js → should-fail-scan-gate-Du7mOvEl.js} +1848 -1825
- package/dist/{should-skip-prompts-fmi7PPp5.js → should-skip-prompts-DaKPFC6p.js} +4 -4
- package/dist/{should-use-tui-DaLPPhMi.js → should-use-tui-DZ2iTCn1.js} +4 -4
- package/dist/start-scan-preamble-DVhXIPc0.d.ts +1 -0
- package/dist/start-scan-preamble-DZknzhHU.js +68 -0
- package/dist/start-scan-preamble.d.ts +1 -0
- package/dist/start-scan-preamble.js +4 -0
- package/dist/{telemetry-runtime-CxBC0gEj.js → telemetry-runtime-o4N789Mp.js} +7 -6
- 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-Bti3M8BN.js → version-CtgKUicn.js} +5 -4
- package/dist/{why-dcQaGoJz.js → why-BDgcBrL3.js} +4 -4
- package/dist/{with-run-span-Lynvloyt.js → with-run-span-Bgitvg5D.js} +7 -6
- package/package.json +7 -5
- package/dist/_react-doctor_require-typescript-DnwIzXJn.js +0 -7
- package/dist/unwrap-typescript-expression-CbO_6kmC.js +0 -14
|
@@ -1,20 +1,21 @@
|
|
|
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-
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as unwrapTypescriptExpression } from "./unwrap-typescript-expression-
|
|
7
|
-
import { a as MAX_GLOB_PATTERN_LENGTH_CHARS, c as GIT_CHECK_ATTR_MAX_BUFFER_BYTES } from "./constants-
|
|
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";
|
|
8
9
|
import { builtinModules } from "node:module";
|
|
9
|
-
import { spawnSync } from "node:child_process";
|
|
10
|
-
import * as path$1 from "node:path";
|
|
11
|
-
import path, { basename, dirname, extname, isAbsolute, join, parse, posix, relative, resolve, sep } from "node:path";
|
|
12
10
|
import * as fs$1 from "node:fs";
|
|
13
11
|
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
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";
|
|
14
16
|
import { parseSync } from "oxc-parser";
|
|
15
17
|
import { readFile } from "node:fs/promises";
|
|
16
18
|
import { ResolverFactory } from "oxc-resolver";
|
|
17
|
-
import { devNull } from "node:os";
|
|
18
19
|
import { parseJSONC, parseTOML, parseYAML } from "confbox";
|
|
19
20
|
import { parse as parse$1 } from "@astrojs/compiler/sync";
|
|
20
21
|
//#region ../core/src/project-analysis/constants.ts
|
|
@@ -13382,19 +13383,19 @@ const collectStylesheetImportSpecifiers = (content) => {
|
|
|
13382
13383
|
const extractJitiLoadReferences = (sourceText) => {
|
|
13383
13384
|
if (!sourceText.includes("jiti")) return [];
|
|
13384
13385
|
const virtualFilePath = "react-doctor-jiti-source.tsx";
|
|
13385
|
-
const sourceFile =
|
|
13386
|
+
const sourceFile = typescriptBinding.createSourceFile(virtualFilePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TSX);
|
|
13386
13387
|
const compilerOptions = {
|
|
13387
13388
|
allowJs: true,
|
|
13388
|
-
jsx:
|
|
13389
|
+
jsx: typescriptBinding.JsxEmit.Preserve,
|
|
13389
13390
|
noLib: true,
|
|
13390
13391
|
noResolve: true,
|
|
13391
|
-
target:
|
|
13392
|
+
target: typescriptBinding.ScriptTarget.Latest
|
|
13392
13393
|
};
|
|
13393
|
-
const compilerHost =
|
|
13394
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
13394
13395
|
compilerHost.fileExists = (candidatePath) => candidatePath === virtualFilePath;
|
|
13395
13396
|
compilerHost.getSourceFile = (candidatePath) => candidatePath === virtualFilePath ? sourceFile : void 0;
|
|
13396
13397
|
compilerHost.readFile = (candidatePath) => candidatePath === virtualFilePath ? sourceText : void 0;
|
|
13397
|
-
const program =
|
|
13398
|
+
const program = typescriptBinding.createProgram({
|
|
13398
13399
|
rootNames: [virtualFilePath],
|
|
13399
13400
|
options: compilerOptions,
|
|
13400
13401
|
host: compilerHost
|
|
@@ -13409,60 +13410,60 @@ const extractJitiLoadReferences = (sourceText) => {
|
|
|
13409
13410
|
const factorySymbols = /* @__PURE__ */ new Set();
|
|
13410
13411
|
const moduleSymbols = /* @__PURE__ */ new Set();
|
|
13411
13412
|
const loaderSymbols = /* @__PURE__ */ new Set();
|
|
13412
|
-
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";
|
|
13413
13414
|
for (const statement of boundSourceFile.statements) {
|
|
13414
|
-
if (
|
|
13415
|
+
if (typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === "jiti") {
|
|
13415
13416
|
const importClause = statement.importClause;
|
|
13416
13417
|
if (!importClause) continue;
|
|
13417
13418
|
if (importClause.name) {
|
|
13418
13419
|
const defaultImportSymbol = typeChecker.getSymbolAtLocation(importClause.name);
|
|
13419
13420
|
if (defaultImportSymbol) factorySymbols.add(defaultImportSymbol);
|
|
13420
13421
|
}
|
|
13421
|
-
if (importClause.namedBindings &&
|
|
13422
|
+
if (importClause.namedBindings && typescriptBinding.isNamespaceImport(importClause.namedBindings)) {
|
|
13422
13423
|
const moduleSymbol = typeChecker.getSymbolAtLocation(importClause.namedBindings.name);
|
|
13423
13424
|
if (moduleSymbol) moduleSymbols.add(moduleSymbol);
|
|
13424
13425
|
}
|
|
13425
|
-
if (importClause.namedBindings &&
|
|
13426
|
+
if (importClause.namedBindings && typescriptBinding.isNamedImports(importClause.namedBindings)) for (const importSpecifier of importClause.namedBindings.elements) {
|
|
13426
13427
|
if ((importSpecifier.propertyName?.text ?? importSpecifier.name.text) !== "createJiti") continue;
|
|
13427
13428
|
const factorySymbol = typeChecker.getSymbolAtLocation(importSpecifier.name);
|
|
13428
13429
|
if (factorySymbol) factorySymbols.add(factorySymbol);
|
|
13429
13430
|
}
|
|
13430
13431
|
continue;
|
|
13431
13432
|
}
|
|
13432
|
-
if (!
|
|
13433
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
13433
13434
|
for (const declaration of statement.declarationList.declarations) {
|
|
13434
13435
|
if (!declaration.initializer || !isRequireJitiCall(declaration.initializer)) continue;
|
|
13435
|
-
if (
|
|
13436
|
+
if (typescriptBinding.isIdentifier(declaration.name)) {
|
|
13436
13437
|
const moduleSymbol = typeChecker.getSymbolAtLocation(declaration.name);
|
|
13437
13438
|
if (moduleSymbol) moduleSymbols.add(moduleSymbol);
|
|
13438
13439
|
continue;
|
|
13439
13440
|
}
|
|
13440
|
-
if (!
|
|
13441
|
+
if (!typescriptBinding.isObjectBindingPattern(declaration.name)) continue;
|
|
13441
13442
|
for (const bindingElement of declaration.name.elements) {
|
|
13442
13443
|
const importedName = bindingElement.propertyName ?? bindingElement.name;
|
|
13443
|
-
if (!
|
|
13444
|
-
if (!
|
|
13444
|
+
if (!typescriptBinding.isIdentifier(importedName) || importedName.text !== "createJiti") continue;
|
|
13445
|
+
if (!typescriptBinding.isIdentifier(bindingElement.name)) continue;
|
|
13445
13446
|
const factorySymbol = typeChecker.getSymbolAtLocation(bindingElement.name);
|
|
13446
13447
|
if (factorySymbol) factorySymbols.add(factorySymbol);
|
|
13447
13448
|
}
|
|
13448
13449
|
}
|
|
13449
13450
|
}
|
|
13450
|
-
const isRequireJitiFactoryCall = (expression) =>
|
|
13451
|
+
const isRequireJitiFactoryCall = (expression) => typescriptBinding.isCallExpression(expression) && isRequireJitiCall(expression.expression);
|
|
13451
13452
|
const isFactoryExpression = (expression) => {
|
|
13452
13453
|
const factorySymbol = typeChecker.getSymbolAtLocation(expression);
|
|
13453
13454
|
if (factorySymbol && factorySymbols.has(factorySymbol)) return true;
|
|
13454
|
-
if (!
|
|
13455
|
+
if (!typescriptBinding.isPropertyAccessExpression(expression) || expression.name.text !== "createJiti") return false;
|
|
13455
13456
|
const moduleSymbol = typeChecker.getSymbolAtLocation(expression.expression);
|
|
13456
13457
|
return moduleSymbol !== void 0 && moduleSymbols.has(moduleSymbol);
|
|
13457
13458
|
};
|
|
13458
13459
|
const collectLoaderBindings = (node) => {
|
|
13459
|
-
if (
|
|
13460
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer && typescriptBinding.isCallExpression(node.initializer)) {
|
|
13460
13461
|
if (isRequireJitiFactoryCall(node.initializer) || isFactoryExpression(node.initializer.expression)) {
|
|
13461
13462
|
const loaderSymbol = typeChecker.getSymbolAtLocation(node.name);
|
|
13462
13463
|
if (loaderSymbol) loaderSymbols.add(loaderSymbol);
|
|
13463
13464
|
}
|
|
13464
13465
|
}
|
|
13465
|
-
|
|
13466
|
+
typescriptBinding.forEachChild(node, collectLoaderBindings);
|
|
13466
13467
|
};
|
|
13467
13468
|
collectLoaderBindings(boundSourceFile);
|
|
13468
13469
|
const references = [];
|
|
@@ -13470,25 +13471,25 @@ const extractJitiLoadReferences = (sourceText) => {
|
|
|
13470
13471
|
const firstArgument = callExpression.arguments[0];
|
|
13471
13472
|
const position = boundSourceFile.getLineAndCharacterOfPosition(callExpression.getStart());
|
|
13472
13473
|
references.push({
|
|
13473
|
-
path: firstArgument &&
|
|
13474
|
+
path: firstArgument && typescriptBinding.isStringLiteralLike(firstArgument) ? firstArgument.text : void 0,
|
|
13474
13475
|
line: position.line + 1,
|
|
13475
13476
|
column: position.character
|
|
13476
13477
|
});
|
|
13477
13478
|
};
|
|
13478
13479
|
const visitLoaderCalls = (node) => {
|
|
13479
|
-
if (
|
|
13480
|
+
if (typescriptBinding.isCallExpression(node)) {
|
|
13480
13481
|
const calleeSymbol = typeChecker.getSymbolAtLocation(node.expression);
|
|
13481
13482
|
if (calleeSymbol && loaderSymbols.has(calleeSymbol)) recordLoaderCall(node);
|
|
13482
|
-
else if (
|
|
13483
|
+
else if (typescriptBinding.isCallExpression(node.expression)) {
|
|
13483
13484
|
if (isRequireJitiFactoryCall(node.expression) || isFactoryExpression(node.expression.expression)) recordLoaderCall(node);
|
|
13484
|
-
} else if (
|
|
13485
|
+
} else if (typescriptBinding.isPropertyAccessExpression(node.expression) && node.expression.name.text === "import") {
|
|
13485
13486
|
const loaderExpression = node.expression.expression;
|
|
13486
13487
|
const loaderSymbol = typeChecker.getSymbolAtLocation(loaderExpression);
|
|
13487
|
-
const isInlineFactory =
|
|
13488
|
+
const isInlineFactory = typescriptBinding.isCallExpression(loaderExpression) && isFactoryExpression(loaderExpression.expression);
|
|
13488
13489
|
if (loaderSymbol && loaderSymbols.has(loaderSymbol) || isInlineFactory) recordLoaderCall(node);
|
|
13489
13490
|
}
|
|
13490
13491
|
}
|
|
13491
|
-
|
|
13492
|
+
typescriptBinding.forEachChild(node, visitLoaderCalls);
|
|
13492
13493
|
};
|
|
13493
13494
|
visitLoaderCalls(boundSourceFile);
|
|
13494
13495
|
return references;
|
|
@@ -36059,10 +36060,10 @@ const extractMarkdownModuleStatements = (sourceText) => {
|
|
|
36059
36060
|
//#endregion
|
|
36060
36061
|
//#region ../core/src/project-analysis/collect/parse.ts
|
|
36061
36062
|
const extractRecoveryImports = (filePath, sourceText) => {
|
|
36062
|
-
const sourceFile =
|
|
36063
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, filePath.endsWith("x") ? typescriptBinding.ScriptKind.TSX : typescriptBinding.ScriptKind.TS);
|
|
36063
36064
|
const imports = [];
|
|
36064
36065
|
for (const statement of sourceFile.statements) {
|
|
36065
|
-
if (!
|
|
36066
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
36066
36067
|
const importedNames = [];
|
|
36067
36068
|
const importClause = statement.importClause;
|
|
36068
36069
|
if (importClause?.name) importedNames.push({
|
|
@@ -36072,14 +36073,14 @@ const extractRecoveryImports = (filePath, sourceText) => {
|
|
|
36072
36073
|
isDefault: true,
|
|
36073
36074
|
isTypeOnly: importClause.isTypeOnly
|
|
36074
36075
|
});
|
|
36075
|
-
if (importClause?.namedBindings &&
|
|
36076
|
+
if (importClause?.namedBindings && typescriptBinding.isNamespaceImport(importClause.namedBindings)) importedNames.push({
|
|
36076
36077
|
name: "*",
|
|
36077
36078
|
alias: importClause.namedBindings.name.text,
|
|
36078
36079
|
isNamespace: true,
|
|
36079
36080
|
isDefault: false,
|
|
36080
36081
|
isTypeOnly: importClause.isTypeOnly
|
|
36081
36082
|
});
|
|
36082
|
-
if (importClause?.namedBindings &&
|
|
36083
|
+
if (importClause?.namedBindings && typescriptBinding.isNamedImports(importClause.namedBindings)) for (const element of importClause.namedBindings.elements) importedNames.push({
|
|
36083
36084
|
name: element.propertyName?.text ?? element.name.text,
|
|
36084
36085
|
alias: element.name.text,
|
|
36085
36086
|
isNamespace: false,
|
|
@@ -36104,18 +36105,18 @@ const restoreMaskedSourceRange = (maskedSource, sourceSection, startOffset) => {
|
|
|
36104
36105
|
for (let characterIndex = 0; characterIndex < sourceSection.length; characterIndex++) maskedSource[startOffset + characterIndex] = sourceSection[characterIndex];
|
|
36105
36106
|
};
|
|
36106
36107
|
const maskSelectedExportKeywords = (sourceText, shouldMaskStatement) => {
|
|
36107
|
-
const sourceFile =
|
|
36108
|
+
const sourceFile = typescriptBinding.createSourceFile("embedded-component.tsx", sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TSX);
|
|
36108
36109
|
const maskedSource = sourceText.split("");
|
|
36109
36110
|
for (const statement of sourceFile.statements) {
|
|
36110
|
-
if (!shouldMaskStatement(statement) || !
|
|
36111
|
-
const exportModifier =
|
|
36111
|
+
if (!shouldMaskStatement(statement) || !typescriptBinding.canHaveModifiers(statement)) continue;
|
|
36112
|
+
const exportModifier = typescriptBinding.getModifiers(statement)?.find((modifier) => modifier.kind === typescriptBinding.SyntaxKind.ExportKeyword);
|
|
36112
36113
|
if (!exportModifier) continue;
|
|
36113
36114
|
for (let characterIndex = exportModifier.getStart(sourceFile); characterIndex < exportModifier.end; characterIndex++) maskedSource[characterIndex] = " ";
|
|
36114
36115
|
}
|
|
36115
36116
|
return maskedSource.join("");
|
|
36116
36117
|
};
|
|
36117
|
-
const maskAstroPropsExports = (sourceText) => maskSelectedExportKeywords(sourceText, (statement) => (
|
|
36118
|
-
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);
|
|
36119
36120
|
const extractAstroSources = (sourceText) => {
|
|
36120
36121
|
const maskedSource = createWhitespaceMask(sourceText);
|
|
36121
36122
|
let astroRoot;
|
|
@@ -38102,52 +38103,52 @@ const addExpoPluginEntry = (entries, packageNamePlugins, rootDirectory, configDi
|
|
|
38102
38103
|
entries.add(resolvedPath);
|
|
38103
38104
|
};
|
|
38104
38105
|
const getPropertyName$4 = (name) => {
|
|
38105
|
-
if (
|
|
38106
|
+
if (typescriptBinding.isIdentifier(name) || typescriptBinding.isStringLiteral(name) || typescriptBinding.isNumericLiteral(name)) return name.text;
|
|
38106
38107
|
};
|
|
38107
38108
|
const collectExpoPluginPathsFromArray = (array, entries, packageNamePlugins, rootDirectory, configDirectory) => {
|
|
38108
38109
|
for (const element of array.elements) {
|
|
38109
|
-
if (
|
|
38110
|
+
if (typescriptBinding.isStringLiteral(element) || typescriptBinding.isNoSubstitutionTemplateLiteral(element)) {
|
|
38110
38111
|
addExpoPluginEntry(entries, packageNamePlugins, rootDirectory, configDirectory, element.text);
|
|
38111
38112
|
continue;
|
|
38112
38113
|
}
|
|
38113
|
-
if (
|
|
38114
|
+
if (typescriptBinding.isArrayLiteralExpression(element)) {
|
|
38114
38115
|
const [pluginName] = element.elements;
|
|
38115
|
-
if (pluginName && (
|
|
38116
|
+
if (pluginName && (typescriptBinding.isStringLiteral(pluginName) || typescriptBinding.isNoSubstitutionTemplateLiteral(pluginName))) addExpoPluginEntry(entries, packageNamePlugins, rootDirectory, configDirectory, pluginName.text);
|
|
38116
38117
|
}
|
|
38117
38118
|
}
|
|
38118
38119
|
};
|
|
38119
38120
|
const collectExpoPluginPathsFromConfigObject = (objectLiteral, entries, packageNamePlugins, rootDirectory, configDirectory) => {
|
|
38120
38121
|
for (const property of objectLiteral.properties) {
|
|
38121
|
-
if (!
|
|
38122
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
38122
38123
|
const propertyName = getPropertyName$4(property.name);
|
|
38123
|
-
if (propertyName === "plugins" &&
|
|
38124
|
-
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);
|
|
38125
38126
|
}
|
|
38126
38127
|
};
|
|
38127
38128
|
const collectReturnedExpoConfigPluginPaths = (body, entries, packageNamePlugins, rootDirectory, configDirectory) => {
|
|
38128
|
-
if (!
|
|
38129
|
+
if (!typescriptBinding.isBlock(body)) {
|
|
38129
38130
|
const expression = unwrapTypescriptExpression(body);
|
|
38130
|
-
if (
|
|
38131
|
+
if (typescriptBinding.isObjectLiteralExpression(expression)) collectExpoPluginPathsFromConfigObject(expression, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38131
38132
|
return;
|
|
38132
38133
|
}
|
|
38133
38134
|
const visit = (node) => {
|
|
38134
|
-
if (
|
|
38135
|
-
if (
|
|
38135
|
+
if (typescriptBinding.isFunctionDeclaration(node) || typescriptBinding.isFunctionExpression(node) || typescriptBinding.isArrowFunction(node)) return;
|
|
38136
|
+
if (typescriptBinding.isReturnStatement(node) && node.expression) {
|
|
38136
38137
|
const expression = unwrapTypescriptExpression(node.expression);
|
|
38137
|
-
if (
|
|
38138
|
+
if (typescriptBinding.isObjectLiteralExpression(expression)) collectExpoPluginPathsFromConfigObject(expression, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38138
38139
|
return;
|
|
38139
38140
|
}
|
|
38140
|
-
|
|
38141
|
+
typescriptBinding.forEachChild(node, visit);
|
|
38141
38142
|
};
|
|
38142
38143
|
visit(body);
|
|
38143
38144
|
};
|
|
38144
38145
|
const collectExpoPluginPathsFromConfigExpression = (expression, entries, packageNamePlugins, rootDirectory, configDirectory, bindings, seenIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
38145
38146
|
const configExpression = unwrapTypescriptExpression(expression);
|
|
38146
|
-
if (
|
|
38147
|
+
if (typescriptBinding.isObjectLiteralExpression(configExpression)) {
|
|
38147
38148
|
collectExpoPluginPathsFromConfigObject(configExpression, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38148
38149
|
return;
|
|
38149
38150
|
}
|
|
38150
|
-
if (
|
|
38151
|
+
if (typescriptBinding.isIdentifier(configExpression)) {
|
|
38151
38152
|
if (seenIdentifiers.has(configExpression.text)) return;
|
|
38152
38153
|
seenIdentifiers.add(configExpression.text);
|
|
38153
38154
|
const boundExpression = bindings.expressions.get(configExpression.text);
|
|
@@ -38159,23 +38160,23 @@ const collectExpoPluginPathsFromConfigExpression = (expression, entries, package
|
|
|
38159
38160
|
if (boundFunction?.body) collectReturnedExpoConfigPluginPaths(boundFunction.body, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38160
38161
|
return;
|
|
38161
38162
|
}
|
|
38162
|
-
if (
|
|
38163
|
+
if (typescriptBinding.isArrowFunction(configExpression)) {
|
|
38163
38164
|
collectReturnedExpoConfigPluginPaths(configExpression.body, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38164
38165
|
return;
|
|
38165
38166
|
}
|
|
38166
|
-
if (
|
|
38167
|
+
if (typescriptBinding.isFunctionExpression(configExpression) && configExpression.body) collectReturnedExpoConfigPluginPaths(configExpression.body, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38167
38168
|
};
|
|
38168
|
-
const hasDefaultExportModifier = (node) => Boolean(
|
|
38169
|
-
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";
|
|
38170
38171
|
const collectStaticConfigBindings = (sourceFile) => {
|
|
38171
38172
|
const expressions = /* @__PURE__ */ new Map();
|
|
38172
38173
|
const functions = /* @__PURE__ */ new Map();
|
|
38173
38174
|
for (const statement of sourceFile.statements) {
|
|
38174
|
-
if (
|
|
38175
|
-
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);
|
|
38176
38177
|
continue;
|
|
38177
38178
|
}
|
|
38178
|
-
if (
|
|
38179
|
+
if (typescriptBinding.isFunctionDeclaration(statement) && statement.name) functions.set(statement.name.text, statement);
|
|
38179
38180
|
}
|
|
38180
38181
|
return {
|
|
38181
38182
|
expressions,
|
|
@@ -38184,23 +38185,23 @@ const collectStaticConfigBindings = (sourceFile) => {
|
|
|
38184
38185
|
};
|
|
38185
38186
|
const collectExpoPluginPathsFromAppConfig = (configPath, entries, packageNamePlugins, rootDirectory) => {
|
|
38186
38187
|
const extension = extname(configPath);
|
|
38187
|
-
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);
|
|
38188
38189
|
const configDirectory = dirname(configPath);
|
|
38189
38190
|
const bindings = collectStaticConfigBindings(sourceFile);
|
|
38190
38191
|
const visit = (node) => {
|
|
38191
|
-
if (
|
|
38192
|
+
if (typescriptBinding.isExportAssignment(node)) {
|
|
38192
38193
|
collectExpoPluginPathsFromConfigExpression(node.expression, entries, packageNamePlugins, rootDirectory, configDirectory, bindings);
|
|
38193
38194
|
return;
|
|
38194
38195
|
}
|
|
38195
|
-
if (
|
|
38196
|
+
if (typescriptBinding.isFunctionDeclaration(node) && hasDefaultExportModifier(node) && node.body) {
|
|
38196
38197
|
collectReturnedExpoConfigPluginPaths(node.body, entries, packageNamePlugins, rootDirectory, configDirectory);
|
|
38197
38198
|
return;
|
|
38198
38199
|
}
|
|
38199
|
-
if (
|
|
38200
|
+
if (typescriptBinding.isBinaryExpression(node) && node.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken && isModuleExportsAssignmentTarget(node.left)) {
|
|
38200
38201
|
collectExpoPluginPathsFromConfigExpression(node.right, entries, packageNamePlugins, rootDirectory, configDirectory, bindings);
|
|
38201
38202
|
return;
|
|
38202
38203
|
}
|
|
38203
|
-
|
|
38204
|
+
typescriptBinding.forEachChild(node, visit);
|
|
38204
38205
|
};
|
|
38205
38206
|
visit(sourceFile);
|
|
38206
38207
|
};
|
|
@@ -38880,23 +38881,23 @@ const resolveGeneratedOutputs = (patterns, configDirectory) => {
|
|
|
38880
38881
|
};
|
|
38881
38882
|
const extractVitePluginConfigContents = (content) => {
|
|
38882
38883
|
const pluginConfigContents = [];
|
|
38883
|
-
const sourceFile =
|
|
38884
|
-
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;
|
|
38885
38886
|
if (!pluginName) return [];
|
|
38886
|
-
const exportAssignment = sourceFile.statements.find((statement) =>
|
|
38887
|
+
const exportAssignment = sourceFile.statements.find((statement) => typescriptBinding.isExportAssignment(statement) && !statement.isExportEquals);
|
|
38887
38888
|
if (!exportAssignment) return [];
|
|
38888
38889
|
const topLevelVariableInitializers = /* @__PURE__ */ new Map();
|
|
38889
38890
|
for (const statement of sourceFile.statements) {
|
|
38890
|
-
if (!
|
|
38891
|
-
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);
|
|
38892
38893
|
}
|
|
38893
38894
|
const unwrapExpression = (expression) => {
|
|
38894
|
-
if (
|
|
38895
|
+
if (typescriptBinding.isParenthesizedExpression(expression) || typescriptBinding.isAsExpression(expression) || typescriptBinding.isSatisfiesExpression(expression)) return unwrapExpression(expression.expression);
|
|
38895
38896
|
return expression;
|
|
38896
38897
|
};
|
|
38897
38898
|
const collectPluginExpression = (expression, variableInitializers, isPluginNameShadowed, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
38898
38899
|
const unwrappedExpression = unwrapExpression(expression);
|
|
38899
|
-
if (
|
|
38900
|
+
if (typescriptBinding.isCallExpression(unwrappedExpression) && typescriptBinding.isIdentifier(unwrappedExpression.expression) && unwrappedExpression.expression.text === pluginName) {
|
|
38900
38901
|
const configArgument = unwrappedExpression.arguments[0];
|
|
38901
38902
|
if (configArgument && !isPluginNameShadowed) {
|
|
38902
38903
|
const bindingStatements = [...variableInitializers.entries()].map(([variableName, initializer]) => `const ${variableName} = (${initializer.getText(sourceFile)});`).join("\n");
|
|
@@ -38904,54 +38905,54 @@ const extractVitePluginConfigContents = (content) => {
|
|
|
38904
38905
|
}
|
|
38905
38906
|
return;
|
|
38906
38907
|
}
|
|
38907
|
-
if (
|
|
38908
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression) && !visitedIdentifiers.has(unwrappedExpression.text)) {
|
|
38908
38909
|
const initializer = variableInitializers.get(unwrappedExpression.text);
|
|
38909
38910
|
if (!initializer) return;
|
|
38910
38911
|
collectPluginExpression(initializer, variableInitializers, isPluginNameShadowed, new Set(visitedIdentifiers).add(unwrappedExpression.text));
|
|
38911
38912
|
return;
|
|
38912
38913
|
}
|
|
38913
|
-
if (
|
|
38914
|
-
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);
|
|
38915
38916
|
return;
|
|
38916
38917
|
}
|
|
38917
|
-
if (
|
|
38918
|
+
if (typescriptBinding.isConditionalExpression(unwrappedExpression)) {
|
|
38918
38919
|
collectPluginExpression(unwrappedExpression.whenTrue, variableInitializers, isPluginNameShadowed, visitedIdentifiers);
|
|
38919
38920
|
collectPluginExpression(unwrappedExpression.whenFalse, variableInitializers, isPluginNameShadowed, visitedIdentifiers);
|
|
38920
38921
|
return;
|
|
38921
38922
|
}
|
|
38922
|
-
if (
|
|
38923
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && (unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.AmpersandAmpersandToken || unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.BarBarToken || unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.QuestionQuestionToken)) {
|
|
38923
38924
|
collectPluginExpression(unwrappedExpression.left, variableInitializers, isPluginNameShadowed, visitedIdentifiers);
|
|
38924
38925
|
collectPluginExpression(unwrappedExpression.right, variableInitializers, isPluginNameShadowed, visitedIdentifiers);
|
|
38925
38926
|
}
|
|
38926
38927
|
};
|
|
38927
38928
|
const collectConfigPlugins = (expression, variableInitializers, isPluginNameShadowed, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
38928
38929
|
const unwrappedExpression = unwrapExpression(expression);
|
|
38929
|
-
if (
|
|
38930
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression) && !visitedIdentifiers.has(unwrappedExpression.text)) {
|
|
38930
38931
|
const initializer = variableInitializers.get(unwrappedExpression.text);
|
|
38931
38932
|
if (!initializer) return;
|
|
38932
38933
|
collectConfigPlugins(initializer, variableInitializers, isPluginNameShadowed, new Set(visitedIdentifiers).add(unwrappedExpression.text));
|
|
38933
38934
|
return;
|
|
38934
38935
|
}
|
|
38935
|
-
if (
|
|
38936
|
+
if (typescriptBinding.isCallExpression(unwrappedExpression)) {
|
|
38936
38937
|
const calledExpression = unwrapExpression(unwrappedExpression.expression);
|
|
38937
|
-
if (!
|
|
38938
|
+
if (!typescriptBinding.isIdentifier(calledExpression) || calledExpression.text !== "defineConfig") return;
|
|
38938
38939
|
const configArgument = unwrappedExpression.arguments[0];
|
|
38939
38940
|
if (!configArgument) return;
|
|
38940
38941
|
const unwrappedArgument = unwrapExpression(configArgument);
|
|
38941
|
-
if (
|
|
38942
|
-
let callbackPluginNameShadowed = isPluginNameShadowed || unwrappedArgument.parameters.some((parameter) =>
|
|
38943
|
-
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)) {
|
|
38944
38945
|
collectConfigPlugins(unwrappedArgument.body, variableInitializers, callbackPluginNameShadowed);
|
|
38945
38946
|
return;
|
|
38946
38947
|
}
|
|
38947
38948
|
const callbackVariableInitializers = new Map(variableInitializers);
|
|
38948
38949
|
for (const statement of unwrappedArgument.body.statements) {
|
|
38949
|
-
if (
|
|
38950
|
-
if (!
|
|
38950
|
+
if (typescriptBinding.isVariableStatement(statement)) for (const declaration of statement.declarationList.declarations) {
|
|
38951
|
+
if (!typescriptBinding.isIdentifier(declaration.name)) continue;
|
|
38951
38952
|
if (declaration.name.text === pluginName) callbackPluginNameShadowed = true;
|
|
38952
38953
|
if (declaration.initializer) callbackVariableInitializers.set(declaration.name.text, declaration.initializer);
|
|
38953
38954
|
}
|
|
38954
|
-
if (
|
|
38955
|
+
if (typescriptBinding.isReturnStatement(statement) && statement.expression) {
|
|
38955
38956
|
collectConfigPlugins(statement.expression, callbackVariableInitializers, callbackPluginNameShadowed);
|
|
38956
38957
|
return;
|
|
38957
38958
|
}
|
|
@@ -38961,10 +38962,10 @@ const extractVitePluginConfigContents = (content) => {
|
|
|
38961
38962
|
collectConfigPlugins(unwrappedArgument, variableInitializers, isPluginNameShadowed);
|
|
38962
38963
|
return;
|
|
38963
38964
|
}
|
|
38964
|
-
if (!
|
|
38965
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
38965
38966
|
for (const property of unwrappedExpression.properties) {
|
|
38966
|
-
if (
|
|
38967
|
-
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);
|
|
38968
38969
|
}
|
|
38969
38970
|
};
|
|
38970
38971
|
collectConfigPlugins(exportAssignment.expression, topLevelVariableInitializers, false);
|
|
@@ -39088,24 +39089,24 @@ const TARO_ARRAY_SELECTION_METHODS = new Set([
|
|
|
39088
39089
|
"splice"
|
|
39089
39090
|
]);
|
|
39090
39091
|
const getPropertyName$2 = (propertyName) => {
|
|
39091
|
-
if (
|
|
39092
|
+
if (typescriptBinding.isIdentifier(propertyName) || typescriptBinding.isStringLiteral(propertyName) || typescriptBinding.isNoSubstitutionTemplateLiteral(propertyName)) return propertyName.text;
|
|
39092
39093
|
};
|
|
39093
39094
|
const unwrapConfigExpression = (expression) => {
|
|
39094
|
-
if (
|
|
39095
|
-
if (
|
|
39095
|
+
if (typescriptBinding.isParenthesizedExpression(expression) || typescriptBinding.isAsExpression(expression) || typescriptBinding.isSatisfiesExpression(expression)) return unwrapConfigExpression(expression.expression);
|
|
39096
|
+
if (typescriptBinding.isCallExpression(expression)) {
|
|
39096
39097
|
const [configArgument] = expression.arguments;
|
|
39097
39098
|
return configArgument ? unwrapConfigExpression(configArgument) : expression;
|
|
39098
39099
|
}
|
|
39099
39100
|
return expression;
|
|
39100
39101
|
};
|
|
39101
39102
|
const unwrapArrayExpression = (expression) => {
|
|
39102
|
-
if (
|
|
39103
|
+
if (typescriptBinding.isParenthesizedExpression(expression) || typescriptBinding.isAsExpression(expression) || typescriptBinding.isSatisfiesExpression(expression)) return unwrapArrayExpression(expression.expression);
|
|
39103
39104
|
return expression;
|
|
39104
39105
|
};
|
|
39105
39106
|
const getPropertyInitializer = (objectLiteral, propertyNames) => {
|
|
39106
39107
|
for (const property of objectLiteral.properties) {
|
|
39107
|
-
if (
|
|
39108
|
-
if (!
|
|
39108
|
+
if (typescriptBinding.isShorthandPropertyAssignment(property) && propertyNames.has(property.name.text)) return property.name;
|
|
39109
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
39109
39110
|
const propertyName = getPropertyName$2(property.name);
|
|
39110
39111
|
if (propertyName && propertyNames.has(propertyName)) return property.initializer;
|
|
39111
39112
|
}
|
|
@@ -39113,16 +39114,16 @@ const getPropertyInitializer = (objectLiteral, propertyNames) => {
|
|
|
39113
39114
|
const collectArrayElements = (expression, variableInitializers, pushedElements, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
39114
39115
|
if (!expression) return [];
|
|
39115
39116
|
const unwrappedExpression = unwrapArrayExpression(expression);
|
|
39116
|
-
if (
|
|
39117
|
-
if (
|
|
39118
|
-
if (
|
|
39119
|
-
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)) {
|
|
39120
39121
|
const nextVisitedIdentifiers = new Set(visitedIdentifiers).add(unwrappedExpression.text);
|
|
39121
39122
|
return [...collectArrayElements(variableInitializers.get(unwrappedExpression.text), variableInitializers, pushedElements, nextVisitedIdentifiers), ...pushedElements.get(unwrappedExpression.text) ?? []];
|
|
39122
39123
|
}
|
|
39123
39124
|
return [];
|
|
39124
39125
|
};
|
|
39125
|
-
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] : []);
|
|
39126
39127
|
const resolvePageEntries = (configDirectory, pagePaths) => pagePaths.flatMap((pagePath) => {
|
|
39127
39128
|
const resolvedEntry = resolveEntryWithExtensions(resolve(configDirectory, pagePath));
|
|
39128
39129
|
return resolvedEntry ? [resolvedEntry] : [];
|
|
@@ -39131,9 +39132,9 @@ const collectConfigPageEntries = (configDirectory, configObject, variableInitial
|
|
|
39131
39132
|
const entries = resolvePageEntries(configDirectory, collectPagePaths(getPropertyInitializer(configObject, new Set(["pages"])), variableInitializers, pushedElements));
|
|
39132
39133
|
const subPackagesExpression = getPropertyInitializer(configObject, new Set(["subPackages", "subpackages"]));
|
|
39133
39134
|
for (const subPackageElement of collectArrayElements(subPackagesExpression, variableInitializers, pushedElements)) {
|
|
39134
|
-
if (!
|
|
39135
|
+
if (!typescriptBinding.isObjectLiteralExpression(subPackageElement)) continue;
|
|
39135
39136
|
const rootExpression = getPropertyInitializer(subPackageElement, new Set(["root"]));
|
|
39136
|
-
if (!rootExpression || !
|
|
39137
|
+
if (!rootExpression || !typescriptBinding.isStringLiteral(rootExpression) && !typescriptBinding.isNoSubstitutionTemplateLiteral(rootExpression)) continue;
|
|
39137
39138
|
const subPackagePages = collectPagePaths(getPropertyInitializer(subPackageElement, new Set(["pages"])), variableInitializers, pushedElements).map((pagePath) => `${rootExpression.text}/${pagePath}`);
|
|
39138
39139
|
entries.push(...resolvePageEntries(configDirectory, subPackagePages));
|
|
39139
39140
|
}
|
|
@@ -39142,56 +39143,56 @@ const collectConfigPageEntries = (configDirectory, configObject, variableInitial
|
|
|
39142
39143
|
const collectVariableInitializers = (sourceFile) => {
|
|
39143
39144
|
const variableInitializers = /* @__PURE__ */ new Map();
|
|
39144
39145
|
for (const statement of sourceFile.statements) {
|
|
39145
|
-
if (!
|
|
39146
|
-
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);
|
|
39147
39148
|
}
|
|
39148
39149
|
return variableInitializers;
|
|
39149
39150
|
};
|
|
39150
39151
|
const collectShadowedBindingNames = (bindingName, topLevelVariableNames) => {
|
|
39151
|
-
if (
|
|
39152
|
-
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) : []);
|
|
39153
39154
|
};
|
|
39154
39155
|
const collectPushedElements = (sourceFile, topLevelVariableNames) => {
|
|
39155
39156
|
const pushedElements = /* @__PURE__ */ new Map();
|
|
39156
39157
|
const visitNode = (node, shadowedNames) => {
|
|
39157
|
-
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;
|
|
39158
39159
|
let nextShadowedNames = shadowedNames;
|
|
39159
39160
|
const shadowBindingNames = (bindingNames) => {
|
|
39160
39161
|
const newlyShadowedNames = bindingNames.flatMap((bindingName) => collectShadowedBindingNames(bindingName, topLevelVariableNames));
|
|
39161
39162
|
if (newlyShadowedNames.length > 0) nextShadowedNames = new Set([...nextShadowedNames, ...newlyShadowedNames]);
|
|
39162
39163
|
};
|
|
39163
|
-
if (
|
|
39164
|
-
if (!
|
|
39164
|
+
if (typescriptBinding.isBlock(node)) shadowBindingNames(node.statements.flatMap((statement) => {
|
|
39165
|
+
if (!typescriptBinding.isVariableStatement(statement) || !(statement.declarationList.flags & typescriptBinding.NodeFlags.BlockScoped)) return [];
|
|
39165
39166
|
return statement.declarationList.declarations.map((declaration) => declaration.name);
|
|
39166
39167
|
}));
|
|
39167
|
-
if (
|
|
39168
|
-
if (
|
|
39168
|
+
if (typescriptBinding.isCatchClause(node) && node.variableDeclaration) shadowBindingNames([node.variableDeclaration.name]);
|
|
39169
|
+
if (typescriptBinding.isForStatement(node) || typescriptBinding.isForInStatement(node) || typescriptBinding.isForOfStatement(node)) {
|
|
39169
39170
|
const initializer = node.initializer;
|
|
39170
|
-
if (initializer &&
|
|
39171
|
+
if (initializer && typescriptBinding.isVariableDeclarationList(initializer) && initializer.flags & typescriptBinding.NodeFlags.BlockScoped) shadowBindingNames(initializer.declarations.map((declaration) => declaration.name));
|
|
39171
39172
|
}
|
|
39172
|
-
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)) {
|
|
39173
39174
|
const identifier = node.expression.expression.text;
|
|
39174
39175
|
const existingElements = pushedElements.get(identifier) ?? [];
|
|
39175
39176
|
existingElements.push(...node.arguments);
|
|
39176
39177
|
pushedElements.set(identifier, existingElements);
|
|
39177
39178
|
}
|
|
39178
|
-
|
|
39179
|
+
typescriptBinding.forEachChild(node, (childNode) => visitNode(childNode, nextShadowedNames));
|
|
39179
39180
|
};
|
|
39180
39181
|
visitNode(sourceFile, /* @__PURE__ */ new Set());
|
|
39181
39182
|
return pushedElements;
|
|
39182
39183
|
};
|
|
39183
39184
|
const extractConfigObject = (sourceFile, variableInitializers) => {
|
|
39184
39185
|
for (const statement of sourceFile.statements) {
|
|
39185
|
-
if (!
|
|
39186
|
+
if (!typescriptBinding.isExportAssignment(statement) || statement.isExportEquals) continue;
|
|
39186
39187
|
let expression = unwrapConfigExpression(statement.expression);
|
|
39187
39188
|
const visitedIdentifiers = /* @__PURE__ */ new Set();
|
|
39188
|
-
while (
|
|
39189
|
+
while (typescriptBinding.isIdentifier(expression) && !visitedIdentifiers.has(expression.text)) {
|
|
39189
39190
|
visitedIdentifiers.add(expression.text);
|
|
39190
39191
|
const initializer = variableInitializers.get(expression.text);
|
|
39191
39192
|
if (!initializer) break;
|
|
39192
39193
|
expression = unwrapConfigExpression(initializer);
|
|
39193
39194
|
}
|
|
39194
|
-
if (
|
|
39195
|
+
if (typescriptBinding.isObjectLiteralExpression(expression)) return expression;
|
|
39195
39196
|
}
|
|
39196
39197
|
};
|
|
39197
39198
|
const extractTaroPageEntries = (directory, dependencies) => {
|
|
@@ -39204,7 +39205,7 @@ const extractTaroPageEntries = (directory, dependencies) => {
|
|
|
39204
39205
|
});
|
|
39205
39206
|
for (const configPath of configPaths) try {
|
|
39206
39207
|
const sourceText = readFileSync(configPath, "utf8");
|
|
39207
|
-
const sourceFile =
|
|
39208
|
+
const sourceFile = typescriptBinding.createSourceFile(configPath, sourceText, typescriptBinding.ScriptTarget.Latest, true);
|
|
39208
39209
|
const variableInitializers = collectVariableInitializers(sourceFile);
|
|
39209
39210
|
const pushedElements = collectPushedElements(sourceFile, new Set(variableInitializers.keys()));
|
|
39210
39211
|
const configObject = extractConfigObject(sourceFile, variableInitializers);
|
|
@@ -39675,20 +39676,20 @@ const extractJestModuleNameMapperAliases = (content, configDirectory) => {
|
|
|
39675
39676
|
const extractWebpackModuleDirectories = (content, configDirectory) => {
|
|
39676
39677
|
const moduleDirectories = [];
|
|
39677
39678
|
const moduleDirectoryNames = [];
|
|
39678
|
-
const sourceFile =
|
|
39679
|
+
const sourceFile = typescriptBinding.createSourceFile("webpack.config.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
39679
39680
|
const variableInitializers = /* @__PURE__ */ new Map();
|
|
39680
39681
|
for (const statement of sourceFile.statements) {
|
|
39681
|
-
if (!
|
|
39682
|
-
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);
|
|
39683
39684
|
}
|
|
39684
39685
|
const unwrapExpression = (expression) => {
|
|
39685
|
-
if (
|
|
39686
|
+
if (typescriptBinding.isParenthesizedExpression(expression) || typescriptBinding.isAsExpression(expression) || typescriptBinding.isSatisfiesExpression(expression)) return unwrapExpression(expression.expression);
|
|
39686
39687
|
return expression;
|
|
39687
39688
|
};
|
|
39688
39689
|
const resolveObjectExpression = (expression, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
39689
39690
|
const unwrappedExpression = unwrapExpression(expression);
|
|
39690
|
-
if (
|
|
39691
|
-
if (
|
|
39691
|
+
if (typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return unwrappedExpression;
|
|
39692
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression) && !visitedIdentifiers.has(unwrappedExpression.text)) {
|
|
39692
39693
|
const initializer = variableInitializers.get(unwrappedExpression.text);
|
|
39693
39694
|
if (!initializer) return void 0;
|
|
39694
39695
|
return resolveObjectExpression(initializer, new Set(visitedIdentifiers).add(unwrappedExpression.text));
|
|
@@ -39696,82 +39697,82 @@ const extractWebpackModuleDirectories = (content, configDirectory) => {
|
|
|
39696
39697
|
};
|
|
39697
39698
|
const collectModules = (resolveObject) => {
|
|
39698
39699
|
for (const property of resolveObject.properties) {
|
|
39699
|
-
if (!
|
|
39700
|
-
const propertyName =
|
|
39700
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
39701
|
+
const propertyName = typescriptBinding.isIdentifier(property.name) || typescriptBinding.isStringLiteral(property.name) ? property.name.text : void 0;
|
|
39701
39702
|
if (propertyName !== "modules" && propertyName !== "modulesDirectories") continue;
|
|
39702
|
-
if (!
|
|
39703
|
+
if (!typescriptBinding.isArrayLiteralExpression(property.initializer)) continue;
|
|
39703
39704
|
for (const element of property.initializer.elements) {
|
|
39704
|
-
if (
|
|
39705
|
+
if (typescriptBinding.isStringLiteral(element) || typescriptBinding.isNoSubstitutionTemplateLiteral(element)) {
|
|
39705
39706
|
if (element.text === "node_modules") continue;
|
|
39706
39707
|
if (element.text.startsWith(".") || element.text.includes("/")) moduleDirectories.push(resolveConfigPathValue(element.text, configDirectory));
|
|
39707
39708
|
else moduleDirectoryNames.push(element.text);
|
|
39708
39709
|
continue;
|
|
39709
39710
|
}
|
|
39710
|
-
if (!
|
|
39711
|
+
if (!typescriptBinding.isCallExpression(element)) continue;
|
|
39711
39712
|
const calledExpression = element.expression;
|
|
39712
|
-
if (!
|
|
39713
|
-
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] : []);
|
|
39714
39715
|
if (pathSegments.length > 0) moduleDirectories.push(resolve(configDirectory, ...pathSegments));
|
|
39715
39716
|
}
|
|
39716
39717
|
}
|
|
39717
39718
|
};
|
|
39718
39719
|
const collectConfigExpression = (expression, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
39719
39720
|
const unwrappedExpression = unwrapExpression(expression);
|
|
39720
|
-
if (
|
|
39721
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken) {
|
|
39721
39722
|
collectConfigExpression(unwrappedExpression.right, visitedIdentifiers);
|
|
39722
39723
|
return;
|
|
39723
39724
|
}
|
|
39724
|
-
if (
|
|
39725
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) {
|
|
39725
39726
|
if (visitedIdentifiers.has(unwrappedExpression.text)) return;
|
|
39726
39727
|
const initializer = variableInitializers.get(unwrappedExpression.text);
|
|
39727
39728
|
if (!initializer) return;
|
|
39728
39729
|
collectConfigExpression(initializer, new Set(visitedIdentifiers).add(unwrappedExpression.text));
|
|
39729
39730
|
return;
|
|
39730
39731
|
}
|
|
39731
|
-
if (
|
|
39732
|
-
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);
|
|
39733
39734
|
else collectConfigExpression(element, visitedIdentifiers);
|
|
39734
39735
|
return;
|
|
39735
39736
|
}
|
|
39736
|
-
if (
|
|
39737
|
+
if (typescriptBinding.isConditionalExpression(unwrappedExpression)) {
|
|
39737
39738
|
collectConfigExpression(unwrappedExpression.whenTrue, visitedIdentifiers);
|
|
39738
39739
|
collectConfigExpression(unwrappedExpression.whenFalse, visitedIdentifiers);
|
|
39739
39740
|
return;
|
|
39740
39741
|
}
|
|
39741
|
-
if (
|
|
39742
|
-
if (!
|
|
39742
|
+
if (typescriptBinding.isArrowFunction(unwrappedExpression) || typescriptBinding.isFunctionExpression(unwrappedExpression)) {
|
|
39743
|
+
if (!typescriptBinding.isBlock(unwrappedExpression.body)) {
|
|
39743
39744
|
collectConfigExpression(unwrappedExpression.body, visitedIdentifiers);
|
|
39744
39745
|
return;
|
|
39745
39746
|
}
|
|
39746
|
-
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);
|
|
39747
39748
|
return;
|
|
39748
39749
|
}
|
|
39749
|
-
if (!
|
|
39750
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
39750
39751
|
for (const property of unwrappedExpression.properties) {
|
|
39751
|
-
if (
|
|
39752
|
+
if (typescriptBinding.isSpreadAssignment(property)) {
|
|
39752
39753
|
collectConfigExpression(property.expression, visitedIdentifiers);
|
|
39753
39754
|
continue;
|
|
39754
39755
|
}
|
|
39755
|
-
if (
|
|
39756
|
+
if (typescriptBinding.isShorthandPropertyAssignment(property) && property.name.text === "resolve") {
|
|
39756
39757
|
const resolveObject = resolveObjectExpression(property.name);
|
|
39757
39758
|
if (resolveObject) collectModules(resolveObject);
|
|
39758
39759
|
continue;
|
|
39759
39760
|
}
|
|
39760
|
-
if (!
|
|
39761
|
-
if ((
|
|
39761
|
+
if (!typescriptBinding.isPropertyAssignment(property)) continue;
|
|
39762
|
+
if ((typescriptBinding.isIdentifier(property.name) || typescriptBinding.isStringLiteral(property.name) ? property.name.text : void 0) !== "resolve") continue;
|
|
39762
39763
|
const resolveObject = resolveObjectExpression(property.initializer);
|
|
39763
39764
|
if (resolveObject) collectModules(resolveObject);
|
|
39764
39765
|
}
|
|
39765
39766
|
};
|
|
39766
|
-
const isModuleExports = (expression) =>
|
|
39767
|
+
const isModuleExports = (expression) => typescriptBinding.isPropertyAccessExpression(expression) && typescriptBinding.isIdentifier(expression.expression) && expression.expression.text === "module" && expression.name.text === "exports";
|
|
39767
39768
|
const collectModuleExportsAssignment = (expression) => {
|
|
39768
|
-
if (
|
|
39769
|
+
if (typescriptBinding.isBinaryExpression(expression) && expression.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken) if (isModuleExports(expression.left)) collectConfigExpression(expression.right);
|
|
39769
39770
|
else collectModuleExportsAssignment(expression.right);
|
|
39770
39771
|
};
|
|
39771
39772
|
for (const statement of sourceFile.statements) {
|
|
39772
|
-
if (
|
|
39773
|
-
if (
|
|
39774
|
-
if (
|
|
39773
|
+
if (typescriptBinding.isExportAssignment(statement) && !statement.isExportEquals) collectConfigExpression(statement.expression);
|
|
39774
|
+
if (typescriptBinding.isExpressionStatement(statement)) collectModuleExportsAssignment(statement.expression);
|
|
39775
|
+
if (typescriptBinding.isVariableStatement(statement)) {
|
|
39775
39776
|
for (const declaration of statement.declarationList.declarations) if (declaration.initializer) collectModuleExportsAssignment(declaration.initializer);
|
|
39776
39777
|
}
|
|
39777
39778
|
}
|
|
@@ -40535,20 +40536,20 @@ const extractImportSpecifiers = (sourceText) => {
|
|
|
40535
40536
|
};
|
|
40536
40537
|
const extractStylelintPluginSpecifiers = (sourceText) => {
|
|
40537
40538
|
const specifiers = [];
|
|
40538
|
-
const sourceFile =
|
|
40539
|
+
const sourceFile = typescriptBinding.createSourceFile("stylelint.config.mjs", sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
40539
40540
|
const collectStringLiterals = (node) => {
|
|
40540
|
-
if (
|
|
40541
|
+
if (typescriptBinding.isStringLiteralLike(node)) {
|
|
40541
40542
|
specifiers.push(node.text);
|
|
40542
40543
|
return;
|
|
40543
40544
|
}
|
|
40544
|
-
|
|
40545
|
+
typescriptBinding.forEachChild(node, collectStringLiterals);
|
|
40545
40546
|
};
|
|
40546
40547
|
const visitNode = (node) => {
|
|
40547
|
-
if (
|
|
40548
|
+
if (typescriptBinding.isPropertyAssignment(node) && (typescriptBinding.isIdentifier(node.name) || typescriptBinding.isStringLiteralLike(node.name)) && node.name.text === "plugins") {
|
|
40548
40549
|
collectStringLiterals(node.initializer);
|
|
40549
40550
|
return;
|
|
40550
40551
|
}
|
|
40551
|
-
|
|
40552
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
40552
40553
|
};
|
|
40553
40554
|
visitNode(sourceFile);
|
|
40554
40555
|
return specifiers;
|
|
@@ -41007,17 +41008,17 @@ const isPathInsideDirectoryOrEqual = (candidatePath, directoryPath) => {
|
|
|
41007
41008
|
//#region ../core/src/project-analysis/collect/static-globby-entries.ts
|
|
41008
41009
|
const getCalledName = (expression) => {
|
|
41009
41010
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41010
|
-
if (
|
|
41011
|
-
if (
|
|
41011
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) return unwrappedExpression.text;
|
|
41012
|
+
if (typescriptBinding.isPropertyAccessExpression(unwrappedExpression)) return unwrappedExpression.name.text;
|
|
41012
41013
|
};
|
|
41013
41014
|
const isImportMetaUrl = (expression) => {
|
|
41014
41015
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41015
|
-
return
|
|
41016
|
+
return typescriptBinding.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === "url" && typescriptBinding.isMetaProperty(unwrappedExpression.expression) && unwrappedExpression.expression.keywordToken === typescriptBinding.SyntaxKind.ImportKeyword;
|
|
41016
41017
|
};
|
|
41017
41018
|
const evaluateDirectoryExpression = (expression, context, seenIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
41018
41019
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41019
|
-
if (
|
|
41020
|
-
if (
|
|
41020
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) return resolve(dirname(context.entryFilePath), unwrappedExpression.text);
|
|
41021
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) {
|
|
41021
41022
|
if (unwrappedExpression.text === "__dirname") return dirname(context.entryFilePath);
|
|
41022
41023
|
if (seenIdentifiers.has(unwrappedExpression.text)) return void 0;
|
|
41023
41024
|
const initializer = context.variableDeclarations.get(unwrappedExpression.text);
|
|
@@ -41026,10 +41027,10 @@ const evaluateDirectoryExpression = (expression, context, seenIdentifiers = /* @
|
|
|
41026
41027
|
nextSeenIdentifiers.add(unwrappedExpression.text);
|
|
41027
41028
|
return evaluateDirectoryExpression(initializer, context, nextSeenIdentifiers);
|
|
41028
41029
|
}
|
|
41029
|
-
if (
|
|
41030
|
-
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;
|
|
41031
41032
|
const calledName = getCalledName(unwrappedExpression.expression);
|
|
41032
|
-
if (calledName === "cwd" &&
|
|
41033
|
+
if (calledName === "cwd" && typescriptBinding.isPropertyAccessExpression(unwrappedExpression.expression) && typescriptBinding.isIdentifier(unwrappedExpression.expression.expression) && unwrappedExpression.expression.expression.text === "process") return context.projectRoot;
|
|
41033
41034
|
if (calledName === "fileURLToPath" && unwrappedExpression.arguments[0] && isImportMetaUrl(unwrappedExpression.arguments[0])) return context.entryFilePath;
|
|
41034
41035
|
if (calledName === "dirname" && unwrappedExpression.arguments[0]) {
|
|
41035
41036
|
const evaluatedPath = evaluateDirectoryExpression(unwrappedExpression.arguments[0], context, seenIdentifiers);
|
|
@@ -41043,19 +41044,19 @@ const evaluateDirectoryExpression = (expression, context, seenIdentifiers = /* @
|
|
|
41043
41044
|
const pathSegments = [];
|
|
41044
41045
|
for (const segmentExpression of segmentExpressions) {
|
|
41045
41046
|
const unwrappedSegment = unwrapTypescriptExpression(segmentExpression);
|
|
41046
|
-
if (!
|
|
41047
|
+
if (!typescriptBinding.isStringLiteralLike(unwrappedSegment)) return void 0;
|
|
41047
41048
|
pathSegments.push(unwrappedSegment.text);
|
|
41048
41049
|
}
|
|
41049
41050
|
return calledName === "join" ? join(baseDirectory, ...pathSegments) : resolve(baseDirectory, ...pathSegments);
|
|
41050
41051
|
};
|
|
41051
41052
|
const collectStaticPatterns = (expression) => {
|
|
41052
41053
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41053
|
-
if (
|
|
41054
|
-
if (!
|
|
41054
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) return [unwrappedExpression.text];
|
|
41055
|
+
if (!typescriptBinding.isArrayLiteralExpression(unwrappedExpression)) return [];
|
|
41055
41056
|
const patterns = [];
|
|
41056
41057
|
for (const element of unwrappedExpression.elements) {
|
|
41057
41058
|
const unwrappedElement = unwrapTypescriptExpression(element);
|
|
41058
|
-
if (!
|
|
41059
|
+
if (!typescriptBinding.isStringLiteralLike(unwrappedElement)) return [];
|
|
41059
41060
|
patterns.push(unwrappedElement.text);
|
|
41060
41061
|
}
|
|
41061
41062
|
return patterns;
|
|
@@ -41063,16 +41064,16 @@ const collectStaticPatterns = (expression) => {
|
|
|
41063
41064
|
const findCwdExpression = (expression) => {
|
|
41064
41065
|
if (!expression) return void 0;
|
|
41065
41066
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
41066
|
-
if (!
|
|
41067
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return void 0;
|
|
41067
41068
|
for (const property of unwrappedExpression.properties) {
|
|
41068
|
-
if (!
|
|
41069
|
-
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;
|
|
41070
41071
|
}
|
|
41071
41072
|
};
|
|
41072
41073
|
const collectGlobbyLocalNames = (sourceFile) => {
|
|
41073
41074
|
const localNames = /* @__PURE__ */ new Set();
|
|
41074
41075
|
for (const statement of sourceFile.statements) {
|
|
41075
|
-
if (!
|
|
41076
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "globby" || !statement.importClause?.namedBindings || !typescriptBinding.isNamedImports(statement.importClause.namedBindings)) continue;
|
|
41076
41077
|
for (const element of statement.importClause.namedBindings.elements) {
|
|
41077
41078
|
const importedName = element.propertyName?.text ?? element.name.text;
|
|
41078
41079
|
if (importedName === "globby" || importedName === "globbySync") localNames.add(element.name.text);
|
|
@@ -41083,8 +41084,8 @@ const collectGlobbyLocalNames = (sourceFile) => {
|
|
|
41083
41084
|
const collectVariableDeclarations = (sourceFile) => {
|
|
41084
41085
|
const declarations = /* @__PURE__ */ new Map();
|
|
41085
41086
|
const visitNode = (node) => {
|
|
41086
|
-
if (
|
|
41087
|
-
|
|
41087
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer) declarations.set(node.name.text, node.initializer);
|
|
41088
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
41088
41089
|
};
|
|
41089
41090
|
visitNode(sourceFile);
|
|
41090
41091
|
return declarations;
|
|
@@ -41098,7 +41099,7 @@ const extractGlobbyEntriesFromFile = (entryFilePath, projectRoot) => {
|
|
|
41098
41099
|
return [];
|
|
41099
41100
|
}
|
|
41100
41101
|
if (!sourceText.includes("globby")) return [];
|
|
41101
|
-
const sourceFile =
|
|
41102
|
+
const sourceFile = typescriptBinding.createSourceFile(entryFilePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TSX);
|
|
41102
41103
|
const globbyLocalNames = collectGlobbyLocalNames(sourceFile);
|
|
41103
41104
|
if (globbyLocalNames.size === 0) return [];
|
|
41104
41105
|
const context = {
|
|
@@ -41109,7 +41110,7 @@ const extractGlobbyEntriesFromFile = (entryFilePath, projectRoot) => {
|
|
|
41109
41110
|
};
|
|
41110
41111
|
const entries = /* @__PURE__ */ new Set();
|
|
41111
41112
|
const visitNode = (node) => {
|
|
41112
|
-
if (
|
|
41113
|
+
if (typescriptBinding.isCallExpression(node) && typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.expression)) && globbyLocalNames.has(unwrapTypescriptExpression(node.expression).getText()) && node.arguments[0]) {
|
|
41113
41114
|
const patterns = collectStaticPatterns(node.arguments[0]);
|
|
41114
41115
|
const cwdExpression = findCwdExpression(node.arguments[1]);
|
|
41115
41116
|
const workingDirectory = cwdExpression ? evaluateDirectoryExpression(cwdExpression, context) : dirname(entryFilePath);
|
|
@@ -41122,7 +41123,7 @@ const extractGlobbyEntriesFromFile = (entryFilePath, projectRoot) => {
|
|
|
41122
41123
|
})) if (isPathInsideDirectoryOrEqual(filePath, projectRoot) && DEFAULT_EXTENSIONS.some((extension) => filePath.endsWith(extension))) entries.add(filePath);
|
|
41123
41124
|
}
|
|
41124
41125
|
}
|
|
41125
|
-
|
|
41126
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
41126
41127
|
};
|
|
41127
41128
|
visitNode(sourceFile);
|
|
41128
41129
|
return [...entries];
|
|
@@ -41630,7 +41631,7 @@ const extractReactEmailTemplateEntries = (directory) => {
|
|
|
41630
41631
|
//#endregion
|
|
41631
41632
|
//#region ../core/src/project-analysis/utils/parse-typescript-config.ts
|
|
41632
41633
|
const parseTypeScriptConfig = (configPath, source) => {
|
|
41633
|
-
const parsedConfig =
|
|
41634
|
+
const parsedConfig = typescriptBinding.parseConfigFileTextToJson(configPath, source);
|
|
41634
41635
|
return parsedConfig.error ? void 0 : parsedConfig.config;
|
|
41635
41636
|
};
|
|
41636
41637
|
//#endregion
|
|
@@ -42688,9 +42689,9 @@ const collectWebpackConfigModules = (configPath) => {
|
|
|
42688
42689
|
if (visitedModulePaths.has(modulePath)) continue;
|
|
42689
42690
|
visitedModulePaths.add(modulePath);
|
|
42690
42691
|
configModulePaths.push(modulePath);
|
|
42691
|
-
const sourceFile =
|
|
42692
|
+
const sourceFile = typescriptBinding.createSourceFile(modulePath, readFileSync(modulePath, "utf-8"), typescriptBinding.ScriptTarget.Latest, true);
|
|
42692
42693
|
for (const statement of sourceFile.statements) {
|
|
42693
|
-
if (!
|
|
42694
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
42694
42695
|
const specifier = statement.moduleSpecifier.text;
|
|
42695
42696
|
if (!specifier.startsWith(".")) continue;
|
|
42696
42697
|
const importedModulePath = resolveEntryWithExtensions(resolve(dirname(modulePath), specifier));
|
|
@@ -42703,7 +42704,7 @@ const extractComputedWebpackEntries = (configPath, projectDirectory) => {
|
|
|
42703
42704
|
const entries = [];
|
|
42704
42705
|
for (const modulePath of collectWebpackConfigModules(configPath)) {
|
|
42705
42706
|
const sourceText = readFileSync(modulePath, "utf-8");
|
|
42706
|
-
const sourceFile =
|
|
42707
|
+
const sourceFile = typescriptBinding.createSourceFile(modulePath, sourceText, typescriptBinding.ScriptTarget.Latest, true);
|
|
42707
42708
|
const program = parseOxcProgram(modulePath, sourceText);
|
|
42708
42709
|
if (program) visitOxcAstWithBindings(program, (node, bindingNames) => {
|
|
42709
42710
|
if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") return false;
|
|
@@ -42715,30 +42716,30 @@ const extractComputedWebpackEntries = (configPath, projectDirectory) => {
|
|
|
42715
42716
|
});
|
|
42716
42717
|
const objectInitializers = /* @__PURE__ */ new Map();
|
|
42717
42718
|
for (const statement of sourceFile.statements) {
|
|
42718
|
-
if (!
|
|
42719
|
-
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);
|
|
42720
42721
|
}
|
|
42721
42722
|
const exportedObjects = sourceFile.statements.flatMap((statement) => {
|
|
42722
42723
|
let exportedExpression;
|
|
42723
|
-
if (
|
|
42724
|
-
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;
|
|
42725
42726
|
if (!exportedExpression) return [];
|
|
42726
|
-
if (
|
|
42727
|
-
if (
|
|
42727
|
+
if (typescriptBinding.isObjectLiteralExpression(exportedExpression)) return [exportedExpression];
|
|
42728
|
+
if (typescriptBinding.isIdentifier(exportedExpression)) {
|
|
42728
42729
|
const objectInitializer = objectInitializers.get(exportedExpression.text);
|
|
42729
42730
|
return objectInitializer ? [objectInitializer] : [];
|
|
42730
42731
|
}
|
|
42731
42732
|
return [];
|
|
42732
42733
|
});
|
|
42733
42734
|
for (const exportedObject of exportedObjects) {
|
|
42734
|
-
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"));
|
|
42735
42736
|
const pathSegments = [];
|
|
42736
|
-
if (entryProperty &&
|
|
42737
|
-
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);
|
|
42738
42739
|
}
|
|
42739
|
-
const entryCallExpression = entryProperty &&
|
|
42740
|
-
const entryPathObjectName = entryCallExpression &&
|
|
42741
|
-
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;
|
|
42742
42743
|
if (!entryProperty || !entryCallExpression || !entryPathObjectName || !entryPathMethodName || !/path/i.test(entryPathObjectName) || pathSegments.length !== entryCallExpression.arguments.length) continue;
|
|
42743
42744
|
const candidatePaths = entryPathObjectName === "path" && (entryPathMethodName === "join" || entryPathMethodName === "resolve") ? [resolve(dirname(modulePath), ...pathSegments)] : [resolve(projectDirectory, entryPathMethodName, ...pathSegments), resolve(projectDirectory, "src", entryPathMethodName, ...pathSegments)];
|
|
42744
42745
|
for (const candidatePath of candidatePaths) {
|
|
@@ -45432,18 +45433,18 @@ const collectDynamicBuildImports = (sourceFile, typeChecker) => {
|
|
|
45432
45433
|
const globNamespaceSymbols = /* @__PURE__ */ new Set();
|
|
45433
45434
|
const pathNamespaceSymbols = /* @__PURE__ */ new Set();
|
|
45434
45435
|
for (const statement of sourceFile.statements) {
|
|
45435
|
-
if (!
|
|
45436
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier) || !statement.importClause) continue;
|
|
45436
45437
|
const moduleName = statement.moduleSpecifier.text;
|
|
45437
45438
|
const namedBindings = statement.importClause.namedBindings;
|
|
45438
|
-
if (moduleName === "glob" && namedBindings &&
|
|
45439
|
+
if (moduleName === "glob" && namedBindings && typescriptBinding.isNamespaceImport(namedBindings)) {
|
|
45439
45440
|
const globNamespaceSymbol = typeChecker.getSymbolAtLocation(namedBindings.name);
|
|
45440
45441
|
if (globNamespaceSymbol) globNamespaceSymbols.add(globNamespaceSymbol);
|
|
45441
45442
|
}
|
|
45442
|
-
if (moduleName === "path" && namedBindings &&
|
|
45443
|
+
if (moduleName === "path" && namedBindings && typescriptBinding.isNamespaceImport(namedBindings)) {
|
|
45443
45444
|
const pathNamespaceSymbol = typeChecker.getSymbolAtLocation(namedBindings.name);
|
|
45444
45445
|
if (pathNamespaceSymbol) pathNamespaceSymbols.add(pathNamespaceSymbol);
|
|
45445
45446
|
}
|
|
45446
|
-
if (moduleName !== "tsup" || !namedBindings || !
|
|
45447
|
+
if (moduleName !== "tsup" || !namedBindings || !typescriptBinding.isNamedImports(namedBindings)) continue;
|
|
45447
45448
|
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") {
|
|
45448
45449
|
const buildSymbol = typeChecker.getSymbolAtLocation(importSpecifier.name);
|
|
45449
45450
|
if (buildSymbol) buildSymbols.add(buildSymbol);
|
|
@@ -45456,18 +45457,18 @@ const collectDynamicBuildImports = (sourceFile, typeChecker) => {
|
|
|
45456
45457
|
};
|
|
45457
45458
|
};
|
|
45458
45459
|
const extractGlobPattern = (expression, imports, scriptDirectory, typeChecker) => {
|
|
45459
|
-
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;
|
|
45460
45461
|
const patternExpression = expression.arguments[0];
|
|
45461
|
-
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;
|
|
45462
45463
|
const relativeGlobPattern = patternExpression.arguments[1].text;
|
|
45463
45464
|
if (!relativeGlobPattern.includes("*")) return void 0;
|
|
45464
45465
|
return toPosixPath(resolve(scriptDirectory, relativeGlobPattern));
|
|
45465
45466
|
};
|
|
45466
45467
|
const extractExcludedPathSubstring = (callback) => {
|
|
45467
|
-
if (callback.parameters.length !== 1 || !
|
|
45468
|
+
if (callback.parameters.length !== 1 || !typescriptBinding.isIdentifier(callback.parameters[0].name)) return;
|
|
45468
45469
|
const filePathName = callback.parameters[0].name.text;
|
|
45469
|
-
const returnedExpression =
|
|
45470
|
-
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;
|
|
45471
45472
|
return toPosixPath(returnedExpression.operand.arguments[0].text);
|
|
45472
45473
|
};
|
|
45473
45474
|
const extractFileCollection = (initializer, imports, scriptDirectory, typeChecker) => {
|
|
@@ -45476,7 +45477,7 @@ const extractFileCollection = (initializer, imports, scriptDirectory, typeChecke
|
|
|
45476
45477
|
excludedPathSubstrings: [],
|
|
45477
45478
|
globPattern: directGlobPattern
|
|
45478
45479
|
};
|
|
45479
|
-
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;
|
|
45480
45481
|
const globPattern = extractGlobPattern(initializer.expression.expression, imports, scriptDirectory, typeChecker);
|
|
45481
45482
|
const excludedPathSubstring = extractExcludedPathSubstring(initializer.arguments[0]);
|
|
45482
45483
|
if (!globPattern || excludedPathSubstring === void 0) return void 0;
|
|
@@ -45485,36 +45486,36 @@ const extractFileCollection = (initializer, imports, scriptDirectory, typeChecke
|
|
|
45485
45486
|
globPattern
|
|
45486
45487
|
};
|
|
45487
45488
|
};
|
|
45488
|
-
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);
|
|
45489
45490
|
const hasMatchingOutputEntryPath = (callback, filePathName, outputEntryName, imports, typeChecker) => {
|
|
45490
|
-
if (!
|
|
45491
|
+
if (!typescriptBinding.isBlock(callback.body)) return false;
|
|
45491
45492
|
const initializersByName = /* @__PURE__ */ new Map();
|
|
45492
45493
|
for (const statement of callback.body.statements) {
|
|
45493
|
-
if (!
|
|
45494
|
-
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);
|
|
45495
45496
|
}
|
|
45496
45497
|
const outputEntryInitializer = initializersByName.get(outputEntryName);
|
|
45497
45498
|
if (!outputEntryInitializer || !isPathNamespaceCall(outputEntryInitializer, "join", imports, typeChecker)) return false;
|
|
45498
45499
|
const outputFilenameExpression = outputEntryInitializer.arguments.at(-1);
|
|
45499
|
-
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;
|
|
45500
45501
|
const basenameSourceName = outputFilenameExpression.left.arguments[0].text;
|
|
45501
45502
|
if (basenameSourceName === filePathName) return true;
|
|
45502
45503
|
const basenameSourceInitializer = initializersByName.get(basenameSourceName);
|
|
45503
|
-
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);
|
|
45504
45505
|
};
|
|
45505
45506
|
const findBuildInvocation = (callback, filePathName, imports, typeChecker) => {
|
|
45506
45507
|
let buildInvocation;
|
|
45507
45508
|
const visitNode = (node) => {
|
|
45508
|
-
if (
|
|
45509
|
-
const hasMatchingEntry = node.arguments[0].properties.some((property) =>
|
|
45510
|
-
const outDirectoryProperty = node.arguments[0].properties.find((property) =>
|
|
45511
|
-
const hasCommonJsFormat = node.arguments[0].properties.some((property) =>
|
|
45512
|
-
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 = {
|
|
45513
45514
|
end: node.parent.end,
|
|
45514
45515
|
outputEntryName: outDirectoryProperty.initializer.arguments[0].text
|
|
45515
45516
|
};
|
|
45516
45517
|
}
|
|
45517
|
-
if (!buildInvocation)
|
|
45518
|
+
if (!buildInvocation) typescriptBinding.forEachChild(node, visitNode);
|
|
45518
45519
|
};
|
|
45519
45520
|
visitNode(callback.body);
|
|
45520
45521
|
return buildInvocation;
|
|
@@ -45523,19 +45524,19 @@ const collectImportedNamespaceExportNames = (callback, buildInvocation, typeChec
|
|
|
45523
45524
|
const importedNamespaceDeclarationEndBySymbol = /* @__PURE__ */ new Map();
|
|
45524
45525
|
const exportNames = /* @__PURE__ */ new Set();
|
|
45525
45526
|
const collectNamespaceNames = (node) => {
|
|
45526
|
-
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) {
|
|
45527
45528
|
const namespaceSymbol = typeChecker.getSymbolAtLocation(node.name);
|
|
45528
45529
|
if (namespaceSymbol) importedNamespaceDeclarationEndBySymbol.set(namespaceSymbol, node.end);
|
|
45529
45530
|
}
|
|
45530
|
-
|
|
45531
|
+
typescriptBinding.forEachChild(node, collectNamespaceNames);
|
|
45531
45532
|
};
|
|
45532
45533
|
collectNamespaceNames(callback.body);
|
|
45533
45534
|
const collectExportNames = (node) => {
|
|
45534
|
-
const namespaceSymbol = (
|
|
45535
|
+
const namespaceSymbol = (typescriptBinding.isPropertyAccessExpression(node) || typescriptBinding.isElementAccessExpression(node)) && typescriptBinding.isIdentifier(node.expression) ? typeChecker.getSymbolAtLocation(node.expression) : void 0;
|
|
45535
45536
|
const namespaceDeclarationEnd = namespaceSymbol ? importedNamespaceDeclarationEndBySymbol.get(namespaceSymbol) : void 0;
|
|
45536
|
-
if (
|
|
45537
|
-
else if (
|
|
45538
|
-
|
|
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);
|
|
45539
45540
|
};
|
|
45540
45541
|
collectExportNames(callback.body);
|
|
45541
45542
|
return exportNames;
|
|
@@ -45551,14 +45552,14 @@ const collectScriptConsumedExportKeys = (scriptPath, packageDirectory) => {
|
|
|
45551
45552
|
noLib: true,
|
|
45552
45553
|
noResolve: true
|
|
45553
45554
|
};
|
|
45554
|
-
const sourceFile =
|
|
45555
|
-
const compilerHost =
|
|
45555
|
+
const sourceFile = typescriptBinding.createSourceFile(scriptPath, source, typescriptBinding.ScriptTarget.Latest, true);
|
|
45556
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
45556
45557
|
const scriptIdentity = getFileIdentityKey(scriptPath);
|
|
45557
45558
|
const isScriptPath = (candidatePath) => getFileIdentityKey(candidatePath) === scriptIdentity;
|
|
45558
45559
|
compilerHost.fileExists = isScriptPath;
|
|
45559
45560
|
compilerHost.getSourceFile = (candidatePath) => isScriptPath(candidatePath) ? sourceFile : void 0;
|
|
45560
45561
|
compilerHost.readFile = (candidatePath) => isScriptPath(candidatePath) ? source : void 0;
|
|
45561
|
-
const program =
|
|
45562
|
+
const program = typescriptBinding.createProgram({
|
|
45562
45563
|
rootNames: [scriptPath],
|
|
45563
45564
|
options: compilerOptions,
|
|
45564
45565
|
host: compilerHost
|
|
@@ -45570,22 +45571,22 @@ const collectScriptConsumedExportKeys = (scriptPath, packageDirectory) => {
|
|
|
45570
45571
|
if (imports.buildSymbols.size === 0 || imports.globNamespaceSymbols.size === 0 || imports.pathNamespaceSymbols.size === 0) return /* @__PURE__ */ new Set();
|
|
45571
45572
|
const collectionsBySymbol = /* @__PURE__ */ new Map();
|
|
45572
45573
|
const visitCollection = (node) => {
|
|
45573
|
-
if (
|
|
45574
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer) {
|
|
45574
45575
|
const collection = extractFileCollection(node.initializer, imports, dirname(scriptPath), typeChecker);
|
|
45575
45576
|
const collectionSymbol = typeChecker.getSymbolAtLocation(node.name);
|
|
45576
45577
|
if (collection && collectionSymbol) collectionsBySymbol.set(collectionSymbol, collection);
|
|
45577
45578
|
}
|
|
45578
|
-
|
|
45579
|
+
typescriptBinding.forEachChild(node, visitCollection);
|
|
45579
45580
|
};
|
|
45580
45581
|
visitCollection(boundSourceFile);
|
|
45581
45582
|
const consumedExportKeys = /* @__PURE__ */ new Set();
|
|
45582
45583
|
const packageManifestIdentity = getFileIdentityKey(resolve(packageDirectory, "package.json"));
|
|
45583
45584
|
const visitMapCall = (node) => {
|
|
45584
|
-
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]))) {
|
|
45585
45586
|
const collectionSymbol = typeChecker.getSymbolAtLocation(node.expression.expression);
|
|
45586
45587
|
const collection = collectionSymbol ? collectionsBySymbol.get(collectionSymbol) : void 0;
|
|
45587
45588
|
const callback = node.arguments[0];
|
|
45588
|
-
if (collection && callback.parameters.length === 1 &&
|
|
45589
|
+
if (collection && callback.parameters.length === 1 && typescriptBinding.isIdentifier(callback.parameters[0].name)) {
|
|
45589
45590
|
const buildInvocation = findBuildInvocation(callback, callback.parameters[0].name.text, imports, typeChecker);
|
|
45590
45591
|
if (!buildInvocation) return;
|
|
45591
45592
|
const exportNames = collectImportedNamespaceExportNames(callback, buildInvocation, typeChecker);
|
|
@@ -45604,7 +45605,7 @@ const collectScriptConsumedExportKeys = (scriptPath, packageDirectory) => {
|
|
|
45604
45605
|
}
|
|
45605
45606
|
}
|
|
45606
45607
|
}
|
|
45607
|
-
|
|
45608
|
+
typescriptBinding.forEachChild(node, visitMapCall);
|
|
45608
45609
|
};
|
|
45609
45610
|
visitMapCall(boundSourceFile);
|
|
45610
45611
|
return consumedExportKeys;
|
|
@@ -45648,7 +45649,7 @@ const readPackageMetadata = (packageDirectory) => {
|
|
|
45648
45649
|
return;
|
|
45649
45650
|
}
|
|
45650
45651
|
};
|
|
45651
|
-
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");
|
|
45652
45653
|
const collectReferencedNextraThemeConfigPaths = (packageDirectory) => {
|
|
45653
45654
|
const referencedPaths = /* @__PURE__ */ new Set();
|
|
45654
45655
|
for (const configFilename of NEXT_CONFIG_FILENAMES) {
|
|
@@ -45660,16 +45661,16 @@ const collectReferencedNextraThemeConfigPaths = (packageDirectory) => {
|
|
|
45660
45661
|
} catch {
|
|
45661
45662
|
continue;
|
|
45662
45663
|
}
|
|
45663
|
-
const sourceFile =
|
|
45664
|
+
const sourceFile = typescriptBinding.createSourceFile(configPath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
45664
45665
|
if (!hasNextraImport(sourceFile)) continue;
|
|
45665
45666
|
const visitNode = (node) => {
|
|
45666
|
-
if (
|
|
45667
|
-
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(".")) {
|
|
45668
45669
|
const resolvedThemeConfigPath = resolveEntryWithExtensions(resolve(dirname(configPath), node.initializer.text));
|
|
45669
45670
|
if (resolvedThemeConfigPath) referencedPaths.add(toPosixPath(toFilesystemIdentityPath(resolve(resolvedThemeConfigPath))));
|
|
45670
45671
|
}
|
|
45671
45672
|
}
|
|
45672
|
-
|
|
45673
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
45673
45674
|
};
|
|
45674
45675
|
visitNode(sourceFile);
|
|
45675
45676
|
}
|
|
@@ -46122,7 +46123,7 @@ const collectStaticModulePackageNames = (sourceText) => {
|
|
|
46122
46123
|
//#region ../core/src/project-analysis/utils/matches-package-import-reference.ts
|
|
46123
46124
|
const collectPackageImportNames = (content) => {
|
|
46124
46125
|
const packageNames = collectStaticModulePackageNames(content);
|
|
46125
|
-
const sourceFile =
|
|
46126
|
+
const sourceFile = typescriptBinding.createSourceFile("package-reference.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
46126
46127
|
for (const typeReferenceDirective of sourceFile.typeReferenceDirectives) {
|
|
46127
46128
|
const packageName = extractPackageName(typeReferenceDirective.fileName);
|
|
46128
46129
|
if (packageName) packageNames.add(packageName);
|
|
@@ -46132,8 +46133,8 @@ const collectPackageImportNames = (content) => {
|
|
|
46132
46133
|
//#endregion
|
|
46133
46134
|
//#region ../core/src/project-analysis/utils/get-object-literal-element-name.ts
|
|
46134
46135
|
const getObjectLiteralElementName = (property) => {
|
|
46135
|
-
if (!
|
|
46136
|
-
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;
|
|
46137
46138
|
};
|
|
46138
46139
|
//#endregion
|
|
46139
46140
|
//#region ../core/src/project-analysis/utils/collect-config-plugin-map-package-names.ts
|
|
@@ -46141,23 +46142,23 @@ const collectConfigPluginMapPackageNames = (expression) => {
|
|
|
46141
46142
|
const packageNames = /* @__PURE__ */ new Set();
|
|
46142
46143
|
const collectExpression = (currentExpression) => {
|
|
46143
46144
|
const unwrappedExpression = unwrapTypescriptExpression(currentExpression);
|
|
46144
|
-
if (
|
|
46145
|
+
if (typescriptBinding.isConditionalExpression(unwrappedExpression)) {
|
|
46145
46146
|
collectExpression(unwrappedExpression.whenTrue);
|
|
46146
46147
|
collectExpression(unwrappedExpression.whenFalse);
|
|
46147
46148
|
return;
|
|
46148
46149
|
}
|
|
46149
|
-
if (
|
|
46150
|
-
|
|
46151
|
-
|
|
46152
|
-
|
|
46150
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && [
|
|
46151
|
+
typescriptBinding.SyntaxKind.AmpersandAmpersandToken,
|
|
46152
|
+
typescriptBinding.SyntaxKind.BarBarToken,
|
|
46153
|
+
typescriptBinding.SyntaxKind.QuestionQuestionToken
|
|
46153
46154
|
].includes(unwrappedExpression.operatorToken.kind)) {
|
|
46154
46155
|
collectExpression(unwrappedExpression.left);
|
|
46155
46156
|
collectExpression(unwrappedExpression.right);
|
|
46156
46157
|
return;
|
|
46157
46158
|
}
|
|
46158
|
-
if (!
|
|
46159
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
46159
46160
|
for (const property of unwrappedExpression.properties) {
|
|
46160
|
-
if (
|
|
46161
|
+
if (typescriptBinding.isSpreadAssignment(property)) {
|
|
46161
46162
|
collectExpression(property.expression);
|
|
46162
46163
|
continue;
|
|
46163
46164
|
}
|
|
@@ -46180,16 +46181,16 @@ const STRUCTURED_TEXT_EXTENSIONS = new Set([
|
|
|
46180
46181
|
const BABEL_CONFIG_FILE_PATTERN = /(?:^|[/\\])(?:babel\.config\.[^/\\]+|\.babelrc(?:\.[^/\\]+)?)$/;
|
|
46181
46182
|
const BABEL_MODULE_PREFIX = "module:";
|
|
46182
46183
|
const isBabelPluginOrPresetSpecifier = (node) => {
|
|
46183
|
-
const parent =
|
|
46184
|
+
const parent = typescriptBinding.isArrayLiteralExpression(node.parent) ? node.parent : void 0;
|
|
46184
46185
|
if (!parent) return false;
|
|
46185
|
-
const property = (parent.elements[0] === node &&
|
|
46186
|
+
const property = (parent.elements[0] === node && typescriptBinding.isArrayLiteralExpression(parent.parent) ? parent.parent : parent).parent;
|
|
46186
46187
|
let ancestor = property;
|
|
46187
|
-
while (ancestor && !
|
|
46188
|
+
while (ancestor && !typescriptBinding.isSourceFile(ancestor)) {
|
|
46188
46189
|
const parentNode = ancestor.parent;
|
|
46189
|
-
if (
|
|
46190
|
+
if (typescriptBinding.isObjectLiteralExpression(ancestor) && typescriptBinding.isArrayLiteralExpression(parentNode) && parentNode.elements[0] !== ancestor && typescriptBinding.isStringLiteralLike(parentNode.elements[0])) return false;
|
|
46190
46191
|
ancestor = parentNode;
|
|
46191
46192
|
}
|
|
46192
|
-
return
|
|
46193
|
+
return typescriptBinding.isPropertyAssignment(property) && (getObjectLiteralElementName(property) === "plugins" || getObjectLiteralElementName(property) === "presets");
|
|
46193
46194
|
};
|
|
46194
46195
|
const collectStructuredTextPackageReferences = (content) => {
|
|
46195
46196
|
const uncommentedContent = content.split("\n").map(stripCoffeeScriptComment).join("\n");
|
|
@@ -46202,16 +46203,16 @@ const collectStructuredTextPackageReferences = (content) => {
|
|
|
46202
46203
|
};
|
|
46203
46204
|
const collectPackageConfigReferences = (filePath, content) => {
|
|
46204
46205
|
if (STRUCTURED_TEXT_EXTENSIONS.has(extname(filePath))) return collectStructuredTextPackageReferences(content);
|
|
46205
|
-
const sourceFile =
|
|
46206
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
46206
46207
|
const packageNames = /* @__PURE__ */ new Set();
|
|
46207
46208
|
const visit = (node) => {
|
|
46208
|
-
if (
|
|
46209
|
-
if (
|
|
46209
|
+
if (typescriptBinding.isPropertyAssignment(node) && getObjectLiteralElementName(node) === "plugins") for (const packageName of collectConfigPluginMapPackageNames(node.initializer)) packageNames.add(packageName);
|
|
46210
|
+
if (typescriptBinding.isStringLiteralLike(node)) {
|
|
46210
46211
|
const packageName = extractPackageName(BABEL_CONFIG_FILE_PATTERN.test(filePath) && node.text.startsWith(BABEL_MODULE_PREFIX) && isBabelPluginOrPresetSpecifier(node) ? node.text.slice(7) : node.text);
|
|
46211
46212
|
if (packageName) packageNames.add(packageName);
|
|
46212
46213
|
return;
|
|
46213
46214
|
}
|
|
46214
|
-
|
|
46215
|
+
typescriptBinding.forEachChild(node, visit);
|
|
46215
46216
|
};
|
|
46216
46217
|
visit(sourceFile);
|
|
46217
46218
|
return packageNames;
|
|
@@ -48439,21 +48440,21 @@ const extractPreviewRegistryNamesFromMdx = (sourceText) => {
|
|
|
48439
48440
|
//#endregion
|
|
48440
48441
|
//#region ../core/src/project-analysis/utils/are-source-files-structurally-equivalent.ts
|
|
48441
48442
|
const buildSourceStructure = (filePath, sourceText) => {
|
|
48442
|
-
const sourceFile =
|
|
48443
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, filePath.endsWith("x") ? typescriptBinding.ScriptKind.TSX : typescriptBinding.ScriptKind.TS);
|
|
48443
48444
|
const structure = [];
|
|
48444
48445
|
const visitNode = (node, normalizeClassNames = false) => {
|
|
48445
48446
|
structure.push(String(node.kind));
|
|
48446
|
-
if (
|
|
48447
|
-
else if (
|
|
48448
|
-
else if (
|
|
48449
|
-
else if (
|
|
48450
|
-
else if (
|
|
48451
|
-
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)) {
|
|
48452
48453
|
visitNode(node.name);
|
|
48453
48454
|
visitNode(node.initializer, true);
|
|
48454
48455
|
return;
|
|
48455
48456
|
}
|
|
48456
|
-
|
|
48457
|
+
typescriptBinding.forEachChild(node, (childNode) => visitNode(childNode));
|
|
48457
48458
|
};
|
|
48458
48459
|
visitNode(sourceFile);
|
|
48459
48460
|
return structure.join("\0");
|
|
@@ -48467,8 +48468,8 @@ const buildScriptAnalysisKey = (scriptFile) => `${scriptFile.workingDirectory}\0
|
|
|
48467
48468
|
const resolveBuildReference = (reference, workingDirectory, projectRoot) => reference.startsWith("/") ? resolve(projectRoot, reference.replace(/^\/+/, "")) : resolve(workingDirectory, reference);
|
|
48468
48469
|
const getPropertyName$1 = (expression) => {
|
|
48469
48470
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48470
|
-
if (
|
|
48471
|
-
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;
|
|
48472
48473
|
};
|
|
48473
48474
|
const resolveImportedScriptPath = (specifier, scriptFile, projectRoot) => {
|
|
48474
48475
|
const importedPath = specifier.startsWith(".") ? resolve(dirname(scriptFile.filePath), specifier) : specifier.startsWith("@/registry/") ? resolve(scriptFile.workingDirectory, "src/registry", specifier.slice(11)) : void 0;
|
|
@@ -48485,20 +48486,20 @@ const collectWebpackEntrySpecifiers = (filePath) => {
|
|
|
48485
48486
|
} catch {
|
|
48486
48487
|
return [];
|
|
48487
48488
|
}
|
|
48488
|
-
const sourceFile =
|
|
48489
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
48489
48490
|
const specifiers = /* @__PURE__ */ new Set();
|
|
48490
48491
|
const collectStringLiterals = (node) => {
|
|
48491
|
-
if (
|
|
48492
|
+
if (typescriptBinding.isStringLiteralLike(node) && node.text.startsWith(".")) {
|
|
48492
48493
|
specifiers.add(node.text);
|
|
48493
48494
|
return;
|
|
48494
48495
|
}
|
|
48495
|
-
|
|
48496
|
+
typescriptBinding.forEachChild(node, collectStringLiterals);
|
|
48496
48497
|
};
|
|
48497
48498
|
const visitNode = (node) => {
|
|
48498
|
-
if (
|
|
48499
|
-
if (
|
|
48500
|
-
if (
|
|
48501
|
-
|
|
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);
|
|
48502
48503
|
};
|
|
48503
48504
|
visitNode(sourceFile);
|
|
48504
48505
|
return [...specifiers];
|
|
@@ -48665,23 +48666,23 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48665
48666
|
} catch {
|
|
48666
48667
|
continue;
|
|
48667
48668
|
}
|
|
48668
|
-
const sourceFile =
|
|
48669
|
+
const sourceFile = typescriptBinding.createSourceFile(scriptFile.filePath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
48669
48670
|
const localFunctions = /* @__PURE__ */ new Map();
|
|
48670
48671
|
const defaultExportExpressions = [];
|
|
48671
48672
|
for (const statement of sourceFile.statements) {
|
|
48672
|
-
if (
|
|
48673
|
+
if (typescriptBinding.isFunctionDeclaration(statement) && statement.body) {
|
|
48673
48674
|
if (statement.name) localFunctions.set(statement.name.text, statement.body);
|
|
48674
|
-
if (statement.modifiers?.some((modifier) => modifier.kind ===
|
|
48675
|
+
if (statement.modifiers?.some((modifier) => modifier.kind === typescriptBinding.SyntaxKind.DefaultKeyword)) localFunctions.set("default", statement.body);
|
|
48675
48676
|
}
|
|
48676
|
-
if (
|
|
48677
|
-
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);
|
|
48678
48679
|
}
|
|
48679
|
-
if (
|
|
48680
|
+
if (typescriptBinding.isExportAssignment(statement) && !statement.isExportEquals) defaultExportExpressions.push(statement.expression);
|
|
48680
48681
|
}
|
|
48681
48682
|
for (const defaultExportExpression of defaultExportExpressions) {
|
|
48682
48683
|
const unwrappedDefaultExport = unwrapTypescriptExpression(defaultExportExpression);
|
|
48683
|
-
if (
|
|
48684
|
-
else if (
|
|
48684
|
+
if (typescriptBinding.isArrowFunction(unwrappedDefaultExport) || typescriptBinding.isFunctionExpression(unwrappedDefaultExport)) localFunctions.set("default", unwrappedDefaultExport.body);
|
|
48685
|
+
else if (typescriptBinding.isIdentifier(unwrappedDefaultExport)) {
|
|
48685
48686
|
const defaultFunctionBody = localFunctions.get(unwrappedDefaultExport.text);
|
|
48686
48687
|
if (defaultFunctionBody) localFunctions.set("default", defaultFunctionBody);
|
|
48687
48688
|
}
|
|
@@ -48695,7 +48696,7 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48695
48696
|
});
|
|
48696
48697
|
}
|
|
48697
48698
|
for (const analysis of analyses.values()) for (const statement of analysis.sourceFile.statements) {
|
|
48698
|
-
if (!
|
|
48699
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteral(statement.moduleSpecifier)) continue;
|
|
48699
48700
|
const importClause = statement.importClause;
|
|
48700
48701
|
if (!importClause || importClause.isTypeOnly) continue;
|
|
48701
48702
|
const importedFilePath = resolveImportedScriptPath(statement.moduleSpecifier.text, analysis.scriptFile, projectRoot);
|
|
@@ -48709,7 +48710,7 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48709
48710
|
analysisKey: importedAnalysisKey,
|
|
48710
48711
|
exportName: "default"
|
|
48711
48712
|
});
|
|
48712
|
-
if (!importClause.namedBindings || !
|
|
48713
|
+
if (!importClause.namedBindings || !typescriptBinding.isNamedImports(importClause.namedBindings)) continue;
|
|
48713
48714
|
for (const element of importClause.namedBindings.elements) {
|
|
48714
48715
|
if (element.isTypeOnly) continue;
|
|
48715
48716
|
analysis.importedFunctions.set(element.name.text, {
|
|
@@ -48731,11 +48732,11 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48731
48732
|
const visitLiveNode = (analysis, rootNode) => {
|
|
48732
48733
|
const visitNode = (node) => {
|
|
48733
48734
|
analysis.liveNodes.add(node);
|
|
48734
|
-
if (node !== rootNode && (
|
|
48735
|
-
if (
|
|
48735
|
+
if (node !== rootNode && (typescriptBinding.isFunctionDeclaration(node) || typescriptBinding.isFunctionExpression(node) || typescriptBinding.isArrowFunction(node) || typescriptBinding.isMethodDeclaration(node))) return;
|
|
48736
|
+
if (typescriptBinding.isCallExpression(node)) {
|
|
48736
48737
|
const calledExpression = unwrapTypescriptExpression(node.expression);
|
|
48737
|
-
if (
|
|
48738
|
-
if (
|
|
48738
|
+
if (typescriptBinding.isFunctionExpression(calledExpression) || typescriptBinding.isArrowFunction(calledExpression)) queueFunctionBody(analysis, calledExpression.body);
|
|
48739
|
+
if (typescriptBinding.isIdentifier(calledExpression)) {
|
|
48739
48740
|
const localFunctionBody = analysis.localFunctions.get(calledExpression.text);
|
|
48740
48741
|
if (localFunctionBody) queueFunctionBody(analysis, localFunctionBody);
|
|
48741
48742
|
const importedFunction = analysis.importedFunctions.get(calledExpression.text);
|
|
@@ -48745,10 +48746,10 @@ const buildScriptAnalyses = (invokedScriptFiles, projectRoot) => {
|
|
|
48745
48746
|
}
|
|
48746
48747
|
for (const argument of node.arguments) {
|
|
48747
48748
|
const unwrappedArgument = unwrapTypescriptExpression(argument);
|
|
48748
|
-
if (
|
|
48749
|
+
if (typescriptBinding.isFunctionExpression(unwrappedArgument) || typescriptBinding.isArrowFunction(unwrappedArgument)) queueFunctionBody(analysis, unwrappedArgument.body);
|
|
48749
48750
|
}
|
|
48750
48751
|
}
|
|
48751
|
-
|
|
48752
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48752
48753
|
};
|
|
48753
48754
|
visitNode(rootNode);
|
|
48754
48755
|
};
|
|
@@ -48773,18 +48774,18 @@ const findVariableDeclaration = (sourceFile, identifierName, usePosition) => {
|
|
|
48773
48774
|
let closestDeclaration;
|
|
48774
48775
|
const visitNode = (node) => {
|
|
48775
48776
|
if (node.getStart(sourceFile) >= usePosition) return;
|
|
48776
|
-
if (
|
|
48777
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name)) {
|
|
48777
48778
|
if (node.name.text === identifierName) closestDeclaration = node;
|
|
48778
48779
|
}
|
|
48779
|
-
|
|
48780
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48780
48781
|
};
|
|
48781
48782
|
visitNode(sourceFile);
|
|
48782
48783
|
return closestDeclaration;
|
|
48783
48784
|
};
|
|
48784
48785
|
const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
48785
48786
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48786
|
-
if (
|
|
48787
|
-
if (
|
|
48787
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) return resolveBuildReference(unwrappedExpression.text, analysis.scriptFile.workingDirectory, projectRoot);
|
|
48788
|
+
if (typescriptBinding.isIdentifier(unwrappedExpression)) {
|
|
48788
48789
|
if (unwrappedExpression.text === "__dirname") return dirname(analysis.scriptFile.filePath);
|
|
48789
48790
|
if (seenIdentifiers.has(unwrappedExpression.text)) return void 0;
|
|
48790
48791
|
const declaration = findVariableDeclaration(analysis.sourceFile, unwrappedExpression.text, unwrappedExpression.getStart(analysis.sourceFile));
|
|
@@ -48793,8 +48794,8 @@ const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifie
|
|
|
48793
48794
|
nextSeenIdentifiers.add(unwrappedExpression.text);
|
|
48794
48795
|
return evaluatePathExpression(declaration.initializer, analysis, projectRoot, nextSeenIdentifiers);
|
|
48795
48796
|
}
|
|
48796
|
-
if (!
|
|
48797
|
-
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;
|
|
48798
48799
|
const pathMethodName = getPropertyName$1(unwrappedExpression.expression);
|
|
48799
48800
|
if (pathMethodName !== "join" && pathMethodName !== "resolve") return void 0;
|
|
48800
48801
|
const [baseExpression, ...segmentExpressions] = unwrappedExpression.arguments;
|
|
@@ -48804,7 +48805,7 @@ const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifie
|
|
|
48804
48805
|
const pathSegments = [];
|
|
48805
48806
|
for (const segmentExpression of segmentExpressions) {
|
|
48806
48807
|
const unwrappedSegment = unwrapTypescriptExpression(segmentExpression);
|
|
48807
|
-
if (!
|
|
48808
|
+
if (!typescriptBinding.isStringLiteralLike(unwrappedSegment)) return void 0;
|
|
48808
48809
|
pathSegments.push(unwrappedSegment.text);
|
|
48809
48810
|
}
|
|
48810
48811
|
const rootRelativeSegment = pathSegments.find((pathSegment) => pathSegment.startsWith("/"));
|
|
@@ -48818,48 +48819,48 @@ const evaluatePathExpression = (expression, analysis, projectRoot, seenIdentifie
|
|
|
48818
48819
|
const expressionContainsIdentifier = (expression, identifierName) => {
|
|
48819
48820
|
let containsIdentifier = false;
|
|
48820
48821
|
const visitNode = (node) => {
|
|
48821
|
-
if (
|
|
48822
|
+
if (typescriptBinding.isIdentifier(node) && node.text === identifierName) {
|
|
48822
48823
|
containsIdentifier = true;
|
|
48823
48824
|
return;
|
|
48824
48825
|
}
|
|
48825
|
-
if (!containsIdentifier)
|
|
48826
|
+
if (!containsIdentifier) typescriptBinding.forEachChild(node, visitNode);
|
|
48826
48827
|
};
|
|
48827
48828
|
visitNode(expression);
|
|
48828
48829
|
return containsIdentifier;
|
|
48829
48830
|
};
|
|
48830
48831
|
const isConditionallyExecuted = (node, boundary) => {
|
|
48831
|
-
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;
|
|
48832
48833
|
return false;
|
|
48833
48834
|
};
|
|
48834
48835
|
const analyzeDirectoryConsumer = (body, helperName, parameterName) => {
|
|
48835
48836
|
const directoryEntryCollectionNames = /* @__PURE__ */ new Set();
|
|
48836
48837
|
let unconditionallyConsumesEntries = false;
|
|
48837
48838
|
let recursivelyTraverses = false;
|
|
48838
|
-
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;
|
|
48839
48840
|
const visitNode = (node) => {
|
|
48840
|
-
if (
|
|
48841
|
-
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)) {
|
|
48842
48843
|
const collectionExpression = unwrapTypescriptExpression(node.expression);
|
|
48843
|
-
if (isDirectoryRead(collectionExpression) ||
|
|
48844
|
+
if (isDirectoryRead(collectionExpression) || typescriptBinding.isIdentifier(collectionExpression) && directoryEntryCollectionNames.has(collectionExpression.text)) {
|
|
48844
48845
|
const loopVariable = node.initializer.declarations[0]?.name;
|
|
48845
|
-
if (loopVariable &&
|
|
48846
|
+
if (loopVariable && typescriptBinding.isIdentifier(loopVariable)) {
|
|
48846
48847
|
const entryDependentNames = new Set([loopVariable.text]);
|
|
48847
48848
|
const visitLoop = (loopNode) => {
|
|
48848
|
-
if (
|
|
48849
|
-
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)) {
|
|
48850
48851
|
if (getPropertyName$1(loopNode.expression)?.match(/^(?:copyFile|readFile)(?:Sync)?$/) && loopNode.arguments.some((argument) => [...entryDependentNames].some((identifierName) => expressionContainsIdentifier(argument, identifierName)))) {
|
|
48851
48852
|
if (!isConditionallyExecuted(loopNode, node.statement)) unconditionallyConsumesEntries = true;
|
|
48852
48853
|
}
|
|
48853
48854
|
const calledExpression = unwrapTypescriptExpression(loopNode.expression);
|
|
48854
|
-
if (
|
|
48855
|
+
if (typescriptBinding.isIdentifier(calledExpression) && calledExpression.text === helperName && loopNode.arguments.some((argument) => [...entryDependentNames].some((identifierName) => expressionContainsIdentifier(argument, identifierName)))) recursivelyTraverses = true;
|
|
48855
48856
|
}
|
|
48856
|
-
|
|
48857
|
+
typescriptBinding.forEachChild(loopNode, visitLoop);
|
|
48857
48858
|
};
|
|
48858
48859
|
visitLoop(node.statement);
|
|
48859
48860
|
}
|
|
48860
48861
|
}
|
|
48861
48862
|
}
|
|
48862
|
-
|
|
48863
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48863
48864
|
};
|
|
48864
48865
|
visitNode(body);
|
|
48865
48866
|
return {
|
|
@@ -48869,11 +48870,11 @@ const analyzeDirectoryConsumer = (body, helperName, parameterName) => {
|
|
|
48869
48870
|
};
|
|
48870
48871
|
const collectRecursiveInputDirectories = (analysis, projectRoot, consumedFiles) => {
|
|
48871
48872
|
for (const node of analysis.liveNodes) {
|
|
48872
|
-
if (!
|
|
48873
|
+
if (!typescriptBinding.isCallExpression(node) || !typescriptBinding.isIdentifier(unwrapTypescriptExpression(node.expression))) continue;
|
|
48873
48874
|
const helperName = unwrapTypescriptExpression(node.expression).getText();
|
|
48874
48875
|
const helperBody = analysis.localFunctions.get(helperName);
|
|
48875
|
-
const helperDeclaration = [...analysis.sourceFile.statements].find((statement) =>
|
|
48876
|
-
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;
|
|
48877
48878
|
const directoryConsumption = analyzeDirectoryConsumer(helperBody, helperName, helperDeclaration.parameters[0].name.text);
|
|
48878
48879
|
if (!directoryConsumption.consumesAllEntries) continue;
|
|
48879
48880
|
const directoryArgument = node.arguments[0];
|
|
@@ -48884,9 +48885,9 @@ const collectRecursiveInputDirectories = (analysis, projectRoot, consumedFiles)
|
|
|
48884
48885
|
};
|
|
48885
48886
|
const evaluateCopySourceExpression = (expression, loopVariableName, loopVariableValue) => {
|
|
48886
48887
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48887
|
-
if (
|
|
48888
|
-
if (
|
|
48889
|
-
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)) {
|
|
48890
48891
|
let resolvedTemplate = unwrappedExpression.head.text;
|
|
48891
48892
|
for (const templateSpan of unwrappedExpression.templateSpans) {
|
|
48892
48893
|
const resolvedExpression = evaluateCopySourceExpression(templateSpan.expression, loopVariableName, loopVariableValue);
|
|
@@ -48895,7 +48896,7 @@ const evaluateCopySourceExpression = (expression, loopVariableName, loopVariable
|
|
|
48895
48896
|
}
|
|
48896
48897
|
return resolvedTemplate;
|
|
48897
48898
|
}
|
|
48898
|
-
if (
|
|
48899
|
+
if (typescriptBinding.isBinaryExpression(unwrappedExpression) && unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.PlusToken) {
|
|
48899
48900
|
const leftValue = evaluateCopySourceExpression(unwrappedExpression.left, loopVariableName, loopVariableValue);
|
|
48900
48901
|
const rightValue = evaluateCopySourceExpression(unwrappedExpression.right, loopVariableName, loopVariableValue);
|
|
48901
48902
|
return leftValue === void 0 || rightValue === void 0 ? void 0 : `${leftValue}${rightValue}`;
|
|
@@ -48903,25 +48904,25 @@ const evaluateCopySourceExpression = (expression, loopVariableName, loopVariable
|
|
|
48903
48904
|
};
|
|
48904
48905
|
const collectCopiedSourceFiles = (analysis, projectRoot, consumedFiles) => {
|
|
48905
48906
|
for (const node of analysis.liveNodes) {
|
|
48906
|
-
if (!
|
|
48907
|
-
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;
|
|
48908
48909
|
const loopVariableName = node.initializer.declarations[0].name.text;
|
|
48909
48910
|
const arrayIdentifier = unwrapTypescriptExpression(node.expression);
|
|
48910
|
-
if (!
|
|
48911
|
+
if (!typescriptBinding.isIdentifier(arrayIdentifier)) continue;
|
|
48911
48912
|
const arrayDeclaration = findVariableDeclaration(analysis.sourceFile, arrayIdentifier.text, node.getStart(analysis.sourceFile));
|
|
48912
|
-
if (!arrayDeclaration?.initializer || !
|
|
48913
|
+
if (!arrayDeclaration?.initializer || !typescriptBinding.isArrayLiteralExpression(arrayDeclaration.initializer)) continue;
|
|
48913
48914
|
const values = arrayDeclaration.initializer.elements.flatMap((element) => {
|
|
48914
48915
|
const unwrappedElement = unwrapTypescriptExpression(element);
|
|
48915
|
-
return
|
|
48916
|
+
return typescriptBinding.isStringLiteralLike(unwrappedElement) ? [unwrappedElement.text] : [];
|
|
48916
48917
|
});
|
|
48917
48918
|
const visitLoopBody = (loopNode) => {
|
|
48918
|
-
if (
|
|
48919
|
+
if (typescriptBinding.isCallExpression(loopNode) && getPropertyName$1(loopNode.expression)?.match(/^copyFile(?:Sync)?$/) && loopNode.arguments[0]) for (const value of values) {
|
|
48919
48920
|
const sourceReference = evaluateCopySourceExpression(loopNode.arguments[0], loopVariableName, value);
|
|
48920
48921
|
if (!sourceReference) continue;
|
|
48921
48922
|
const sourcePath = resolveBuildReference(sourceReference, analysis.scriptFile.workingDirectory, projectRoot);
|
|
48922
48923
|
if (isPathInsideDirectoryOrEqual(sourcePath, projectRoot) && existsSync(sourcePath) && statSync(sourcePath).isFile() && SOURCE_FILE_EXTENSION_PATTERN.test(sourcePath)) consumedFiles.add(sourcePath);
|
|
48923
48924
|
}
|
|
48924
|
-
|
|
48925
|
+
typescriptBinding.forEachChild(loopNode, visitLoopBody);
|
|
48925
48926
|
};
|
|
48926
48927
|
visitLoopBody(node.statement);
|
|
48927
48928
|
}
|
|
@@ -48930,56 +48931,56 @@ const expressionContainsString = (expression, value) => {
|
|
|
48930
48931
|
let containsString = false;
|
|
48931
48932
|
const visitNode = (node) => {
|
|
48932
48933
|
if (containsString) return;
|
|
48933
|
-
if (
|
|
48934
|
+
if (typescriptBinding.isStringLiteralLike(node) && node.text === value) {
|
|
48934
48935
|
containsString = true;
|
|
48935
48936
|
return;
|
|
48936
48937
|
}
|
|
48937
|
-
|
|
48938
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
48938
48939
|
};
|
|
48939
48940
|
visitNode(expression);
|
|
48940
48941
|
return containsString;
|
|
48941
48942
|
};
|
|
48942
48943
|
const collectObjectPathReferences = (expression, fileReferences) => {
|
|
48943
48944
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
48944
|
-
if (
|
|
48945
|
+
if (typescriptBinding.isStringLiteralLike(unwrappedExpression)) {
|
|
48945
48946
|
fileReferences.add(unwrappedExpression.text);
|
|
48946
48947
|
return;
|
|
48947
48948
|
}
|
|
48948
|
-
if (
|
|
48949
|
+
if (typescriptBinding.isArrayLiteralExpression(unwrappedExpression)) {
|
|
48949
48950
|
for (const element of unwrappedExpression.elements) collectObjectPathReferences(element, fileReferences);
|
|
48950
48951
|
return;
|
|
48951
48952
|
}
|
|
48952
|
-
if (!
|
|
48953
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return;
|
|
48953
48954
|
for (const property of unwrappedExpression.properties) {
|
|
48954
|
-
if (!
|
|
48955
|
-
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);
|
|
48956
48957
|
}
|
|
48957
48958
|
};
|
|
48958
48959
|
const findStyleRegistryFanoutSources = (analysis, analyses) => {
|
|
48959
48960
|
for (const node of analysis.liveNodes) {
|
|
48960
|
-
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;
|
|
48961
48962
|
const styleVariableName = node.initializer.declarations[0].name.text;
|
|
48962
48963
|
const styleCollectionExpression = unwrapTypescriptExpression(node.expression);
|
|
48963
|
-
if (!
|
|
48964
|
+
if (!typescriptBinding.isIdentifier(styleCollectionExpression)) continue;
|
|
48964
48965
|
const stylesImport = analysis.importedFunctions.get(styleCollectionExpression.text);
|
|
48965
48966
|
const stylesAnalysis = stylesImport ? analyses.get(stylesImport.analysisKey) : void 0;
|
|
48966
48967
|
if (!stylesAnalysis) continue;
|
|
48967
48968
|
let registryAnalysis;
|
|
48968
48969
|
const visitStyleLoop = (loopNode) => {
|
|
48969
|
-
if (registryAnalysis || !
|
|
48970
|
-
if (!registryAnalysis)
|
|
48970
|
+
if (registryAnalysis || !typescriptBinding.isForOfStatement(loopNode)) {
|
|
48971
|
+
if (!registryAnalysis) typescriptBinding.forEachChild(loopNode, visitStyleLoop);
|
|
48971
48972
|
return;
|
|
48972
48973
|
}
|
|
48973
|
-
if (!
|
|
48974
|
-
|
|
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);
|
|
48975
48976
|
return;
|
|
48976
48977
|
}
|
|
48977
48978
|
const registryItemName = loopNode.initializer.declarations[0].name.text;
|
|
48978
48979
|
const registryCollectionExpression = unwrapTypescriptExpression(loopNode.expression);
|
|
48979
|
-
if (!
|
|
48980
|
+
if (!typescriptBinding.isIdentifier(registryCollectionExpression)) return;
|
|
48980
48981
|
const normalizedLoopBodyText = loopNode.statement.getText(analysis.sourceFile).replace(/\s/g, "");
|
|
48981
48982
|
if (!normalizedLoopBodyText.includes(`src/registry/\${${styleVariableName}.name}/`) || !normalizedLoopBodyText.includes(`${registryItemName}.files`) || !/\$\{[A-Za-z_$][\w$]*\.path\}/.test(normalizedLoopBodyText)) {
|
|
48982
|
-
|
|
48983
|
+
typescriptBinding.forEachChild(loopNode, visitStyleLoop);
|
|
48983
48984
|
return;
|
|
48984
48985
|
}
|
|
48985
48986
|
const registryImport = analysis.importedFunctions.get(registryCollectionExpression.text);
|
|
@@ -48996,10 +48997,10 @@ const collectRegistryFileReferences = (registryAnalysis, analyses) => {
|
|
|
48996
48997
|
const registryFileReferences = /* @__PURE__ */ new Set();
|
|
48997
48998
|
const collectRegistryModule = (moduleAnalysis) => {
|
|
48998
48999
|
const visitNode = (node) => {
|
|
48999
|
-
if (
|
|
49000
|
-
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);
|
|
49001
49002
|
}
|
|
49002
|
-
|
|
49003
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49003
49004
|
};
|
|
49004
49005
|
visitNode(moduleAnalysis.sourceFile);
|
|
49005
49006
|
};
|
|
@@ -49013,11 +49014,11 @@ const collectRegistryFileReferences = (registryAnalysis, analyses) => {
|
|
|
49013
49014
|
const collectRegistryStyleNames = (stylesAnalysis) => {
|
|
49014
49015
|
const styleNames = /* @__PURE__ */ new Set();
|
|
49015
49016
|
const visitNode = (node) => {
|
|
49016
|
-
if (
|
|
49017
|
+
if (typescriptBinding.isPropertyAssignment(node) && (typescriptBinding.isIdentifier(node.name) || typescriptBinding.isStringLiteralLike(node.name)) && node.name.text === "name") {
|
|
49017
49018
|
const styleNameExpression = unwrapTypescriptExpression(node.initializer);
|
|
49018
|
-
if (
|
|
49019
|
+
if (typescriptBinding.isStringLiteralLike(styleNameExpression)) styleNames.add(styleNameExpression.text);
|
|
49019
49020
|
}
|
|
49020
|
-
|
|
49021
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49021
49022
|
};
|
|
49022
49023
|
visitNode(stylesAnalysis.sourceFile);
|
|
49023
49024
|
return styleNames;
|
|
@@ -49031,7 +49032,7 @@ const collectResolvedRegistryFiles = (registryFileReferences, styleNames, regist
|
|
|
49031
49032
|
const collectRegistryMetadataConsumedFiles = (analyses, projectRoot, consumedFiles) => {
|
|
49032
49033
|
for (const analysis of analyses.values()) {
|
|
49033
49034
|
if (!basename(analysis.scriptFile.filePath).includes("registry")) continue;
|
|
49034
|
-
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;
|
|
49035
49036
|
const registryImport = analysis.importedFunctions.get("registry");
|
|
49036
49037
|
const stylesImport = analysis.importedFunctions.get("styles");
|
|
49037
49038
|
const registryAnalysis = registryImport ? analyses.get(registryImport.analysisKey) : void 0;
|
|
@@ -49052,7 +49053,7 @@ const nodeContainsNode = (rootNode, targetNode) => {
|
|
|
49052
49053
|
containsNode = true;
|
|
49053
49054
|
return;
|
|
49054
49055
|
}
|
|
49055
|
-
if (!containsNode)
|
|
49056
|
+
if (!containsNode) typescriptBinding.forEachChild(node, visitNode);
|
|
49056
49057
|
};
|
|
49057
49058
|
visitNode(rootNode);
|
|
49058
49059
|
return containsNode;
|
|
@@ -49061,11 +49062,11 @@ const findAssignedVariableName = (analysis, targetNode) => {
|
|
|
49061
49062
|
let variableName;
|
|
49062
49063
|
let smallestInitializerWidth = Number.POSITIVE_INFINITY;
|
|
49063
49064
|
const visitNode = (node) => {
|
|
49064
|
-
if (
|
|
49065
|
+
if (typescriptBinding.isVariableDeclaration(node) && typescriptBinding.isIdentifier(node.name) && node.initializer && nodeContainsNode(node.initializer, targetNode) && node.initializer.end - node.initializer.pos < smallestInitializerWidth) {
|
|
49065
49066
|
variableName = node.name.text;
|
|
49066
49067
|
smallestInitializerWidth = node.initializer.end - node.initializer.pos;
|
|
49067
49068
|
}
|
|
49068
|
-
|
|
49069
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49069
49070
|
};
|
|
49070
49071
|
visitNode(analysis.sourceFile);
|
|
49071
49072
|
return variableName;
|
|
@@ -49073,29 +49074,29 @@ const findAssignedVariableName = (analysis, targetNode) => {
|
|
|
49073
49074
|
const recursivelyReadsManifestWildcards = (analysis, readCall) => {
|
|
49074
49075
|
const registryVariableName = findAssignedVariableName(analysis, readCall);
|
|
49075
49076
|
if (!registryVariableName) return false;
|
|
49076
|
-
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");
|
|
49077
49078
|
const sourceBaseDeclaration = findVariableDeclaration(analysis.sourceFile, "sourceBase", analysis.sourceFile.end);
|
|
49078
49079
|
if (hasDirectRecursiveRead && sourceBaseDeclaration?.initializer && sourceBaseDeclaration.initializer.getText(analysis.sourceFile).includes(registryVariableName) && sourceBaseDeclaration.initializer.getText(analysis.sourceFile).includes("split")) return true;
|
|
49079
49080
|
const collectionNames = new Set([registryVariableName]);
|
|
49080
|
-
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))) {
|
|
49081
49082
|
const propertyAccess = unwrapTypescriptExpression(node.initializer);
|
|
49082
|
-
if (
|
|
49083
|
+
if (typescriptBinding.isPropertyAccessExpression(propertyAccess) && typescriptBinding.isIdentifier(propertyAccess.expression) && collectionNames.has(propertyAccess.expression.text)) collectionNames.add(node.name.text);
|
|
49083
49084
|
}
|
|
49084
49085
|
for (const node of analysis.liveNodes) {
|
|
49085
|
-
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;
|
|
49086
49087
|
const collectionExpression = unwrapTypescriptExpression(node.expression);
|
|
49087
|
-
if (!
|
|
49088
|
+
if (!typescriptBinding.isIdentifier(collectionExpression) || !collectionNames.has(collectionExpression.text)) continue;
|
|
49088
49089
|
const componentName = node.initializer.declarations[0].name.text;
|
|
49089
49090
|
let hasRecursiveFileLoop = false;
|
|
49090
49091
|
const visitOuterLoop = (outerNode) => {
|
|
49091
|
-
if (
|
|
49092
|
+
if (typescriptBinding.isForOfStatement(outerNode) && typescriptBinding.isPropertyAccessExpression(unwrapTypescriptExpression(outerNode.expression))) {
|
|
49092
49093
|
const filesExpression = unwrapTypescriptExpression(outerNode.expression);
|
|
49093
|
-
if (
|
|
49094
|
+
if (typescriptBinding.isPropertyAccessExpression(filesExpression) && typescriptBinding.isIdentifier(filesExpression.expression) && filesExpression.expression.text === componentName && filesExpression.name.text === "files") {
|
|
49094
49095
|
const innerLoopText = outerNode.statement.getText(analysis.sourceFile);
|
|
49095
49096
|
if (/\.includes\(\s*["']\*["']\s*\)/.test(innerLoopText) && /\.split\(\s*["']\*["']\s*\)/.test(innerLoopText) && /\bwalk\s*\(\s*sourceBase\s*,\s*sourceBase\s*\)/.test(innerLoopText)) hasRecursiveFileLoop = true;
|
|
49096
49097
|
}
|
|
49097
49098
|
}
|
|
49098
|
-
if (!hasRecursiveFileLoop)
|
|
49099
|
+
if (!hasRecursiveFileLoop) typescriptBinding.forEachChild(outerNode, visitOuterLoop);
|
|
49099
49100
|
};
|
|
49100
49101
|
visitOuterLoop(node.statement);
|
|
49101
49102
|
if (hasRecursiveFileLoop) return true;
|
|
@@ -49104,7 +49105,7 @@ const recursivelyReadsManifestWildcards = (analysis, readCall) => {
|
|
|
49104
49105
|
};
|
|
49105
49106
|
const collectReferencedManifestFiles = (analysis, projectRoot, consumedFiles) => {
|
|
49106
49107
|
for (const node of analysis.liveNodes) {
|
|
49107
|
-
if (!
|
|
49108
|
+
if (!typescriptBinding.isCallExpression(node) || !getPropertyName$1(node.expression)?.match(/^readFile(?:Sync)?$/) || !node.arguments[0]) continue;
|
|
49108
49109
|
const manifestPath = evaluatePathExpression(node.arguments[0], analysis, projectRoot);
|
|
49109
49110
|
if (!manifestPath || basename(manifestPath) !== "registry.json") continue;
|
|
49110
49111
|
if (!isPathInsideDirectoryOrEqual(manifestPath, projectRoot)) continue;
|
|
@@ -49295,46 +49296,46 @@ const collectParcelHtmlEntryPaths = (rootDirectory) => {
|
|
|
49295
49296
|
} catch {
|
|
49296
49297
|
continue;
|
|
49297
49298
|
}
|
|
49298
|
-
const sourceFile =
|
|
49299
|
+
const sourceFile = typescriptBinding.createSourceFile(scriptPath, sourceText, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49299
49300
|
const parcelConstructorNames = /* @__PURE__ */ new Set();
|
|
49300
49301
|
const variableInitializers = /* @__PURE__ */ new Map();
|
|
49301
49302
|
for (const statement of sourceFile.statements) {
|
|
49302
|
-
if (
|
|
49303
|
+
if (typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteralLike(statement.moduleSpecifier) && statement.moduleSpecifier.text === "parcel-bundler") {
|
|
49303
49304
|
const importClause = statement.importClause;
|
|
49304
49305
|
if (importClause?.name) parcelConstructorNames.add(importClause.name.text);
|
|
49305
49306
|
}
|
|
49306
|
-
if (!
|
|
49307
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
49307
49308
|
for (const declaration of statement.declarationList.declarations) {
|
|
49308
|
-
if (!
|
|
49309
|
+
if (!typescriptBinding.isIdentifier(declaration.name) || !declaration.initializer) continue;
|
|
49309
49310
|
variableInitializers.set(declaration.name.text, declaration.initializer);
|
|
49310
|
-
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);
|
|
49311
49312
|
}
|
|
49312
49313
|
}
|
|
49313
49314
|
if (parcelConstructorNames.size === 0) continue;
|
|
49314
49315
|
const evaluateEntryExpression = (expression, visitedIdentifiers = /* @__PURE__ */ new Set()) => {
|
|
49315
|
-
if (
|
|
49316
|
-
if (
|
|
49317
|
-
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)) {
|
|
49318
49319
|
if (visitedIdentifiers.has(expression.text)) return [];
|
|
49319
49320
|
const initializer = variableInitializers.get(expression.text);
|
|
49320
49321
|
if (!initializer) return [];
|
|
49321
49322
|
return evaluateEntryExpression(initializer, new Set(visitedIdentifiers).add(expression.text));
|
|
49322
49323
|
}
|
|
49323
|
-
if (
|
|
49324
|
-
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] : []);
|
|
49325
49326
|
return [resolve(dirname(scriptPath), ...pathSegments)];
|
|
49326
49327
|
}
|
|
49327
49328
|
return [];
|
|
49328
49329
|
};
|
|
49329
49330
|
const visitNode = (node) => {
|
|
49330
|
-
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])) {
|
|
49331
49332
|
const entryPattern = isAbsolute(entrySpecifier) ? entrySpecifier : resolve(dirname(scriptPath), entrySpecifier);
|
|
49332
49333
|
for (const htmlEntryPath of import_out.default.sync(entryPattern.replaceAll("\\", "/"), {
|
|
49333
49334
|
absolute: true,
|
|
49334
49335
|
onlyFiles: true
|
|
49335
49336
|
})) if (/\.html?$/i.test(htmlEntryPath)) htmlEntryPaths.add(htmlEntryPath);
|
|
49336
49337
|
}
|
|
49337
|
-
|
|
49338
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49338
49339
|
};
|
|
49339
49340
|
visitNode(sourceFile);
|
|
49340
49341
|
}
|
|
@@ -49380,22 +49381,22 @@ const isConsumedStringLiteral = (node) => {
|
|
|
49380
49381
|
let currentNode = node;
|
|
49381
49382
|
while (currentNode.parent) {
|
|
49382
49383
|
const parentNode = currentNode.parent;
|
|
49383
|
-
if (
|
|
49384
|
-
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;
|
|
49385
49386
|
currentNode = parentNode;
|
|
49386
49387
|
}
|
|
49387
49388
|
return false;
|
|
49388
49389
|
};
|
|
49389
49390
|
const matchesExecutableNodeModulesPackageReference = (content, packageName) => {
|
|
49390
|
-
const sourceFile =
|
|
49391
|
+
const sourceFile = typescriptBinding.createSourceFile("node-modules-reference.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49391
49392
|
let isMatched = false;
|
|
49392
49393
|
const visit = (node) => {
|
|
49393
49394
|
if (isMatched) return;
|
|
49394
|
-
if (
|
|
49395
|
+
if (typescriptBinding.isStringLiteralLike(node) && isConsumedStringLiteral(node) && matchesNodeModulesPackageReference(node.text, packageName)) {
|
|
49395
49396
|
isMatched = true;
|
|
49396
49397
|
return;
|
|
49397
49398
|
}
|
|
49398
|
-
|
|
49399
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49399
49400
|
};
|
|
49400
49401
|
visit(sourceFile);
|
|
49401
49402
|
return isMatched;
|
|
@@ -49455,14 +49456,14 @@ const collectTwoslashPackageNames = (sourceText) => {
|
|
|
49455
49456
|
const packageNames = /* @__PURE__ */ new Set();
|
|
49456
49457
|
for (const source of sources) try {
|
|
49457
49458
|
for (const packageName of collectStaticModulePackageNames(source)) packageNames.add(packageName);
|
|
49458
|
-
const sourceFile =
|
|
49459
|
+
const sourceFile = typescriptBinding.createSourceFile("twoslash-source.js", source, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.JS);
|
|
49459
49460
|
const visitNode = (node) => {
|
|
49460
|
-
for (const tag of
|
|
49461
|
-
if (!
|
|
49461
|
+
for (const tag of typescriptBinding.getJSDocTags(node)) {
|
|
49462
|
+
if (!typescriptBinding.isJSDocImportTag(tag) || !typescriptBinding.isStringLiteralLike(tag.moduleSpecifier)) continue;
|
|
49462
49463
|
const packageName = extractPackageName(tag.moduleSpecifier.text);
|
|
49463
49464
|
if (packageName) packageNames.add(packageName);
|
|
49464
49465
|
}
|
|
49465
|
-
|
|
49466
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
49466
49467
|
};
|
|
49467
49468
|
visitNode(sourceFile);
|
|
49468
49469
|
} catch {
|
|
@@ -49516,27 +49517,27 @@ const KARMA_BROWSER_PACKAGES = new Map([
|
|
|
49516
49517
|
["Safari", ["karma-safari-launcher"]]
|
|
49517
49518
|
]);
|
|
49518
49519
|
const collectExpressionStrings = (expression, identifierStrings, strings) => {
|
|
49519
|
-
if (
|
|
49520
|
+
if (typescriptBinding.isStringLiteralLike(expression)) {
|
|
49520
49521
|
strings.add(expression.text);
|
|
49521
49522
|
return;
|
|
49522
49523
|
}
|
|
49523
|
-
if (
|
|
49524
|
+
if (typescriptBinding.isIdentifier(expression)) {
|
|
49524
49525
|
for (const value of identifierStrings.get(expression.text) ?? []) strings.add(value);
|
|
49525
49526
|
return;
|
|
49526
49527
|
}
|
|
49527
|
-
if (
|
|
49528
|
-
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);
|
|
49529
49530
|
else collectExpressionStrings(element, identifierStrings, strings);
|
|
49530
49531
|
return;
|
|
49531
49532
|
}
|
|
49532
|
-
if (
|
|
49533
|
+
if (typescriptBinding.isConditionalExpression(expression)) {
|
|
49533
49534
|
collectExpressionStrings(expression.whenTrue, identifierStrings, strings);
|
|
49534
49535
|
collectExpressionStrings(expression.whenFalse, identifierStrings, strings);
|
|
49535
49536
|
return;
|
|
49536
49537
|
}
|
|
49537
|
-
if (
|
|
49538
|
-
for (const property of expression.properties) if (
|
|
49539
|
-
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);
|
|
49540
49541
|
}
|
|
49541
49542
|
};
|
|
49542
49543
|
const collectIdentifierStrings = (sourceFile) => {
|
|
@@ -49547,21 +49548,21 @@ const collectIdentifierStrings = (sourceFile) => {
|
|
|
49547
49548
|
identifierStrings.set(identifierName, strings);
|
|
49548
49549
|
};
|
|
49549
49550
|
const visit = (node) => {
|
|
49550
|
-
if (
|
|
49551
|
-
if (
|
|
49552
|
-
|
|
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);
|
|
49553
49554
|
};
|
|
49554
49555
|
visit(sourceFile);
|
|
49555
49556
|
return identifierStrings;
|
|
49556
49557
|
};
|
|
49557
49558
|
const collectPropertyStrings = (property, identifierStrings) => {
|
|
49558
49559
|
const strings = /* @__PURE__ */ new Set();
|
|
49559
|
-
if (
|
|
49560
|
-
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);
|
|
49561
49562
|
return strings;
|
|
49562
49563
|
};
|
|
49563
49564
|
const extractKarmaConfigPackageReferences = (content, declaredPackageNames) => {
|
|
49564
|
-
const sourceFile =
|
|
49565
|
+
const sourceFile = typescriptBinding.createSourceFile("karma.config.ts", content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49565
49566
|
const identifierStrings = collectIdentifierStrings(sourceFile);
|
|
49566
49567
|
const referencedPackages = /* @__PURE__ */ new Set();
|
|
49567
49568
|
const propertyPackageMaps = new Map([
|
|
@@ -49571,12 +49572,12 @@ const extractKarmaConfigPackageReferences = (content, declaredPackageNames) => {
|
|
|
49571
49572
|
["browsers", KARMA_BROWSER_PACKAGES]
|
|
49572
49573
|
]);
|
|
49573
49574
|
const visit = (node) => {
|
|
49574
|
-
if (
|
|
49575
|
+
if (typescriptBinding.isObjectLiteralExpression(node)) for (const property of node.properties) {
|
|
49575
49576
|
const packageMap = propertyPackageMaps.get(getObjectLiteralElementName(property) ?? "");
|
|
49576
49577
|
if (!packageMap) continue;
|
|
49577
49578
|
for (const token of collectPropertyStrings(property, identifierStrings)) for (const packageName of packageMap.get(token) ?? []) if (declaredPackageNames.has(packageName)) referencedPackages.add(packageName);
|
|
49578
49579
|
}
|
|
49579
|
-
|
|
49580
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49580
49581
|
};
|
|
49581
49582
|
visit(sourceFile);
|
|
49582
49583
|
return [...referencedPackages];
|
|
@@ -49593,23 +49594,23 @@ const hasExpoReactServerFunctions = (rootDirectory) => {
|
|
|
49593
49594
|
//#endregion
|
|
49594
49595
|
//#region ../core/src/project-analysis/utils/has-antfu-eslint-react-config.ts
|
|
49595
49596
|
const hasReactEnabled = (expression) => {
|
|
49596
|
-
if (!
|
|
49597
|
-
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)));
|
|
49598
49599
|
};
|
|
49599
49600
|
const hasAntfuEslintReactConfig = (content) => {
|
|
49600
49601
|
const virtualFilePath = "eslint.config.ts";
|
|
49601
|
-
const sourceFile =
|
|
49602
|
+
const sourceFile = typescriptBinding.createSourceFile(virtualFilePath, content, typescriptBinding.ScriptTarget.Latest, true, typescriptBinding.ScriptKind.TS);
|
|
49602
49603
|
const compilerOptions = {
|
|
49603
49604
|
allowJs: true,
|
|
49604
49605
|
noLib: true,
|
|
49605
49606
|
noResolve: true,
|
|
49606
|
-
target:
|
|
49607
|
+
target: typescriptBinding.ScriptTarget.Latest
|
|
49607
49608
|
};
|
|
49608
|
-
const compilerHost =
|
|
49609
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
49609
49610
|
compilerHost.fileExists = (candidatePath) => candidatePath === virtualFilePath;
|
|
49610
49611
|
compilerHost.getSourceFile = (candidatePath) => candidatePath === virtualFilePath ? sourceFile : void 0;
|
|
49611
49612
|
compilerHost.readFile = (candidatePath) => candidatePath === virtualFilePath ? content : void 0;
|
|
49612
|
-
const program =
|
|
49613
|
+
const program = typescriptBinding.createProgram({
|
|
49613
49614
|
rootNames: [virtualFilePath],
|
|
49614
49615
|
options: compilerOptions,
|
|
49615
49616
|
host: compilerHost
|
|
@@ -49619,24 +49620,24 @@ const hasAntfuEslintReactConfig = (content) => {
|
|
|
49619
49620
|
const typeChecker = program.getTypeChecker();
|
|
49620
49621
|
const antfuFactorySymbols = /* @__PURE__ */ new Set();
|
|
49621
49622
|
for (const statement of boundSourceFile.statements) {
|
|
49622
|
-
if (!
|
|
49623
|
+
if (!typescriptBinding.isImportDeclaration(statement) || !typescriptBinding.isStringLiteralLike(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "@antfu/eslint-config" || !statement.importClause?.name) continue;
|
|
49623
49624
|
const factorySymbol = typeChecker.getSymbolAtLocation(statement.importClause.name);
|
|
49624
49625
|
if (factorySymbol) antfuFactorySymbols.add(factorySymbol);
|
|
49625
49626
|
}
|
|
49626
49627
|
let isReactEnabled = false;
|
|
49627
49628
|
const visit = (node) => {
|
|
49628
49629
|
if (isReactEnabled) return;
|
|
49629
|
-
if (
|
|
49630
|
-
if (
|
|
49630
|
+
if (typescriptBinding.isFunctionLike(node)) return;
|
|
49631
|
+
if (typescriptBinding.isCallExpression(node) && node.arguments[0] && hasReactEnabled(node.arguments[0])) {
|
|
49631
49632
|
const factorySymbol = typeChecker.getSymbolAtLocation(node.expression);
|
|
49632
49633
|
if (factorySymbol && antfuFactorySymbols.has(factorySymbol)) {
|
|
49633
49634
|
isReactEnabled = true;
|
|
49634
49635
|
return;
|
|
49635
49636
|
}
|
|
49636
49637
|
}
|
|
49637
|
-
|
|
49638
|
+
typescriptBinding.forEachChild(node, visit);
|
|
49638
49639
|
};
|
|
49639
|
-
for (const statement of boundSourceFile.statements) if (
|
|
49640
|
+
for (const statement of boundSourceFile.statements) if (typescriptBinding.isExportAssignment(statement)) visit(statement.expression);
|
|
49640
49641
|
return isReactEnabled;
|
|
49641
49642
|
};
|
|
49642
49643
|
//#endregion
|
|
@@ -51043,13 +51044,6 @@ const buildPlatformSiblingIndex = (graph, additionalPlatformSuffixesForFile = ()
|
|
|
51043
51044
|
return siblingIndex;
|
|
51044
51045
|
};
|
|
51045
51046
|
//#endregion
|
|
51046
|
-
//#region ../core/src/project-info/fs-utils.ts
|
|
51047
|
-
const isPlainObject = (value) => {
|
|
51048
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
51049
|
-
const prototype = Object.getPrototypeOf(value);
|
|
51050
|
-
return prototype === null || prototype === Object.prototype;
|
|
51051
|
-
};
|
|
51052
|
-
//#endregion
|
|
51053
51047
|
//#region ../core/src/utils/fail-open-read-json.ts
|
|
51054
51048
|
const failOpenReadJson = (filePath, fallback) => {
|
|
51055
51049
|
try {
|
|
@@ -51089,32 +51083,32 @@ const SUPPORTED_GLOBAL_VALUES = new Set([
|
|
|
51089
51083
|
"writeable"
|
|
51090
51084
|
]);
|
|
51091
51085
|
const getStaticProperty = (objectExpression, propertyName) => objectExpression.properties.find((property) => {
|
|
51092
|
-
if (
|
|
51093
|
-
const name =
|
|
51094
|
-
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;
|
|
51095
51089
|
}) ?? null;
|
|
51096
|
-
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)));
|
|
51097
51091
|
const getStaticPropertyAssignment = (objectExpression, propertyName) => {
|
|
51098
51092
|
const property = getStaticProperty(objectExpression, propertyName);
|
|
51099
|
-
return property &&
|
|
51093
|
+
return property && typescriptBinding.isPropertyAssignment(property) ? property : null;
|
|
51100
51094
|
};
|
|
51101
51095
|
const getRequireModuleSpecifier = (expression) => {
|
|
51102
51096
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
51103
|
-
if (
|
|
51104
|
-
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;
|
|
51105
51099
|
const moduleSpecifier = unwrappedExpression.arguments[0];
|
|
51106
|
-
return moduleSpecifier &&
|
|
51100
|
+
return moduleSpecifier && typescriptBinding.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
|
|
51107
51101
|
};
|
|
51108
51102
|
const getRequiredPropertyModuleSpecifier = (expression, propertyName) => {
|
|
51109
51103
|
const unwrappedExpression = unwrapTypescriptExpression(expression);
|
|
51110
|
-
return
|
|
51104
|
+
return typescriptBinding.isPropertyAccessExpression(unwrappedExpression) && unwrappedExpression.name.text === propertyName ? getRequireModuleSpecifier(unwrappedExpression.expression) : null;
|
|
51111
51105
|
};
|
|
51112
|
-
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");
|
|
51113
51107
|
const isTopLevelExpression = (node) => {
|
|
51114
51108
|
let ancestor = node.parent;
|
|
51115
|
-
while (ancestor && !
|
|
51116
|
-
if (
|
|
51117
|
-
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;
|
|
51118
51112
|
ancestor = ancestor.parent;
|
|
51119
51113
|
}
|
|
51120
51114
|
return false;
|
|
@@ -51122,21 +51116,21 @@ const isTopLevelExpression = (node) => {
|
|
|
51122
51116
|
const isInsideActiveConfigProperty = (node, propertyName, sourceFile, esbuildBindings, esbuildNamespaceBindings) => {
|
|
51123
51117
|
let ancestor = node.parent;
|
|
51124
51118
|
let didFindConfigProperty = false;
|
|
51125
|
-
while (ancestor && !
|
|
51126
|
-
if (!didFindConfigProperty && !
|
|
51127
|
-
if (
|
|
51128
|
-
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;
|
|
51129
51123
|
if (didFindConfigProperty || !isConfigProperty) return false;
|
|
51130
|
-
if (!
|
|
51124
|
+
if (!typescriptBinding.isObjectLiteralExpression(ancestor.parent) || ancestor.parent.properties.some(typescriptBinding.isSpreadAssignment)) return false;
|
|
51131
51125
|
didFindConfigProperty = true;
|
|
51132
51126
|
ancestor = ancestor.parent;
|
|
51133
51127
|
continue;
|
|
51134
51128
|
}
|
|
51135
51129
|
if (didFindConfigProperty) {
|
|
51136
|
-
if (
|
|
51130
|
+
if (typescriptBinding.isExportAssignment(ancestor)) return true;
|
|
51137
51131
|
if (isCommonJsExportAssignment(ancestor, sourceFile)) return isTopLevelExpression(ancestor);
|
|
51138
|
-
if (propertyName === "plugins" &&
|
|
51139
|
-
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;
|
|
51140
51134
|
}
|
|
51141
51135
|
ancestor = ancestor.parent;
|
|
51142
51136
|
}
|
|
@@ -51146,21 +51140,21 @@ const getGlobalsPathFromActiveAutoImportCall = (callExpression, packageDirectory
|
|
|
51146
51140
|
const optionsExpression = callExpression.arguments[0];
|
|
51147
51141
|
if (!optionsExpression) return null;
|
|
51148
51142
|
const unwrappedOptions = unwrapTypescriptExpression(optionsExpression);
|
|
51149
|
-
if (!
|
|
51150
|
-
if (unwrappedOptions.properties.some(
|
|
51143
|
+
if (!typescriptBinding.isObjectLiteralExpression(unwrappedOptions)) return null;
|
|
51144
|
+
if (unwrappedOptions.properties.some(typescriptBinding.isSpreadAssignment) || hasNonLiteralComputedProperty(unwrappedOptions)) return null;
|
|
51151
51145
|
if (getStaticProperty(unwrappedOptions, "include") || getStaticProperty(unwrappedOptions, "exclude")) return null;
|
|
51152
51146
|
const eslintrcProperty = getStaticPropertyAssignment(unwrappedOptions, "eslintrc");
|
|
51153
51147
|
if (!eslintrcProperty) return null;
|
|
51154
51148
|
const eslintrcExpression = unwrapTypescriptExpression(eslintrcProperty.initializer);
|
|
51155
|
-
if (!
|
|
51156
|
-
if (eslintrcExpression.properties.some(
|
|
51149
|
+
if (!typescriptBinding.isObjectLiteralExpression(eslintrcExpression)) return null;
|
|
51150
|
+
if (eslintrcExpression.properties.some(typescriptBinding.isSpreadAssignment) || hasNonLiteralComputedProperty(eslintrcExpression)) return null;
|
|
51157
51151
|
const enabledProperty = getStaticPropertyAssignment(eslintrcExpression, "enabled");
|
|
51158
|
-
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !==
|
|
51152
|
+
if (!enabledProperty || unwrapTypescriptExpression(enabledProperty.initializer).kind !== typescriptBinding.SyntaxKind.TrueKeyword) return null;
|
|
51159
51153
|
const filepathProperty = getStaticProperty(eslintrcExpression, "filepath");
|
|
51160
51154
|
if (!filepathProperty) return path$1.join(packageDirectory, DEFAULT_ESLINT_GLOBALS_PATH);
|
|
51161
|
-
if (!
|
|
51155
|
+
if (!typescriptBinding.isPropertyAssignment(filepathProperty)) return null;
|
|
51162
51156
|
const filepathExpression = unwrapTypescriptExpression(filepathProperty.initializer);
|
|
51163
|
-
return
|
|
51157
|
+
return typescriptBinding.isStringLiteralLike(filepathExpression) ? path$1.resolve(packageDirectory, filepathExpression.text) : null;
|
|
51164
51158
|
};
|
|
51165
51159
|
const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
51166
51160
|
let sourceText;
|
|
@@ -51172,12 +51166,16 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51172
51166
|
globalsPaths: []
|
|
51173
51167
|
};
|
|
51174
51168
|
}
|
|
51175
|
-
|
|
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);
|
|
51176
51174
|
const autoImportBindings = /* @__PURE__ */ new Map();
|
|
51177
51175
|
const esbuildBindings = /* @__PURE__ */ new Set();
|
|
51178
51176
|
const esbuildNamespaceBindings = /* @__PURE__ */ new Set();
|
|
51179
51177
|
for (const statement of sourceFile.statements) {
|
|
51180
|
-
if (
|
|
51178
|
+
if (typescriptBinding.isImportDeclaration(statement) && typescriptBinding.isStringLiteralLike(statement.moduleSpecifier)) {
|
|
51181
51179
|
const moduleSpecifier = statement.moduleSpecifier.text;
|
|
51182
51180
|
if (AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
51183
51181
|
const defaultBinding = statement.importClause?.name;
|
|
@@ -51187,23 +51185,23 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51187
51185
|
const defaultBinding = statement.importClause?.name;
|
|
51188
51186
|
if (defaultBinding) esbuildNamespaceBindings.add(defaultBinding.text);
|
|
51189
51187
|
const namedBindings = statement.importClause?.namedBindings;
|
|
51190
|
-
if (namedBindings &&
|
|
51188
|
+
if (namedBindings && typescriptBinding.isNamedImports(namedBindings)) {
|
|
51191
51189
|
for (const importSpecifier of namedBindings.elements) if ((importSpecifier.propertyName ?? importSpecifier.name).text === "build") esbuildBindings.add(importSpecifier.name.text);
|
|
51192
51190
|
}
|
|
51193
|
-
if (namedBindings &&
|
|
51191
|
+
if (namedBindings && typescriptBinding.isNamespaceImport(namedBindings)) esbuildNamespaceBindings.add(namedBindings.name.text);
|
|
51194
51192
|
}
|
|
51195
51193
|
}
|
|
51196
|
-
if (!
|
|
51194
|
+
if (!typescriptBinding.isVariableStatement(statement)) continue;
|
|
51197
51195
|
for (const declaration of statement.declarationList.declarations) {
|
|
51198
51196
|
if (!declaration.initializer) continue;
|
|
51199
|
-
const declarationName =
|
|
51197
|
+
const declarationName = typescriptBinding.isIdentifier(declaration.name) ? declaration.name.text : null;
|
|
51200
51198
|
const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
|
|
51201
51199
|
if (declarationName && moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) autoImportBindings.set(declarationName, moduleSpecifier);
|
|
51202
51200
|
if (moduleSpecifier === "esbuild") {
|
|
51203
51201
|
if (declarationName) esbuildNamespaceBindings.add(declarationName);
|
|
51204
|
-
if (
|
|
51202
|
+
if (typescriptBinding.isObjectBindingPattern(declaration.name)) for (const bindingElement of declaration.name.elements) {
|
|
51205
51203
|
const importedName = bindingElement.propertyName ?? bindingElement.name;
|
|
51206
|
-
if (
|
|
51204
|
+
if (typescriptBinding.isIdentifier(importedName) && importedName.text === "build" && typescriptBinding.isIdentifier(bindingElement.name)) esbuildBindings.add(bindingElement.name.text);
|
|
51207
51205
|
}
|
|
51208
51206
|
}
|
|
51209
51207
|
if (declarationName && getRequiredPropertyModuleSpecifier(declaration.initializer, "build") === "esbuild") esbuildBindings.add(declarationName);
|
|
@@ -51213,8 +51211,8 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51213
51211
|
let didFindActiveAutoImport = false;
|
|
51214
51212
|
let didFindUnsafeActiveAutoImport = false;
|
|
51215
51213
|
const visit = (node) => {
|
|
51216
|
-
if (
|
|
51217
|
-
const moduleSpecifier =
|
|
51214
|
+
if (typescriptBinding.isCallExpression(node)) {
|
|
51215
|
+
const moduleSpecifier = typescriptBinding.isIdentifier(node.expression) ? autoImportBindings.get(node.expression.text) : getRequireModuleSpecifier(node.expression);
|
|
51218
51216
|
if (moduleSpecifier && AUTO_IMPORT_ADAPTER_PATTERN.test(moduleSpecifier)) {
|
|
51219
51217
|
if (isInsideActiveConfigProperty(node, moduleSpecifier.endsWith("/astro") ? "integrations" : "plugins", sourceFile, esbuildBindings, esbuildNamespaceBindings)) {
|
|
51220
51218
|
didFindActiveAutoImport = true;
|
|
@@ -51224,7 +51222,7 @@ const collectGlobalsPathsFromConfig = (configPath, packageDirectory) => {
|
|
|
51224
51222
|
}
|
|
51225
51223
|
}
|
|
51226
51224
|
}
|
|
51227
|
-
|
|
51225
|
+
typescriptBinding.forEachChild(node, visit);
|
|
51228
51226
|
};
|
|
51229
51227
|
visit(sourceFile);
|
|
51230
51228
|
return {
|
|
@@ -51305,7 +51303,7 @@ const GENERATED_AUTO_IMPORT_MARKER = "Generated by unplugin-auto-import";
|
|
|
51305
51303
|
const AUTO_IMPORT_SOURCE_BINDING_PATTERN = /\bconst\s+([A-Za-z_$][\w$]*)\s*:\s*typeof\s+import\(["']([^"']+)["']\)\[["']([^"']+)["']\]/g;
|
|
51306
51304
|
const isNonReferenceIdentifier = (identifier) => {
|
|
51307
51305
|
const parent = identifier.parent;
|
|
51308
|
-
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;
|
|
51309
51307
|
};
|
|
51310
51308
|
const collectUnboundGlobalNames = (filePath, candidateGlobalNames) => {
|
|
51311
51309
|
let source;
|
|
@@ -51314,19 +51312,19 @@ const collectUnboundGlobalNames = (filePath, candidateGlobalNames) => {
|
|
|
51314
51312
|
} catch {
|
|
51315
51313
|
return /* @__PURE__ */ new Set();
|
|
51316
51314
|
}
|
|
51317
|
-
const sourceFile =
|
|
51315
|
+
const sourceFile = typescriptBinding.createSourceFile(filePath, source, typescriptBinding.ScriptTarget.Latest, true);
|
|
51318
51316
|
const compilerOptions = {
|
|
51319
51317
|
allowJs: true,
|
|
51320
|
-
jsx:
|
|
51318
|
+
jsx: typescriptBinding.JsxEmit.Preserve,
|
|
51321
51319
|
noLib: true,
|
|
51322
51320
|
noResolve: true,
|
|
51323
|
-
target:
|
|
51321
|
+
target: typescriptBinding.ScriptTarget.Latest
|
|
51324
51322
|
};
|
|
51325
|
-
const compilerHost =
|
|
51323
|
+
const compilerHost = typescriptBinding.createCompilerHost(compilerOptions);
|
|
51326
51324
|
compilerHost.fileExists = (candidatePath) => candidatePath === filePath;
|
|
51327
51325
|
compilerHost.getSourceFile = (candidatePath) => candidatePath === filePath ? sourceFile : void 0;
|
|
51328
51326
|
compilerHost.readFile = (candidatePath) => candidatePath === filePath ? source : void 0;
|
|
51329
|
-
const program =
|
|
51327
|
+
const program = typescriptBinding.createProgram({
|
|
51330
51328
|
rootNames: [filePath],
|
|
51331
51329
|
options: compilerOptions,
|
|
51332
51330
|
host: compilerHost
|
|
@@ -51336,10 +51334,10 @@ const collectUnboundGlobalNames = (filePath, candidateGlobalNames) => {
|
|
|
51336
51334
|
if (!boundSourceFile) return /* @__PURE__ */ new Set();
|
|
51337
51335
|
const unboundGlobalNames = /* @__PURE__ */ new Set();
|
|
51338
51336
|
const visitNode = (node) => {
|
|
51339
|
-
if (
|
|
51340
|
-
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);
|
|
51341
51339
|
}
|
|
51342
|
-
|
|
51340
|
+
typescriptBinding.forEachChild(node, visitNode);
|
|
51343
51341
|
};
|
|
51344
51342
|
visitNode(boundSourceFile);
|
|
51345
51343
|
return unboundGlobalNames;
|
|
@@ -51512,7 +51510,7 @@ const hasUnparseableCompilerConfig = (packageRootDirectory) => {
|
|
|
51512
51510
|
return configNames.some((configName) => {
|
|
51513
51511
|
const configPath = join(packageRootDirectory, configName);
|
|
51514
51512
|
try {
|
|
51515
|
-
return
|
|
51513
|
+
return typescriptBinding.parseConfigFileTextToJson(configPath, readFileSync(configPath, "utf8")).error !== void 0;
|
|
51516
51514
|
} catch {
|
|
51517
51515
|
return true;
|
|
51518
51516
|
}
|
|
@@ -51885,4 +51883,4 @@ startProjectAnalysisWorker();
|
|
|
51885
51883
|
export {};
|
|
51886
51884
|
|
|
51887
51885
|
//# sourceMappingURL=project-analysis-worker.js.map
|
|
51888
|
-
//# debugId=
|
|
51886
|
+
//# debugId=81139e97-fbde-59ee-9b65-cb0499a5510a
|