@suss/adapter-typescript 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +914 -945
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +952 -983
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
GENERIC_TERMINALS: () => GENERIC_TERMINALS,
|
|
35
35
|
NO_BARRIERS: () => NO_BARRIERS,
|
|
36
36
|
ResolutionStore: () => ResolutionStore,
|
|
37
|
+
TSCONFIG_NAMES: () => TSCONFIG_NAMES,
|
|
37
38
|
TypeScriptWhySession: () => TypeScriptWhySession,
|
|
38
39
|
accessContextFor: () => accessContextFor,
|
|
39
40
|
buildProjectHelperIndex: () => buildProjectHelperIndex,
|
|
@@ -41,7 +42,7 @@ __export(index_exports, {
|
|
|
41
42
|
collectAncestorBranches: () => collectAncestorBranches,
|
|
42
43
|
collectClientFieldAccesses: () => collectClientFieldAccesses,
|
|
43
44
|
computeAdapterPacksDigest: () => computeAdapterPacksDigest,
|
|
44
|
-
computeContentHash: () =>
|
|
45
|
+
computeContentHash: () => import_extractor11.computeContentHash,
|
|
45
46
|
createProjectWithoutTsconfig: () => createProjectWithoutTsconfig,
|
|
46
47
|
createTsDiscoveryContext: () => createTsDiscoveryContext,
|
|
47
48
|
createTsSubUnitContext: () => createTsSubUnitContext,
|
|
@@ -78,10 +79,10 @@ module.exports = __toCommonJS(index_exports);
|
|
|
78
79
|
|
|
79
80
|
// src/adapter.ts
|
|
80
81
|
var import_node_path11 = __toESM(require("path"), 1);
|
|
81
|
-
var
|
|
82
|
+
var import_ts_morph68 = require("ts-morph");
|
|
82
83
|
var import_behavioral_ir8 = require("@suss/behavioral-ir");
|
|
83
|
-
var
|
|
84
|
-
var
|
|
84
|
+
var import_datalog5 = require("@suss/datalog");
|
|
85
|
+
var import_extractor12 = require("@suss/extractor");
|
|
85
86
|
|
|
86
87
|
// src/assembly.ts
|
|
87
88
|
var import_ts_morph55 = require("ts-morph");
|
|
@@ -897,11 +898,11 @@ function tryExpandArrayIncludes(call) {
|
|
|
897
898
|
return {
|
|
898
899
|
type: "compound",
|
|
899
900
|
op: "or",
|
|
900
|
-
operands: literalValues.map((
|
|
901
|
+
operands: literalValues.map((lit5) => ({
|
|
901
902
|
type: "comparison",
|
|
902
903
|
left: subject,
|
|
903
904
|
op: "eq",
|
|
904
|
-
right:
|
|
905
|
+
right: lit5
|
|
905
906
|
}))
|
|
906
907
|
};
|
|
907
908
|
}
|
|
@@ -2028,7 +2029,8 @@ function readFileText(project, filePath) {
|
|
|
2028
2029
|
return null;
|
|
2029
2030
|
}
|
|
2030
2031
|
}
|
|
2031
|
-
function parseTsconfig(tsConfigFilePath) {
|
|
2032
|
+
function parseTsconfig(tsConfigFilePath, seen = /* @__PURE__ */ new Set()) {
|
|
2033
|
+
seen.add(tsConfigFilePath);
|
|
2032
2034
|
const configFile = import_ts_morph10.ts.readConfigFile(tsConfigFilePath, import_ts_morph10.ts.sys.readFile);
|
|
2033
2035
|
if (configFile.error !== void 0) {
|
|
2034
2036
|
return { fileNames: [], options: {} };
|
|
@@ -2041,7 +2043,18 @@ function parseTsconfig(tsConfigFilePath) {
|
|
|
2041
2043
|
void 0,
|
|
2042
2044
|
tsConfigFilePath
|
|
2043
2045
|
);
|
|
2044
|
-
|
|
2046
|
+
if (parsed.fileNames.length > 0) {
|
|
2047
|
+
return { fileNames: parsed.fileNames, options: parsed.options };
|
|
2048
|
+
}
|
|
2049
|
+
const referenced = (parsed.projectReferences ?? []).map((reference) => import_ts_morph10.ts.resolveProjectReferencePath(reference)).filter((referencePath) => !seen.has(referencePath));
|
|
2050
|
+
const fileNames = [
|
|
2051
|
+
...new Set(
|
|
2052
|
+
referenced.flatMap(
|
|
2053
|
+
(referencePath) => parseTsconfig(referencePath, seen).fileNames
|
|
2054
|
+
)
|
|
2055
|
+
)
|
|
2056
|
+
];
|
|
2057
|
+
return { fileNames, options: parsed.options };
|
|
2045
2058
|
}
|
|
2046
2059
|
async function selectCandidateFiles(allFiles, packs, options) {
|
|
2047
2060
|
const ungatedExists = packs.some(packIsUngated);
|
|
@@ -4399,178 +4412,11 @@ function declarationOf(value) {
|
|
|
4399
4412
|
}
|
|
4400
4413
|
|
|
4401
4414
|
// src/discovery/clientCall.ts
|
|
4402
|
-
var
|
|
4415
|
+
var import_ts_morph19 = require("ts-morph");
|
|
4403
4416
|
|
|
4404
4417
|
// src/discovery/importScan.ts
|
|
4405
|
-
var import_node_path3 = __toESM(require("path"), 1);
|
|
4406
|
-
|
|
4407
|
-
// src/diagnostics.ts
|
|
4408
4418
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
4409
|
-
var import_ts_morph17 = require("ts-morph");
|
|
4410
4419
|
var import_extractor3 = require("@suss/extractor");
|
|
4411
|
-
function commonDirectoryOf(files) {
|
|
4412
|
-
const absolute = files.filter((f) => import_node_path2.default.isAbsolute(f));
|
|
4413
|
-
const first = absolute[0];
|
|
4414
|
-
if (first === void 0) {
|
|
4415
|
-
return void 0;
|
|
4416
|
-
}
|
|
4417
|
-
let shared = import_node_path2.default.dirname(first).split(import_node_path2.default.sep);
|
|
4418
|
-
for (const file of absolute.slice(1)) {
|
|
4419
|
-
const parts = import_node_path2.default.dirname(file).split(import_node_path2.default.sep);
|
|
4420
|
-
let i = 0;
|
|
4421
|
-
while (i < shared.length && i < parts.length && shared[i] === parts[i]) {
|
|
4422
|
-
i += 1;
|
|
4423
|
-
}
|
|
4424
|
-
shared = shared.slice(0, i);
|
|
4425
|
-
}
|
|
4426
|
-
const joined2 = shared.join(import_node_path2.default.sep);
|
|
4427
|
-
return joined2.length > 1 ? joined2 : void 0;
|
|
4428
|
-
}
|
|
4429
|
-
var DEFAULT_RESOLUTION = {
|
|
4430
|
-
moduleResolution: import_ts_morph17.ts.ModuleResolutionKind.Bundler,
|
|
4431
|
-
target: import_ts_morph17.ts.ScriptTarget.ESNext,
|
|
4432
|
-
module: import_ts_morph17.ts.ModuleKind.ESNext
|
|
4433
|
-
};
|
|
4434
|
-
function resolutionContext(args) {
|
|
4435
|
-
if (args.tsConfigFilePath !== void 0) {
|
|
4436
|
-
const configFile = import_ts_morph17.ts.readConfigFile(
|
|
4437
|
-
args.tsConfigFilePath,
|
|
4438
|
-
import_ts_morph17.ts.sys.readFile
|
|
4439
|
-
);
|
|
4440
|
-
if (configFile.error !== void 0) {
|
|
4441
|
-
return null;
|
|
4442
|
-
}
|
|
4443
|
-
const dir = import_node_path2.default.dirname(args.tsConfigFilePath);
|
|
4444
|
-
const parsed = import_ts_morph17.ts.parseJsonConfigFileContent(
|
|
4445
|
-
configFile.config,
|
|
4446
|
-
import_ts_morph17.ts.sys,
|
|
4447
|
-
dir,
|
|
4448
|
-
/*existingOptions*/
|
|
4449
|
-
void 0,
|
|
4450
|
-
args.tsConfigFilePath
|
|
4451
|
-
);
|
|
4452
|
-
return {
|
|
4453
|
-
containingFile: import_node_path2.default.join(dir, "index.ts"),
|
|
4454
|
-
options: parsed.options
|
|
4455
|
-
};
|
|
4456
|
-
}
|
|
4457
|
-
if (args.projectRoot === void 0 || !import_node_path2.default.isAbsolute(args.projectRoot)) {
|
|
4458
|
-
return null;
|
|
4459
|
-
}
|
|
4460
|
-
return {
|
|
4461
|
-
containingFile: import_node_path2.default.join(args.projectRoot, "index.ts"),
|
|
4462
|
-
options: DEFAULT_RESOLUTION
|
|
4463
|
-
};
|
|
4464
|
-
}
|
|
4465
|
-
function unresolvedGatesFor(gates, args) {
|
|
4466
|
-
if (gates.length === 0) {
|
|
4467
|
-
return [];
|
|
4468
|
-
}
|
|
4469
|
-
const context = resolutionContext(args);
|
|
4470
|
-
if (context === null) {
|
|
4471
|
-
return [];
|
|
4472
|
-
}
|
|
4473
|
-
const unresolved = [];
|
|
4474
|
-
for (const gate of gates) {
|
|
4475
|
-
const resolved = import_ts_morph17.ts.resolveModuleName(
|
|
4476
|
-
gate,
|
|
4477
|
-
context.containingFile,
|
|
4478
|
-
context.options,
|
|
4479
|
-
import_ts_morph17.ts.sys
|
|
4480
|
-
);
|
|
4481
|
-
if (resolved.resolvedModule === void 0) {
|
|
4482
|
-
unresolved.push(gate);
|
|
4483
|
-
}
|
|
4484
|
-
}
|
|
4485
|
-
return unresolved;
|
|
4486
|
-
}
|
|
4487
|
-
function helpersWithNoCall(patterns, matched, projectRoot) {
|
|
4488
|
-
const missing = [];
|
|
4489
|
-
for (const pattern of patterns) {
|
|
4490
|
-
if (pattern.match.type !== "registrationTemplate" || matched.has(pattern.match.helperName)) {
|
|
4491
|
-
continue;
|
|
4492
|
-
}
|
|
4493
|
-
const from = pattern.match.importModule;
|
|
4494
|
-
missing.push(
|
|
4495
|
-
from === void 0 ? pattern.match.helperName : `${pattern.match.helperName} from ${shortModule(from, projectRoot)}`
|
|
4496
|
-
);
|
|
4497
|
-
}
|
|
4498
|
-
return missing;
|
|
4499
|
-
}
|
|
4500
|
-
function shortModule(module2, projectRoot) {
|
|
4501
|
-
if (projectRoot === void 0 || !import_node_path2.default.isAbsolute(module2)) {
|
|
4502
|
-
return module2;
|
|
4503
|
-
}
|
|
4504
|
-
return import_node_path2.default.relative(projectRoot, module2);
|
|
4505
|
-
}
|
|
4506
|
-
function buildExtractionReport(args) {
|
|
4507
|
-
const bySummary = (0, import_extractor3.summaryCountsByPack)(args.summaries);
|
|
4508
|
-
const packFunnels = args.packs.map((pack) => {
|
|
4509
|
-
const gates = packIsUngated(pack) ? [] : collectPackGates(pack);
|
|
4510
|
-
const tally = args.tallies.get(pack.name) ?? (0, import_extractor3.emptyTally)();
|
|
4511
|
-
const counted = bySummary.get(pack.name) ?? {
|
|
4512
|
-
bound: 0,
|
|
4513
|
-
providers: 0,
|
|
4514
|
-
withBehavior: 0
|
|
4515
|
-
};
|
|
4516
|
-
return {
|
|
4517
|
-
pack: pack.name,
|
|
4518
|
-
version: pack.version ?? null,
|
|
4519
|
-
discovers: pack.discovery.length > 0 || pack.discoverUnits !== void 0,
|
|
4520
|
-
recognizes: (pack.invocationRecognizers?.length ?? 0) > 0 || (pack.accessRecognizers?.length ?? 0) > 0,
|
|
4521
|
-
gates,
|
|
4522
|
-
unresolvedGates: unresolvedGatesFor(gates, {
|
|
4523
|
-
tsConfigFilePath: args.tsConfigFilePath,
|
|
4524
|
-
projectRoot: args.projectRoot
|
|
4525
|
-
}),
|
|
4526
|
-
candidateFiles: tally.candidateFiles,
|
|
4527
|
-
unitsDiscovered: tally.unitsDiscovered,
|
|
4528
|
-
unitsInGatedFiles: tally.unitsInGatedFiles,
|
|
4529
|
-
effectsRecognized: tally.effectsRecognized,
|
|
4530
|
-
unitsClaimed: tally.unitsClaimed,
|
|
4531
|
-
summariesProduced: tally.summariesProduced,
|
|
4532
|
-
failures: tally.failures,
|
|
4533
|
-
helpersUnmatched: helpersWithNoCall(
|
|
4534
|
-
[...pack.discovery, ...args.contributedPatterns?.(pack.name) ?? []],
|
|
4535
|
-
tally.helpersMatched,
|
|
4536
|
-
args.projectRoot
|
|
4537
|
-
),
|
|
4538
|
-
summariesBound: counted.bound,
|
|
4539
|
-
providerSummaries: counted.providers,
|
|
4540
|
-
summariesWithBehavior: counted.withBehavior,
|
|
4541
|
-
declarations: pack.declarations ?? null
|
|
4542
|
-
};
|
|
4543
|
-
});
|
|
4544
|
-
return {
|
|
4545
|
-
filesInProject: args.filesInProject,
|
|
4546
|
-
filesWalked: args.filesWalked,
|
|
4547
|
-
packs: packFunnels,
|
|
4548
|
-
summaries: args.summaries.length,
|
|
4549
|
-
filesWithUnreadableExports: [...args.filesWithUnreadableExports ?? []],
|
|
4550
|
-
reassignedNamesUnstated: args.reassignedNamesUnstated ?? 0,
|
|
4551
|
-
emptyStage: args.summaries.length === 0 ? firstEmptyStage(packFunnels, args) : null
|
|
4552
|
-
};
|
|
4553
|
-
}
|
|
4554
|
-
function firstEmptyStage(packs, args) {
|
|
4555
|
-
if (args.filesInProject === 0) {
|
|
4556
|
-
return "tsconfig";
|
|
4557
|
-
}
|
|
4558
|
-
const gateFailed = packs.some(
|
|
4559
|
-
(p) => p.unresolvedGates.length > 0 && p.candidateFiles > 0
|
|
4560
|
-
);
|
|
4561
|
-
if (gateFailed) {
|
|
4562
|
-
return "gateResolution";
|
|
4563
|
-
}
|
|
4564
|
-
if (args.filesWalked === 0 || packs.every((p) => p.candidateFiles === 0)) {
|
|
4565
|
-
return "candidateFiles";
|
|
4566
|
-
}
|
|
4567
|
-
if (packs.every((p) => p.unitsDiscovered === 0)) {
|
|
4568
|
-
return "discovery";
|
|
4569
|
-
}
|
|
4570
|
-
return "assembly";
|
|
4571
|
-
}
|
|
4572
|
-
|
|
4573
|
-
// src/discovery/importScan.ts
|
|
4574
4420
|
function specifierMatches(specifier, moduleName, subpaths) {
|
|
4575
4421
|
if (specifier === moduleName) {
|
|
4576
4422
|
return true;
|
|
@@ -4661,8 +4507,8 @@ function resolvedModuleFile(project, importModule, resolution) {
|
|
|
4661
4507
|
}
|
|
4662
4508
|
function projectFileNamedBy(project, specifier) {
|
|
4663
4509
|
const files = project.getSourceFiles().filter((sf) => !sf.isDeclarationFile());
|
|
4664
|
-
const root = commonDirectoryOf(files.map((sf) => sf.getFilePath())) ?? "/";
|
|
4665
|
-
const target = withoutSourceExtension(
|
|
4510
|
+
const root = (0, import_extractor3.commonDirectoryOf)(files.map((sf) => sf.getFilePath())) ?? "/";
|
|
4511
|
+
const target = withoutSourceExtension(import_node_path2.default.resolve(root, specifier));
|
|
4666
4512
|
for (const candidate of files) {
|
|
4667
4513
|
if (withoutSourceExtension(candidate.getFilePath()) === target) {
|
|
4668
4514
|
return candidate;
|
|
@@ -4710,14 +4556,14 @@ function importedReferenceSpellings(sourceFile, importModule, importName) {
|
|
|
4710
4556
|
}
|
|
4711
4557
|
|
|
4712
4558
|
// src/discovery/resolveValue.ts
|
|
4713
|
-
var
|
|
4559
|
+
var import_ts_morph18 = require("ts-morph");
|
|
4714
4560
|
var import_values3 = require("@suss/values");
|
|
4715
4561
|
|
|
4716
4562
|
// src/values/evaluator.ts
|
|
4717
4563
|
var import_values2 = require("@suss/values");
|
|
4718
4564
|
|
|
4719
4565
|
// src/values/lowering.ts
|
|
4720
|
-
var
|
|
4566
|
+
var import_ts_morph17 = require("ts-morph");
|
|
4721
4567
|
var ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set([
|
|
4722
4568
|
"=",
|
|
4723
4569
|
"+=",
|
|
@@ -4781,11 +4627,11 @@ function typescriptLowering(options) {
|
|
|
4781
4627
|
},
|
|
4782
4628
|
callable: (node) => {
|
|
4783
4629
|
const call = peelValue(node);
|
|
4784
|
-
if (resolution === void 0 || !
|
|
4630
|
+
if (resolution === void 0 || !import_ts_morph17.Node.isCallExpression(call) && !import_ts_morph17.Node.isNewExpression(call)) {
|
|
4785
4631
|
return null;
|
|
4786
4632
|
}
|
|
4787
4633
|
const target = resolution.resolveCallable(call.getExpression());
|
|
4788
|
-
return target !== null &&
|
|
4634
|
+
return target !== null && import_ts_morph17.Node.isFunctionLikeDeclaration(target) ? target : null;
|
|
4789
4635
|
},
|
|
4790
4636
|
mutatedInNestedFunction: (root, name) => {
|
|
4791
4637
|
let mutated = mutatedByRoot.get(root);
|
|
@@ -4801,34 +4647,34 @@ function typescriptLowering(options) {
|
|
|
4801
4647
|
};
|
|
4802
4648
|
}
|
|
4803
4649
|
function placeholderName(expr) {
|
|
4804
|
-
if (
|
|
4650
|
+
if (import_ts_morph17.Node.isIdentifier(expr)) {
|
|
4805
4651
|
return expr.getText();
|
|
4806
4652
|
}
|
|
4807
|
-
if (
|
|
4653
|
+
if (import_ts_morph17.Node.isPropertyAccessExpression(expr)) {
|
|
4808
4654
|
return expr.getName();
|
|
4809
4655
|
}
|
|
4810
4656
|
return "param";
|
|
4811
4657
|
}
|
|
4812
4658
|
function expressionOf(node, originOf) {
|
|
4813
|
-
if (
|
|
4659
|
+
if (import_ts_morph17.Node.isStringLiteral(node) || import_ts_morph17.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
4814
4660
|
return { kind: "literal", value: node.getLiteralValue() };
|
|
4815
4661
|
}
|
|
4816
|
-
if (
|
|
4662
|
+
if (import_ts_morph17.Node.isNumericLiteral(node)) {
|
|
4817
4663
|
return { kind: "literal", value: node.getLiteralValue() };
|
|
4818
4664
|
}
|
|
4819
|
-
if (
|
|
4665
|
+
if (import_ts_morph17.Node.isTrueLiteral(node)) {
|
|
4820
4666
|
return { kind: "literal", value: true };
|
|
4821
4667
|
}
|
|
4822
|
-
if (
|
|
4668
|
+
if (import_ts_morph17.Node.isFalseLiteral(node)) {
|
|
4823
4669
|
return { kind: "literal", value: false };
|
|
4824
4670
|
}
|
|
4825
|
-
if (
|
|
4671
|
+
if (import_ts_morph17.Node.isNullLiteral(node)) {
|
|
4826
4672
|
return { kind: "literal", value: null };
|
|
4827
4673
|
}
|
|
4828
|
-
if (
|
|
4674
|
+
if (import_ts_morph17.Node.isIdentifier(node)) {
|
|
4829
4675
|
return node.getText() === "undefined" ? { kind: "literal", value: void 0 } : { kind: "name", text: node.getText() };
|
|
4830
4676
|
}
|
|
4831
|
-
if (
|
|
4677
|
+
if (import_ts_morph17.Node.isTemplateExpression(node)) {
|
|
4832
4678
|
return {
|
|
4833
4679
|
kind: "template",
|
|
4834
4680
|
parts: [
|
|
@@ -4840,32 +4686,32 @@ function expressionOf(node, originOf) {
|
|
|
4840
4686
|
]
|
|
4841
4687
|
};
|
|
4842
4688
|
}
|
|
4843
|
-
if (
|
|
4689
|
+
if (import_ts_morph17.Node.isPropertyAccessExpression(node)) {
|
|
4844
4690
|
return {
|
|
4845
4691
|
kind: "member",
|
|
4846
4692
|
object: node.getExpression(),
|
|
4847
4693
|
name: node.getName()
|
|
4848
4694
|
};
|
|
4849
4695
|
}
|
|
4850
|
-
if (
|
|
4696
|
+
if (import_ts_morph17.Node.isElementAccessExpression(node)) {
|
|
4851
4697
|
const index = node.getArgumentExpression();
|
|
4852
4698
|
return index === void 0 ? { kind: "opaque" } : { kind: "element", object: node.getExpression(), index };
|
|
4853
4699
|
}
|
|
4854
|
-
if (
|
|
4700
|
+
if (import_ts_morph17.Node.isArrayLiteralExpression(node)) {
|
|
4855
4701
|
return { kind: "array", items: node.getElements().map(elementOf) };
|
|
4856
4702
|
}
|
|
4857
|
-
if (
|
|
4703
|
+
if (import_ts_morph17.Node.isObjectLiteralExpression(node)) {
|
|
4858
4704
|
return { kind: "record", fields: node.getProperties().flatMap(fieldOf) };
|
|
4859
4705
|
}
|
|
4860
|
-
if (
|
|
4706
|
+
if (import_ts_morph17.Node.isCallExpression(node) || import_ts_morph17.Node.isNewExpression(node)) {
|
|
4861
4707
|
return {
|
|
4862
4708
|
kind: "call",
|
|
4863
4709
|
callee: calleeOf(node.getExpression(), originOf),
|
|
4864
4710
|
args: node.getArguments().map(elementOf),
|
|
4865
|
-
constructs:
|
|
4711
|
+
constructs: import_ts_morph17.Node.isNewExpression(node)
|
|
4866
4712
|
};
|
|
4867
4713
|
}
|
|
4868
|
-
if (
|
|
4714
|
+
if (import_ts_morph17.Node.isBinaryExpression(node)) {
|
|
4869
4715
|
const operator = node.getOperatorToken().getText();
|
|
4870
4716
|
return ASSIGNMENT_OPERATORS.has(operator) ? { kind: "opaque" } : {
|
|
4871
4717
|
kind: "operator",
|
|
@@ -4873,11 +4719,11 @@ function expressionOf(node, originOf) {
|
|
|
4873
4719
|
operands: [node.getLeft(), node.getRight()]
|
|
4874
4720
|
};
|
|
4875
4721
|
}
|
|
4876
|
-
if (
|
|
4722
|
+
if (import_ts_morph17.Node.isPrefixUnaryExpression(node)) {
|
|
4877
4723
|
const operator = node.getOperatorToken();
|
|
4878
|
-
return operator ===
|
|
4724
|
+
return operator === import_ts_morph17.SyntaxKind.ExclamationToken ? { kind: "operator", operator: "!", operands: [node.getOperand()] } : { kind: "opaque" };
|
|
4879
4725
|
}
|
|
4880
|
-
if (
|
|
4726
|
+
if (import_ts_morph17.Node.isConditionalExpression(node)) {
|
|
4881
4727
|
return {
|
|
4882
4728
|
kind: "conditional",
|
|
4883
4729
|
condition: node.getCondition(),
|
|
@@ -4885,23 +4731,23 @@ function expressionOf(node, originOf) {
|
|
|
4885
4731
|
whenFalse: node.getWhenFalse()
|
|
4886
4732
|
};
|
|
4887
4733
|
}
|
|
4888
|
-
if (
|
|
4734
|
+
if (import_ts_morph17.Node.isArrowFunction(node) || import_ts_morph17.Node.isFunctionExpression(node)) {
|
|
4889
4735
|
return { kind: "function", node };
|
|
4890
4736
|
}
|
|
4891
4737
|
return { kind: "opaque" };
|
|
4892
4738
|
}
|
|
4893
4739
|
function elementOf(node) {
|
|
4894
|
-
return
|
|
4740
|
+
return import_ts_morph17.Node.isSpreadElement(node) ? { kind: "spread", node: node.getExpression() } : { kind: "value", node };
|
|
4895
4741
|
}
|
|
4896
4742
|
function fieldOf(property) {
|
|
4897
|
-
if (
|
|
4743
|
+
if (import_ts_morph17.Node.isSpreadAssignment(property)) {
|
|
4898
4744
|
return [{ kind: "spread", node: property.getExpression() }];
|
|
4899
4745
|
}
|
|
4900
|
-
if (
|
|
4746
|
+
if (import_ts_morph17.Node.isShorthandPropertyAssignment(property)) {
|
|
4901
4747
|
const nameNode2 = property.getNameNode();
|
|
4902
4748
|
return [{ kind: "field", name: nameNode2.getText(), value: nameNode2 }];
|
|
4903
4749
|
}
|
|
4904
|
-
if (!
|
|
4750
|
+
if (!import_ts_morph17.Node.isPropertyAssignment(property)) {
|
|
4905
4751
|
return [];
|
|
4906
4752
|
}
|
|
4907
4753
|
const value = property.getInitializer();
|
|
@@ -4909,22 +4755,22 @@ function fieldOf(property) {
|
|
|
4909
4755
|
return [];
|
|
4910
4756
|
}
|
|
4911
4757
|
const nameNode = property.getNameNode();
|
|
4912
|
-
if (
|
|
4758
|
+
if (import_ts_morph17.Node.isComputedPropertyName(nameNode)) {
|
|
4913
4759
|
return [{ kind: "computed", name: nameNode.getExpression(), value }];
|
|
4914
4760
|
}
|
|
4915
|
-
const name =
|
|
4761
|
+
const name = import_ts_morph17.Node.isStringLiteral(nameNode) || import_ts_morph17.Node.isNumericLiteral(nameNode) ? String(nameNode.getLiteralValue()) : nameNode.getText();
|
|
4916
4762
|
return [{ kind: "field", name, value }];
|
|
4917
4763
|
}
|
|
4918
4764
|
function calleeOf(expression, originOf) {
|
|
4919
4765
|
const callee = peelValue(expression);
|
|
4920
|
-
if (
|
|
4766
|
+
if (import_ts_morph17.Node.isPropertyAccessExpression(callee)) {
|
|
4921
4767
|
return {
|
|
4922
4768
|
receiver: callee.getExpression(),
|
|
4923
4769
|
name: callee.getName(),
|
|
4924
4770
|
origin: () => originOf(callee)
|
|
4925
4771
|
};
|
|
4926
4772
|
}
|
|
4927
|
-
if (
|
|
4773
|
+
if (import_ts_morph17.Node.isIdentifier(callee)) {
|
|
4928
4774
|
return {
|
|
4929
4775
|
receiver: null,
|
|
4930
4776
|
name: callee.getText(),
|
|
@@ -4936,17 +4782,17 @@ function calleeOf(expression, originOf) {
|
|
|
4936
4782
|
function memberChainOf(node) {
|
|
4937
4783
|
const names = [];
|
|
4938
4784
|
let current2 = peelValue(node);
|
|
4939
|
-
while (
|
|
4785
|
+
while (import_ts_morph17.Node.isPropertyAccessExpression(current2)) {
|
|
4940
4786
|
names.unshift(current2.getName());
|
|
4941
4787
|
current2 = peelValue(current2.getExpression());
|
|
4942
4788
|
}
|
|
4943
|
-
if (!
|
|
4789
|
+
if (!import_ts_morph17.Node.isIdentifier(current2)) {
|
|
4944
4790
|
return null;
|
|
4945
4791
|
}
|
|
4946
4792
|
return { root: current2, names: [current2.getText(), ...names] };
|
|
4947
4793
|
}
|
|
4948
4794
|
function statementOf2(node) {
|
|
4949
|
-
if (
|
|
4795
|
+
if (import_ts_morph17.Node.isVariableStatement(node)) {
|
|
4950
4796
|
return {
|
|
4951
4797
|
kind: "declare",
|
|
4952
4798
|
bindings: node.getDeclarationList().getDeclarations().flatMap(
|
|
@@ -4957,9 +4803,9 @@ function statementOf2(node) {
|
|
|
4957
4803
|
)
|
|
4958
4804
|
};
|
|
4959
4805
|
}
|
|
4960
|
-
if (
|
|
4806
|
+
if (import_ts_morph17.Node.isExpressionStatement(node)) {
|
|
4961
4807
|
const expression = peelValue(node.getExpression());
|
|
4962
|
-
if (
|
|
4808
|
+
if (import_ts_morph17.Node.isBinaryExpression(expression)) {
|
|
4963
4809
|
const operator = expression.getOperatorToken().getText();
|
|
4964
4810
|
if (ASSIGNMENT_OPERATORS.has(operator)) {
|
|
4965
4811
|
return {
|
|
@@ -4972,7 +4818,7 @@ function statementOf2(node) {
|
|
|
4972
4818
|
}
|
|
4973
4819
|
return { kind: "expression", value: node.getExpression() };
|
|
4974
4820
|
}
|
|
4975
|
-
if (
|
|
4821
|
+
if (import_ts_morph17.Node.isIfStatement(node)) {
|
|
4976
4822
|
const otherwise = node.getElseStatement();
|
|
4977
4823
|
return {
|
|
4978
4824
|
kind: "branch",
|
|
@@ -4983,23 +4829,23 @@ function statementOf2(node) {
|
|
|
4983
4829
|
]
|
|
4984
4830
|
};
|
|
4985
4831
|
}
|
|
4986
|
-
if (
|
|
4832
|
+
if (import_ts_morph17.Node.isSwitchStatement(node)) {
|
|
4987
4833
|
return {
|
|
4988
4834
|
kind: "branch",
|
|
4989
4835
|
condition: null,
|
|
4990
4836
|
arms: node.getClauses().map((clause) => clause.getStatements())
|
|
4991
4837
|
};
|
|
4992
4838
|
}
|
|
4993
|
-
if (
|
|
4839
|
+
if (import_ts_morph17.Node.isIterationStatement(node)) {
|
|
4994
4840
|
return { kind: "loop", body: armOf(node.getStatement()) };
|
|
4995
4841
|
}
|
|
4996
|
-
if (
|
|
4842
|
+
if (import_ts_morph17.Node.isReturnStatement(node)) {
|
|
4997
4843
|
return { kind: "return", value: node.getExpression() ?? null };
|
|
4998
4844
|
}
|
|
4999
|
-
if (
|
|
4845
|
+
if (import_ts_morph17.Node.isBlock(node)) {
|
|
5000
4846
|
return { kind: "block", body: node.getStatements() };
|
|
5001
4847
|
}
|
|
5002
|
-
if (
|
|
4848
|
+
if (import_ts_morph17.Node.isTryStatement(node)) {
|
|
5003
4849
|
return {
|
|
5004
4850
|
kind: "block",
|
|
5005
4851
|
body: [
|
|
@@ -5011,31 +4857,31 @@ function statementOf2(node) {
|
|
|
5011
4857
|
return { kind: "opaque" };
|
|
5012
4858
|
}
|
|
5013
4859
|
function armOf(statement) {
|
|
5014
|
-
return
|
|
4860
|
+
return import_ts_morph17.Node.isBlock(statement) ? statement.getStatements() : [statement];
|
|
5015
4861
|
}
|
|
5016
4862
|
function declarationsOf2(nameNode, value) {
|
|
5017
|
-
if (
|
|
4863
|
+
if (import_ts_morph17.Node.isIdentifier(nameNode)) {
|
|
5018
4864
|
return [{ name: nameNode.getText(), value }];
|
|
5019
4865
|
}
|
|
5020
|
-
if (
|
|
4866
|
+
if (import_ts_morph17.Node.isObjectBindingPattern(nameNode) || import_ts_morph17.Node.isArrayBindingPattern(nameNode)) {
|
|
5021
4867
|
return nameNode.getElements().flatMap(
|
|
5022
|
-
(element) =>
|
|
4868
|
+
(element) => import_ts_morph17.Node.isBindingElement(element) ? declarationsOf2(element.getNameNode(), null) : []
|
|
5023
4869
|
);
|
|
5024
4870
|
}
|
|
5025
4871
|
return [];
|
|
5026
4872
|
}
|
|
5027
4873
|
function isRoot(node) {
|
|
5028
|
-
return
|
|
4874
|
+
return import_ts_morph17.Node.isSourceFile(node) || import_ts_morph17.Node.isFunctionLikeDeclaration(node);
|
|
5029
4875
|
}
|
|
5030
4876
|
function isStandaloneBlock(node) {
|
|
5031
4877
|
const parent = node.getParent();
|
|
5032
|
-
return parent !== void 0 && (
|
|
4878
|
+
return parent !== void 0 && (import_ts_morph17.Node.isBlock(parent) || import_ts_morph17.Node.isSourceFile(parent) || import_ts_morph17.Node.isModuleBlock(parent) || import_ts_morph17.Node.isCaseClause(parent) || import_ts_morph17.Node.isDefaultClause(parent));
|
|
5033
4879
|
}
|
|
5034
4880
|
function isPathStatement(node) {
|
|
5035
|
-
if (
|
|
4881
|
+
if (import_ts_morph17.Node.isBlock(node)) {
|
|
5036
4882
|
return isStandaloneBlock(node);
|
|
5037
4883
|
}
|
|
5038
|
-
return
|
|
4884
|
+
return import_ts_morph17.Node.isStatement(node) && !import_ts_morph17.Node.isFunctionDeclaration(node);
|
|
5039
4885
|
}
|
|
5040
4886
|
function siteOf(node) {
|
|
5041
4887
|
const path15 = [];
|
|
@@ -5055,26 +4901,26 @@ function siteOf(node) {
|
|
|
5055
4901
|
}
|
|
5056
4902
|
}
|
|
5057
4903
|
function functionOf(node) {
|
|
5058
|
-
if (
|
|
4904
|
+
if (import_ts_morph17.Node.isSourceFile(node)) {
|
|
5059
4905
|
return { parameters: [], body: node.getStatements() };
|
|
5060
4906
|
}
|
|
5061
|
-
if (!
|
|
4907
|
+
if (!import_ts_morph17.Node.isFunctionLikeDeclaration(node)) {
|
|
5062
4908
|
return null;
|
|
5063
4909
|
}
|
|
5064
4910
|
const parameters = node.getParameters().flatMap((parameter) => {
|
|
5065
4911
|
const nameNode = parameter.getNameNode();
|
|
5066
|
-
return
|
|
4912
|
+
return import_ts_morph17.Node.isIdentifier(nameNode) ? [
|
|
5067
4913
|
{
|
|
5068
4914
|
name: nameNode.getText(),
|
|
5069
4915
|
default: parameter.getInitializer() ?? null
|
|
5070
4916
|
}
|
|
5071
4917
|
] : [];
|
|
5072
4918
|
});
|
|
5073
|
-
const body =
|
|
4919
|
+
const body = import_ts_morph17.Node.isBodied(node) ? node.getBody() : import_ts_morph17.Node.isBodyable(node) ? node.getBody() : void 0;
|
|
5074
4920
|
if (body === void 0) {
|
|
5075
4921
|
return { parameters, body: [] };
|
|
5076
4922
|
}
|
|
5077
|
-
return
|
|
4923
|
+
return import_ts_morph17.Node.isBlock(body) ? { parameters, body: body.getStatements() } : { parameters, body: { expression: body } };
|
|
5078
4924
|
}
|
|
5079
4925
|
function namesMutatedInNestedFunctions(root) {
|
|
5080
4926
|
const mutated = /* @__PURE__ */ new Set();
|
|
@@ -5087,21 +4933,21 @@ function namesMutatedInNestedFunctions(root) {
|
|
|
5087
4933
|
return mutated;
|
|
5088
4934
|
}
|
|
5089
4935
|
function writtenNameOf(node) {
|
|
5090
|
-
if (
|
|
4936
|
+
if (import_ts_morph17.Node.isBinaryExpression(node)) {
|
|
5091
4937
|
const target = peelValue(node.getLeft());
|
|
5092
|
-
return ASSIGNMENT_OPERATORS.has(node.getOperatorToken().getText()) &&
|
|
4938
|
+
return ASSIGNMENT_OPERATORS.has(node.getOperatorToken().getText()) && import_ts_morph17.Node.isIdentifier(target) ? target.getText() : null;
|
|
5093
4939
|
}
|
|
5094
|
-
if (
|
|
4940
|
+
if (import_ts_morph17.Node.isPostfixUnaryExpression(node) || import_ts_morph17.Node.isPrefixUnaryExpression(node)) {
|
|
5095
4941
|
const operand2 = peelValue(node.getOperand());
|
|
5096
|
-
return
|
|
4942
|
+
return import_ts_morph17.Node.isIdentifier(operand2) ? operand2.getText() : null;
|
|
5097
4943
|
}
|
|
5098
|
-
if (
|
|
4944
|
+
if (import_ts_morph17.Node.isCallExpression(node)) {
|
|
5099
4945
|
const callee = peelValue(node.getExpression());
|
|
5100
|
-
if (!
|
|
4946
|
+
if (!import_ts_morph17.Node.isPropertyAccessExpression(callee)) {
|
|
5101
4947
|
return null;
|
|
5102
4948
|
}
|
|
5103
4949
|
const receiver = peelValue(callee.getExpression());
|
|
5104
|
-
return MUTATING_METHODS.has(callee.getName()) &&
|
|
4950
|
+
return MUTATING_METHODS.has(callee.getName()) && import_ts_morph17.Node.isIdentifier(receiver) ? receiver.getText() : null;
|
|
5105
4951
|
}
|
|
5106
4952
|
return null;
|
|
5107
4953
|
}
|
|
@@ -5116,18 +4962,18 @@ function freeNamesOf(fn) {
|
|
|
5116
4962
|
const declared = /* @__PURE__ */ new Set();
|
|
5117
4963
|
const read2 = /* @__PURE__ */ new Set();
|
|
5118
4964
|
fn.forEachDescendant((descendant) => {
|
|
5119
|
-
if (!
|
|
4965
|
+
if (!import_ts_morph17.Node.isIdentifier(descendant)) {
|
|
5120
4966
|
return;
|
|
5121
4967
|
}
|
|
5122
4968
|
const parent = descendant.getParent();
|
|
5123
|
-
if (
|
|
4969
|
+
if (import_ts_morph17.Node.isPropertyAccessExpression(parent) && parent.getNameNode() === descendant) {
|
|
5124
4970
|
return;
|
|
5125
4971
|
}
|
|
5126
|
-
if (
|
|
4972
|
+
if (import_ts_morph17.Node.isVariableDeclaration(parent) || import_ts_morph17.Node.isParameterDeclaration(parent) || import_ts_morph17.Node.isBindingElement(parent) || import_ts_morph17.Node.isFunctionDeclaration(parent)) {
|
|
5127
4973
|
declared.add(descendant.getText());
|
|
5128
4974
|
return;
|
|
5129
4975
|
}
|
|
5130
|
-
if (
|
|
4976
|
+
if (import_ts_morph17.Node.isPropertyAssignment(parent) && parent.getNameNode() === descendant) {
|
|
5131
4977
|
return;
|
|
5132
4978
|
}
|
|
5133
4979
|
read2.add(descendant.getText());
|
|
@@ -5291,13 +5137,13 @@ function evaluatedValue(node, resolution) {
|
|
|
5291
5137
|
|
|
5292
5138
|
// src/discovery/resolveValue.ts
|
|
5293
5139
|
function couldNameAValue(value) {
|
|
5294
|
-
return
|
|
5140
|
+
return import_ts_morph18.Node.isIdentifier(value) || import_ts_morph18.Node.isPropertyAccessExpression(value) || import_ts_morph18.Node.isElementAccessExpression(value) || import_ts_morph18.Node.isCallExpression(value);
|
|
5295
5141
|
}
|
|
5296
5142
|
function propertyValueOf(property) {
|
|
5297
|
-
if (
|
|
5143
|
+
if (import_ts_morph18.Node.isPropertyAssignment(property)) {
|
|
5298
5144
|
return property.getInitializer() ?? null;
|
|
5299
5145
|
}
|
|
5300
|
-
if (
|
|
5146
|
+
if (import_ts_morph18.Node.isShorthandPropertyAssignment(property)) {
|
|
5301
5147
|
return property.getNameNode();
|
|
5302
5148
|
}
|
|
5303
5149
|
return null;
|
|
@@ -5315,20 +5161,20 @@ function functionValueOf(value, resolution) {
|
|
|
5315
5161
|
if (resolved !== null) {
|
|
5316
5162
|
return toFunctionRoot(resolved);
|
|
5317
5163
|
}
|
|
5318
|
-
if (!
|
|
5164
|
+
if (!import_ts_morph18.Node.isCallExpression(written)) {
|
|
5319
5165
|
return null;
|
|
5320
5166
|
}
|
|
5321
5167
|
const returned = resolution.resolveReturnedCallable(written);
|
|
5322
5168
|
return returned === null ? null : toFunctionRoot(returned);
|
|
5323
5169
|
}
|
|
5324
5170
|
function propertyNameOf(property) {
|
|
5325
|
-
if (
|
|
5171
|
+
if (import_ts_morph18.Node.isPropertyAssignment(property) || import_ts_morph18.Node.isShorthandPropertyAssignment(property) || import_ts_morph18.Node.isMethodDeclaration(property)) {
|
|
5326
5172
|
return property.getName();
|
|
5327
5173
|
}
|
|
5328
5174
|
return null;
|
|
5329
5175
|
}
|
|
5330
5176
|
function propertyFunctionOf(property, resolution) {
|
|
5331
|
-
if (
|
|
5177
|
+
if (import_ts_morph18.Node.isMethodDeclaration(property)) {
|
|
5332
5178
|
return property;
|
|
5333
5179
|
}
|
|
5334
5180
|
const held = propertyValueOf(property);
|
|
@@ -5338,7 +5184,7 @@ function objectLiteralOf(value, resolution) {
|
|
|
5338
5184
|
return literalValueOf(
|
|
5339
5185
|
value,
|
|
5340
5186
|
resolution,
|
|
5341
|
-
(node) =>
|
|
5187
|
+
(node) => import_ts_morph18.Node.isObjectLiteralExpression(node)
|
|
5342
5188
|
);
|
|
5343
5189
|
}
|
|
5344
5190
|
function propertiesOf(object, resolution) {
|
|
@@ -5350,7 +5196,7 @@ function propertiesReached(object, resolution, seen) {
|
|
|
5350
5196
|
}
|
|
5351
5197
|
seen.add(object);
|
|
5352
5198
|
return object.getProperties().flatMap((property) => {
|
|
5353
|
-
if (!
|
|
5199
|
+
if (!import_ts_morph18.Node.isSpreadAssignment(property)) {
|
|
5354
5200
|
return [property];
|
|
5355
5201
|
}
|
|
5356
5202
|
const spread = objectLiteralOf(property.getExpression(), resolution);
|
|
@@ -5359,17 +5205,17 @@ function propertiesReached(object, resolution, seen) {
|
|
|
5359
5205
|
}
|
|
5360
5206
|
function writtenNodeOf(value, resolution) {
|
|
5361
5207
|
const written = factKeyOf(value);
|
|
5362
|
-
if (
|
|
5208
|
+
if (import_ts_morph18.Node.isNewExpression(written)) {
|
|
5363
5209
|
return written;
|
|
5364
5210
|
}
|
|
5365
|
-
if (
|
|
5211
|
+
if (import_ts_morph18.Node.isCallExpression(written)) {
|
|
5366
5212
|
return writtenThroughCall(written, resolution);
|
|
5367
5213
|
}
|
|
5368
5214
|
if (resolution === void 0 || !couldNameAValue(written)) {
|
|
5369
5215
|
return null;
|
|
5370
5216
|
}
|
|
5371
5217
|
const resolved = resolution.resolveWrittenValue(written);
|
|
5372
|
-
return resolved !== null &&
|
|
5218
|
+
return resolved !== null && import_ts_morph18.Node.isCallExpression(resolved) ? writtenThroughCall(resolved, resolution) : resolved;
|
|
5373
5219
|
}
|
|
5374
5220
|
function writtenThroughCall(call, resolution) {
|
|
5375
5221
|
if (resolution !== void 0 && resolution.resolveCallable(call.getExpression()) !== null) {
|
|
@@ -5395,7 +5241,7 @@ function arrayLiteralOf(value, resolution) {
|
|
|
5395
5241
|
return literalValueOf(
|
|
5396
5242
|
value,
|
|
5397
5243
|
resolution,
|
|
5398
|
-
(node) =>
|
|
5244
|
+
(node) => import_ts_morph18.Node.isArrayLiteralExpression(node)
|
|
5399
5245
|
);
|
|
5400
5246
|
}
|
|
5401
5247
|
function literalValueOf(value, resolution, isWanted) {
|
|
@@ -5411,6 +5257,7 @@ function literalValueOf(value, resolution, isWanted) {
|
|
|
5411
5257
|
}
|
|
5412
5258
|
|
|
5413
5259
|
// src/discovery/clientCall.ts
|
|
5260
|
+
var GLOBAL_OBJECTS = /* @__PURE__ */ new Set(["globalThis", "window", "self", "global"]);
|
|
5414
5261
|
function discoverClientCalls(sourceFile, match, kind, resolution) {
|
|
5415
5262
|
const results = [];
|
|
5416
5263
|
const isGlobal = match.importModule === "global";
|
|
@@ -5418,26 +5265,32 @@ function discoverClientCalls(sourceFile, match, kind, resolution) {
|
|
|
5418
5265
|
if (!isGlobal) {
|
|
5419
5266
|
for (const varDecl of sourceFile.getVariableDeclarations()) {
|
|
5420
5267
|
const init = varDecl.getInitializer();
|
|
5421
|
-
if (init !== void 0 && (
|
|
5268
|
+
if (init !== void 0 && (import_ts_morph19.Node.isCallExpression(init) || import_ts_morph19.Node.isNewExpression(init)) && isCreationCall(init, match, resolution)) {
|
|
5422
5269
|
clientVarNames.add(varDecl.getName());
|
|
5423
5270
|
}
|
|
5424
5271
|
}
|
|
5425
5272
|
}
|
|
5426
5273
|
const methodFilter = match.methodFilter !== void 0 ? new Set(match.methodFilter) : null;
|
|
5427
5274
|
sourceFile.forEachDescendant((node) => {
|
|
5428
|
-
if (!
|
|
5275
|
+
if (!import_ts_morph19.Node.isCallExpression(node)) {
|
|
5429
5276
|
return;
|
|
5430
5277
|
}
|
|
5431
5278
|
const callee = node.getExpression();
|
|
5432
5279
|
let methodName = null;
|
|
5433
5280
|
let matched = false;
|
|
5434
|
-
if (isGlobal &&
|
|
5281
|
+
if (isGlobal && import_ts_morph19.Node.isIdentifier(callee)) {
|
|
5435
5282
|
if (callee.getText() === match.importName) {
|
|
5436
5283
|
matched = true;
|
|
5437
5284
|
}
|
|
5438
|
-
} else if (
|
|
5285
|
+
} else if (isGlobal && import_ts_morph19.Node.isPropertyAccessExpression(callee)) {
|
|
5286
|
+
if (callee.getName() === match.importName && GLOBAL_OBJECTS.has(callee.getExpression().getText())) {
|
|
5287
|
+
matched = true;
|
|
5288
|
+
}
|
|
5289
|
+
} else if (match.callable === true && isClientItself(callee, match, clientVarNames, resolution)) {
|
|
5290
|
+
matched = true;
|
|
5291
|
+
} else if (import_ts_morph19.Node.isPropertyAccessExpression(callee)) {
|
|
5439
5292
|
const subject = callee.getExpression();
|
|
5440
|
-
if (
|
|
5293
|
+
if (isClientItself(subject, match, clientVarNames, resolution)) {
|
|
5441
5294
|
methodName = callee.getName();
|
|
5442
5295
|
if (methodFilter === null || methodFilter.has(methodName)) {
|
|
5443
5296
|
matched = true;
|
|
@@ -5463,6 +5316,9 @@ function discoverClientCalls(sourceFile, match, kind, resolution) {
|
|
|
5463
5316
|
});
|
|
5464
5317
|
return results;
|
|
5465
5318
|
}
|
|
5319
|
+
function isClientItself(subject, match, clientVarNames, resolution) {
|
|
5320
|
+
return import_ts_morph19.Node.isIdentifier(subject) && (isClientImport(subject, match, resolution, true) || clientVarNames.has(subject.getText())) || resolvesToKnownInstance(subject, match, resolution);
|
|
5321
|
+
}
|
|
5466
5322
|
function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
5467
5323
|
const localName = resolveImportedLocalName(
|
|
5468
5324
|
sourceFile,
|
|
@@ -5471,16 +5327,16 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
|
5471
5327
|
);
|
|
5472
5328
|
const constructedHere = /* @__PURE__ */ new Set();
|
|
5473
5329
|
sourceFile.forEachDescendant((node) => {
|
|
5474
|
-
if (
|
|
5330
|
+
if (import_ts_morph19.Node.isVariableDeclaration(node)) {
|
|
5475
5331
|
const init = node.getInitializer();
|
|
5476
|
-
if (init !== void 0 && (
|
|
5332
|
+
if (init !== void 0 && (import_ts_morph19.Node.isCallExpression(init) || import_ts_morph19.Node.isNewExpression(init)) && isCreationCall(init, match, resolution) || localName !== null && typedAsClient(node.getTypeNode(), localName)) {
|
|
5477
5333
|
constructedHere.add(node.getName());
|
|
5478
5334
|
}
|
|
5479
5335
|
return;
|
|
5480
5336
|
}
|
|
5481
|
-
if (
|
|
5337
|
+
if (import_ts_morph19.Node.isParameterDeclaration(node) && localName !== null && typedAsClient(node.getTypeNode(), localName)) {
|
|
5482
5338
|
const written = node.getNameNode();
|
|
5483
|
-
if (
|
|
5339
|
+
if (import_ts_morph19.Node.isIdentifier(written)) {
|
|
5484
5340
|
constructedHere.add(written.getText());
|
|
5485
5341
|
}
|
|
5486
5342
|
}
|
|
@@ -5491,10 +5347,10 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
|
5491
5347
|
importName: match.importName,
|
|
5492
5348
|
...match.factoryMethods === void 0 ? {} : { factoryMethods: match.factoryMethods }
|
|
5493
5349
|
};
|
|
5494
|
-
return (subject) => isClientImport(subject, match, resolution, true) ||
|
|
5350
|
+
return (subject) => isClientImport(subject, match, resolution, true) || import_ts_morph19.Node.isIdentifier(subject) && constructedHere.has(subject.getText()) || resolvesToKnownInstance(subject, full, resolution);
|
|
5495
5351
|
}
|
|
5496
5352
|
function typedAsClient(typeNode, localName) {
|
|
5497
|
-
if (typeNode === void 0 || !
|
|
5353
|
+
if (typeNode === void 0 || !import_ts_morph19.Node.isTypeReference(typeNode)) {
|
|
5498
5354
|
return false;
|
|
5499
5355
|
}
|
|
5500
5356
|
return typeNode.getTypeName().getText() === localName;
|
|
@@ -5504,27 +5360,27 @@ function resolvesToKnownInstance(subject, match, resolution) {
|
|
|
5504
5360
|
return false;
|
|
5505
5361
|
}
|
|
5506
5362
|
const written = writtenNodeOf(subject, resolution);
|
|
5507
|
-
if (written === null || !
|
|
5363
|
+
if (written === null || !import_ts_morph19.Node.isCallExpression(written) && !import_ts_morph19.Node.isNewExpression(written)) {
|
|
5508
5364
|
return false;
|
|
5509
5365
|
}
|
|
5510
5366
|
return isCreationCall(written, match, resolution);
|
|
5511
5367
|
}
|
|
5512
5368
|
function isCreationCall(call, match, resolution) {
|
|
5513
5369
|
const callee = call.getExpression();
|
|
5514
|
-
if (
|
|
5370
|
+
if (import_ts_morph19.Node.isIdentifier(callee)) {
|
|
5515
5371
|
return isClientImport(callee, match, resolution, false);
|
|
5516
5372
|
}
|
|
5517
|
-
if (!
|
|
5373
|
+
if (!import_ts_morph19.Node.isPropertyAccessExpression(callee)) {
|
|
5518
5374
|
return false;
|
|
5519
5375
|
}
|
|
5520
5376
|
const base = callee.getExpression();
|
|
5521
|
-
return
|
|
5377
|
+
return import_ts_morph19.Node.isIdentifier(base) && (match.factoryMethods?.includes(callee.getName()) ?? false) && isClientImport(base, match, resolution, false);
|
|
5522
5378
|
}
|
|
5523
5379
|
function isPathShaped(specifier) {
|
|
5524
5380
|
return specifier.startsWith(".") || specifier.startsWith("/");
|
|
5525
5381
|
}
|
|
5526
5382
|
function isClientImport(subject, match, resolution, strictDefaultName) {
|
|
5527
|
-
if (!
|
|
5383
|
+
if (!import_ts_morph19.Node.isIdentifier(subject)) {
|
|
5528
5384
|
return false;
|
|
5529
5385
|
}
|
|
5530
5386
|
if (resolution === void 0) {
|
|
@@ -5572,27 +5428,27 @@ function resolvedImportLocalName(sourceFile, importModule, importName, strictDef
|
|
|
5572
5428
|
return null;
|
|
5573
5429
|
}
|
|
5574
5430
|
function clientUnitName(enclosingFunc, methodName) {
|
|
5575
|
-
if (
|
|
5431
|
+
if (import_ts_morph19.Node.isFunctionDeclaration(enclosingFunc)) {
|
|
5576
5432
|
return enclosingFunc.getName() ?? methodName ?? "anonymous";
|
|
5577
5433
|
}
|
|
5578
|
-
if (
|
|
5434
|
+
if (import_ts_morph19.Node.isMethodDeclaration(enclosingFunc)) {
|
|
5579
5435
|
return enclosingFunc.getName();
|
|
5580
5436
|
}
|
|
5581
5437
|
const parent = enclosingFunc.getParent();
|
|
5582
|
-
if (parent !== void 0 &&
|
|
5438
|
+
if (parent !== void 0 && import_ts_morph19.Node.isVariableDeclaration(parent)) {
|
|
5583
5439
|
return parent.getName();
|
|
5584
5440
|
}
|
|
5585
|
-
if (parent !== void 0 &&
|
|
5441
|
+
if (parent !== void 0 && import_ts_morph19.Node.isPropertyAssignment(parent)) {
|
|
5586
5442
|
return parent.getName();
|
|
5587
5443
|
}
|
|
5588
5444
|
return methodName ?? "anonymous";
|
|
5589
5445
|
}
|
|
5590
5446
|
|
|
5591
5447
|
// src/discovery/decoratedMethod.ts
|
|
5592
|
-
var
|
|
5448
|
+
var import_ts_morph22 = require("ts-morph");
|
|
5593
5449
|
|
|
5594
5450
|
// src/discovery/decoratedMembers.ts
|
|
5595
|
-
var
|
|
5451
|
+
var import_ts_morph20 = require("ts-morph");
|
|
5596
5452
|
function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
|
|
5597
5453
|
const localToCanonical = /* @__PURE__ */ new Map();
|
|
5598
5454
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
@@ -5612,7 +5468,7 @@ function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
|
|
|
5612
5468
|
function decoratedCallablesOf(cls, decoratorNames) {
|
|
5613
5469
|
const callables = [];
|
|
5614
5470
|
for (const member of cls.getMembers()) {
|
|
5615
|
-
if (!
|
|
5471
|
+
if (!import_ts_morph20.Node.isMethodDeclaration(member) && !import_ts_morph20.Node.isPropertyDeclaration(member)) {
|
|
5616
5472
|
continue;
|
|
5617
5473
|
}
|
|
5618
5474
|
const func = callableOf(member);
|
|
@@ -5636,7 +5492,7 @@ function decoratedCallablesOf(cls, decoratorNames) {
|
|
|
5636
5492
|
return callables;
|
|
5637
5493
|
}
|
|
5638
5494
|
function callableOf(member) {
|
|
5639
|
-
if (
|
|
5495
|
+
if (import_ts_morph20.Node.isMethodDeclaration(member)) {
|
|
5640
5496
|
return toFunctionRoot(member);
|
|
5641
5497
|
}
|
|
5642
5498
|
const held = member.getInitializer();
|
|
@@ -5644,7 +5500,7 @@ function callableOf(member) {
|
|
|
5644
5500
|
}
|
|
5645
5501
|
|
|
5646
5502
|
// src/discovery/decoratorComposition.ts
|
|
5647
|
-
var
|
|
5503
|
+
var import_ts_morph21 = require("ts-morph");
|
|
5648
5504
|
function classDecoratorStandingFor(cls, names, modules, resolution) {
|
|
5649
5505
|
for (const candidate of names) {
|
|
5650
5506
|
const decorator = cls.getDecorator(candidate);
|
|
@@ -5682,7 +5538,7 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
|
|
|
5682
5538
|
if (wrapper === null) {
|
|
5683
5539
|
return atClass;
|
|
5684
5540
|
}
|
|
5685
|
-
for (const call of wrapper.getDescendantsOfKind(
|
|
5541
|
+
for (const call of wrapper.getDescendantsOfKind(import_ts_morph21.SyntaxKind.CallExpression)) {
|
|
5686
5542
|
const names = resolution.importedNamesOf(call.getExpression(), modules);
|
|
5687
5543
|
if (!names.includes(standsFor)) {
|
|
5688
5544
|
continue;
|
|
@@ -5693,10 +5549,10 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
|
|
|
5693
5549
|
return atClass;
|
|
5694
5550
|
}
|
|
5695
5551
|
function statesAValue(arg, wrapper) {
|
|
5696
|
-
const identifiers =
|
|
5552
|
+
const identifiers = import_ts_morph21.Node.isIdentifier(arg) ? [arg] : arg.getDescendantsOfKind(import_ts_morph21.SyntaxKind.Identifier);
|
|
5697
5553
|
return !identifiers.some(
|
|
5698
5554
|
(identifier) => identifier.getSymbol()?.getDeclarations().some(
|
|
5699
|
-
(declaration) =>
|
|
5555
|
+
(declaration) => import_ts_morph21.Node.isParameterDeclaration(declaration) && isWithin(declaration, wrapper)
|
|
5700
5556
|
)
|
|
5701
5557
|
);
|
|
5702
5558
|
}
|
|
@@ -5716,39 +5572,39 @@ function resolverTypeName(args) {
|
|
|
5716
5572
|
return args.typeMap[args.decoratorName] ?? args.classTypeName ?? null;
|
|
5717
5573
|
}
|
|
5718
5574
|
function resolveResolverClassTypeName(decoratorArg) {
|
|
5719
|
-
if (
|
|
5575
|
+
if (import_ts_morph22.Node.isArrowFunction(decoratorArg)) {
|
|
5720
5576
|
const body = decoratorArg.getBody();
|
|
5721
|
-
if (
|
|
5577
|
+
if (import_ts_morph22.Node.isIdentifier(body)) {
|
|
5722
5578
|
return body.getText();
|
|
5723
5579
|
}
|
|
5724
5580
|
return null;
|
|
5725
5581
|
}
|
|
5726
|
-
if (
|
|
5582
|
+
if (import_ts_morph22.Node.isStringLiteral(decoratorArg)) {
|
|
5727
5583
|
return decoratorArg.getLiteralValue();
|
|
5728
5584
|
}
|
|
5729
|
-
if (
|
|
5585
|
+
if (import_ts_morph22.Node.isIdentifier(decoratorArg)) {
|
|
5730
5586
|
return decoratorArg.getText();
|
|
5731
5587
|
}
|
|
5732
5588
|
return null;
|
|
5733
5589
|
}
|
|
5734
5590
|
function resolveOperationNameOverride(decorator) {
|
|
5735
|
-
if (!
|
|
5591
|
+
if (!import_ts_morph22.Node.isDecorator(decorator)) {
|
|
5736
5592
|
return null;
|
|
5737
5593
|
}
|
|
5738
5594
|
const args = decorator.getArguments();
|
|
5739
5595
|
for (const arg of args) {
|
|
5740
|
-
if (!
|
|
5596
|
+
if (!import_ts_morph22.Node.isObjectLiteralExpression(arg)) {
|
|
5741
5597
|
continue;
|
|
5742
5598
|
}
|
|
5743
5599
|
const prop = arg.getProperty("name");
|
|
5744
|
-
if (prop === void 0 || !
|
|
5600
|
+
if (prop === void 0 || !import_ts_morph22.Node.isPropertyAssignment(prop)) {
|
|
5745
5601
|
continue;
|
|
5746
5602
|
}
|
|
5747
5603
|
const init = prop.getInitializer();
|
|
5748
5604
|
if (init === void 0) {
|
|
5749
5605
|
continue;
|
|
5750
5606
|
}
|
|
5751
|
-
if (
|
|
5607
|
+
if (import_ts_morph22.Node.isStringLiteral(init) || import_ts_morph22.Node.isNoSubstitutionTemplateLiteral(init)) {
|
|
5752
5608
|
return init.getLiteralValue();
|
|
5753
5609
|
}
|
|
5754
5610
|
}
|
|
@@ -5801,9 +5657,9 @@ function discoverDecoratedMethods(sourceFile, match, kind, resolution) {
|
|
|
5801
5657
|
}
|
|
5802
5658
|
|
|
5803
5659
|
// src/discovery/decoratedRoute.ts
|
|
5804
|
-
var
|
|
5660
|
+
var import_ts_morph23 = require("ts-morph");
|
|
5805
5661
|
function resolveRoutePathArg(decorator, resolution) {
|
|
5806
|
-
if (!
|
|
5662
|
+
if (!import_ts_morph23.Node.isDecorator(decorator)) {
|
|
5807
5663
|
return "";
|
|
5808
5664
|
}
|
|
5809
5665
|
return routePathOf(decorator.getArguments(), resolution);
|
|
@@ -5831,7 +5687,7 @@ function declaredChannelOf(source, decorator, resolution) {
|
|
|
5831
5687
|
if (source.from === "unstated") {
|
|
5832
5688
|
return null;
|
|
5833
5689
|
}
|
|
5834
|
-
if (!
|
|
5690
|
+
if (!import_ts_morph23.Node.isDecorator(decorator)) {
|
|
5835
5691
|
return null;
|
|
5836
5692
|
}
|
|
5837
5693
|
const arg = decorator.getArguments()[source.position];
|
|
@@ -5842,7 +5698,7 @@ function declaredChannelOf(source, decorator, resolution) {
|
|
|
5842
5698
|
return text === null || text === "" ? null : text;
|
|
5843
5699
|
}
|
|
5844
5700
|
function literalStringOf(node, resolution) {
|
|
5845
|
-
if (
|
|
5701
|
+
if (import_ts_morph23.Node.isStringLiteral(node) || import_ts_morph23.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
5846
5702
|
return node.getLiteralValue();
|
|
5847
5703
|
}
|
|
5848
5704
|
const written = resolution?.resolveWrittenValue(node) ?? null;
|
|
@@ -5912,31 +5768,31 @@ function discoverDecoratedRoutes(sourceFile, match, kind, resolution, binding) {
|
|
|
5912
5768
|
var import_picomatch = __toESM(require("picomatch"), 1);
|
|
5913
5769
|
|
|
5914
5770
|
// src/discovery/namedExport.ts
|
|
5915
|
-
var
|
|
5771
|
+
var import_ts_morph24 = require("ts-morph");
|
|
5916
5772
|
function nameWrittenAt(expression) {
|
|
5917
|
-
if (
|
|
5773
|
+
if (import_ts_morph24.Node.isIdentifier(expression)) {
|
|
5918
5774
|
return expression.getText();
|
|
5919
5775
|
}
|
|
5920
|
-
if (
|
|
5776
|
+
if (import_ts_morph24.Node.isPropertyAccessExpression(expression)) {
|
|
5921
5777
|
return expression.getName();
|
|
5922
5778
|
}
|
|
5923
5779
|
return null;
|
|
5924
5780
|
}
|
|
5925
5781
|
function resolveDefaultExportName(decl, fn) {
|
|
5926
|
-
if (
|
|
5782
|
+
if (import_ts_morph24.Node.isFunctionDeclaration(fn) || import_ts_morph24.Node.isFunctionExpression(fn)) {
|
|
5927
5783
|
const n = fn.getName?.();
|
|
5928
5784
|
if (typeof n === "string" && n.length > 0) {
|
|
5929
5785
|
return n;
|
|
5930
5786
|
}
|
|
5931
5787
|
}
|
|
5932
|
-
if (
|
|
5788
|
+
if (import_ts_morph24.Node.isVariableDeclaration(decl)) {
|
|
5933
5789
|
const name = decl.getName();
|
|
5934
5790
|
if (name.length > 0) {
|
|
5935
5791
|
return name;
|
|
5936
5792
|
}
|
|
5937
5793
|
}
|
|
5938
5794
|
const binding = fn.getParent();
|
|
5939
|
-
if (binding !== void 0 &&
|
|
5795
|
+
if (binding !== void 0 && import_ts_morph24.Node.isVariableDeclaration(binding)) {
|
|
5940
5796
|
const name = binding.getName();
|
|
5941
5797
|
if (name.length > 0) {
|
|
5942
5798
|
return name;
|
|
@@ -5991,7 +5847,7 @@ function discoverNamedExports(sourceFile, match, kind, resolution) {
|
|
|
5991
5847
|
}
|
|
5992
5848
|
continue;
|
|
5993
5849
|
}
|
|
5994
|
-
if (
|
|
5850
|
+
if (import_ts_morph24.Node.isArrowFunction(init) || import_ts_morph24.Node.isFunctionExpression(init)) {
|
|
5995
5851
|
results.push({
|
|
5996
5852
|
func: init,
|
|
5997
5853
|
kind,
|
|
@@ -6100,13 +5956,13 @@ function discoverFileConventions(sourceFile, match, kind, resolution) {
|
|
|
6100
5956
|
}
|
|
6101
5957
|
|
|
6102
5958
|
// src/discovery/graphqlHookCall.ts
|
|
6103
|
-
var
|
|
5959
|
+
var import_ts_morph27 = require("ts-morph");
|
|
6104
5960
|
|
|
6105
5961
|
// src/discovery/graphqlShared.ts
|
|
6106
5962
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
6107
|
-
var
|
|
5963
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
6108
5964
|
var import_graphql = require("graphql");
|
|
6109
|
-
var
|
|
5965
|
+
var import_ts_morph25 = require("ts-morph");
|
|
6110
5966
|
var DOCUMENT_TAGS = /* @__PURE__ */ new Set(["gql", "graphql"]);
|
|
6111
5967
|
var UNQUALIFIED_DOCUMENT_TAG = "gql";
|
|
6112
5968
|
function parseGraphqlOperation(source) {
|
|
@@ -6172,10 +6028,10 @@ function startAssembly(resolution) {
|
|
|
6172
6028
|
};
|
|
6173
6029
|
}
|
|
6174
6030
|
function assembledTemplateText(template, assembly) {
|
|
6175
|
-
if (
|
|
6031
|
+
if (import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(template)) {
|
|
6176
6032
|
return innerTemplateText(template);
|
|
6177
6033
|
}
|
|
6178
|
-
if (!
|
|
6034
|
+
if (!import_ts_morph25.Node.isTemplateExpression(template)) {
|
|
6179
6035
|
return null;
|
|
6180
6036
|
}
|
|
6181
6037
|
let text = template.getHead().getLiteralText();
|
|
@@ -6311,7 +6167,7 @@ function collectDanglingSpreads(selectionSet, defined, dangling) {
|
|
|
6311
6167
|
}
|
|
6312
6168
|
}
|
|
6313
6169
|
function documentTextFromExpression(node, assembly) {
|
|
6314
|
-
if (
|
|
6170
|
+
if (import_ts_morph25.Node.isTaggedTemplateExpression(node)) {
|
|
6315
6171
|
if (!isDocumentTag(node.getTag())) {
|
|
6316
6172
|
return null;
|
|
6317
6173
|
}
|
|
@@ -6321,7 +6177,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
6321
6177
|
assembly.seen.add(node);
|
|
6322
6178
|
return assembledTemplateText(node.getTemplate(), assembly);
|
|
6323
6179
|
}
|
|
6324
|
-
if (!
|
|
6180
|
+
if (!import_ts_morph25.Node.isCallExpression(node)) {
|
|
6325
6181
|
return null;
|
|
6326
6182
|
}
|
|
6327
6183
|
if (!isDocumentTag(node.getExpression())) {
|
|
@@ -6332,7 +6188,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
6332
6188
|
return null;
|
|
6333
6189
|
}
|
|
6334
6190
|
const template = stripDocumentNodeCasts(first);
|
|
6335
|
-
if (!
|
|
6191
|
+
if (!import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(template) && !import_ts_morph25.Node.isTemplateExpression(template)) {
|
|
6336
6192
|
return null;
|
|
6337
6193
|
}
|
|
6338
6194
|
if (assembly.seen.has(node)) {
|
|
@@ -6342,7 +6198,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
6342
6198
|
return assembledTemplateText(template, assembly);
|
|
6343
6199
|
}
|
|
6344
6200
|
function isDocumentTag(tag) {
|
|
6345
|
-
if (!
|
|
6201
|
+
if (!import_ts_morph25.Node.isIdentifier(tag)) {
|
|
6346
6202
|
return false;
|
|
6347
6203
|
}
|
|
6348
6204
|
if (tag.getText() === UNQUALIFIED_DOCUMENT_TAG) {
|
|
@@ -6353,14 +6209,14 @@ function isDocumentTag(tag) {
|
|
|
6353
6209
|
return false;
|
|
6354
6210
|
}
|
|
6355
6211
|
for (const declaration of symbol.getDeclarations()) {
|
|
6356
|
-
if (
|
|
6212
|
+
if (import_ts_morph25.Node.isImportSpecifier(declaration) && DOCUMENT_TAGS.has(declaration.getName())) {
|
|
6357
6213
|
return true;
|
|
6358
6214
|
}
|
|
6359
6215
|
}
|
|
6360
6216
|
return false;
|
|
6361
6217
|
}
|
|
6362
6218
|
function resolveThroughFacts(arg, assembly) {
|
|
6363
|
-
if (assembly.resolution === void 0 || !
|
|
6219
|
+
if (assembly.resolution === void 0 || !import_ts_morph25.Node.isIdentifier(arg)) {
|
|
6364
6220
|
return null;
|
|
6365
6221
|
}
|
|
6366
6222
|
const written = assembly.resolution.resolveWrittenValue(arg);
|
|
@@ -6409,7 +6265,7 @@ function singleLine(text) {
|
|
|
6409
6265
|
return collapsed.length > 80 ? `${collapsed.slice(0, 79)}\u2026` : collapsed;
|
|
6410
6266
|
}
|
|
6411
6267
|
function importedVariableInitializers(identifier) {
|
|
6412
|
-
if (!
|
|
6268
|
+
if (!import_ts_morph25.Node.isIdentifier(identifier)) {
|
|
6413
6269
|
return [];
|
|
6414
6270
|
}
|
|
6415
6271
|
const symbol = identifier.getSymbol();
|
|
@@ -6419,7 +6275,7 @@ function importedVariableInitializers(identifier) {
|
|
|
6419
6275
|
const resolved = resolveAliasedSymbol(symbol) ?? symbol;
|
|
6420
6276
|
const inits = [];
|
|
6421
6277
|
for (const decl of resolved.getDeclarations()) {
|
|
6422
|
-
if (
|
|
6278
|
+
if (import_ts_morph25.Node.isVariableDeclaration(decl)) {
|
|
6423
6279
|
const init = decl.getInitializer();
|
|
6424
6280
|
if (init !== void 0) {
|
|
6425
6281
|
inits.push(init);
|
|
@@ -6433,7 +6289,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
6433
6289
|
if (direct !== null) {
|
|
6434
6290
|
return direct;
|
|
6435
6291
|
}
|
|
6436
|
-
if (!
|
|
6292
|
+
if (!import_ts_morph25.Node.isIdentifier(arg)) {
|
|
6437
6293
|
return null;
|
|
6438
6294
|
}
|
|
6439
6295
|
const symbol = arg.getSymbol();
|
|
@@ -6441,7 +6297,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
6441
6297
|
return null;
|
|
6442
6298
|
}
|
|
6443
6299
|
for (const decl of symbol.getDeclarations()) {
|
|
6444
|
-
if (
|
|
6300
|
+
if (import_ts_morph25.Node.isImportClause(decl) || import_ts_morph25.Node.isImportSpecifier(decl)) {
|
|
6445
6301
|
const fromGraphqlFile = resolveGraphqlFileImport(decl);
|
|
6446
6302
|
if (fromGraphqlFile !== null) {
|
|
6447
6303
|
return fromGraphqlFile;
|
|
@@ -6460,7 +6316,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
6460
6316
|
return null;
|
|
6461
6317
|
}
|
|
6462
6318
|
function resolveTypedDocumentSource(arg) {
|
|
6463
|
-
if (!
|
|
6319
|
+
if (!import_ts_morph25.Node.isIdentifier(arg)) {
|
|
6464
6320
|
return null;
|
|
6465
6321
|
}
|
|
6466
6322
|
for (const init of importedVariableInitializers(arg)) {
|
|
@@ -6473,7 +6329,7 @@ function resolveTypedDocumentSource(arg) {
|
|
|
6473
6329
|
}
|
|
6474
6330
|
function typedDocumentSourceOf(node) {
|
|
6475
6331
|
const inner = stripDocumentNodeCasts(node);
|
|
6476
|
-
if (!
|
|
6332
|
+
if (!import_ts_morph25.Node.isObjectLiteralExpression(inner)) {
|
|
6477
6333
|
return null;
|
|
6478
6334
|
}
|
|
6479
6335
|
const evaluated = evaluateObjectLiteralAsJson(inner);
|
|
@@ -6491,7 +6347,7 @@ function typedDocumentSourceOf(node) {
|
|
|
6491
6347
|
}
|
|
6492
6348
|
}
|
|
6493
6349
|
function resolveTypedDocumentHeader(arg) {
|
|
6494
|
-
if (!
|
|
6350
|
+
if (!import_ts_morph25.Node.isIdentifier(arg)) {
|
|
6495
6351
|
return null;
|
|
6496
6352
|
}
|
|
6497
6353
|
const reference = arg.getText();
|
|
@@ -6501,7 +6357,7 @@ function resolveTypedDocumentHeader(arg) {
|
|
|
6501
6357
|
}
|
|
6502
6358
|
const resolved = resolveAliasedSymbol(symbol) ?? symbol;
|
|
6503
6359
|
for (const decl of resolved.getDeclarations()) {
|
|
6504
|
-
if (!
|
|
6360
|
+
if (!import_ts_morph25.Node.isVariableDeclaration(decl)) {
|
|
6505
6361
|
continue;
|
|
6506
6362
|
}
|
|
6507
6363
|
const init = decl.getInitializer();
|
|
@@ -6534,10 +6390,10 @@ function resolveTypedDocumentHeader(arg) {
|
|
|
6534
6390
|
}
|
|
6535
6391
|
function documentNodeCastTypeArgs(node) {
|
|
6536
6392
|
let current2 = node;
|
|
6537
|
-
while (
|
|
6538
|
-
if (
|
|
6393
|
+
while (import_ts_morph25.Node.isAsExpression(current2) || import_ts_morph25.Node.isParenthesizedExpression(current2)) {
|
|
6394
|
+
if (import_ts_morph25.Node.isAsExpression(current2)) {
|
|
6539
6395
|
const typeNode = current2.getTypeNode();
|
|
6540
|
-
if (typeNode !== void 0 &&
|
|
6396
|
+
if (typeNode !== void 0 && import_ts_morph25.Node.isTypeReference(typeNode)) {
|
|
6541
6397
|
const name = typeNode.getTypeName().getText();
|
|
6542
6398
|
const simpleName = name.includes(".") ? name.split(".").pop() ?? name : name;
|
|
6543
6399
|
if (simpleName === "TypedDocumentNode" || simpleName === "DocumentNode") {
|
|
@@ -6550,7 +6406,7 @@ function documentNodeCastTypeArgs(node) {
|
|
|
6550
6406
|
return null;
|
|
6551
6407
|
}
|
|
6552
6408
|
function operationHeaderFromResultType(typeNode) {
|
|
6553
|
-
if (typeNode === void 0 || !
|
|
6409
|
+
if (typeNode === void 0 || !import_ts_morph25.Node.isTypeReference(typeNode)) {
|
|
6554
6410
|
return null;
|
|
6555
6411
|
}
|
|
6556
6412
|
const name = typeNode.getTypeName().getText();
|
|
@@ -6571,16 +6427,16 @@ function operationHeaderFromResultType(typeNode) {
|
|
|
6571
6427
|
}
|
|
6572
6428
|
function stripDocumentNodeCasts(node) {
|
|
6573
6429
|
let current2 = node;
|
|
6574
|
-
while (
|
|
6430
|
+
while (import_ts_morph25.Node.isAsExpression(current2) || import_ts_morph25.Node.isParenthesizedExpression(current2)) {
|
|
6575
6431
|
current2 = current2.getExpression();
|
|
6576
6432
|
}
|
|
6577
6433
|
return current2;
|
|
6578
6434
|
}
|
|
6579
6435
|
function evaluateObjectLiteralAsJson(node) {
|
|
6580
|
-
if (
|
|
6436
|
+
if (import_ts_morph25.Node.isStringLiteral(node) || import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
6581
6437
|
return node.getLiteralValue();
|
|
6582
6438
|
}
|
|
6583
|
-
if (
|
|
6439
|
+
if (import_ts_morph25.Node.isNumericLiteral(node)) {
|
|
6584
6440
|
return Number(node.getText());
|
|
6585
6441
|
}
|
|
6586
6442
|
const kind = node.getText();
|
|
@@ -6593,17 +6449,17 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
6593
6449
|
if (kind === "null") {
|
|
6594
6450
|
return null;
|
|
6595
6451
|
}
|
|
6596
|
-
if (
|
|
6452
|
+
if (import_ts_morph25.Node.isObjectLiteralExpression(node)) {
|
|
6597
6453
|
const out = {};
|
|
6598
6454
|
for (const prop of node.getProperties()) {
|
|
6599
|
-
if (!
|
|
6455
|
+
if (!import_ts_morph25.Node.isPropertyAssignment(prop)) {
|
|
6600
6456
|
return null;
|
|
6601
6457
|
}
|
|
6602
6458
|
const nameNode = prop.getNameNode();
|
|
6603
6459
|
let name;
|
|
6604
|
-
if (
|
|
6460
|
+
if (import_ts_morph25.Node.isIdentifier(nameNode)) {
|
|
6605
6461
|
name = nameNode.getText();
|
|
6606
|
-
} else if (
|
|
6462
|
+
} else if (import_ts_morph25.Node.isStringLiteral(nameNode) || import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(nameNode)) {
|
|
6607
6463
|
name = nameNode.getLiteralValue();
|
|
6608
6464
|
} else {
|
|
6609
6465
|
return null;
|
|
@@ -6620,7 +6476,7 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
6620
6476
|
}
|
|
6621
6477
|
return out;
|
|
6622
6478
|
}
|
|
6623
|
-
if (
|
|
6479
|
+
if (import_ts_morph25.Node.isArrayLiteralExpression(node)) {
|
|
6624
6480
|
const out = [];
|
|
6625
6481
|
for (const el of node.getElements()) {
|
|
6626
6482
|
const value = evaluateObjectLiteralAsJson(el);
|
|
@@ -6634,8 +6490,8 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
6634
6490
|
return void 0;
|
|
6635
6491
|
}
|
|
6636
6492
|
function resolveGraphqlFileImport(decl) {
|
|
6637
|
-
const importDecl =
|
|
6638
|
-
if (importDecl === null || importDecl === void 0 || !
|
|
6493
|
+
const importDecl = import_ts_morph25.Node.isImportSpecifier(decl) ? decl.getImportDeclaration() : import_ts_morph25.Node.isImportClause(decl) ? decl.getParent() : null;
|
|
6494
|
+
if (importDecl === null || importDecl === void 0 || !import_ts_morph25.Node.isImportDeclaration(importDecl)) {
|
|
6639
6495
|
return null;
|
|
6640
6496
|
}
|
|
6641
6497
|
const specifier = importDecl.getModuleSpecifierValue();
|
|
@@ -6643,8 +6499,8 @@ function resolveGraphqlFileImport(decl) {
|
|
|
6643
6499
|
return null;
|
|
6644
6500
|
}
|
|
6645
6501
|
const sourceFile = importDecl.getSourceFile();
|
|
6646
|
-
const baseDir =
|
|
6647
|
-
const absolute =
|
|
6502
|
+
const baseDir = import_node_path3.default.dirname(sourceFile.getFilePath());
|
|
6503
|
+
const absolute = import_node_path3.default.resolve(baseDir, specifier);
|
|
6648
6504
|
try {
|
|
6649
6505
|
return import_node_fs.default.readFileSync(absolute, "utf8");
|
|
6650
6506
|
} catch {
|
|
@@ -6654,7 +6510,7 @@ function resolveGraphqlFileImport(decl) {
|
|
|
6654
6510
|
function enclosingFunctionRoot(node) {
|
|
6655
6511
|
let current2 = node.getParent();
|
|
6656
6512
|
while (current2 !== void 0) {
|
|
6657
|
-
if (
|
|
6513
|
+
if (import_ts_morph25.Node.isFunctionDeclaration(current2) || import_ts_morph25.Node.isFunctionExpression(current2) || import_ts_morph25.Node.isArrowFunction(current2) || import_ts_morph25.Node.isMethodDeclaration(current2)) {
|
|
6658
6514
|
return current2;
|
|
6659
6515
|
}
|
|
6660
6516
|
current2 = current2.getParent();
|
|
@@ -6662,18 +6518,18 @@ function enclosingFunctionRoot(node) {
|
|
|
6662
6518
|
return null;
|
|
6663
6519
|
}
|
|
6664
6520
|
function functionNameOrAnon(func) {
|
|
6665
|
-
if (
|
|
6521
|
+
if (import_ts_morph25.Node.isFunctionDeclaration(func) || import_ts_morph25.Node.isMethodDeclaration(func)) {
|
|
6666
6522
|
return func.getName() ?? "<anon>";
|
|
6667
6523
|
}
|
|
6668
6524
|
const parent = func.getParent();
|
|
6669
|
-
if (parent !== void 0 &&
|
|
6525
|
+
if (parent !== void 0 && import_ts_morph25.Node.isVariableDeclaration(parent)) {
|
|
6670
6526
|
return parent.getName();
|
|
6671
6527
|
}
|
|
6672
6528
|
return "<anon>";
|
|
6673
6529
|
}
|
|
6674
6530
|
|
|
6675
6531
|
// src/discovery/importedCalls.ts
|
|
6676
|
-
var
|
|
6532
|
+
var import_ts_morph26 = require("ts-morph");
|
|
6677
6533
|
function callsResolvingTo(sourceFile, resolution, spec) {
|
|
6678
6534
|
return [
|
|
6679
6535
|
...callsByOriginName(
|
|
@@ -6687,11 +6543,11 @@ function callsResolvingTo(sourceFile, resolution, spec) {
|
|
|
6687
6543
|
function callsByOriginName(sourceFile, resolution, module2, names) {
|
|
6688
6544
|
const candidates = [];
|
|
6689
6545
|
sourceFile.forEachDescendant((node) => {
|
|
6690
|
-
if (!
|
|
6546
|
+
if (!import_ts_morph26.Node.isCallExpression(node) && !import_ts_morph26.Node.isNewExpression(node)) {
|
|
6691
6547
|
return;
|
|
6692
6548
|
}
|
|
6693
6549
|
const callee = node.getExpression();
|
|
6694
|
-
if (
|
|
6550
|
+
if (import_ts_morph26.Node.isIdentifier(callee) && !declaredLocally(callee)) {
|
|
6695
6551
|
candidates.push(node);
|
|
6696
6552
|
}
|
|
6697
6553
|
});
|
|
@@ -6717,7 +6573,7 @@ function callsByOriginName(sourceFile, resolution, module2, names) {
|
|
|
6717
6573
|
function declaredLocally(callee) {
|
|
6718
6574
|
const declarations = callee.getSymbol()?.getDeclarations() ?? [];
|
|
6719
6575
|
return declarations.length > 0 && declarations.every(
|
|
6720
|
-
(declaration) => (
|
|
6576
|
+
(declaration) => (import_ts_morph26.Node.isFunctionDeclaration(declaration) || import_ts_morph26.Node.isClassDeclaration(declaration)) && !declaration.getSourceFile().isInNodeModules()
|
|
6721
6577
|
);
|
|
6722
6578
|
}
|
|
6723
6579
|
|
|
@@ -6735,7 +6591,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
|
|
|
6735
6591
|
);
|
|
6736
6592
|
const results = [];
|
|
6737
6593
|
for (const [node, canonical] of hookCalls) {
|
|
6738
|
-
if (!
|
|
6594
|
+
if (!import_ts_morph27.Node.isCallExpression(node)) {
|
|
6739
6595
|
continue;
|
|
6740
6596
|
}
|
|
6741
6597
|
const operationType = operationTypeByHook.get(canonical);
|
|
@@ -6772,7 +6628,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
|
|
|
6772
6628
|
}
|
|
6773
6629
|
|
|
6774
6630
|
// src/discovery/graphqlImperativeCall.ts
|
|
6775
|
-
var
|
|
6631
|
+
var import_ts_morph28 = require("ts-morph");
|
|
6776
6632
|
function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
6777
6633
|
const isTheClient = clientReceiverCheckFor(sourceFile, match, resolution);
|
|
6778
6634
|
const methodSpec = /* @__PURE__ */ new Map();
|
|
@@ -6784,11 +6640,11 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
6784
6640
|
}
|
|
6785
6641
|
const results = [];
|
|
6786
6642
|
sourceFile.forEachDescendant((node) => {
|
|
6787
|
-
if (!
|
|
6643
|
+
if (!import_ts_morph28.Node.isCallExpression(node)) {
|
|
6788
6644
|
return;
|
|
6789
6645
|
}
|
|
6790
6646
|
const callee = node.getExpression();
|
|
6791
|
-
if (!
|
|
6647
|
+
if (!import_ts_morph28.Node.isPropertyAccessExpression(callee)) {
|
|
6792
6648
|
return;
|
|
6793
6649
|
}
|
|
6794
6650
|
const methodName = callee.getName();
|
|
@@ -6800,7 +6656,7 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
6800
6656
|
return;
|
|
6801
6657
|
}
|
|
6802
6658
|
const args = node.getArguments();
|
|
6803
|
-
if (args.length === 0 || !
|
|
6659
|
+
if (args.length === 0 || !import_ts_morph28.Node.isObjectLiteralExpression(args[0])) {
|
|
6804
6660
|
return;
|
|
6805
6661
|
}
|
|
6806
6662
|
const config = args[0];
|
|
@@ -6836,16 +6692,16 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
6836
6692
|
return results;
|
|
6837
6693
|
}
|
|
6838
6694
|
function imperativeConfigValue(prop) {
|
|
6839
|
-
if (
|
|
6695
|
+
if (import_ts_morph28.Node.isPropertyAssignment(prop)) {
|
|
6840
6696
|
return prop.getInitializer() ?? null;
|
|
6841
6697
|
}
|
|
6842
|
-
if (
|
|
6698
|
+
if (import_ts_morph28.Node.isShorthandPropertyAssignment(prop)) {
|
|
6843
6699
|
const valueSymbol = prop.getValueSymbol();
|
|
6844
6700
|
if (valueSymbol === void 0) {
|
|
6845
6701
|
return null;
|
|
6846
6702
|
}
|
|
6847
6703
|
for (const decl of valueSymbol.getDeclarations()) {
|
|
6848
|
-
if (
|
|
6704
|
+
if (import_ts_morph28.Node.isVariableDeclaration(decl)) {
|
|
6849
6705
|
const init = decl.getInitializer();
|
|
6850
6706
|
if (init !== void 0) {
|
|
6851
6707
|
return init;
|
|
@@ -6858,7 +6714,7 @@ function imperativeConfigValue(prop) {
|
|
|
6858
6714
|
}
|
|
6859
6715
|
|
|
6860
6716
|
// src/discovery/jsxElementRoute.ts
|
|
6861
|
-
var
|
|
6717
|
+
var import_ts_morph29 = require("ts-morph");
|
|
6862
6718
|
var PATH_NOT_LITERAL = "The path this route declares is not written as a string literal, so no path is claimed and this route pairs with nothing";
|
|
6863
6719
|
var ENCLOSING_PATH_NOT_LITERAL = "A route this one is nested under declares its path as something other than a string literal, so the full path is not claimed and this route pairs with nothing";
|
|
6864
6720
|
var SPREAD_NOT_ENUMERATED = "A spread stands in for routes declared elsewhere in this array, and they are not read here, so no path is claimed for any of them";
|
|
@@ -6890,7 +6746,7 @@ function discoverJsxElementRoutes(sourceFile, match, kind, resolution) {
|
|
|
6890
6746
|
}
|
|
6891
6747
|
return;
|
|
6892
6748
|
}
|
|
6893
|
-
if (
|
|
6749
|
+
if (import_ts_morph29.Node.isCallExpression(node) && callsAFactory(node, factoryNames)) {
|
|
6894
6750
|
results.push(
|
|
6895
6751
|
...unitsForRouteArray(node, match, elementsNames, kind, resolution)
|
|
6896
6752
|
);
|
|
@@ -6912,7 +6768,7 @@ function localNamesFor(sourceFile, match, exported) {
|
|
|
6912
6768
|
return local;
|
|
6913
6769
|
}
|
|
6914
6770
|
function asRouteJsx(node, routeNames) {
|
|
6915
|
-
if (!
|
|
6771
|
+
if (!import_ts_morph29.Node.isJsxSelfClosingElement(node) && !import_ts_morph29.Node.isJsxElement(node)) {
|
|
6916
6772
|
return null;
|
|
6917
6773
|
}
|
|
6918
6774
|
return isRouteJsx(node, routeNames) ? node : null;
|
|
@@ -6922,15 +6778,15 @@ function isRouteJsx(node, routeNames) {
|
|
|
6922
6778
|
return tag !== null && routeNames.has(tag.getText());
|
|
6923
6779
|
}
|
|
6924
6780
|
function tagNameOf(node) {
|
|
6925
|
-
const tag =
|
|
6926
|
-
return
|
|
6781
|
+
const tag = import_ts_morph29.Node.isJsxElement(node) ? node.getOpeningElement().getTagNameNode() : node.getTagNameNode();
|
|
6782
|
+
return import_ts_morph29.Node.isIdentifier(tag) ? tag : null;
|
|
6927
6783
|
}
|
|
6928
6784
|
function attributesOf(node) {
|
|
6929
|
-
return
|
|
6785
|
+
return import_ts_morph29.Node.isJsxElement(node) ? node.getOpeningElement().getAttributes() : node.getAttributes();
|
|
6930
6786
|
}
|
|
6931
6787
|
function attributeValueOf(node, name) {
|
|
6932
6788
|
for (const attribute of attributesOf(node)) {
|
|
6933
|
-
if (!
|
|
6789
|
+
if (!import_ts_morph29.Node.isJsxAttribute(attribute)) {
|
|
6934
6790
|
continue;
|
|
6935
6791
|
}
|
|
6936
6792
|
if (attribute.getNameNode().getText() !== name) {
|
|
@@ -6941,8 +6797,8 @@ function attributeValueOf(node, name) {
|
|
|
6941
6797
|
return null;
|
|
6942
6798
|
}
|
|
6943
6799
|
function literalStringOf2(value) {
|
|
6944
|
-
const unwrapped2 =
|
|
6945
|
-
if (
|
|
6800
|
+
const unwrapped2 = import_ts_morph29.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
|
|
6801
|
+
if (import_ts_morph29.Node.isStringLiteral(unwrapped2) || import_ts_morph29.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
|
|
6946
6802
|
return unwrapped2.getLiteralValue();
|
|
6947
6803
|
}
|
|
6948
6804
|
return null;
|
|
@@ -6962,8 +6818,8 @@ function elementTargetOfValue(value) {
|
|
|
6962
6818
|
if (value === null) {
|
|
6963
6819
|
return { kind: "absent" };
|
|
6964
6820
|
}
|
|
6965
|
-
const unwrapped2 =
|
|
6966
|
-
if (!
|
|
6821
|
+
const unwrapped2 = import_ts_morph29.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
|
|
6822
|
+
if (!import_ts_morph29.Node.isJsxSelfClosingElement(unwrapped2) && !import_ts_morph29.Node.isJsxElement(unwrapped2)) {
|
|
6967
6823
|
return { kind: "unreadable" };
|
|
6968
6824
|
}
|
|
6969
6825
|
const tag = tagNameOf(unwrapped2);
|
|
@@ -6975,7 +6831,7 @@ function elementTargetOfValue(value) {
|
|
|
6975
6831
|
function composedPrefixOf(node, match, routeNames) {
|
|
6976
6832
|
const enclosing = [];
|
|
6977
6833
|
for (const ancestor of node.getAncestors()) {
|
|
6978
|
-
if (
|
|
6834
|
+
if (import_ts_morph29.Node.isJsxElement(ancestor) && isRouteJsx(ancestor, routeNames)) {
|
|
6979
6835
|
enclosing.push(ancestor);
|
|
6980
6836
|
}
|
|
6981
6837
|
}
|
|
@@ -7091,14 +6947,14 @@ function abstention(at, kind, sentence, label) {
|
|
|
7091
6947
|
}
|
|
7092
6948
|
function callsAFactory(call, factoryNames) {
|
|
7093
6949
|
const callee = call.getExpression();
|
|
7094
|
-
return
|
|
6950
|
+
return import_ts_morph29.Node.isIdentifier(callee) && factoryNames.has(callee.getText());
|
|
7095
6951
|
}
|
|
7096
6952
|
function unitsForRouteArray(call, match, elementsNames, kind, resolution) {
|
|
7097
6953
|
const first = call.getArguments()[0];
|
|
7098
6954
|
if (first === void 0) {
|
|
7099
6955
|
return [];
|
|
7100
6956
|
}
|
|
7101
|
-
if (
|
|
6957
|
+
if (import_ts_morph29.Node.isJsxElement(first) || import_ts_morph29.Node.isJsxSelfClosingElement(first) || import_ts_morph29.Node.isCallExpression(first) && callsAFactory(first, elementsNames)) {
|
|
7102
6958
|
return [];
|
|
7103
6959
|
}
|
|
7104
6960
|
const array = arrayLiteralOf(first, resolution);
|
|
@@ -7123,7 +6979,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
|
|
|
7123
6979
|
const nestedIn = new Set(ancestry).add(array);
|
|
7124
6980
|
const results = [];
|
|
7125
6981
|
for (const element of array.getElements()) {
|
|
7126
|
-
if (
|
|
6982
|
+
if (import_ts_morph29.Node.isSpreadElement(element)) {
|
|
7127
6983
|
results.push(
|
|
7128
6984
|
abstention(
|
|
7129
6985
|
element,
|
|
@@ -7134,7 +6990,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
|
|
|
7134
6990
|
);
|
|
7135
6991
|
continue;
|
|
7136
6992
|
}
|
|
7137
|
-
if (!
|
|
6993
|
+
if (!import_ts_morph29.Node.isObjectLiteralExpression(element)) {
|
|
7138
6994
|
results.push(
|
|
7139
6995
|
abstention(
|
|
7140
6996
|
element,
|
|
@@ -7223,7 +7079,7 @@ function ownPathOfObject(object, match) {
|
|
|
7223
7079
|
}
|
|
7224
7080
|
if (match.indexAttribute !== void 0) {
|
|
7225
7081
|
const indexValue = routePropertyOf(object, match.indexAttribute);
|
|
7226
|
-
if (indexValue !== null &&
|
|
7082
|
+
if (indexValue !== null && import_ts_morph29.Node.isTrueLiteral(indexValue)) {
|
|
7227
7083
|
return { kind: "inherited" };
|
|
7228
7084
|
}
|
|
7229
7085
|
}
|
|
@@ -7237,27 +7093,27 @@ function objectLabelOf(target) {
|
|
|
7237
7093
|
return target.kind === "named" ? target.identifier.getText() : "declaration";
|
|
7238
7094
|
}
|
|
7239
7095
|
function labelOfExpression(node) {
|
|
7240
|
-
if (
|
|
7096
|
+
if (import_ts_morph29.Node.isIdentifier(node)) {
|
|
7241
7097
|
return node.getText();
|
|
7242
7098
|
}
|
|
7243
|
-
if (
|
|
7099
|
+
if (import_ts_morph29.Node.isCallExpression(node)) {
|
|
7244
7100
|
return node.getExpression().getText();
|
|
7245
7101
|
}
|
|
7246
7102
|
return node.getKindName();
|
|
7247
7103
|
}
|
|
7248
7104
|
|
|
7249
7105
|
// src/discovery/packageExports.ts
|
|
7250
|
-
var
|
|
7106
|
+
var import_ts_morph31 = require("ts-morph");
|
|
7251
7107
|
|
|
7252
7108
|
// src/packageExports.ts
|
|
7253
7109
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
7254
|
-
var
|
|
7110
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
7255
7111
|
function resolvePackageExports(packageJsonPath, opts = {}) {
|
|
7256
|
-
const absPkgJson =
|
|
7257
|
-
const pkgDir =
|
|
7112
|
+
const absPkgJson = import_node_path4.default.resolve(packageJsonPath);
|
|
7113
|
+
const pkgDir = import_node_path4.default.dirname(absPkgJson);
|
|
7258
7114
|
const raw = import_node_fs2.default.readFileSync(absPkgJson, "utf8");
|
|
7259
7115
|
const pkg = JSON.parse(raw);
|
|
7260
|
-
const packageName = pkg.name ??
|
|
7116
|
+
const packageName = pkg.name ?? import_node_path4.default.basename(pkgDir);
|
|
7261
7117
|
const warnings = [];
|
|
7262
7118
|
const entries = [];
|
|
7263
7119
|
const pushEntry = (subPath, distPath) => {
|
|
@@ -7276,7 +7132,7 @@ function resolvePackageExports(packageJsonPath, opts = {}) {
|
|
|
7276
7132
|
subPath,
|
|
7277
7133
|
exportPathPrefix: subPathToPrefix(subPath),
|
|
7278
7134
|
sourceFile: src,
|
|
7279
|
-
publishedFile:
|
|
7135
|
+
publishedFile: import_node_path4.default.resolve(pkgDir, distPath)
|
|
7280
7136
|
});
|
|
7281
7137
|
};
|
|
7282
7138
|
const exportsField = pkg.exports;
|
|
@@ -7318,12 +7174,12 @@ function resolvePackageExportsCached(packageJsonPath) {
|
|
|
7318
7174
|
return fresh;
|
|
7319
7175
|
}
|
|
7320
7176
|
function namedPackageDirAbove(start) {
|
|
7321
|
-
let at =
|
|
7177
|
+
let at = import_node_path4.default.resolve(start);
|
|
7322
7178
|
for (let up = 0; up < 12; up += 1) {
|
|
7323
7179
|
if (packageNameAt(at) !== null) {
|
|
7324
7180
|
return at;
|
|
7325
7181
|
}
|
|
7326
|
-
const parent =
|
|
7182
|
+
const parent = import_node_path4.default.dirname(at);
|
|
7327
7183
|
if (parent === at) {
|
|
7328
7184
|
break;
|
|
7329
7185
|
}
|
|
@@ -7334,7 +7190,7 @@ function namedPackageDirAbove(start) {
|
|
|
7334
7190
|
function packageNameAt(dir) {
|
|
7335
7191
|
try {
|
|
7336
7192
|
const manifest = JSON.parse(
|
|
7337
|
-
import_node_fs2.default.readFileSync(
|
|
7193
|
+
import_node_fs2.default.readFileSync(import_node_path4.default.join(dir, "package.json"), "utf8")
|
|
7338
7194
|
);
|
|
7339
7195
|
if (typeof manifest.name === "string" && manifest.name.length > 0) {
|
|
7340
7196
|
return manifest.name;
|
|
@@ -7384,7 +7240,7 @@ function resolveSourceFor(pkgDir, distPath, srcRoot) {
|
|
|
7384
7240
|
const stem = withoutDist.replace(/\.d\.ts$/, "").replace(/\.js$/, "").replace(/\.cjs$/, "").replace(/\.mjs$/, "").replace(/\.ts$/, "");
|
|
7385
7241
|
const candidates = [`${stem}.ts`, `${stem}.tsx`];
|
|
7386
7242
|
for (const candidate of candidates) {
|
|
7387
|
-
const abs =
|
|
7243
|
+
const abs = import_node_path4.default.resolve(pkgDir, candidate);
|
|
7388
7244
|
if (import_node_fs2.default.existsSync(abs)) {
|
|
7389
7245
|
return abs;
|
|
7390
7246
|
}
|
|
@@ -7393,20 +7249,20 @@ function resolveSourceFor(pkgDir, distPath, srcRoot) {
|
|
|
7393
7249
|
}
|
|
7394
7250
|
|
|
7395
7251
|
// src/resolve/sourceDeclaration.ts
|
|
7396
|
-
var
|
|
7252
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
7397
7253
|
function sourceDeclarationsBehind(decl, resolution, visited = /* @__PURE__ */ new Set()) {
|
|
7398
7254
|
const file = decl.getSourceFile();
|
|
7399
7255
|
if (!file.isDeclarationFile() || file.isInNodeModules()) {
|
|
7400
7256
|
return [decl];
|
|
7401
7257
|
}
|
|
7402
|
-
const packageDir = namedPackageDirAbove(
|
|
7258
|
+
const packageDir = namedPackageDirAbove(import_node_path5.default.dirname(file.getFilePath()));
|
|
7403
7259
|
if (packageDir === null || visited.has(packageDir)) {
|
|
7404
7260
|
return [decl];
|
|
7405
7261
|
}
|
|
7406
7262
|
visited.add(packageDir);
|
|
7407
7263
|
const project = file.getProject();
|
|
7408
7264
|
const { entries } = resolvePackageExportsCached(
|
|
7409
|
-
|
|
7265
|
+
import_node_path5.default.join(packageDir, "package.json")
|
|
7410
7266
|
);
|
|
7411
7267
|
const found = [];
|
|
7412
7268
|
for (const entry of entries) {
|
|
@@ -7439,13 +7295,13 @@ function sameDeclaration(a, b) {
|
|
|
7439
7295
|
}
|
|
7440
7296
|
|
|
7441
7297
|
// src/discovery/factorySurface.ts
|
|
7442
|
-
var
|
|
7298
|
+
var import_ts_morph30 = require("ts-morph");
|
|
7443
7299
|
var MAX_BUILDER_HOPS = 2;
|
|
7444
7300
|
function surfaceMethods(decl) {
|
|
7445
|
-
if (
|
|
7301
|
+
if (import_ts_morph30.Node.isClassDeclaration(decl)) {
|
|
7446
7302
|
return surfaceClassMethods(decl);
|
|
7447
7303
|
}
|
|
7448
|
-
if (
|
|
7304
|
+
if (import_ts_morph30.Node.isFunctionDeclaration(decl) || import_ts_morph30.Node.isFunctionExpression(decl) || import_ts_morph30.Node.isArrowFunction(decl) || import_ts_morph30.Node.isMethodDeclaration(decl)) {
|
|
7449
7305
|
return surfaceFactoryReturnMethods(decl);
|
|
7450
7306
|
}
|
|
7451
7307
|
return [];
|
|
@@ -7454,7 +7310,7 @@ function surfaceClassMethods(cls) {
|
|
|
7454
7310
|
const out = [];
|
|
7455
7311
|
const seen = /* @__PURE__ */ new Set();
|
|
7456
7312
|
for (const method of cls.getInstanceMethods()) {
|
|
7457
|
-
if (method.hasModifier(
|
|
7313
|
+
if (method.hasModifier(import_ts_morph30.SyntaxKind.PrivateKeyword)) {
|
|
7458
7314
|
continue;
|
|
7459
7315
|
}
|
|
7460
7316
|
const name = method.getName();
|
|
@@ -7465,7 +7321,7 @@ function surfaceClassMethods(cls) {
|
|
|
7465
7321
|
out.push({ func: method, name });
|
|
7466
7322
|
}
|
|
7467
7323
|
for (const method of cls.getStaticMethods()) {
|
|
7468
|
-
if (method.hasModifier(
|
|
7324
|
+
if (method.hasModifier(import_ts_morph30.SyntaxKind.PrivateKeyword)) {
|
|
7469
7325
|
continue;
|
|
7470
7326
|
}
|
|
7471
7327
|
const name = method.getName();
|
|
@@ -7484,9 +7340,9 @@ function surfaceFactoryReturnMethods(fn) {
|
|
|
7484
7340
|
return out;
|
|
7485
7341
|
}
|
|
7486
7342
|
function collectFromFunctionReturns(fn, out, seen, depth) {
|
|
7487
|
-
if (
|
|
7343
|
+
if (import_ts_morph30.Node.isArrowFunction(fn)) {
|
|
7488
7344
|
const body2 = fn.getBody();
|
|
7489
|
-
if (
|
|
7345
|
+
if (import_ts_morph30.Node.isExpression(body2)) {
|
|
7490
7346
|
collectFromReturnValue(body2, out, seen, depth);
|
|
7491
7347
|
return;
|
|
7492
7348
|
}
|
|
@@ -7497,11 +7353,11 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
|
|
|
7497
7353
|
}
|
|
7498
7354
|
const returns = [];
|
|
7499
7355
|
body.forEachDescendant((node, traversal) => {
|
|
7500
|
-
if (
|
|
7356
|
+
if (import_ts_morph30.Node.isFunctionDeclaration(node) || import_ts_morph30.Node.isFunctionExpression(node) || import_ts_morph30.Node.isArrowFunction(node) || import_ts_morph30.Node.isMethodDeclaration(node) || import_ts_morph30.Node.isConstructorDeclaration(node) || import_ts_morph30.Node.isGetAccessorDeclaration(node) || import_ts_morph30.Node.isSetAccessorDeclaration(node)) {
|
|
7501
7357
|
traversal.skip();
|
|
7502
7358
|
return;
|
|
7503
7359
|
}
|
|
7504
|
-
if (
|
|
7360
|
+
if (import_ts_morph30.Node.isReturnStatement(node)) {
|
|
7505
7361
|
returns.push(node);
|
|
7506
7362
|
}
|
|
7507
7363
|
});
|
|
@@ -7515,15 +7371,15 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
|
|
|
7515
7371
|
}
|
|
7516
7372
|
function collectFromReturnValue(node, out, seen, depth) {
|
|
7517
7373
|
const expr = peelParens(node);
|
|
7518
|
-
if (
|
|
7374
|
+
if (import_ts_morph30.Node.isObjectLiteralExpression(expr)) {
|
|
7519
7375
|
collectFromObjectLiteral(expr, out, seen);
|
|
7520
7376
|
return;
|
|
7521
7377
|
}
|
|
7522
|
-
if (depth >= MAX_BUILDER_HOPS || !
|
|
7378
|
+
if (depth >= MAX_BUILDER_HOPS || !import_ts_morph30.Node.isCallExpression(expr)) {
|
|
7523
7379
|
return;
|
|
7524
7380
|
}
|
|
7525
7381
|
const callee = expr.getExpression();
|
|
7526
|
-
if (!
|
|
7382
|
+
if (!import_ts_morph30.Node.isIdentifier(callee)) {
|
|
7527
7383
|
return;
|
|
7528
7384
|
}
|
|
7529
7385
|
const helper = sameFileFunctionBehind(callee);
|
|
@@ -7546,12 +7402,12 @@ function functionAmong(declarations, filePath) {
|
|
|
7546
7402
|
if (decl.getSourceFile().getFilePath() !== filePath) {
|
|
7547
7403
|
continue;
|
|
7548
7404
|
}
|
|
7549
|
-
if (
|
|
7405
|
+
if (import_ts_morph30.Node.isFunctionDeclaration(decl)) {
|
|
7550
7406
|
return decl;
|
|
7551
7407
|
}
|
|
7552
|
-
if (
|
|
7408
|
+
if (import_ts_morph30.Node.isVariableDeclaration(decl)) {
|
|
7553
7409
|
const init = decl.getInitializer();
|
|
7554
|
-
if (init !== void 0 && (
|
|
7410
|
+
if (init !== void 0 && (import_ts_morph30.Node.isArrowFunction(init) || import_ts_morph30.Node.isFunctionExpression(init))) {
|
|
7555
7411
|
return init;
|
|
7556
7412
|
}
|
|
7557
7413
|
}
|
|
@@ -7560,11 +7416,11 @@ function functionAmong(declarations, filePath) {
|
|
|
7560
7416
|
}
|
|
7561
7417
|
function collectFromObjectLiteral(node, out, seen) {
|
|
7562
7418
|
const e = peelParens(node);
|
|
7563
|
-
if (!
|
|
7419
|
+
if (!import_ts_morph30.Node.isObjectLiteralExpression(e)) {
|
|
7564
7420
|
return;
|
|
7565
7421
|
}
|
|
7566
7422
|
for (const prop of e.getProperties()) {
|
|
7567
|
-
if (
|
|
7423
|
+
if (import_ts_morph30.Node.isMethodDeclaration(prop)) {
|
|
7568
7424
|
const name = prop.getName();
|
|
7569
7425
|
if (seen.has(name)) {
|
|
7570
7426
|
continue;
|
|
@@ -7573,16 +7429,16 @@ function collectFromObjectLiteral(node, out, seen) {
|
|
|
7573
7429
|
out.push({ func: prop, name });
|
|
7574
7430
|
continue;
|
|
7575
7431
|
}
|
|
7576
|
-
if (
|
|
7432
|
+
if (import_ts_morph30.Node.isPropertyAssignment(prop)) {
|
|
7577
7433
|
const init = prop.getInitializer();
|
|
7578
7434
|
if (init === void 0) {
|
|
7579
7435
|
continue;
|
|
7580
7436
|
}
|
|
7581
7437
|
let v3 = init;
|
|
7582
|
-
while (
|
|
7438
|
+
while (import_ts_morph30.Node.isParenthesizedExpression(v3)) {
|
|
7583
7439
|
v3 = v3.getExpression();
|
|
7584
7440
|
}
|
|
7585
|
-
if (
|
|
7441
|
+
if (import_ts_morph30.Node.isArrowFunction(v3) || import_ts_morph30.Node.isFunctionExpression(v3)) {
|
|
7586
7442
|
const name = prop.getName();
|
|
7587
7443
|
if (seen.has(name)) {
|
|
7588
7444
|
continue;
|
|
@@ -7591,7 +7447,7 @@ function collectFromObjectLiteral(node, out, seen) {
|
|
|
7591
7447
|
out.push({ func: v3, name });
|
|
7592
7448
|
}
|
|
7593
7449
|
}
|
|
7594
|
-
if (
|
|
7450
|
+
if (import_ts_morph30.Node.isShorthandPropertyAssignment(prop)) {
|
|
7595
7451
|
collectShorthandFunction(prop, out, seen);
|
|
7596
7452
|
}
|
|
7597
7453
|
}
|
|
@@ -7654,9 +7510,9 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
|
|
|
7654
7510
|
(decl) => sourceDeclarationsBehind(decl, resolution)
|
|
7655
7511
|
);
|
|
7656
7512
|
for (const decl of candidates) {
|
|
7657
|
-
if (
|
|
7513
|
+
if (import_ts_morph31.Node.isVariableDeclaration(decl)) {
|
|
7658
7514
|
const init = decl.getInitializer();
|
|
7659
|
-
if (init !== void 0 && (
|
|
7515
|
+
if (init !== void 0 && (import_ts_morph31.Node.isArrowFunction(init) || import_ts_morph31.Node.isFunctionExpression(init))) {
|
|
7660
7516
|
results.push(buildUnit(init, kind, exportName, entry));
|
|
7661
7517
|
for (const m of surfaceMethods(init)) {
|
|
7662
7518
|
results.push(buildSurfacedUnit(m, kind, exportName, entry));
|
|
@@ -7666,7 +7522,7 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
|
|
|
7666
7522
|
}
|
|
7667
7523
|
continue;
|
|
7668
7524
|
}
|
|
7669
|
-
if (
|
|
7525
|
+
if (import_ts_morph31.Node.isClassDeclaration(decl)) {
|
|
7670
7526
|
for (const m of surfaceMethods(decl)) {
|
|
7671
7527
|
results.push(buildSurfacedUnit(m, kind, exportName, entry));
|
|
7672
7528
|
}
|
|
@@ -7711,7 +7567,7 @@ function buildSurfacedUnit(m, kind, parentExportName, entry) {
|
|
|
7711
7567
|
}
|
|
7712
7568
|
|
|
7713
7569
|
// src/discovery/packageImport.ts
|
|
7714
|
-
var
|
|
7570
|
+
var import_ts_morph32 = require("ts-morph");
|
|
7715
7571
|
function isLanguageLib(file) {
|
|
7716
7572
|
return /[\\/]typescript[\\/]lib[\\/]lib\..*\.d\.ts$/.test(file.getFilePath());
|
|
7717
7573
|
}
|
|
@@ -7732,13 +7588,13 @@ function splitPackageSpec(spec) {
|
|
|
7732
7588
|
};
|
|
7733
7589
|
}
|
|
7734
7590
|
function enclosingFunctionName(func) {
|
|
7735
|
-
if (
|
|
7591
|
+
if (import_ts_morph32.Node.isFunctionDeclaration(func) || import_ts_morph32.Node.isMethodDeclaration(func)) {
|
|
7736
7592
|
const n = func.getName?.();
|
|
7737
7593
|
if (typeof n === "string" && n.length > 0) {
|
|
7738
7594
|
return n;
|
|
7739
7595
|
}
|
|
7740
7596
|
}
|
|
7741
|
-
if (
|
|
7597
|
+
if (import_ts_morph32.Node.isFunctionExpression(func)) {
|
|
7742
7598
|
const n = func.getName();
|
|
7743
7599
|
if (typeof n === "string" && n.length > 0) {
|
|
7744
7600
|
return n;
|
|
@@ -7746,10 +7602,10 @@ function enclosingFunctionName(func) {
|
|
|
7746
7602
|
}
|
|
7747
7603
|
const parent = func.getParent();
|
|
7748
7604
|
if (parent !== void 0) {
|
|
7749
|
-
if (
|
|
7605
|
+
if (import_ts_morph32.Node.isVariableDeclaration(parent)) {
|
|
7750
7606
|
return parent.getName();
|
|
7751
7607
|
}
|
|
7752
|
-
if (
|
|
7608
|
+
if (import_ts_morph32.Node.isPropertyAssignment(parent)) {
|
|
7753
7609
|
return parent.getName();
|
|
7754
7610
|
}
|
|
7755
7611
|
}
|
|
@@ -7768,7 +7624,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7768
7624
|
const calls = [];
|
|
7769
7625
|
const candidates = /* @__PURE__ */ new Set();
|
|
7770
7626
|
sourceFile.forEachDescendant((node) => {
|
|
7771
|
-
if (!
|
|
7627
|
+
if (!import_ts_morph32.Node.isCallExpression(node)) {
|
|
7772
7628
|
return;
|
|
7773
7629
|
}
|
|
7774
7630
|
calls.push(node);
|
|
@@ -7776,7 +7632,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7776
7632
|
if (couldBePackageLinked(callee, packages)) {
|
|
7777
7633
|
candidates.add(callee);
|
|
7778
7634
|
}
|
|
7779
|
-
if (
|
|
7635
|
+
if (import_ts_morph32.Node.isPropertyAccessExpression(callee) && couldBePackageLinked(callee.getExpression(), packages)) {
|
|
7780
7636
|
candidates.add(callee.getExpression());
|
|
7781
7637
|
}
|
|
7782
7638
|
});
|
|
@@ -7798,7 +7654,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7798
7654
|
if (direct !== null) {
|
|
7799
7655
|
return direct;
|
|
7800
7656
|
}
|
|
7801
|
-
if (!
|
|
7657
|
+
if (!import_ts_morph32.Node.isPropertyAccessExpression(callee)) {
|
|
7802
7658
|
return null;
|
|
7803
7659
|
}
|
|
7804
7660
|
const subject = originOf(callee.getExpression());
|
|
@@ -7823,7 +7679,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7823
7679
|
return results;
|
|
7824
7680
|
}
|
|
7825
7681
|
function couldBePackageLinked(value, packages) {
|
|
7826
|
-
if (!
|
|
7682
|
+
if (!import_ts_morph32.Node.isIdentifier(value)) {
|
|
7827
7683
|
return true;
|
|
7828
7684
|
}
|
|
7829
7685
|
const declarations = value.getSymbol()?.getDeclarations() ?? [];
|
|
@@ -7831,7 +7687,7 @@ function couldBePackageLinked(value, packages) {
|
|
|
7831
7687
|
return true;
|
|
7832
7688
|
}
|
|
7833
7689
|
return !declarations.every(
|
|
7834
|
-
(declaration) =>
|
|
7690
|
+
(declaration) => import_ts_morph32.Node.isFunctionDeclaration(declaration) || import_ts_morph32.Node.isMethodDeclaration(declaration) || import_ts_morph32.Node.isClassDeclaration(declaration) || import_ts_morph32.Node.isImportSpecifier(declaration) && importAimsElsewhere(declaration, packages)
|
|
7835
7691
|
);
|
|
7836
7692
|
}
|
|
7837
7693
|
function importAimsElsewhere(declaration, packages) {
|
|
@@ -7884,7 +7740,7 @@ function discoverPackageImports(sourceFile, match, kind, resolution) {
|
|
|
7884
7740
|
}
|
|
7885
7741
|
|
|
7886
7742
|
// src/discovery/registrationCall.ts
|
|
7887
|
-
var
|
|
7743
|
+
var import_ts_morph35 = require("ts-morph");
|
|
7888
7744
|
var import_resolution3 = require("@suss/resolution");
|
|
7889
7745
|
|
|
7890
7746
|
// src/resolve/routePath.ts
|
|
@@ -7892,35 +7748,169 @@ var import_values4 = require("@suss/values");
|
|
|
7892
7748
|
function pathFromArgument(arg, resolution) {
|
|
7893
7749
|
return (0, import_values4.pathOf)(evaluatedValue(arg, resolution));
|
|
7894
7750
|
}
|
|
7751
|
+
function pathFromProperty(arg, property, resolution) {
|
|
7752
|
+
const record2 = evaluatedValue(arg, resolution);
|
|
7753
|
+
if (record2.kind !== "record") {
|
|
7754
|
+
return void 0;
|
|
7755
|
+
}
|
|
7756
|
+
const field = record2.fields.get(property);
|
|
7757
|
+
return field === void 0 ? void 0 : (0, import_values4.pathOf)((0, import_values4.force)(field.value));
|
|
7758
|
+
}
|
|
7895
7759
|
|
|
7896
|
-
// src/discovery/
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7760
|
+
// src/discovery/wrapperFactory.ts
|
|
7761
|
+
var import_ts_morph34 = require("ts-morph");
|
|
7762
|
+
|
|
7763
|
+
// src/resolve/unfollowedCall.ts
|
|
7764
|
+
var import_ts_morph33 = require("ts-morph");
|
|
7765
|
+
var import_behavioral_ir2 = require("@suss/behavioral-ir");
|
|
7766
|
+
function isInExternalCode(sourceFile) {
|
|
7767
|
+
if (sourceFile.isDeclarationFile()) {
|
|
7768
|
+
return true;
|
|
7769
|
+
}
|
|
7770
|
+
return sourceFile.getFilePath().includes("/node_modules/");
|
|
7771
|
+
}
|
|
7772
|
+
function hasBody(fn) {
|
|
7773
|
+
if (import_ts_morph33.Node.isFunctionDeclaration(fn) || import_ts_morph33.Node.isMethodDeclaration(fn) || import_ts_morph33.Node.isFunctionExpression(fn)) {
|
|
7774
|
+
return fn.getBody?.() !== void 0;
|
|
7775
|
+
}
|
|
7776
|
+
return true;
|
|
7777
|
+
}
|
|
7778
|
+
function isDeclaredShape(declaration) {
|
|
7779
|
+
return (import_ts_morph33.Node.isMethodSignature(declaration) || import_ts_morph33.Node.isPropertySignature(declaration)) && !isInExternalCode(declaration.getSourceFile());
|
|
7780
|
+
}
|
|
7781
|
+
function isExternalDeclaration(declaration) {
|
|
7782
|
+
if (isInExternalCode(declaration.getSourceFile())) {
|
|
7783
|
+
return true;
|
|
7784
|
+
}
|
|
7785
|
+
if (import_ts_morph33.Node.isImportSpecifier(declaration) || import_ts_morph33.Node.isImportClause(declaration) || import_ts_morph33.Node.isNamespaceImport(declaration)) {
|
|
7786
|
+
const target = declaration.getFirstAncestorByKind(import_ts_morph33.SyntaxKind.ImportDeclaration)?.getModuleSpecifierSourceFile();
|
|
7787
|
+
return target === void 0 || isInExternalCode(target);
|
|
7788
|
+
}
|
|
7789
|
+
return declaresAnotherModule(declaration);
|
|
7790
|
+
}
|
|
7791
|
+
function declaresAnotherModule(declaration) {
|
|
7792
|
+
const module2 = declaration.getFirstAncestorByKind(
|
|
7793
|
+
import_ts_morph33.SyntaxKind.ModuleDeclaration
|
|
7907
7794
|
);
|
|
7908
|
-
|
|
7909
|
-
|
|
7795
|
+
return module2 !== void 0 && import_ts_morph33.Node.isStringLiteral(module2.getNameNode());
|
|
7796
|
+
}
|
|
7797
|
+
function statesShapeOnly(declaration) {
|
|
7798
|
+
if (isExternalDeclaration(declaration)) {
|
|
7799
|
+
return false;
|
|
7910
7800
|
}
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7801
|
+
if (import_ts_morph33.Node.isMethodSignature(declaration) || import_ts_morph33.Node.isPropertySignature(declaration)) {
|
|
7802
|
+
return true;
|
|
7803
|
+
}
|
|
7804
|
+
if (import_ts_morph33.Node.isFunctionDeclaration(declaration) || import_ts_morph33.Node.isMethodDeclaration(declaration)) {
|
|
7805
|
+
return declaration.getBody() === void 0;
|
|
7806
|
+
}
|
|
7807
|
+
return false;
|
|
7808
|
+
}
|
|
7809
|
+
function declarationsBehind(symbol) {
|
|
7810
|
+
if (symbol === void 0) {
|
|
7811
|
+
return [];
|
|
7812
|
+
}
|
|
7813
|
+
const behind = symbol.getAliasedSymbol()?.getDeclarations() ?? [];
|
|
7814
|
+
return behind.length > 0 ? behind : symbol.getDeclarations();
|
|
7815
|
+
}
|
|
7816
|
+
function isParameterOf(declaration, scanning) {
|
|
7817
|
+
return import_ts_morph33.Node.isParameterDeclaration(declaration) && declaration.getParent() === scanning;
|
|
7818
|
+
}
|
|
7819
|
+
function parameterIndexOf(declarations, scanning) {
|
|
7820
|
+
if (scanning === void 0) {
|
|
7821
|
+
return void 0;
|
|
7822
|
+
}
|
|
7823
|
+
const params = scanning.getParameters();
|
|
7824
|
+
for (const declaration of declarations) {
|
|
7825
|
+
const index = params.findIndex((param) => param === declaration);
|
|
7826
|
+
if (index !== -1) {
|
|
7827
|
+
return index;
|
|
7828
|
+
}
|
|
7829
|
+
}
|
|
7830
|
+
return void 0;
|
|
7831
|
+
}
|
|
7832
|
+
function classifyStop(declarations, scanning) {
|
|
7833
|
+
if (declarations.length === 0) {
|
|
7834
|
+
return "noDeclaration";
|
|
7835
|
+
}
|
|
7836
|
+
for (const declaration of declarations) {
|
|
7837
|
+
if (!isInExternalCode(declaration.getSourceFile())) {
|
|
7838
|
+
recordFileDependency(declaration.getSourceFile().getFilePath());
|
|
7839
|
+
}
|
|
7840
|
+
}
|
|
7841
|
+
if (scanning !== void 0 && declarations.some((declaration) => isParameterOf(declaration, scanning))) {
|
|
7842
|
+
return "callerSupplied";
|
|
7843
|
+
}
|
|
7844
|
+
if (declarations.every(isExternalDeclaration)) {
|
|
7845
|
+
return "outsideRun";
|
|
7846
|
+
}
|
|
7847
|
+
if (declarations.some(statesShapeOnly)) {
|
|
7848
|
+
return "noBody";
|
|
7849
|
+
}
|
|
7850
|
+
return "unsettledValue";
|
|
7851
|
+
}
|
|
7852
|
+
|
|
7853
|
+
// src/discovery/wrapperFactory.ts
|
|
7854
|
+
function factoryNameOf(targetArg) {
|
|
7855
|
+
const written = factKeyOf(targetArg);
|
|
7856
|
+
if (!import_ts_morph34.Node.isCallExpression(written)) {
|
|
7857
|
+
return void 0;
|
|
7858
|
+
}
|
|
7859
|
+
const callee = written.getExpression();
|
|
7860
|
+
if (import_ts_morph34.Node.isIdentifier(callee)) {
|
|
7861
|
+
return callee.getText();
|
|
7862
|
+
}
|
|
7863
|
+
if (import_ts_morph34.Node.isPropertyAccessExpression(callee)) {
|
|
7864
|
+
return callee.getName();
|
|
7865
|
+
}
|
|
7866
|
+
return void 0;
|
|
7867
|
+
}
|
|
7868
|
+
function factoryStopOf(targetArg) {
|
|
7869
|
+
const written = factKeyOf(targetArg);
|
|
7870
|
+
if (!import_ts_morph34.Node.isCallExpression(written)) {
|
|
7871
|
+
return null;
|
|
7872
|
+
}
|
|
7873
|
+
const callee = factoryNameOf(targetArg);
|
|
7874
|
+
if (callee === void 0) {
|
|
7875
|
+
return null;
|
|
7876
|
+
}
|
|
7877
|
+
const reason = classifyStop(
|
|
7878
|
+
declarationsBehind(written.getExpression().getSymbol())
|
|
7879
|
+
);
|
|
7880
|
+
if (!(0, import_behavioral_ir2.worthRecording)(reason)) {
|
|
7881
|
+
return null;
|
|
7882
|
+
}
|
|
7883
|
+
return { callee, reason: "unresolvedWrapper" };
|
|
7884
|
+
}
|
|
7885
|
+
|
|
7886
|
+
// src/discovery/registrationCall.ts
|
|
7887
|
+
function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, resolution, mountPrefixes, expandedElsewhere, routeWrapperPattern) {
|
|
7888
|
+
const results = [];
|
|
7889
|
+
const registrationSubjects = registrationSubjectsOf(
|
|
7890
|
+
sourceFile,
|
|
7891
|
+
match.importModule,
|
|
7892
|
+
match.importName,
|
|
7893
|
+
resolution
|
|
7894
|
+
);
|
|
7895
|
+
const registrationMethods = match.registrationChain.map(
|
|
7896
|
+
(c) => c.startsWith(".") ? c.slice(1) : c
|
|
7897
|
+
);
|
|
7898
|
+
if (registrationSubjects.size === 0 && !storeCanFindSubjects(sourceFile, match, resolution, registrationMethods)) {
|
|
7899
|
+
return results;
|
|
7900
|
+
}
|
|
7901
|
+
sourceFile.forEachDescendant((node) => {
|
|
7902
|
+
if (!import_ts_morph35.Node.isCallExpression(node)) {
|
|
7903
|
+
return;
|
|
7904
|
+
}
|
|
7905
|
+
const callee = node.getExpression();
|
|
7906
|
+
if (!import_ts_morph35.Node.isPropertyAccessExpression(callee)) {
|
|
7907
|
+
return;
|
|
7908
|
+
}
|
|
7909
|
+
const methodName = callee.getName();
|
|
7910
|
+
if (!registrationMethods.includes(methodName)) {
|
|
7911
|
+
return;
|
|
7912
|
+
}
|
|
7913
|
+
if (expandedAtCallSites(node, methodName, expandedElsewhere)) {
|
|
7924
7914
|
return;
|
|
7925
7915
|
}
|
|
7926
7916
|
const receiver = receiverOf(
|
|
@@ -7950,12 +7940,12 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7950
7940
|
const registrationSubjectId = nodeId(subjectNode);
|
|
7951
7941
|
let foundObjectArg = false;
|
|
7952
7942
|
for (const arg of args) {
|
|
7953
|
-
if (!
|
|
7943
|
+
if (!import_ts_morph35.Node.isObjectLiteralExpression(arg)) {
|
|
7954
7944
|
continue;
|
|
7955
7945
|
}
|
|
7956
7946
|
foundObjectArg = true;
|
|
7957
7947
|
for (const prop of arg.getProperties()) {
|
|
7958
|
-
if (
|
|
7948
|
+
if (import_ts_morph35.Node.isMethodDeclaration(prop)) {
|
|
7959
7949
|
results.push({
|
|
7960
7950
|
func: prop,
|
|
7961
7951
|
kind,
|
|
@@ -7964,7 +7954,7 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7964
7954
|
});
|
|
7965
7955
|
continue;
|
|
7966
7956
|
}
|
|
7967
|
-
if (!
|
|
7957
|
+
if (!import_ts_morph35.Node.isPropertyAssignment(prop)) {
|
|
7968
7958
|
continue;
|
|
7969
7959
|
}
|
|
7970
7960
|
const propInit = prop.getInitializer();
|
|
@@ -7996,6 +7986,13 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7996
7986
|
mountPrefixes
|
|
7997
7987
|
);
|
|
7998
7988
|
if (handler !== null) {
|
|
7989
|
+
const chain = routeWrapperPattern === void 0 ? null : routeChainOf(
|
|
7990
|
+
args.slice(0, -1),
|
|
7991
|
+
routeWrapperPattern,
|
|
7992
|
+
methodName,
|
|
7993
|
+
routeInfo,
|
|
7994
|
+
resolution
|
|
7995
|
+
);
|
|
7999
7996
|
results.push({
|
|
8000
7997
|
func: handler,
|
|
8001
7998
|
kind,
|
|
@@ -8003,8 +8000,13 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
8003
8000
|
name: methodName,
|
|
8004
8001
|
nameKind: "label",
|
|
8005
8002
|
registrationSubjectId,
|
|
8006
|
-
...routeInfo !== null ? { routeInfo } : {}
|
|
8003
|
+
...routeInfo !== null ? { routeInfo } : {},
|
|
8004
|
+
...chain === null || chain.references.length === 0 ? {} : { routeWrappers: chain.references },
|
|
8005
|
+
...chain === null || chain.unfollowed.length === 0 ? {} : { routeUnfollowed: chain.unfollowed }
|
|
8007
8006
|
});
|
|
8007
|
+
if (chain !== null) {
|
|
8008
|
+
results.push(...chain.units);
|
|
8009
|
+
}
|
|
8008
8010
|
return;
|
|
8009
8011
|
}
|
|
8010
8012
|
if (routeInfo !== null && lastArg !== void 0 && namesAParameter(lastArg)) {
|
|
@@ -8050,6 +8052,47 @@ function declinedRegistration(call, callee, methodName, kind, receiver, resoluti
|
|
|
8050
8052
|
}
|
|
8051
8053
|
];
|
|
8052
8054
|
}
|
|
8055
|
+
function routeChainOf(listed, pattern, methodName, routeInfo, resolution) {
|
|
8056
|
+
const chain = { units: [], references: [], unfollowed: [] };
|
|
8057
|
+
const anonymousLabels = /* @__PURE__ */ new Map();
|
|
8058
|
+
for (const arg of listed) {
|
|
8059
|
+
const elements = import_ts_morph35.Node.isArrayLiteralExpression(arg) ? arg.getElements() : [arg];
|
|
8060
|
+
for (const element of elements) {
|
|
8061
|
+
const target = functionValueOf(element, resolution);
|
|
8062
|
+
if (target === null) {
|
|
8063
|
+
const stop = factoryStopOf(element);
|
|
8064
|
+
if (stop !== null) {
|
|
8065
|
+
chain.unfollowed.push(stop);
|
|
8066
|
+
}
|
|
8067
|
+
continue;
|
|
8068
|
+
}
|
|
8069
|
+
const ownName = functionNameOrAnon(target);
|
|
8070
|
+
const named2 = ownName !== "<anon>";
|
|
8071
|
+
const label = factoryNameOf(element) ?? methodName;
|
|
8072
|
+
const seen = anonymousLabels.get(label) ?? 0;
|
|
8073
|
+
if (!named2) {
|
|
8074
|
+
anonymousLabels.set(label, seen + 1);
|
|
8075
|
+
}
|
|
8076
|
+
const name = named2 ? ownName : routeWrapperLabel(label, routeInfo, element, seen);
|
|
8077
|
+
chain.units.push({
|
|
8078
|
+
func: target,
|
|
8079
|
+
kind: pattern.kind,
|
|
8080
|
+
name,
|
|
8081
|
+
pattern,
|
|
8082
|
+
...named2 ? {} : { nameKind: "label" }
|
|
8083
|
+
});
|
|
8084
|
+
chain.references.push({
|
|
8085
|
+
file: target.getSourceFile().getFilePath(),
|
|
8086
|
+
name
|
|
8087
|
+
});
|
|
8088
|
+
}
|
|
8089
|
+
}
|
|
8090
|
+
return chain;
|
|
8091
|
+
}
|
|
8092
|
+
function routeWrapperLabel(label, routeInfo, element, seen) {
|
|
8093
|
+
const where = routeInfo === null ? `L${element.getStartLineNumber()}` : `${routeInfo.method} ${routeInfo.path}`;
|
|
8094
|
+
return seen === 0 ? `${label}@${where}` : `${label}@${where}#${seen + 1}`;
|
|
8095
|
+
}
|
|
8053
8096
|
function withMountPrefix(routeInfo, subjectNode, mountPrefixes) {
|
|
8054
8097
|
if (routeInfo === null || mountPrefixes === void 0) {
|
|
8055
8098
|
return routeInfo;
|
|
@@ -8077,13 +8120,13 @@ function subjectNodeFor(subject, subjects, match, resolution) {
|
|
|
8077
8120
|
}
|
|
8078
8121
|
var NOT_A_ROUTABLE = { kind: "none" };
|
|
8079
8122
|
function receiverOf(subject, subjects, match, resolution) {
|
|
8080
|
-
if (
|
|
8123
|
+
if (import_ts_morph35.Node.isIdentifier(subject)) {
|
|
8081
8124
|
const known = subjects.get(subject.getText());
|
|
8082
8125
|
if (known !== void 0) {
|
|
8083
8126
|
return { kind: "routable", node: known };
|
|
8084
8127
|
}
|
|
8085
8128
|
}
|
|
8086
|
-
if (resolution === void 0 || !(
|
|
8129
|
+
if (resolution === void 0 || !(import_ts_morph35.Node.isIdentifier(subject) || import_ts_morph35.Node.isPropertyAccessExpression(subject))) {
|
|
8087
8130
|
return NOT_A_ROUTABLE;
|
|
8088
8131
|
}
|
|
8089
8132
|
const construction = resolution.subjectConstructionOf(
|
|
@@ -8123,18 +8166,18 @@ function collectMethodsCalledOnCallResults(sourceFile) {
|
|
|
8123
8166
|
const setToCalls = /* @__PURE__ */ new Set();
|
|
8124
8167
|
const calledOn = /* @__PURE__ */ new Map();
|
|
8125
8168
|
sourceFile.forEachDescendant((node) => {
|
|
8126
|
-
if (
|
|
8169
|
+
if (import_ts_morph35.Node.isVariableDeclaration(node)) {
|
|
8127
8170
|
const init = node.getInitializer();
|
|
8128
|
-
if (init !== void 0 &&
|
|
8171
|
+
if (init !== void 0 && import_ts_morph35.Node.isCallExpression(init)) {
|
|
8129
8172
|
setToCalls.add(node.getName());
|
|
8130
8173
|
}
|
|
8131
8174
|
return;
|
|
8132
8175
|
}
|
|
8133
|
-
if (!
|
|
8176
|
+
if (!import_ts_morph35.Node.isCallExpression(node)) {
|
|
8134
8177
|
return;
|
|
8135
8178
|
}
|
|
8136
8179
|
const callee = node.getExpression();
|
|
8137
|
-
if (!
|
|
8180
|
+
if (!import_ts_morph35.Node.isPropertyAccessExpression(callee) || !import_ts_morph35.Node.isIdentifier(callee.getExpression())) {
|
|
8138
8181
|
return;
|
|
8139
8182
|
}
|
|
8140
8183
|
const receiver = callee.getExpression().getText();
|
|
@@ -8161,18 +8204,18 @@ function registrationSubjectsOf(sourceFile, importModule, importName, resolution
|
|
|
8161
8204
|
return subjects;
|
|
8162
8205
|
}
|
|
8163
8206
|
sourceFile.forEachDescendant((node) => {
|
|
8164
|
-
if (
|
|
8207
|
+
if (import_ts_morph35.Node.isVariableDeclaration(node)) {
|
|
8165
8208
|
const init = node.getInitializer();
|
|
8166
8209
|
if (init === void 0) {
|
|
8167
8210
|
return;
|
|
8168
8211
|
}
|
|
8169
|
-
const calleeText =
|
|
8212
|
+
const calleeText = import_ts_morph35.Node.isCallExpression(init) || import_ts_morph35.Node.isNewExpression(init) ? init.getExpression().getText() : null;
|
|
8170
8213
|
if (calleeText !== null && spellings.includes(calleeText)) {
|
|
8171
8214
|
subjects.set(node.getName(), init);
|
|
8172
8215
|
}
|
|
8173
8216
|
return;
|
|
8174
8217
|
}
|
|
8175
|
-
if (!
|
|
8218
|
+
if (!import_ts_morph35.Node.isParameterDeclaration(node)) {
|
|
8176
8219
|
return;
|
|
8177
8220
|
}
|
|
8178
8221
|
const typeNode = node.getTypeNode();
|
|
@@ -8193,7 +8236,7 @@ function creationSiteBehind(parameter, resolution) {
|
|
|
8193
8236
|
return parameter;
|
|
8194
8237
|
}
|
|
8195
8238
|
const written = resolution.resolveWrittenValue(parameter);
|
|
8196
|
-
if (written === null || !(
|
|
8239
|
+
if (written === null || !(import_ts_morph35.Node.isCallExpression(written) || import_ts_morph35.Node.isNewExpression(written))) {
|
|
8197
8240
|
return parameter;
|
|
8198
8241
|
}
|
|
8199
8242
|
return written;
|
|
@@ -8236,7 +8279,7 @@ function unboundConstructionsOf(sourceFile, importModule, importName) {
|
|
|
8236
8279
|
}
|
|
8237
8280
|
const constructions = [];
|
|
8238
8281
|
sourceFile.forEachDescendant((node) => {
|
|
8239
|
-
if ((
|
|
8282
|
+
if ((import_ts_morph35.Node.isCallExpression(node) || import_ts_morph35.Node.isNewExpression(node)) && spellings.includes(node.getExpression().getText()) && !import_ts_morph35.Node.isVariableDeclaration(node.getParent())) {
|
|
8240
8283
|
constructions.push(node);
|
|
8241
8284
|
}
|
|
8242
8285
|
});
|
|
@@ -8254,11 +8297,11 @@ function discoverMountEdges(sourceFile, match, mount, knownSubjectIds, resolutio
|
|
|
8254
8297
|
}
|
|
8255
8298
|
const edges = [];
|
|
8256
8299
|
sourceFile.forEachDescendant((node) => {
|
|
8257
|
-
if (!
|
|
8300
|
+
if (!import_ts_morph35.Node.isCallExpression(node)) {
|
|
8258
8301
|
return;
|
|
8259
8302
|
}
|
|
8260
8303
|
const callee = node.getExpression();
|
|
8261
|
-
if (!
|
|
8304
|
+
if (!import_ts_morph35.Node.isPropertyAccessExpression(callee) || callee.getName() !== mount.method) {
|
|
8262
8305
|
return;
|
|
8263
8306
|
}
|
|
8264
8307
|
const subjectNode = subjectNodeFor(
|
|
@@ -8272,7 +8315,7 @@ function discoverMountEdges(sourceFile, match, mount, knownSubjectIds, resolutio
|
|
|
8272
8315
|
}
|
|
8273
8316
|
const args = node.getArguments();
|
|
8274
8317
|
const prefixArg = args[mount.prefixPosition];
|
|
8275
|
-
if (prefixArg === void 0 || !(
|
|
8318
|
+
if (prefixArg === void 0 || !(import_ts_morph35.Node.isStringLiteral(prefixArg) || import_ts_morph35.Node.isNoSubstitutionTemplateLiteral(prefixArg))) {
|
|
8276
8319
|
return;
|
|
8277
8320
|
}
|
|
8278
8321
|
const targetNodes = mountTargetsAmong(
|
|
@@ -8327,7 +8370,7 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8327
8370
|
} else {
|
|
8328
8371
|
const args = call.getArguments();
|
|
8329
8372
|
const arg = args[binding.method.position];
|
|
8330
|
-
if (arg === void 0 || !(
|
|
8373
|
+
if (arg === void 0 || !(import_ts_morph35.Node.isStringLiteral(arg) || import_ts_morph35.Node.isNoSubstitutionTemplateLiteral(arg))) {
|
|
8331
8374
|
return null;
|
|
8332
8375
|
}
|
|
8333
8376
|
method = arg.getLiteralValue().toUpperCase();
|
|
@@ -8338,7 +8381,7 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8338
8381
|
}
|
|
8339
8382
|
|
|
8340
8383
|
// src/discovery/registrationLoop.ts
|
|
8341
|
-
var
|
|
8384
|
+
var import_ts_morph36 = require("ts-morph");
|
|
8342
8385
|
function discoverRegistrationLoops(sourceFile, match, kind, resolution) {
|
|
8343
8386
|
const results = [];
|
|
8344
8387
|
const guard = receiverGuard(sourceFile, match.receiver, resolution);
|
|
@@ -8346,7 +8389,7 @@ function discoverRegistrationLoops(sourceFile, match, kind, resolution) {
|
|
|
8346
8389
|
return results;
|
|
8347
8390
|
}
|
|
8348
8391
|
sourceFile.forEachDescendant((node) => {
|
|
8349
|
-
if (!
|
|
8392
|
+
if (!import_ts_morph36.Node.isForOfStatement(node)) {
|
|
8350
8393
|
return;
|
|
8351
8394
|
}
|
|
8352
8395
|
const expanded = tryExpandLoop(node, match, kind, resolution, guard);
|
|
@@ -8409,13 +8452,13 @@ function tryExpandLoop(loop, match, kind, resolution, guard) {
|
|
|
8409
8452
|
}
|
|
8410
8453
|
function loopVariableName(loop) {
|
|
8411
8454
|
const initializer = loop.getInitializer();
|
|
8412
|
-
if (
|
|
8455
|
+
if (import_ts_morph36.Node.isVariableDeclarationList(initializer)) {
|
|
8413
8456
|
const decls = initializer.getDeclarations();
|
|
8414
8457
|
if (decls.length !== 1) {
|
|
8415
8458
|
return null;
|
|
8416
8459
|
}
|
|
8417
8460
|
const nameNode = decls[0]?.getNameNode();
|
|
8418
|
-
if (nameNode !== void 0 &&
|
|
8461
|
+
if (nameNode !== void 0 && import_ts_morph36.Node.isIdentifier(nameNode)) {
|
|
8419
8462
|
return nameNode.getText();
|
|
8420
8463
|
}
|
|
8421
8464
|
}
|
|
@@ -8428,14 +8471,14 @@ function bodyReferencesLoopVar(loop, name) {
|
|
|
8428
8471
|
if (referenced) {
|
|
8429
8472
|
return;
|
|
8430
8473
|
}
|
|
8431
|
-
if (!
|
|
8474
|
+
if (!import_ts_morph36.Node.isCallExpression(node)) {
|
|
8432
8475
|
return;
|
|
8433
8476
|
}
|
|
8434
8477
|
node.forEachDescendant((inner) => {
|
|
8435
8478
|
if (referenced) {
|
|
8436
8479
|
return;
|
|
8437
8480
|
}
|
|
8438
|
-
if (
|
|
8481
|
+
if (import_ts_morph36.Node.isIdentifier(inner) && inner.getText() === name) {
|
|
8439
8482
|
referenced = true;
|
|
8440
8483
|
}
|
|
8441
8484
|
});
|
|
@@ -8445,11 +8488,11 @@ function bodyReferencesLoopVar(loop, name) {
|
|
|
8445
8488
|
function bodyCallsOnRoutable(loop, guard, resolution) {
|
|
8446
8489
|
let found = false;
|
|
8447
8490
|
loop.getStatement().forEachDescendant((node) => {
|
|
8448
|
-
if (found || !
|
|
8491
|
+
if (found || !import_ts_morph36.Node.isCallExpression(node)) {
|
|
8449
8492
|
return;
|
|
8450
8493
|
}
|
|
8451
8494
|
const callee = node.getExpression();
|
|
8452
|
-
if (!
|
|
8495
|
+
if (!import_ts_morph36.Node.isPropertyAccessExpression(callee) && !import_ts_morph36.Node.isElementAccessExpression(callee)) {
|
|
8453
8496
|
return;
|
|
8454
8497
|
}
|
|
8455
8498
|
const subject = callee.getExpression();
|
|
@@ -8469,11 +8512,11 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
8469
8512
|
let path15 = null;
|
|
8470
8513
|
let handler = null;
|
|
8471
8514
|
for (const prop of element.getProperties()) {
|
|
8472
|
-
if (
|
|
8515
|
+
if (import_ts_morph36.Node.isMethodDeclaration(prop) && prop.getName() === shape.handlerKey) {
|
|
8473
8516
|
handler = { func: prop, name: shape.handlerKey };
|
|
8474
8517
|
continue;
|
|
8475
8518
|
}
|
|
8476
|
-
if (!
|
|
8519
|
+
if (!import_ts_morph36.Node.isPropertyAssignment(prop)) {
|
|
8477
8520
|
continue;
|
|
8478
8521
|
}
|
|
8479
8522
|
const name = prop.getName();
|
|
@@ -8496,111 +8539,19 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
8496
8539
|
return { method, path: path15, handler: handler.func, handlerName: handler.name };
|
|
8497
8540
|
}
|
|
8498
8541
|
function readStringLiteralValue(node) {
|
|
8499
|
-
if (
|
|
8542
|
+
if (import_ts_morph36.Node.isStringLiteral(node) || import_ts_morph36.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
8500
8543
|
return node.getLiteralValue();
|
|
8501
8544
|
}
|
|
8502
8545
|
return null;
|
|
8503
8546
|
}
|
|
8504
8547
|
function handlerName(value) {
|
|
8505
|
-
return
|
|
8548
|
+
return import_ts_morph36.Node.isIdentifier(value) ? value.getText() : value.getKindName();
|
|
8506
8549
|
}
|
|
8507
8550
|
|
|
8508
8551
|
// src/discovery/registrationTemplate.ts
|
|
8509
|
-
var
|
|
8552
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
8510
8553
|
var import_ts_morph37 = require("ts-morph");
|
|
8511
8554
|
var import_resolution4 = require("@suss/resolution");
|
|
8512
|
-
|
|
8513
|
-
// src/resolve/unfollowedCall.ts
|
|
8514
|
-
var import_ts_morph36 = require("ts-morph");
|
|
8515
|
-
var import_behavioral_ir2 = require("@suss/behavioral-ir");
|
|
8516
|
-
function isInExternalCode(sourceFile) {
|
|
8517
|
-
if (sourceFile.isDeclarationFile()) {
|
|
8518
|
-
return true;
|
|
8519
|
-
}
|
|
8520
|
-
return sourceFile.getFilePath().includes("/node_modules/");
|
|
8521
|
-
}
|
|
8522
|
-
function hasBody(fn) {
|
|
8523
|
-
if (import_ts_morph36.Node.isFunctionDeclaration(fn) || import_ts_morph36.Node.isMethodDeclaration(fn) || import_ts_morph36.Node.isFunctionExpression(fn)) {
|
|
8524
|
-
return fn.getBody?.() !== void 0;
|
|
8525
|
-
}
|
|
8526
|
-
return true;
|
|
8527
|
-
}
|
|
8528
|
-
function isDeclaredShape(declaration) {
|
|
8529
|
-
return (import_ts_morph36.Node.isMethodSignature(declaration) || import_ts_morph36.Node.isPropertySignature(declaration)) && !isInExternalCode(declaration.getSourceFile());
|
|
8530
|
-
}
|
|
8531
|
-
function isExternalDeclaration(declaration) {
|
|
8532
|
-
if (isInExternalCode(declaration.getSourceFile())) {
|
|
8533
|
-
return true;
|
|
8534
|
-
}
|
|
8535
|
-
if (import_ts_morph36.Node.isImportSpecifier(declaration) || import_ts_morph36.Node.isImportClause(declaration) || import_ts_morph36.Node.isNamespaceImport(declaration)) {
|
|
8536
|
-
const target = declaration.getFirstAncestorByKind(import_ts_morph36.SyntaxKind.ImportDeclaration)?.getModuleSpecifierSourceFile();
|
|
8537
|
-
return target === void 0 || isInExternalCode(target);
|
|
8538
|
-
}
|
|
8539
|
-
return declaresAnotherModule(declaration);
|
|
8540
|
-
}
|
|
8541
|
-
function declaresAnotherModule(declaration) {
|
|
8542
|
-
const module2 = declaration.getFirstAncestorByKind(
|
|
8543
|
-
import_ts_morph36.SyntaxKind.ModuleDeclaration
|
|
8544
|
-
);
|
|
8545
|
-
return module2 !== void 0 && import_ts_morph36.Node.isStringLiteral(module2.getNameNode());
|
|
8546
|
-
}
|
|
8547
|
-
function statesShapeOnly(declaration) {
|
|
8548
|
-
if (isExternalDeclaration(declaration)) {
|
|
8549
|
-
return false;
|
|
8550
|
-
}
|
|
8551
|
-
if (import_ts_morph36.Node.isMethodSignature(declaration) || import_ts_morph36.Node.isPropertySignature(declaration)) {
|
|
8552
|
-
return true;
|
|
8553
|
-
}
|
|
8554
|
-
if (import_ts_morph36.Node.isFunctionDeclaration(declaration) || import_ts_morph36.Node.isMethodDeclaration(declaration)) {
|
|
8555
|
-
return declaration.getBody() === void 0;
|
|
8556
|
-
}
|
|
8557
|
-
return false;
|
|
8558
|
-
}
|
|
8559
|
-
function declarationsBehind(symbol) {
|
|
8560
|
-
if (symbol === void 0) {
|
|
8561
|
-
return [];
|
|
8562
|
-
}
|
|
8563
|
-
const behind = symbol.getAliasedSymbol()?.getDeclarations() ?? [];
|
|
8564
|
-
return behind.length > 0 ? behind : symbol.getDeclarations();
|
|
8565
|
-
}
|
|
8566
|
-
function isParameterOf(declaration, scanning) {
|
|
8567
|
-
return import_ts_morph36.Node.isParameterDeclaration(declaration) && declaration.getParent() === scanning;
|
|
8568
|
-
}
|
|
8569
|
-
function parameterIndexOf(declarations, scanning) {
|
|
8570
|
-
if (scanning === void 0) {
|
|
8571
|
-
return void 0;
|
|
8572
|
-
}
|
|
8573
|
-
const params = scanning.getParameters();
|
|
8574
|
-
for (const declaration of declarations) {
|
|
8575
|
-
const index = params.findIndex((param) => param === declaration);
|
|
8576
|
-
if (index !== -1) {
|
|
8577
|
-
return index;
|
|
8578
|
-
}
|
|
8579
|
-
}
|
|
8580
|
-
return void 0;
|
|
8581
|
-
}
|
|
8582
|
-
function classifyStop(declarations, scanning) {
|
|
8583
|
-
if (declarations.length === 0) {
|
|
8584
|
-
return "noDeclaration";
|
|
8585
|
-
}
|
|
8586
|
-
for (const declaration of declarations) {
|
|
8587
|
-
if (!isInExternalCode(declaration.getSourceFile())) {
|
|
8588
|
-
recordFileDependency(declaration.getSourceFile().getFilePath());
|
|
8589
|
-
}
|
|
8590
|
-
}
|
|
8591
|
-
if (scanning !== void 0 && declarations.some((declaration) => isParameterOf(declaration, scanning))) {
|
|
8592
|
-
return "callerSupplied";
|
|
8593
|
-
}
|
|
8594
|
-
if (declarations.every(isExternalDeclaration)) {
|
|
8595
|
-
return "outsideRun";
|
|
8596
|
-
}
|
|
8597
|
-
if (declarations.some(statesShapeOnly)) {
|
|
8598
|
-
return "noBody";
|
|
8599
|
-
}
|
|
8600
|
-
return "unsettledValue";
|
|
8601
|
-
}
|
|
8602
|
-
|
|
8603
|
-
// src/discovery/registrationTemplate.ts
|
|
8604
8555
|
function discoverRegistrationTemplates(sourceFile, match, kind, resolution, mountPrefixes) {
|
|
8605
8556
|
const results = [];
|
|
8606
8557
|
for (const node of helperCallsOf(sourceFile, match, resolution)) {
|
|
@@ -8656,7 +8607,7 @@ function subjectOfCall(sourceFile, args, match, resolution) {
|
|
|
8656
8607
|
}
|
|
8657
8608
|
function helperCallsOf(sourceFile, match, resolution) {
|
|
8658
8609
|
const module2 = match.importModule;
|
|
8659
|
-
if (module2 !== void 0 && !
|
|
8610
|
+
if (module2 !== void 0 && !import_node_path6.default.isAbsolute(module2)) {
|
|
8660
8611
|
const store = resolution ?? new ResolutionStore();
|
|
8661
8612
|
return callsResolvingTo(sourceFile, store, {
|
|
8662
8613
|
module: module2,
|
|
@@ -8871,7 +8822,7 @@ function writtenSdl(expr) {
|
|
|
8871
8822
|
}
|
|
8872
8823
|
|
|
8873
8824
|
// src/discovery/index.ts
|
|
8874
|
-
function runPattern(sourceFile, pattern, resolution, mountPrefixes, expandedElsewhere) {
|
|
8825
|
+
function runPattern(sourceFile, pattern, resolution, mountPrefixes, expandedElsewhere, routeWrapperPattern) {
|
|
8875
8826
|
if (pattern.match.type === "namedExport") {
|
|
8876
8827
|
return discoverNamedExports(
|
|
8877
8828
|
sourceFile,
|
|
@@ -8888,7 +8839,8 @@ function runPattern(sourceFile, pattern, resolution, mountPrefixes, expandedElse
|
|
|
8888
8839
|
pattern.bindingExtraction,
|
|
8889
8840
|
resolution,
|
|
8890
8841
|
mountPrefixes,
|
|
8891
|
-
expandedElsewhere
|
|
8842
|
+
expandedElsewhere,
|
|
8843
|
+
routeWrapperPattern
|
|
8892
8844
|
);
|
|
8893
8845
|
}
|
|
8894
8846
|
if (pattern.match.type === "registrationTemplate") {
|
|
@@ -8994,19 +8946,26 @@ function runPattern(sourceFile, pattern, resolution, mountPrefixes, expandedElse
|
|
|
8994
8946
|
}
|
|
8995
8947
|
return [];
|
|
8996
8948
|
}
|
|
8949
|
+
function routeWrapperPatternOf(patterns) {
|
|
8950
|
+
return patterns.find(
|
|
8951
|
+
(pattern) => pattern.wraps !== void 0 && "method" in pattern.wraps && pattern.wraps.continuationParam !== void 0 && pattern.wraps.throwParam === void 0 && pattern.wraps.arity === void 0 && pattern.wraps.scopePosition === void 0
|
|
8952
|
+
);
|
|
8953
|
+
}
|
|
8997
8954
|
function discoverUnits(sourceFile, patterns, resolution, mountPrefixes, expandedElsewhere) {
|
|
8998
8955
|
const store = resolution ?? new ResolutionStore();
|
|
8999
8956
|
const allResults = [];
|
|
8957
|
+
const routeWrapperPattern = routeWrapperPatternOf(patterns);
|
|
9000
8958
|
for (const pattern of patterns) {
|
|
9001
8959
|
const found = runPattern(
|
|
9002
8960
|
sourceFile,
|
|
9003
8961
|
pattern,
|
|
9004
8962
|
store,
|
|
9005
8963
|
mountPrefixes,
|
|
9006
|
-
expandedElsewhere
|
|
8964
|
+
expandedElsewhere,
|
|
8965
|
+
routeWrapperPattern
|
|
9007
8966
|
);
|
|
9008
8967
|
for (const unit of found) {
|
|
9009
|
-
unit.pattern
|
|
8968
|
+
unit.pattern ??= pattern;
|
|
9010
8969
|
}
|
|
9011
8970
|
allResults.push(...found);
|
|
9012
8971
|
}
|
|
@@ -11494,8 +11453,8 @@ function implementationBeside(declaration, name) {
|
|
|
11494
11453
|
return candidate;
|
|
11495
11454
|
}
|
|
11496
11455
|
}
|
|
11497
|
-
const
|
|
11498
|
-
const fn =
|
|
11456
|
+
const variable3 = source.getVariableDeclaration(name);
|
|
11457
|
+
const fn = variable3 === void 0 ? null : asFunctionLike(variable3);
|
|
11499
11458
|
if (fn !== null) {
|
|
11500
11459
|
return fn;
|
|
11501
11460
|
}
|
|
@@ -12817,6 +12776,154 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12817
12776
|
return null;
|
|
12818
12777
|
}
|
|
12819
12778
|
|
|
12779
|
+
// src/diagnostics.ts
|
|
12780
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
12781
|
+
var import_ts_morph58 = require("ts-morph");
|
|
12782
|
+
var import_extractor6 = require("@suss/extractor");
|
|
12783
|
+
var DEFAULT_RESOLUTION = {
|
|
12784
|
+
moduleResolution: import_ts_morph58.ts.ModuleResolutionKind.Bundler,
|
|
12785
|
+
target: import_ts_morph58.ts.ScriptTarget.ESNext,
|
|
12786
|
+
module: import_ts_morph58.ts.ModuleKind.ESNext
|
|
12787
|
+
};
|
|
12788
|
+
function resolutionContext(args) {
|
|
12789
|
+
if (args.tsConfigFilePath !== void 0) {
|
|
12790
|
+
const configFile = import_ts_morph58.ts.readConfigFile(
|
|
12791
|
+
args.tsConfigFilePath,
|
|
12792
|
+
import_ts_morph58.ts.sys.readFile
|
|
12793
|
+
);
|
|
12794
|
+
if (configFile.error !== void 0) {
|
|
12795
|
+
return null;
|
|
12796
|
+
}
|
|
12797
|
+
const dir = import_node_path7.default.dirname(args.tsConfigFilePath);
|
|
12798
|
+
const parsed = import_ts_morph58.ts.parseJsonConfigFileContent(
|
|
12799
|
+
configFile.config,
|
|
12800
|
+
import_ts_morph58.ts.sys,
|
|
12801
|
+
dir,
|
|
12802
|
+
/*existingOptions*/
|
|
12803
|
+
void 0,
|
|
12804
|
+
args.tsConfigFilePath
|
|
12805
|
+
);
|
|
12806
|
+
return {
|
|
12807
|
+
containingFile: import_node_path7.default.join(dir, "index.ts"),
|
|
12808
|
+
options: parsed.options
|
|
12809
|
+
};
|
|
12810
|
+
}
|
|
12811
|
+
if (args.projectRoot === void 0 || !import_node_path7.default.isAbsolute(args.projectRoot)) {
|
|
12812
|
+
return null;
|
|
12813
|
+
}
|
|
12814
|
+
return {
|
|
12815
|
+
containingFile: import_node_path7.default.join(args.projectRoot, "index.ts"),
|
|
12816
|
+
options: DEFAULT_RESOLUTION
|
|
12817
|
+
};
|
|
12818
|
+
}
|
|
12819
|
+
function unresolvedGatesFor(gates, args) {
|
|
12820
|
+
if (gates.length === 0) {
|
|
12821
|
+
return [];
|
|
12822
|
+
}
|
|
12823
|
+
const context = resolutionContext(args);
|
|
12824
|
+
if (context === null) {
|
|
12825
|
+
return [];
|
|
12826
|
+
}
|
|
12827
|
+
const unresolved = [];
|
|
12828
|
+
for (const gate of gates) {
|
|
12829
|
+
const resolved = import_ts_morph58.ts.resolveModuleName(
|
|
12830
|
+
gate,
|
|
12831
|
+
context.containingFile,
|
|
12832
|
+
context.options,
|
|
12833
|
+
import_ts_morph58.ts.sys
|
|
12834
|
+
);
|
|
12835
|
+
if (resolved.resolvedModule === void 0) {
|
|
12836
|
+
unresolved.push(gate);
|
|
12837
|
+
}
|
|
12838
|
+
}
|
|
12839
|
+
return unresolved;
|
|
12840
|
+
}
|
|
12841
|
+
function helpersWithNoCall(patterns, matched, projectRoot) {
|
|
12842
|
+
const missing = [];
|
|
12843
|
+
for (const pattern of patterns) {
|
|
12844
|
+
if (pattern.match.type !== "registrationTemplate" || matched.has(pattern.match.helperName)) {
|
|
12845
|
+
continue;
|
|
12846
|
+
}
|
|
12847
|
+
const from = pattern.match.importModule;
|
|
12848
|
+
missing.push(
|
|
12849
|
+
from === void 0 ? pattern.match.helperName : `${pattern.match.helperName} from ${shortModule(from, projectRoot)}`
|
|
12850
|
+
);
|
|
12851
|
+
}
|
|
12852
|
+
return missing;
|
|
12853
|
+
}
|
|
12854
|
+
function shortModule(module2, projectRoot) {
|
|
12855
|
+
if (projectRoot === void 0 || !import_node_path7.default.isAbsolute(module2)) {
|
|
12856
|
+
return module2;
|
|
12857
|
+
}
|
|
12858
|
+
return import_node_path7.default.relative(projectRoot, module2);
|
|
12859
|
+
}
|
|
12860
|
+
function buildExtractionReport(args) {
|
|
12861
|
+
const bySummary = (0, import_extractor6.summaryCountsByPack)(args.summaries);
|
|
12862
|
+
const packFunnels = args.packs.map((pack) => {
|
|
12863
|
+
const gates = packIsUngated(pack) ? [] : collectPackGates(pack);
|
|
12864
|
+
const tally = args.tallies.get(pack.name) ?? (0, import_extractor6.emptyTally)();
|
|
12865
|
+
const counted = bySummary.get(pack.name) ?? {
|
|
12866
|
+
bound: 0,
|
|
12867
|
+
providers: 0,
|
|
12868
|
+
withBehavior: 0
|
|
12869
|
+
};
|
|
12870
|
+
return {
|
|
12871
|
+
pack: pack.name,
|
|
12872
|
+
version: pack.version ?? null,
|
|
12873
|
+
discovers: pack.discovery.length > 0 || pack.discoverUnits !== void 0,
|
|
12874
|
+
recognizes: (pack.invocationRecognizers?.length ?? 0) > 0 || (pack.accessRecognizers?.length ?? 0) > 0,
|
|
12875
|
+
gates,
|
|
12876
|
+
unresolvedGates: unresolvedGatesFor(gates, {
|
|
12877
|
+
tsConfigFilePath: args.tsConfigFilePath,
|
|
12878
|
+
projectRoot: args.projectRoot
|
|
12879
|
+
}),
|
|
12880
|
+
candidateFiles: tally.candidateFiles,
|
|
12881
|
+
unitsDiscovered: tally.unitsDiscovered,
|
|
12882
|
+
unitsInGatedFiles: tally.unitsInGatedFiles,
|
|
12883
|
+
effectsRecognized: tally.effectsRecognized,
|
|
12884
|
+
unitsClaimed: tally.unitsClaimed,
|
|
12885
|
+
summariesProduced: tally.summariesProduced,
|
|
12886
|
+
failures: tally.failures,
|
|
12887
|
+
helpersUnmatched: helpersWithNoCall(
|
|
12888
|
+
[...pack.discovery, ...args.contributedPatterns?.(pack.name) ?? []],
|
|
12889
|
+
tally.helpersMatched,
|
|
12890
|
+
args.projectRoot
|
|
12891
|
+
),
|
|
12892
|
+
summariesBound: counted.bound,
|
|
12893
|
+
providerSummaries: counted.providers,
|
|
12894
|
+
summariesWithBehavior: counted.withBehavior,
|
|
12895
|
+
declarations: pack.declarations ?? null
|
|
12896
|
+
};
|
|
12897
|
+
});
|
|
12898
|
+
return {
|
|
12899
|
+
filesInProject: args.filesInProject,
|
|
12900
|
+
filesWalked: args.filesWalked,
|
|
12901
|
+
packs: packFunnels,
|
|
12902
|
+
summaries: args.summaries.length,
|
|
12903
|
+
filesWithUnreadableExports: [...args.filesWithUnreadableExports ?? []],
|
|
12904
|
+
reassignedNamesUnstated: args.reassignedNamesUnstated ?? 0,
|
|
12905
|
+
emptyStage: args.summaries.length === 0 ? firstEmptyStage(packFunnels, args) : null
|
|
12906
|
+
};
|
|
12907
|
+
}
|
|
12908
|
+
function firstEmptyStage(packs, args) {
|
|
12909
|
+
if (args.filesInProject === 0) {
|
|
12910
|
+
return "tsconfig";
|
|
12911
|
+
}
|
|
12912
|
+
const gateFailed = packs.some(
|
|
12913
|
+
(p) => p.unresolvedGates.length > 0 && p.candidateFiles > 0
|
|
12914
|
+
);
|
|
12915
|
+
if (gateFailed) {
|
|
12916
|
+
return "gateResolution";
|
|
12917
|
+
}
|
|
12918
|
+
if (args.filesWalked === 0 || packs.every((p) => p.candidateFiles === 0)) {
|
|
12919
|
+
return "candidateFiles";
|
|
12920
|
+
}
|
|
12921
|
+
if (packs.every((p) => p.unitsDiscovered === 0)) {
|
|
12922
|
+
return "discovery";
|
|
12923
|
+
}
|
|
12924
|
+
return "assembly";
|
|
12925
|
+
}
|
|
12926
|
+
|
|
12820
12927
|
// src/discovery/filenameRoute.ts
|
|
12821
12928
|
function routePathFromFile(filePath, convention) {
|
|
12822
12929
|
const belowRoot = segmentsBelowRoot(filePath, convention.root);
|
|
@@ -12896,7 +13003,7 @@ var import_node_fs3 = __toESM(require("fs"), 1);
|
|
|
12896
13003
|
var import_node_path8 = __toESM(require("path"), 1);
|
|
12897
13004
|
var import_graphql2 = require("graphql");
|
|
12898
13005
|
var import_picomatch2 = __toESM(require("picomatch"), 1);
|
|
12899
|
-
var
|
|
13006
|
+
var import_ts_morph59 = require("ts-morph");
|
|
12900
13007
|
var import_behavioral_ir5 = require("@suss/behavioral-ir");
|
|
12901
13008
|
function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
|
|
12902
13009
|
const scopes = compileOperationScopes(packs);
|
|
@@ -12936,11 +13043,11 @@ function fragmentsRegisteredIn(sourceFiles) {
|
|
|
12936
13043
|
const registered = /* @__PURE__ */ new Set();
|
|
12937
13044
|
for (const sourceFile of sourceFiles) {
|
|
12938
13045
|
sourceFile.forEachDescendant((node) => {
|
|
12939
|
-
if (!
|
|
13046
|
+
if (!import_ts_morph59.Node.isCallExpression(node)) {
|
|
12940
13047
|
return;
|
|
12941
13048
|
}
|
|
12942
13049
|
const argument = node.getArguments()[0];
|
|
12943
|
-
if (argument === void 0 || !
|
|
13050
|
+
if (argument === void 0 || !import_ts_morph59.Node.isNoSubstitutionTemplateLiteral(argument)) {
|
|
12944
13051
|
return;
|
|
12945
13052
|
}
|
|
12946
13053
|
for (const name of fragmentOnlyDocumentNames(argument.getLiteralText())) {
|
|
@@ -13127,7 +13234,7 @@ function constructionRegistryStatus(construction, spec) {
|
|
|
13127
13234
|
if (cacheConstruction === null) {
|
|
13128
13235
|
return "unknown";
|
|
13129
13236
|
}
|
|
13130
|
-
if (!
|
|
13237
|
+
if (!import_ts_morph59.Node.isNewExpression(cacheConstruction) && !import_ts_morph59.Node.isCallExpression(cacheConstruction)) {
|
|
13131
13238
|
return "unknown";
|
|
13132
13239
|
}
|
|
13133
13240
|
const args = cacheConstruction.getArguments();
|
|
@@ -13141,15 +13248,15 @@ function constructionRegistryStatus(construction, spec) {
|
|
|
13141
13248
|
if (cacheOptions.getProperty(spec.registryProperty) !== void 0) {
|
|
13142
13249
|
return "configured";
|
|
13143
13250
|
}
|
|
13144
|
-
const hasSpread = cacheOptions.getProperties().some((property) =>
|
|
13251
|
+
const hasSpread = cacheOptions.getProperties().some((property) => import_ts_morph59.Node.isSpreadAssignment(property));
|
|
13145
13252
|
return hasSpread ? "unknown" : "absent";
|
|
13146
13253
|
}
|
|
13147
13254
|
function firstArgumentObjectLiteral(construction) {
|
|
13148
|
-
if (!
|
|
13255
|
+
if (!import_ts_morph59.Node.isNewExpression(construction) && !import_ts_morph59.Node.isCallExpression(construction)) {
|
|
13149
13256
|
return null;
|
|
13150
13257
|
}
|
|
13151
13258
|
const arg = construction.getArguments()[0];
|
|
13152
|
-
if (arg === void 0 || !
|
|
13259
|
+
if (arg === void 0 || !import_ts_morph59.Node.isObjectLiteralExpression(arg)) {
|
|
13153
13260
|
return null;
|
|
13154
13261
|
}
|
|
13155
13262
|
return arg;
|
|
@@ -13159,10 +13266,10 @@ function propertyValueOf2(options, name) {
|
|
|
13159
13266
|
if (property === void 0) {
|
|
13160
13267
|
return null;
|
|
13161
13268
|
}
|
|
13162
|
-
if (
|
|
13269
|
+
if (import_ts_morph59.Node.isPropertyAssignment(property)) {
|
|
13163
13270
|
return property.getInitializer() ?? null;
|
|
13164
13271
|
}
|
|
13165
|
-
if (
|
|
13272
|
+
if (import_ts_morph59.Node.isShorthandPropertyAssignment(property)) {
|
|
13166
13273
|
const symbol = property.getProject().getTypeChecker().getShorthandAssignmentValueSymbol(property);
|
|
13167
13274
|
return symbol?.getValueDeclaration() ?? null;
|
|
13168
13275
|
}
|
|
@@ -13172,13 +13279,13 @@ function resolveToConstructionOf(expression, cacheClass) {
|
|
|
13172
13279
|
let current2 = expression;
|
|
13173
13280
|
for (let hop = 0; hop < 4 && current2 !== void 0; hop += 1) {
|
|
13174
13281
|
current2 = unwrapExpression2(current2);
|
|
13175
|
-
if (
|
|
13282
|
+
if (import_ts_morph59.Node.isVariableDeclaration(current2)) {
|
|
13176
13283
|
current2 = current2.getInitializer();
|
|
13177
13284
|
continue;
|
|
13178
13285
|
}
|
|
13179
|
-
if (
|
|
13286
|
+
if (import_ts_morph59.Node.isNewExpression(current2) || import_ts_morph59.Node.isCallExpression(current2)) {
|
|
13180
13287
|
const callee = current2.getExpression();
|
|
13181
|
-
if (callee === void 0 || !
|
|
13288
|
+
if (callee === void 0 || !import_ts_morph59.Node.isIdentifier(callee)) {
|
|
13182
13289
|
return null;
|
|
13183
13290
|
}
|
|
13184
13291
|
const local = localImportName(
|
|
@@ -13188,11 +13295,11 @@ function resolveToConstructionOf(expression, cacheClass) {
|
|
|
13188
13295
|
);
|
|
13189
13296
|
return local !== null && callee.getText() === local ? current2 : null;
|
|
13190
13297
|
}
|
|
13191
|
-
if (!
|
|
13298
|
+
if (!import_ts_morph59.Node.isIdentifier(current2)) {
|
|
13192
13299
|
return null;
|
|
13193
13300
|
}
|
|
13194
13301
|
const declaration = current2.getSymbol()?.getValueDeclaration();
|
|
13195
|
-
if (declaration === void 0 || !
|
|
13302
|
+
if (declaration === void 0 || !import_ts_morph59.Node.isVariableDeclaration(declaration)) {
|
|
13196
13303
|
return null;
|
|
13197
13304
|
}
|
|
13198
13305
|
current2 = declaration.getInitializer();
|
|
@@ -13203,11 +13310,11 @@ function unwrapExpression2(node) {
|
|
|
13203
13310
|
return peelSyntax(node);
|
|
13204
13311
|
}
|
|
13205
13312
|
function isConstructionNamed(node, localName) {
|
|
13206
|
-
if (!
|
|
13313
|
+
if (!import_ts_morph59.Node.isNewExpression(node) && !import_ts_morph59.Node.isCallExpression(node)) {
|
|
13207
13314
|
return false;
|
|
13208
13315
|
}
|
|
13209
13316
|
const callee = node.getExpression();
|
|
13210
|
-
return callee !== void 0 &&
|
|
13317
|
+
return callee !== void 0 && import_ts_morph59.Node.isIdentifier(callee) && callee.getText() === localName;
|
|
13211
13318
|
}
|
|
13212
13319
|
function localImportName(sourceFile, importModule, importName) {
|
|
13213
13320
|
for (const one of namedImportsOf(sourceFile, [importModule], {
|
|
@@ -13221,11 +13328,11 @@ function localImportName(sourceFile, importModule, importName) {
|
|
|
13221
13328
|
}
|
|
13222
13329
|
function constructionRef(node, uriProperty, resolution) {
|
|
13223
13330
|
const optionsArg = node.getArguments()[0];
|
|
13224
|
-
if (optionsArg === void 0 || !
|
|
13331
|
+
if (optionsArg === void 0 || !import_ts_morph59.Node.isObjectLiteralExpression(optionsArg)) {
|
|
13225
13332
|
return null;
|
|
13226
13333
|
}
|
|
13227
13334
|
const property = optionsArg.getProperty(uriProperty);
|
|
13228
|
-
if (property === void 0 || !
|
|
13335
|
+
if (property === void 0 || !import_ts_morph59.Node.isPropertyAssignment(property)) {
|
|
13229
13336
|
return null;
|
|
13230
13337
|
}
|
|
13231
13338
|
const value = property.getInitializer();
|
|
@@ -13240,10 +13347,10 @@ function constructionRef(node, uriProperty, resolution) {
|
|
|
13240
13347
|
}
|
|
13241
13348
|
|
|
13242
13349
|
// src/discovery/helperIndex.ts
|
|
13243
|
-
var
|
|
13350
|
+
var import_ts_morph61 = require("ts-morph");
|
|
13244
13351
|
|
|
13245
13352
|
// src/discovery/helperReading.ts
|
|
13246
|
-
var
|
|
13353
|
+
var import_ts_morph60 = require("ts-morph");
|
|
13247
13354
|
var UNREAD = { as: "unread" };
|
|
13248
13355
|
function readHelperSinks(helper) {
|
|
13249
13356
|
const positions = parameterPositions(helper);
|
|
@@ -13253,11 +13360,11 @@ function readHelperSinks(helper) {
|
|
|
13253
13360
|
return sinks;
|
|
13254
13361
|
}
|
|
13255
13362
|
body.forEachDescendant((node) => {
|
|
13256
|
-
if (!
|
|
13363
|
+
if (!import_ts_morph60.Node.isCallExpression(node)) {
|
|
13257
13364
|
return;
|
|
13258
13365
|
}
|
|
13259
13366
|
const callee = node.getExpression();
|
|
13260
|
-
const [method, receiver] =
|
|
13367
|
+
const [method, receiver] = import_ts_morph60.Node.isPropertyAccessExpression(callee) ? [callee.getName(), readValue(callee.getExpression(), positions)] : [null, UNREAD];
|
|
13261
13368
|
sinks.push({
|
|
13262
13369
|
method,
|
|
13263
13370
|
receiver,
|
|
@@ -13277,25 +13384,25 @@ function parameterPositions(helper) {
|
|
|
13277
13384
|
return positions;
|
|
13278
13385
|
}
|
|
13279
13386
|
function readValue(node, positions) {
|
|
13280
|
-
if (
|
|
13387
|
+
if (import_ts_morph60.Node.isStringLiteral(node) || import_ts_morph60.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
13281
13388
|
return { as: "text", text: node.getLiteralValue() };
|
|
13282
13389
|
}
|
|
13283
|
-
if (
|
|
13390
|
+
if (import_ts_morph60.Node.isTemplateExpression(node)) {
|
|
13284
13391
|
return templateText(node, positions);
|
|
13285
13392
|
}
|
|
13286
|
-
if (
|
|
13393
|
+
if (import_ts_morph60.Node.isIdentifier(node)) {
|
|
13287
13394
|
const position = positions.get(node.getText());
|
|
13288
13395
|
return position === void 0 ? UNREAD : { as: "parameter", position };
|
|
13289
13396
|
}
|
|
13290
|
-
if (
|
|
13397
|
+
if (import_ts_morph60.Node.isPropertyAccessExpression(node)) {
|
|
13291
13398
|
const target = node.getExpression();
|
|
13292
|
-
const position =
|
|
13399
|
+
const position = import_ts_morph60.Node.isIdentifier(target) ? positions.get(target.getText()) : void 0;
|
|
13293
13400
|
return position === void 0 ? UNREAD : { as: "parameter", position, property: node.getName() };
|
|
13294
13401
|
}
|
|
13295
|
-
if (
|
|
13402
|
+
if (import_ts_morph60.Node.isObjectLiteralExpression(node)) {
|
|
13296
13403
|
return objectValue(node, positions);
|
|
13297
13404
|
}
|
|
13298
|
-
if (
|
|
13405
|
+
if (import_ts_morph60.Node.isCallExpression(node)) {
|
|
13299
13406
|
return {
|
|
13300
13407
|
as: "call",
|
|
13301
13408
|
callee: node.getExpression().getText(),
|
|
@@ -13305,13 +13412,13 @@ function readValue(node, positions) {
|
|
|
13305
13412
|
return UNREAD;
|
|
13306
13413
|
}
|
|
13307
13414
|
function templateText(node, positions) {
|
|
13308
|
-
if (!
|
|
13415
|
+
if (!import_ts_morph60.Node.isTemplateExpression(node)) {
|
|
13309
13416
|
return UNREAD;
|
|
13310
13417
|
}
|
|
13311
13418
|
let text = node.getHead().getLiteralText();
|
|
13312
13419
|
for (const span of node.getTemplateSpans()) {
|
|
13313
13420
|
const expression = span.getExpression();
|
|
13314
|
-
const position =
|
|
13421
|
+
const position = import_ts_morph60.Node.isIdentifier(expression) ? positions.get(expression.getText()) : void 0;
|
|
13315
13422
|
if (position === void 0) {
|
|
13316
13423
|
return UNREAD;
|
|
13317
13424
|
}
|
|
@@ -13320,12 +13427,12 @@ function templateText(node, positions) {
|
|
|
13320
13427
|
return { as: "text", text };
|
|
13321
13428
|
}
|
|
13322
13429
|
function objectValue(node, positions) {
|
|
13323
|
-
if (!
|
|
13430
|
+
if (!import_ts_morph60.Node.isObjectLiteralExpression(node)) {
|
|
13324
13431
|
return UNREAD;
|
|
13325
13432
|
}
|
|
13326
13433
|
const properties = {};
|
|
13327
13434
|
for (const property of node.getProperties()) {
|
|
13328
|
-
if (!
|
|
13435
|
+
if (!import_ts_morph60.Node.isPropertyAssignment(property)) {
|
|
13329
13436
|
continue;
|
|
13330
13437
|
}
|
|
13331
13438
|
const initializer = property.getInitializer();
|
|
@@ -13340,7 +13447,7 @@ function objectValue(node, positions) {
|
|
|
13340
13447
|
return { as: "object", properties };
|
|
13341
13448
|
}
|
|
13342
13449
|
function propertyKey(name) {
|
|
13343
|
-
return
|
|
13450
|
+
return import_ts_morph60.Node.isStringLiteral(name) ? name.getLiteralValue() : name.getText();
|
|
13344
13451
|
}
|
|
13345
13452
|
|
|
13346
13453
|
// src/discovery/helperIndex.ts
|
|
@@ -13470,11 +13577,11 @@ function registrationMatchesOf(pack) {
|
|
|
13470
13577
|
}
|
|
13471
13578
|
function collectHandOffs(sourceFile, subjects, match, resolution, found) {
|
|
13472
13579
|
sourceFile.forEachDescendant((node) => {
|
|
13473
|
-
if (!
|
|
13580
|
+
if (!import_ts_morph61.Node.isCallExpression(node)) {
|
|
13474
13581
|
return;
|
|
13475
13582
|
}
|
|
13476
13583
|
const callee = node.getExpression();
|
|
13477
|
-
if (!
|
|
13584
|
+
if (!import_ts_morph61.Node.isIdentifier(callee)) {
|
|
13478
13585
|
return;
|
|
13479
13586
|
}
|
|
13480
13587
|
const handedOver = subjectArgument(node, subjects, match, resolution);
|
|
@@ -13489,12 +13596,12 @@ function collectHandOffs(sourceFile, subjects, match, resolution, found) {
|
|
|
13489
13596
|
});
|
|
13490
13597
|
}
|
|
13491
13598
|
function subjectArgument(call, subjects, match, resolution) {
|
|
13492
|
-
if (!
|
|
13599
|
+
if (!import_ts_morph61.Node.isCallExpression(call)) {
|
|
13493
13600
|
return -1;
|
|
13494
13601
|
}
|
|
13495
13602
|
const args = call.getArguments();
|
|
13496
13603
|
for (const [position, argument] of args.entries()) {
|
|
13497
|
-
if (!
|
|
13604
|
+
if (!import_ts_morph61.Node.isIdentifier(argument) && !import_ts_morph61.Node.isPropertyAccessExpression(argument)) {
|
|
13498
13605
|
continue;
|
|
13499
13606
|
}
|
|
13500
13607
|
if (subjectNodeFor(argument, subjects, match, resolution) !== void 0) {
|
|
@@ -13553,10 +13660,10 @@ function declaredFunctions(sourceFile) {
|
|
|
13553
13660
|
found.push([name, declaration]);
|
|
13554
13661
|
}
|
|
13555
13662
|
}
|
|
13556
|
-
for (const
|
|
13557
|
-
const initializer =
|
|
13558
|
-
if (initializer !== void 0 && (
|
|
13559
|
-
found.push([
|
|
13663
|
+
for (const variable3 of sourceFile.getVariableDeclarations()) {
|
|
13664
|
+
const initializer = variable3.getInitializer();
|
|
13665
|
+
if (initializer !== void 0 && (import_ts_morph61.Node.isArrowFunction(initializer) || import_ts_morph61.Node.isFunctionExpression(initializer))) {
|
|
13666
|
+
found.push([variable3.getName(), initializer]);
|
|
13560
13667
|
}
|
|
13561
13668
|
}
|
|
13562
13669
|
return found;
|
|
@@ -13648,7 +13755,7 @@ function recordEdge(edgesByChild, candidate) {
|
|
|
13648
13755
|
}
|
|
13649
13756
|
|
|
13650
13757
|
// src/discovery/wrapperIndex.ts
|
|
13651
|
-
var
|
|
13758
|
+
var import_ts_morph62 = require("ts-morph");
|
|
13652
13759
|
var import_resolution6 = require("@suss/resolution");
|
|
13653
13760
|
var NO_WRAPPERS = {
|
|
13654
13761
|
wrappersFor: () => [],
|
|
@@ -13772,11 +13879,11 @@ function discoverWrapperRegistrations(sourceFile, pattern, match, wraps, resolut
|
|
|
13772
13879
|
const candidates = [];
|
|
13773
13880
|
const unresolved = [];
|
|
13774
13881
|
sourceFile.forEachDescendant((node) => {
|
|
13775
|
-
if (!
|
|
13882
|
+
if (!import_ts_morph62.Node.isCallExpression(node)) {
|
|
13776
13883
|
return;
|
|
13777
13884
|
}
|
|
13778
13885
|
const callee = node.getExpression();
|
|
13779
|
-
if (!
|
|
13886
|
+
if (!import_ts_morph62.Node.isPropertyAccessExpression(callee) || callee.getName() !== wraps.method) {
|
|
13780
13887
|
return;
|
|
13781
13888
|
}
|
|
13782
13889
|
const subjectNode = subjectNodeFor(
|
|
@@ -13871,7 +13978,7 @@ function discoverConstructorOptions(sourceFile, pattern, wraps, subjects, resolu
|
|
|
13871
13978
|
return { candidates, unresolved };
|
|
13872
13979
|
}
|
|
13873
13980
|
function constructorOptionOf(construction, wraps, resolution) {
|
|
13874
|
-
if (!(
|
|
13981
|
+
if (!(import_ts_morph62.Node.isNewExpression(construction) || import_ts_morph62.Node.isCallExpression(construction))) {
|
|
13875
13982
|
return void 0;
|
|
13876
13983
|
}
|
|
13877
13984
|
const optionsArg = construction.getArguments()[wraps.targetPosition];
|
|
@@ -13901,6 +14008,7 @@ function candidateOf(registration, pattern, sourceFile) {
|
|
|
13901
14008
|
reference: {
|
|
13902
14009
|
file: target.getSourceFile().getFilePath(),
|
|
13903
14010
|
name: named2 ? functionNameOrAnon(target) : label,
|
|
14011
|
+
...named2 ? {} : { line: target.getStartLineNumber() },
|
|
13904
14012
|
...onThrow ? { onThrow: true } : {},
|
|
13905
14013
|
...scope === void 0 ? {} : { scope }
|
|
13906
14014
|
}
|
|
@@ -13909,37 +14017,6 @@ function candidateOf(registration, pattern, sourceFile) {
|
|
|
13909
14017
|
function labelFor(targetArg, wraps) {
|
|
13910
14018
|
return factoryNameOf(targetArg) ?? wraps.method;
|
|
13911
14019
|
}
|
|
13912
|
-
function factoryNameOf(targetArg) {
|
|
13913
|
-
const written = factKeyOf(targetArg);
|
|
13914
|
-
if (!import_ts_morph61.Node.isCallExpression(written)) {
|
|
13915
|
-
return void 0;
|
|
13916
|
-
}
|
|
13917
|
-
const callee = written.getExpression();
|
|
13918
|
-
if (import_ts_morph61.Node.isIdentifier(callee)) {
|
|
13919
|
-
return callee.getText();
|
|
13920
|
-
}
|
|
13921
|
-
if (import_ts_morph61.Node.isPropertyAccessExpression(callee)) {
|
|
13922
|
-
return callee.getName();
|
|
13923
|
-
}
|
|
13924
|
-
return void 0;
|
|
13925
|
-
}
|
|
13926
|
-
function factoryStopOf(targetArg) {
|
|
13927
|
-
const written = factKeyOf(targetArg);
|
|
13928
|
-
if (!import_ts_morph61.Node.isCallExpression(written)) {
|
|
13929
|
-
return null;
|
|
13930
|
-
}
|
|
13931
|
-
const callee = factoryNameOf(targetArg);
|
|
13932
|
-
if (callee === void 0) {
|
|
13933
|
-
return null;
|
|
13934
|
-
}
|
|
13935
|
-
const reason = classifyStop(
|
|
13936
|
-
declarationsBehind(written.getExpression().getSymbol())
|
|
13937
|
-
);
|
|
13938
|
-
if (!(0, import_behavioral_ir2.worthRecording)(reason)) {
|
|
13939
|
-
return null;
|
|
13940
|
-
}
|
|
13941
|
-
return { callee, reason: "unresolvedWrapper" };
|
|
13942
|
-
}
|
|
13943
14020
|
function mountedAt(subjectId, mountPrefixes, scope) {
|
|
13944
14021
|
const prefix = mountPrefixes?.prefixForId?.(subjectId) ?? "";
|
|
13945
14022
|
return (0, import_resolution6.joinMountedPath)(prefix, scope);
|
|
@@ -13956,7 +14033,7 @@ function scopeOf(args, wraps, resolution) {
|
|
|
13956
14033
|
}
|
|
13957
14034
|
|
|
13958
14035
|
// src/discoveryContext.ts
|
|
13959
|
-
var
|
|
14036
|
+
var import_ts_morph63 = require("ts-morph");
|
|
13960
14037
|
function createTsDiscoveryContext(resolution) {
|
|
13961
14038
|
const store = resolution ?? new ResolutionStore();
|
|
13962
14039
|
return {
|
|
@@ -13991,7 +14068,7 @@ function exportedFunctions(sourceFile, resolution) {
|
|
|
13991
14068
|
return out;
|
|
13992
14069
|
}
|
|
13993
14070
|
function exportedFunction(decl, resolution) {
|
|
13994
|
-
const writtenAgain =
|
|
14071
|
+
const writtenAgain = import_ts_morph63.Node.isVariableDeclaration(decl) && isWrittenAgain(decl);
|
|
13995
14072
|
if (!writtenAgain) {
|
|
13996
14073
|
const declared = resolveDeclarationToFunction(decl);
|
|
13997
14074
|
if (declared !== null) {
|
|
@@ -14012,7 +14089,7 @@ function valueToAskAbout(decl, writtenAgain) {
|
|
|
14012
14089
|
if (writtenAgain) {
|
|
14013
14090
|
return decl;
|
|
14014
14091
|
}
|
|
14015
|
-
const value =
|
|
14092
|
+
const value = import_ts_morph63.Node.isVariableDeclaration(decl) ? decl.getInitializer() ?? decl : decl;
|
|
14016
14093
|
return couldStillNameAFunction(value) ? value : null;
|
|
14017
14094
|
}
|
|
14018
14095
|
function resolveDeclarationToFunction(decl) {
|
|
@@ -14020,18 +14097,18 @@ function resolveDeclarationToFunction(decl) {
|
|
|
14020
14097
|
if (fn !== null) {
|
|
14021
14098
|
return fn;
|
|
14022
14099
|
}
|
|
14023
|
-
if (
|
|
14100
|
+
if (import_ts_morph63.Node.isVariableDeclaration(decl)) {
|
|
14024
14101
|
const init = decl.getInitializer();
|
|
14025
|
-
if (init !== void 0 && (
|
|
14102
|
+
if (init !== void 0 && (import_ts_morph63.Node.isArrowFunction(init) || import_ts_morph63.Node.isFunctionExpression(init))) {
|
|
14026
14103
|
return init;
|
|
14027
14104
|
}
|
|
14028
14105
|
}
|
|
14029
14106
|
return null;
|
|
14030
14107
|
}
|
|
14031
14108
|
function hasJsxReturn(func) {
|
|
14032
|
-
if (
|
|
14109
|
+
if (import_ts_morph63.Node.isArrowFunction(func)) {
|
|
14033
14110
|
const body2 = func.getBody();
|
|
14034
|
-
if (
|
|
14111
|
+
if (import_ts_morph63.Node.isExpression(body2) && isJsxOrFragment(body2)) {
|
|
14035
14112
|
return true;
|
|
14036
14113
|
}
|
|
14037
14114
|
}
|
|
@@ -14045,11 +14122,11 @@ function hasJsxReturn(func) {
|
|
|
14045
14122
|
traversal.stop();
|
|
14046
14123
|
return;
|
|
14047
14124
|
}
|
|
14048
|
-
if (node !== func && (
|
|
14125
|
+
if (node !== func && (import_ts_morph63.Node.isFunctionDeclaration(node) || import_ts_morph63.Node.isFunctionExpression(node) || import_ts_morph63.Node.isArrowFunction(node) || import_ts_morph63.Node.isMethodDeclaration(node))) {
|
|
14049
14126
|
traversal.skip();
|
|
14050
14127
|
return;
|
|
14051
14128
|
}
|
|
14052
|
-
if (
|
|
14129
|
+
if (import_ts_morph63.Node.isReturnStatement(node)) {
|
|
14053
14130
|
const expr = node.getExpression();
|
|
14054
14131
|
if (expr !== void 0 && isJsxOrFragment(expr)) {
|
|
14055
14132
|
found = true;
|
|
@@ -14060,7 +14137,7 @@ function hasJsxReturn(func) {
|
|
|
14060
14137
|
}
|
|
14061
14138
|
function isJsxOrFragment(node) {
|
|
14062
14139
|
const current2 = peelParens(node);
|
|
14063
|
-
return
|
|
14140
|
+
return import_ts_morph63.Node.isJsxElement(current2) || import_ts_morph63.Node.isJsxSelfClosingElement(current2) || import_ts_morph63.Node.isJsxFragment(current2);
|
|
14064
14141
|
}
|
|
14065
14142
|
|
|
14066
14143
|
// src/graphqlContract.ts
|
|
@@ -14143,7 +14220,7 @@ function scalarOrRef(node) {
|
|
|
14143
14220
|
}
|
|
14144
14221
|
|
|
14145
14222
|
// src/moduleInit.ts
|
|
14146
|
-
var
|
|
14223
|
+
var import_extractor7 = require("@suss/extractor");
|
|
14147
14224
|
function moduleInitName(sourceFile) {
|
|
14148
14225
|
return sourceFile.getBaseName();
|
|
14149
14226
|
}
|
|
@@ -14151,8 +14228,8 @@ function moduleInitSummary(sourceFile, effects, options) {
|
|
|
14151
14228
|
if (effects.length === 0) {
|
|
14152
14229
|
return null;
|
|
14153
14230
|
}
|
|
14154
|
-
return (0,
|
|
14155
|
-
(0,
|
|
14231
|
+
return (0, import_extractor7.assembleSummary)(
|
|
14232
|
+
(0, import_extractor7.moduleInitStructure)({
|
|
14156
14233
|
name: moduleInitName(sourceFile),
|
|
14157
14234
|
file: sourceFile.getFilePath(),
|
|
14158
14235
|
range: { start: 0, end: sourceFile.getEnd() },
|
|
@@ -14183,133 +14260,11 @@ function createReferenceIndex(sourceFiles) {
|
|
|
14183
14260
|
};
|
|
14184
14261
|
}
|
|
14185
14262
|
|
|
14186
|
-
// src/resolve/boundaryEffects.ts
|
|
14187
|
-
var import_datalog3 = require("@suss/datalog");
|
|
14188
|
-
var EFFECT_RULES = [
|
|
14189
|
-
(0, import_datalog3.rule)(
|
|
14190
|
-
"reachFrom",
|
|
14191
|
-
[(0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("e")],
|
|
14192
|
-
[(0, import_datalog3.lit)("entry", (0, import_datalog3.variable)("e"))]
|
|
14193
|
-
),
|
|
14194
|
-
(0, import_datalog3.rule)(
|
|
14195
|
-
"reachFrom",
|
|
14196
|
-
[(0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("v")],
|
|
14197
|
-
[
|
|
14198
|
-
(0, import_datalog3.lit)("reachFrom", (0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("u")),
|
|
14199
|
-
(0, import_datalog3.lit)("calls", (0, import_datalog3.variable)("u"), (0, import_datalog3.variable)("v"))
|
|
14200
|
-
]
|
|
14201
|
-
),
|
|
14202
|
-
(0, import_datalog3.rule)(
|
|
14203
|
-
"boundaryEffect",
|
|
14204
|
-
[(0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("kind"), (0, import_datalog3.variable)("target")],
|
|
14205
|
-
[
|
|
14206
|
-
(0, import_datalog3.lit)("reachFrom", (0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("u")),
|
|
14207
|
-
(0, import_datalog3.lit)("unitEffect", (0, import_datalog3.variable)("u"), (0, import_datalog3.variable)("kind"), (0, import_datalog3.variable)("target"))
|
|
14208
|
-
]
|
|
14209
|
-
)
|
|
14210
|
-
];
|
|
14211
|
-
function bindingLabel(binding) {
|
|
14212
|
-
const semantics = binding.semantics;
|
|
14213
|
-
if (semantics.name === "rest") {
|
|
14214
|
-
return `${semantics.method} ${semantics.path}`;
|
|
14215
|
-
}
|
|
14216
|
-
if (semantics.name === "storage") {
|
|
14217
|
-
return `${semantics.storageSystem}:${semantics.container}`;
|
|
14218
|
-
}
|
|
14219
|
-
if (semantics.name === "message-bus") {
|
|
14220
|
-
return `${semantics.messageBus}:${semantics.channel}`;
|
|
14221
|
-
}
|
|
14222
|
-
if (semantics.name === "runtime-config") {
|
|
14223
|
-
return semantics.instanceName;
|
|
14224
|
-
}
|
|
14225
|
-
if (semantics.name === "graphql-resolver") {
|
|
14226
|
-
return `${semantics.typeName}.${semantics.fieldName}`;
|
|
14227
|
-
}
|
|
14228
|
-
if (semantics.name === "graphql-operation") {
|
|
14229
|
-
return `${semantics.operationType} ${semantics.operationName ?? ""}`.trim();
|
|
14230
|
-
}
|
|
14231
|
-
if ("exportName" in semantics || "module" in semantics) {
|
|
14232
|
-
return semantics.exportName ?? semantics.module ?? binding.recognition;
|
|
14233
|
-
}
|
|
14234
|
-
if ("instanceName" in semantics && semantics.instanceName !== null) {
|
|
14235
|
-
return `${semantics.deploymentTarget}:${semantics.instanceName}`;
|
|
14236
|
-
}
|
|
14237
|
-
return binding.recognition;
|
|
14238
|
-
}
|
|
14239
|
-
function effectFact(effect) {
|
|
14240
|
-
if (effect.type === "invocation") {
|
|
14241
|
-
return { kind: "invocation", target: effect.callee };
|
|
14242
|
-
}
|
|
14243
|
-
if (effect.type === "mutation") {
|
|
14244
|
-
return { kind: "mutation", target: `${effect.operation}:${effect.target}` };
|
|
14245
|
-
}
|
|
14246
|
-
if (effect.type === "emission") {
|
|
14247
|
-
return { kind: "emission", target: effect.event };
|
|
14248
|
-
}
|
|
14249
|
-
if (effect.type === "stateChange") {
|
|
14250
|
-
return { kind: "stateChange", target: effect.variable };
|
|
14251
|
-
}
|
|
14252
|
-
if (effect.type === "interaction") {
|
|
14253
|
-
return { kind: "interaction", target: bindingLabel(effect.binding) };
|
|
14254
|
-
}
|
|
14255
|
-
return null;
|
|
14256
|
-
}
|
|
14257
|
-
function deriveBoundaryEffects(summaries, facts) {
|
|
14258
|
-
const { db, unitKeyBySummary } = facts;
|
|
14259
|
-
for (const summary of summaries) {
|
|
14260
|
-
const key = unitKeyBySummary.get(summary);
|
|
14261
|
-
if (key === void 0) {
|
|
14262
|
-
continue;
|
|
14263
|
-
}
|
|
14264
|
-
for (const transition of summary.transitions) {
|
|
14265
|
-
for (const effect of transition.effects) {
|
|
14266
|
-
const fact2 = effectFact(effect);
|
|
14267
|
-
if (fact2 !== null) {
|
|
14268
|
-
db.add("unitEffect", [key, fact2.kind, fact2.target]);
|
|
14269
|
-
}
|
|
14270
|
-
}
|
|
14271
|
-
}
|
|
14272
|
-
}
|
|
14273
|
-
(0, import_datalog3.evaluate)(db, EFFECT_RULES);
|
|
14274
|
-
const ownByEntry = /* @__PURE__ */ new Map();
|
|
14275
|
-
for (const [unit, kind, target] of db.facts("unitEffect")) {
|
|
14276
|
-
const bucket = ownByEntry.get(String(unit)) ?? /* @__PURE__ */ new Set();
|
|
14277
|
-
bucket.add(`${kind}\0${target}`);
|
|
14278
|
-
ownByEntry.set(String(unit), bucket);
|
|
14279
|
-
}
|
|
14280
|
-
const closureByEntry = /* @__PURE__ */ new Map();
|
|
14281
|
-
for (const [entry, kind, target] of db.facts("boundaryEffect")) {
|
|
14282
|
-
const entryKey2 = String(entry);
|
|
14283
|
-
const bucket = closureByEntry.get(entryKey2) ?? [];
|
|
14284
|
-
bucket.push({
|
|
14285
|
-
kind: String(kind),
|
|
14286
|
-
target: String(target),
|
|
14287
|
-
transitive: !(ownByEntry.get(entryKey2)?.has(`${kind}\0${target}`) ?? false)
|
|
14288
|
-
});
|
|
14289
|
-
closureByEntry.set(entryKey2, bucket);
|
|
14290
|
-
}
|
|
14291
|
-
for (const summary of summaries) {
|
|
14292
|
-
const key = unitKeyBySummary.get(summary);
|
|
14293
|
-
if (key === void 0 || !db.has("entry", [key])) {
|
|
14294
|
-
continue;
|
|
14295
|
-
}
|
|
14296
|
-
const effects = closureByEntry.get(key);
|
|
14297
|
-
if (effects === void 0 || effects.length === 0) {
|
|
14298
|
-
continue;
|
|
14299
|
-
}
|
|
14300
|
-
const sorted = [...effects].sort(
|
|
14301
|
-
(a, b) => `${a.kind}:${a.target}`.localeCompare(`${b.kind}:${b.target}`)
|
|
14302
|
-
);
|
|
14303
|
-
summary.metadata = { ...summary.metadata, effectsClosure: sorted };
|
|
14304
|
-
}
|
|
14305
|
-
return summaries;
|
|
14306
|
-
}
|
|
14307
|
-
|
|
14308
14263
|
// src/resolve/reachableClosure.ts
|
|
14309
|
-
var
|
|
14264
|
+
var import_ts_morph64 = require("ts-morph");
|
|
14310
14265
|
var import_behavioral_ir6 = require("@suss/behavioral-ir");
|
|
14311
|
-
var
|
|
14312
|
-
var
|
|
14266
|
+
var import_datalog3 = require("@suss/datalog");
|
|
14267
|
+
var import_extractor8 = require("@suss/extractor");
|
|
14313
14268
|
var GENERIC_TERMINALS = [
|
|
14314
14269
|
{ kind: "return", match: { type: "returnStatement" }, extraction: {} },
|
|
14315
14270
|
{ kind: "throw", match: { type: "throwExpression" }, extraction: {} },
|
|
@@ -14339,7 +14294,7 @@ function targetOf(node) {
|
|
|
14339
14294
|
};
|
|
14340
14295
|
}
|
|
14341
14296
|
function resolveCallee(call, calleeName, scan) {
|
|
14342
|
-
if (!
|
|
14297
|
+
if (!import_ts_morph64.Node.isCallExpression(call)) {
|
|
14343
14298
|
return null;
|
|
14344
14299
|
}
|
|
14345
14300
|
const callee = call.getExpression();
|
|
@@ -14352,7 +14307,7 @@ function resolveCallee(call, calleeName, scan) {
|
|
|
14352
14307
|
}
|
|
14353
14308
|
}
|
|
14354
14309
|
const resolveSources = scan.resolveCallableSources;
|
|
14355
|
-
if (resolveSources !== void 0 &&
|
|
14310
|
+
if (resolveSources !== void 0 && import_ts_morph64.Node.isPropertyAccessExpression(callee) && declarations.some(isDeclaredShape)) {
|
|
14356
14311
|
const sources = resolveSources(callee, scan.reachedFrom);
|
|
14357
14312
|
const only = sources.length === 1 ? sources[0] : void 0;
|
|
14358
14313
|
const resolved = only === void 0 ? null : resolveDecl(only, calleeName);
|
|
@@ -14398,11 +14353,11 @@ function passedPositionKey(target, position) {
|
|
|
14398
14353
|
return `${offsetKeyFor(target.file, target.span)}#${position}`;
|
|
14399
14354
|
}
|
|
14400
14355
|
function resolveJsxReference(node, scan) {
|
|
14401
|
-
if (!
|
|
14356
|
+
if (!import_ts_morph64.Node.isJsxOpeningElement(node) && !import_ts_morph64.Node.isJsxSelfClosingElement(node)) {
|
|
14402
14357
|
return null;
|
|
14403
14358
|
}
|
|
14404
14359
|
const tag = node.getTagNameNode();
|
|
14405
|
-
if (!
|
|
14360
|
+
if (!import_ts_morph64.Node.isIdentifier(tag) || !/^[A-Z]/.test(tag.getText())) {
|
|
14406
14361
|
return null;
|
|
14407
14362
|
}
|
|
14408
14363
|
const name = tag.getText();
|
|
@@ -14448,12 +14403,12 @@ function collectReachable(func, scan) {
|
|
|
14448
14403
|
candidates.push(outcome.candidate);
|
|
14449
14404
|
};
|
|
14450
14405
|
const recordPassedArgs = (call, calleeText, calleeOutcome) => {
|
|
14451
|
-
if (!
|
|
14406
|
+
if (!import_ts_morph64.Node.isCallExpression(call)) {
|
|
14452
14407
|
return;
|
|
14453
14408
|
}
|
|
14454
14409
|
const calleeTarget = declaredAtOf(calleeOutcome);
|
|
14455
14410
|
call.getArguments().forEach((arg, position) => {
|
|
14456
|
-
if (!
|
|
14411
|
+
if (!import_ts_morph64.Node.isIdentifier(arg)) {
|
|
14457
14412
|
return;
|
|
14458
14413
|
}
|
|
14459
14414
|
const resolved = functionTargetOf(arg);
|
|
@@ -14473,7 +14428,7 @@ function collectReachable(func, scan) {
|
|
|
14473
14428
|
record2(jsx.outcome);
|
|
14474
14429
|
return;
|
|
14475
14430
|
}
|
|
14476
|
-
if (!
|
|
14431
|
+
if (!import_ts_morph64.Node.isCallExpression(node)) {
|
|
14477
14432
|
return;
|
|
14478
14433
|
}
|
|
14479
14434
|
const calleeText = normalizeCallee(node.getExpression().getText());
|
|
@@ -14522,16 +14477,16 @@ function extractReachableSummary(candidate, options, recognizers) {
|
|
|
14522
14477
|
transport: "in-process",
|
|
14523
14478
|
recognition: "reachable"
|
|
14524
14479
|
});
|
|
14525
|
-
return (0,
|
|
14480
|
+
return (0, import_extractor8.assembleSummary)(raw, options);
|
|
14526
14481
|
}
|
|
14527
14482
|
var REACHABLE_RULES = [
|
|
14528
|
-
(0,
|
|
14529
|
-
(0,
|
|
14483
|
+
(0, import_datalog3.rule)("reachable", [(0, import_datalog3.variable)("f")], [(0, import_datalog3.lit)("entry", (0, import_datalog3.variable)("f"))]),
|
|
14484
|
+
(0, import_datalog3.rule)(
|
|
14530
14485
|
"reachable",
|
|
14531
|
-
[(0,
|
|
14486
|
+
[(0, import_datalog3.variable)("g")],
|
|
14532
14487
|
[
|
|
14533
|
-
(0,
|
|
14534
|
-
(0,
|
|
14488
|
+
(0, import_datalog3.lit)("reachable", (0, import_datalog3.variable)("f")),
|
|
14489
|
+
(0, import_datalog3.lit)("calls", (0, import_datalog3.variable)("f"), (0, import_datalog3.variable)("g"))
|
|
14535
14490
|
]
|
|
14536
14491
|
)
|
|
14537
14492
|
];
|
|
@@ -14559,7 +14514,7 @@ function recognizerOnlyRoots(packsByFile) {
|
|
|
14559
14514
|
}
|
|
14560
14515
|
for (const declaration of variableStatement.getDeclarations()) {
|
|
14561
14516
|
const init = declaration.getInitializer();
|
|
14562
|
-
if (init !== void 0 && (
|
|
14517
|
+
if (init !== void 0 && (import_ts_morph64.Node.isArrowFunction(init) || import_ts_morph64.Node.isFunctionExpression(init)) && hasBody(init)) {
|
|
14563
14518
|
roots.push({ func: init, name: declaration.getName() });
|
|
14564
14519
|
}
|
|
14565
14520
|
}
|
|
@@ -14569,7 +14524,7 @@ function recognizerOnlyRoots(packsByFile) {
|
|
|
14569
14524
|
}
|
|
14570
14525
|
function expandReachableClosure(seeds, project, options, projectFileSet, facts, recognizers = NO_RECOGNIZERS, alreadySummarized = [], extraRoots = []) {
|
|
14571
14526
|
const lookup = createSourceFileLookup(project);
|
|
14572
|
-
const db = facts?.db ?? new
|
|
14527
|
+
const db = facts?.db ?? new import_datalog3.Database();
|
|
14573
14528
|
const functionByKey = /* @__PURE__ */ new Map();
|
|
14574
14529
|
const seedKeys = /* @__PURE__ */ new Set();
|
|
14575
14530
|
const scanned = /* @__PURE__ */ new Set();
|
|
@@ -14608,7 +14563,7 @@ function expandReachableClosure(seeds, project, options, projectFileSet, facts,
|
|
|
14608
14563
|
}
|
|
14609
14564
|
}
|
|
14610
14565
|
for (; ; ) {
|
|
14611
|
-
(0,
|
|
14566
|
+
(0, import_datalog3.evaluate)(db, REACHABLE_RULES);
|
|
14612
14567
|
const frontier = db.facts("reachable").map(([key]) => String(key)).filter((key) => !scanned.has(key));
|
|
14613
14568
|
if (frontier.length === 0) {
|
|
14614
14569
|
break;
|
|
@@ -14813,21 +14768,21 @@ function recordParameterGaps(parameterCallsByKey, summariesByKey, passedPosition
|
|
|
14813
14768
|
}
|
|
14814
14769
|
|
|
14815
14770
|
// src/resolve/rethrowEnrichment.ts
|
|
14816
|
-
var
|
|
14817
|
-
var
|
|
14771
|
+
var import_ts_morph65 = require("ts-morph");
|
|
14772
|
+
var import_datalog4 = require("@suss/datalog");
|
|
14818
14773
|
var RETHROW_RULES = [
|
|
14819
|
-
(0,
|
|
14774
|
+
(0, import_datalog4.rule)(
|
|
14820
14775
|
"contributes",
|
|
14821
|
-
[(0,
|
|
14822
|
-
[(0,
|
|
14776
|
+
[(0, import_datalog4.variable)("u"), (0, import_datalog4.variable)("s")],
|
|
14777
|
+
[(0, import_datalog4.lit)("throwsDirect", (0, import_datalog4.variable)("u"), (0, import_datalog4.variable)("s"))]
|
|
14823
14778
|
),
|
|
14824
|
-
(0,
|
|
14779
|
+
(0, import_datalog4.rule)(
|
|
14825
14780
|
"contributes",
|
|
14826
|
-
[(0,
|
|
14781
|
+
[(0, import_datalog4.variable)("u"), (0, import_datalog4.variable)("s")],
|
|
14827
14782
|
[
|
|
14828
|
-
(0,
|
|
14829
|
-
(0,
|
|
14830
|
-
(0,
|
|
14783
|
+
(0, import_datalog4.lit)("rethrowSite", (0, import_datalog4.variable)("u"), (0, import_datalog4.variable)("site")),
|
|
14784
|
+
(0, import_datalog4.lit)("siteCalls", (0, import_datalog4.variable)("site"), (0, import_datalog4.variable)("c")),
|
|
14785
|
+
(0, import_datalog4.lit)("contributes", (0, import_datalog4.variable)("c"), (0, import_datalog4.variable)("s"))
|
|
14831
14786
|
]
|
|
14832
14787
|
)
|
|
14833
14788
|
];
|
|
@@ -14839,7 +14794,7 @@ function enrichRethrows(summaries, project, facts) {
|
|
|
14839
14794
|
summary.location.range.start,
|
|
14840
14795
|
summary.location.range.end
|
|
14841
14796
|
));
|
|
14842
|
-
const db = facts?.db ?? new
|
|
14797
|
+
const db = facts?.db ?? new import_datalog4.Database();
|
|
14843
14798
|
const sourceById = /* @__PURE__ */ new Map();
|
|
14844
14799
|
const nameByUnit = /* @__PURE__ */ new Map();
|
|
14845
14800
|
const targets = [];
|
|
@@ -14889,7 +14844,7 @@ function enrichRethrows(summaries, project, facts) {
|
|
|
14889
14844
|
}
|
|
14890
14845
|
}
|
|
14891
14846
|
}
|
|
14892
|
-
(0,
|
|
14847
|
+
(0, import_datalog4.evaluate)(db, RETHROW_RULES);
|
|
14893
14848
|
const contributesByUnit = /* @__PURE__ */ new Map();
|
|
14894
14849
|
for (const [unit, sourceId] of db.facts("contributes")) {
|
|
14895
14850
|
const bucket = contributesByUnit.get(String(unit));
|
|
@@ -14950,7 +14905,7 @@ function findBareRethrow(func, location) {
|
|
|
14950
14905
|
traversal.stop();
|
|
14951
14906
|
return;
|
|
14952
14907
|
}
|
|
14953
|
-
if (!
|
|
14908
|
+
if (!import_ts_morph65.Node.isThrowStatement(node)) {
|
|
14954
14909
|
return;
|
|
14955
14910
|
}
|
|
14956
14911
|
if (startLineOf(node) !== location.start) {
|
|
@@ -14960,7 +14915,7 @@ function findBareRethrow(func, location) {
|
|
|
14960
14915
|
return;
|
|
14961
14916
|
}
|
|
14962
14917
|
const thrown = node.getExpression();
|
|
14963
|
-
if (thrown !== void 0 &&
|
|
14918
|
+
if (thrown !== void 0 && import_ts_morph65.Node.isIdentifier(thrown)) {
|
|
14964
14919
|
found = node;
|
|
14965
14920
|
}
|
|
14966
14921
|
});
|
|
@@ -14970,13 +14925,13 @@ function enclosingTry(throwStmt) {
|
|
|
14970
14925
|
let current2 = throwStmt.getParent();
|
|
14971
14926
|
let sawCatchClause = false;
|
|
14972
14927
|
while (current2 !== void 0) {
|
|
14973
|
-
if (
|
|
14928
|
+
if (import_ts_morph65.Node.isCatchClause(current2)) {
|
|
14974
14929
|
sawCatchClause = true;
|
|
14975
14930
|
}
|
|
14976
|
-
if (
|
|
14931
|
+
if (import_ts_morph65.Node.isTryStatement(current2)) {
|
|
14977
14932
|
return sawCatchClause ? current2 : null;
|
|
14978
14933
|
}
|
|
14979
|
-
if (
|
|
14934
|
+
if (import_ts_morph65.Node.isFunctionDeclaration(current2) || import_ts_morph65.Node.isFunctionExpression(current2) || import_ts_morph65.Node.isArrowFunction(current2) || import_ts_morph65.Node.isMethodDeclaration(current2)) {
|
|
14980
14935
|
return null;
|
|
14981
14936
|
}
|
|
14982
14937
|
current2 = current2.getParent();
|
|
@@ -14984,14 +14939,14 @@ function enclosingTry(throwStmt) {
|
|
|
14984
14939
|
return null;
|
|
14985
14940
|
}
|
|
14986
14941
|
function collectTryBodyCallees(tryStmt, index, keyFor) {
|
|
14987
|
-
if (!
|
|
14942
|
+
if (!import_ts_morph65.Node.isTryStatement(tryStmt)) {
|
|
14988
14943
|
return [];
|
|
14989
14944
|
}
|
|
14990
14945
|
const tryBlock = tryStmt.getTryBlock();
|
|
14991
14946
|
const callees = [];
|
|
14992
14947
|
const seen = /* @__PURE__ */ new Set();
|
|
14993
14948
|
tryBlock.forEachDescendant((node) => {
|
|
14994
|
-
if (!
|
|
14949
|
+
if (!import_ts_morph65.Node.isCallExpression(node)) {
|
|
14995
14950
|
return;
|
|
14996
14951
|
}
|
|
14997
14952
|
const calleeSummary = resolveCalleeSummary(node, index);
|
|
@@ -15008,7 +14963,7 @@ function collectTryBodyCallees(tryStmt, index, keyFor) {
|
|
|
15008
14963
|
return callees;
|
|
15009
14964
|
}
|
|
15010
14965
|
function resolveCalleeSummary(call, index) {
|
|
15011
|
-
if (!
|
|
14966
|
+
if (!import_ts_morph65.Node.isCallExpression(call)) {
|
|
15012
14967
|
return null;
|
|
15013
14968
|
}
|
|
15014
14969
|
const callee = call.getExpression();
|
|
@@ -15038,12 +14993,12 @@ function resolveCalleeSummary(call, index) {
|
|
|
15038
14993
|
return null;
|
|
15039
14994
|
}
|
|
15040
14995
|
function functionFromDecl(decl) {
|
|
15041
|
-
if (
|
|
14996
|
+
if (import_ts_morph65.Node.isFunctionDeclaration(decl) || import_ts_morph65.Node.isFunctionExpression(decl) || import_ts_morph65.Node.isArrowFunction(decl) || import_ts_morph65.Node.isMethodDeclaration(decl)) {
|
|
15042
14997
|
return decl;
|
|
15043
14998
|
}
|
|
15044
|
-
if (
|
|
14999
|
+
if (import_ts_morph65.Node.isVariableDeclaration(decl)) {
|
|
15045
15000
|
const init = decl.getInitializer();
|
|
15046
|
-
if (init !== void 0 && (
|
|
15001
|
+
if (init !== void 0 && (import_ts_morph65.Node.isArrowFunction(init) || import_ts_morph65.Node.isFunctionExpression(init))) {
|
|
15047
15002
|
return init;
|
|
15048
15003
|
}
|
|
15049
15004
|
}
|
|
@@ -15051,22 +15006,22 @@ function functionFromDecl(decl) {
|
|
|
15051
15006
|
}
|
|
15052
15007
|
|
|
15053
15008
|
// src/shapes/fieldAccesses.ts
|
|
15054
|
-
var
|
|
15009
|
+
var import_ts_morph66 = require("ts-morph");
|
|
15055
15010
|
function findResponseAccessor(callExpr) {
|
|
15056
15011
|
let current2 = callExpr;
|
|
15057
15012
|
const parent1 = current2.getParent();
|
|
15058
|
-
if (parent1 !== void 0 &&
|
|
15013
|
+
if (parent1 !== void 0 && import_ts_morph66.Node.isAwaitExpression(parent1)) {
|
|
15059
15014
|
current2 = parent1;
|
|
15060
15015
|
}
|
|
15061
15016
|
const parent2 = current2.getParent();
|
|
15062
|
-
if (parent2 === void 0 || !
|
|
15017
|
+
if (parent2 === void 0 || !import_ts_morph66.Node.isVariableDeclaration(parent2)) {
|
|
15063
15018
|
return null;
|
|
15064
15019
|
}
|
|
15065
15020
|
const nameNode = parent2.getNameNode();
|
|
15066
|
-
if (
|
|
15021
|
+
if (import_ts_morph66.Node.isIdentifier(nameNode)) {
|
|
15067
15022
|
return { kind: "identifier", name: nameNode.getText() };
|
|
15068
15023
|
}
|
|
15069
|
-
if (
|
|
15024
|
+
if (import_ts_morph66.Node.isObjectBindingPattern(nameNode)) {
|
|
15070
15025
|
const bindings = /* @__PURE__ */ new Map();
|
|
15071
15026
|
for (const element of nameNode.getElements()) {
|
|
15072
15027
|
if (element.getDotDotDotToken() !== void 0) {
|
|
@@ -15087,11 +15042,11 @@ function findResponseAccessor(callExpr) {
|
|
|
15087
15042
|
function buildThenChainAccessor(callExpr, func) {
|
|
15088
15043
|
const bindings = /* @__PURE__ */ new Map();
|
|
15089
15044
|
func.forEachDescendant((node) => {
|
|
15090
|
-
if (!
|
|
15045
|
+
if (!import_ts_morph66.Node.isParameterDeclaration(node)) {
|
|
15091
15046
|
return;
|
|
15092
15047
|
}
|
|
15093
15048
|
const nameNode = node.getNameNode();
|
|
15094
|
-
if (!
|
|
15049
|
+
if (!import_ts_morph66.Node.isIdentifier(nameNode)) {
|
|
15095
15050
|
return;
|
|
15096
15051
|
}
|
|
15097
15052
|
const prefix = prefixOfThenParam(node, callExpr, 0);
|
|
@@ -15123,7 +15078,7 @@ function prefixOfExpr(expr, responseCall, depth) {
|
|
|
15123
15078
|
if (node === responseCall) {
|
|
15124
15079
|
return [];
|
|
15125
15080
|
}
|
|
15126
|
-
if (
|
|
15081
|
+
if (import_ts_morph66.Node.isCallExpression(node)) {
|
|
15127
15082
|
const hop = thenLikeCall(node);
|
|
15128
15083
|
if (hop !== null) {
|
|
15129
15084
|
if (hop.method === "catch") {
|
|
@@ -15155,14 +15110,14 @@ function prefixOfMemberExpr(expr, responseCall, depth) {
|
|
|
15155
15110
|
return null;
|
|
15156
15111
|
}
|
|
15157
15112
|
const decl = chain.root.getSymbol()?.getDeclarations()?.[0];
|
|
15158
|
-
if (decl === void 0 || !
|
|
15113
|
+
if (decl === void 0 || !import_ts_morph66.Node.isParameterDeclaration(decl)) {
|
|
15159
15114
|
return null;
|
|
15160
15115
|
}
|
|
15161
15116
|
const base = prefixOfThenParam(decl, responseCall, depth + 1);
|
|
15162
15117
|
return base === null ? null : [...base, ...chain.segments];
|
|
15163
15118
|
}
|
|
15164
15119
|
function firstCallbackParamName(callback) {
|
|
15165
|
-
if (callback === void 0 || !(
|
|
15120
|
+
if (callback === void 0 || !(import_ts_morph66.Node.isArrowFunction(callback) || import_ts_morph66.Node.isFunctionExpression(callback))) {
|
|
15166
15121
|
return null;
|
|
15167
15122
|
}
|
|
15168
15123
|
const param = callback.getParameters()[0];
|
|
@@ -15170,11 +15125,11 @@ function firstCallbackParamName(callback) {
|
|
|
15170
15125
|
return null;
|
|
15171
15126
|
}
|
|
15172
15127
|
const nameNode = param.getNameNode();
|
|
15173
|
-
return
|
|
15128
|
+
return import_ts_morph66.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
|
|
15174
15129
|
}
|
|
15175
15130
|
function unwrap(expr) {
|
|
15176
15131
|
let node = expr;
|
|
15177
|
-
while (
|
|
15132
|
+
while (import_ts_morph66.Node.isAwaitExpression(node) || import_ts_morph66.Node.isParenthesizedExpression(node) || import_ts_morph66.Node.isAsExpression(node)) {
|
|
15178
15133
|
node = node.getExpression();
|
|
15179
15134
|
}
|
|
15180
15135
|
return node;
|
|
@@ -15184,15 +15139,15 @@ function chainRootedAt(expr, rootName) {
|
|
|
15184
15139
|
if (chain === null) {
|
|
15185
15140
|
return null;
|
|
15186
15141
|
}
|
|
15187
|
-
return
|
|
15142
|
+
return import_ts_morph66.Node.isIdentifier(chain.root) && chain.root.getText() === rootName ? chain.segments : null;
|
|
15188
15143
|
}
|
|
15189
15144
|
function memberChain(expr) {
|
|
15190
|
-
let node =
|
|
15191
|
-
if (
|
|
15145
|
+
let node = import_ts_morph66.Node.isExpression(expr) ? unwrap(expr) : expr;
|
|
15146
|
+
if (import_ts_morph66.Node.isCallExpression(node)) {
|
|
15192
15147
|
node = node.getExpression();
|
|
15193
15148
|
}
|
|
15194
15149
|
const segments = [];
|
|
15195
|
-
while (
|
|
15150
|
+
while (import_ts_morph66.Node.isPropertyAccessExpression(node)) {
|
|
15196
15151
|
segments.unshift(node.getName());
|
|
15197
15152
|
node = node.getExpression();
|
|
15198
15153
|
}
|
|
@@ -15211,16 +15166,16 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
15211
15166
|
if (accessor.kind === "identifier") {
|
|
15212
15167
|
const varName = accessor.name;
|
|
15213
15168
|
subtree.forEachDescendant((node) => {
|
|
15214
|
-
if (!
|
|
15169
|
+
if (!import_ts_morph66.Node.isPropertyAccessExpression(node)) {
|
|
15215
15170
|
return;
|
|
15216
15171
|
}
|
|
15217
15172
|
const chain = [];
|
|
15218
15173
|
let current2 = node;
|
|
15219
|
-
while (
|
|
15174
|
+
while (import_ts_morph66.Node.isPropertyAccessExpression(current2)) {
|
|
15220
15175
|
chain.unshift(current2.getName());
|
|
15221
15176
|
current2 = current2.getExpression();
|
|
15222
15177
|
}
|
|
15223
|
-
if (
|
|
15178
|
+
if (import_ts_morph66.Node.isIdentifier(current2) && current2.getText() === varName) {
|
|
15224
15179
|
pushChain(chain);
|
|
15225
15180
|
}
|
|
15226
15181
|
});
|
|
@@ -15231,7 +15186,7 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
15231
15186
|
return source === void 0 ? void 0 : [source];
|
|
15232
15187
|
} : (name) => accessor.bindings.get(name);
|
|
15233
15188
|
subtree.forEachDescendant((node) => {
|
|
15234
|
-
if (!
|
|
15189
|
+
if (!import_ts_morph66.Node.isIdentifier(node)) {
|
|
15235
15190
|
return;
|
|
15236
15191
|
}
|
|
15237
15192
|
const prefix = prefixOf(node.getText());
|
|
@@ -15243,13 +15198,13 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
15243
15198
|
}
|
|
15244
15199
|
let chainTop = node;
|
|
15245
15200
|
let parent = chainTop.getParent();
|
|
15246
|
-
while (parent !== void 0 &&
|
|
15201
|
+
while (parent !== void 0 && import_ts_morph66.Node.isPropertyAccessExpression(parent) && parent.getExpression() === chainTop) {
|
|
15247
15202
|
chainTop = parent;
|
|
15248
15203
|
parent = chainTop.getParent();
|
|
15249
15204
|
}
|
|
15250
15205
|
const segments = [];
|
|
15251
15206
|
let current2 = chainTop;
|
|
15252
|
-
while (
|
|
15207
|
+
while (import_ts_morph66.Node.isPropertyAccessExpression(current2)) {
|
|
15253
15208
|
segments.push(current2.getName());
|
|
15254
15209
|
current2 = current2.getExpression();
|
|
15255
15210
|
}
|
|
@@ -15263,15 +15218,15 @@ function isBindingDeclarationSite(node) {
|
|
|
15263
15218
|
return true;
|
|
15264
15219
|
}
|
|
15265
15220
|
const parent = node.getParent();
|
|
15266
|
-
return parent !== void 0 &&
|
|
15221
|
+
return parent !== void 0 && import_ts_morph66.Node.isParameterDeclaration(parent) && parent.getNameNode() === node;
|
|
15267
15222
|
}
|
|
15268
15223
|
function isInsideObjectBindingPattern(node) {
|
|
15269
15224
|
let current2 = node.getParent();
|
|
15270
15225
|
while (current2 !== void 0) {
|
|
15271
|
-
if (
|
|
15226
|
+
if (import_ts_morph66.Node.isObjectBindingPattern(current2)) {
|
|
15272
15227
|
return true;
|
|
15273
15228
|
}
|
|
15274
|
-
if (
|
|
15229
|
+
if (import_ts_morph66.Node.isFunctionLikeDeclaration(current2) || import_ts_morph66.Node.isVariableStatement(current2)) {
|
|
15275
15230
|
break;
|
|
15276
15231
|
}
|
|
15277
15232
|
current2 = current2.getParent();
|
|
@@ -15334,7 +15289,7 @@ function findBranchSubtree(func, byLineRange, terminalStartLine, terminalEndLine
|
|
|
15334
15289
|
if (parent === void 0) {
|
|
15335
15290
|
break;
|
|
15336
15291
|
}
|
|
15337
|
-
if (
|
|
15292
|
+
if (import_ts_morph66.Node.isIfStatement(parent)) {
|
|
15338
15293
|
const ifStmt = parent;
|
|
15339
15294
|
const thenBlock = ifStmt.getThenStatement();
|
|
15340
15295
|
const elseBlock = ifStmt.getElseStatement();
|
|
@@ -15396,7 +15351,7 @@ function buildNonBodyPropertySet(semantics) {
|
|
|
15396
15351
|
}
|
|
15397
15352
|
|
|
15398
15353
|
// src/subUnitContext.ts
|
|
15399
|
-
var
|
|
15354
|
+
var import_ts_morph67 = require("ts-morph");
|
|
15400
15355
|
function createTsSubUnitContext() {
|
|
15401
15356
|
return {
|
|
15402
15357
|
findJsxAttributes,
|
|
@@ -15423,18 +15378,18 @@ function findJsxAttributes(parent) {
|
|
|
15423
15378
|
if (skip(node, traversal)) {
|
|
15424
15379
|
return;
|
|
15425
15380
|
}
|
|
15426
|
-
if (!
|
|
15381
|
+
if (!import_ts_morph67.Node.isJsxOpeningElement(node) && !import_ts_morph67.Node.isJsxSelfClosingElement(node)) {
|
|
15427
15382
|
return;
|
|
15428
15383
|
}
|
|
15429
15384
|
const tag = node.getTagNameNode().getText();
|
|
15430
15385
|
for (const attr of node.getAttributes()) {
|
|
15431
|
-
if (!
|
|
15386
|
+
if (!import_ts_morph67.Node.isJsxAttribute(attr)) {
|
|
15432
15387
|
continue;
|
|
15433
15388
|
}
|
|
15434
15389
|
const initializer = attr.getInitializer();
|
|
15435
15390
|
let valueExpression = null;
|
|
15436
15391
|
if (initializer !== void 0) {
|
|
15437
|
-
if (
|
|
15392
|
+
if (import_ts_morph67.Node.isJsxExpression(initializer)) {
|
|
15438
15393
|
const inner = initializer.getExpression();
|
|
15439
15394
|
valueExpression = inner ?? null;
|
|
15440
15395
|
} else {
|
|
@@ -15457,11 +15412,11 @@ function findCallExpressionsByName(parent, name) {
|
|
|
15457
15412
|
if (skip(node, traversal)) {
|
|
15458
15413
|
return;
|
|
15459
15414
|
}
|
|
15460
|
-
if (!
|
|
15415
|
+
if (!import_ts_morph67.Node.isCallExpression(node)) {
|
|
15461
15416
|
return;
|
|
15462
15417
|
}
|
|
15463
15418
|
const callee = node.getExpression();
|
|
15464
|
-
if (
|
|
15419
|
+
if (import_ts_morph67.Node.isIdentifier(callee) && callee.getText() === name) {
|
|
15465
15420
|
out.push(node);
|
|
15466
15421
|
}
|
|
15467
15422
|
});
|
|
@@ -15472,10 +15427,10 @@ function resolveAttributeValueFunction(attr, parent) {
|
|
|
15472
15427
|
if (expr === null) {
|
|
15473
15428
|
return null;
|
|
15474
15429
|
}
|
|
15475
|
-
if (
|
|
15430
|
+
if (import_ts_morph67.Node.isArrowFunction(expr) || import_ts_morph67.Node.isFunctionExpression(expr)) {
|
|
15476
15431
|
return { func: expr, localName: null };
|
|
15477
15432
|
}
|
|
15478
|
-
if (
|
|
15433
|
+
if (import_ts_morph67.Node.isIdentifier(expr)) {
|
|
15479
15434
|
const symbol = expr.getSymbol();
|
|
15480
15435
|
if (symbol === void 0) {
|
|
15481
15436
|
return null;
|
|
@@ -15494,15 +15449,15 @@ function resolveAttributeValueFunction(attr, parent) {
|
|
|
15494
15449
|
return null;
|
|
15495
15450
|
}
|
|
15496
15451
|
function tryExtractFunction(decl) {
|
|
15497
|
-
if (
|
|
15452
|
+
if (import_ts_morph67.Node.isFunctionDeclaration(decl)) {
|
|
15498
15453
|
return decl;
|
|
15499
15454
|
}
|
|
15500
|
-
if (
|
|
15455
|
+
if (import_ts_morph67.Node.isVariableDeclaration(decl)) {
|
|
15501
15456
|
const init = decl.getInitializer();
|
|
15502
15457
|
if (init === void 0) {
|
|
15503
15458
|
return null;
|
|
15504
15459
|
}
|
|
15505
|
-
if (
|
|
15460
|
+
if (import_ts_morph67.Node.isArrowFunction(init) || import_ts_morph67.Node.isFunctionExpression(init)) {
|
|
15506
15461
|
return init;
|
|
15507
15462
|
}
|
|
15508
15463
|
}
|
|
@@ -15523,7 +15478,7 @@ function getCallArgumentFunction(call, position) {
|
|
|
15523
15478
|
if (arg === void 0) {
|
|
15524
15479
|
return null;
|
|
15525
15480
|
}
|
|
15526
|
-
if (
|
|
15481
|
+
if (import_ts_morph67.Node.isArrowFunction(arg) || import_ts_morph67.Node.isFunctionExpression(arg)) {
|
|
15527
15482
|
return arg;
|
|
15528
15483
|
}
|
|
15529
15484
|
return null;
|
|
@@ -15535,7 +15490,7 @@ function readArrayLiteralText(node) {
|
|
|
15535
15490
|
if (node === null) {
|
|
15536
15491
|
return null;
|
|
15537
15492
|
}
|
|
15538
|
-
if (
|
|
15493
|
+
if (import_ts_morph67.Node.isArrayLiteralExpression(node)) {
|
|
15539
15494
|
return node.getElements().map((e) => e.getText());
|
|
15540
15495
|
}
|
|
15541
15496
|
return [node.getText()];
|
|
@@ -15586,14 +15541,14 @@ function idFor(workspace, file, summary) {
|
|
|
15586
15541
|
}
|
|
15587
15542
|
|
|
15588
15543
|
// src/timing.ts
|
|
15589
|
-
var
|
|
15544
|
+
var import_extractor9 = require("@suss/extractor");
|
|
15590
15545
|
|
|
15591
15546
|
// src/version.ts
|
|
15592
|
-
var import_extractor9 = require("@suss/extractor");
|
|
15593
15547
|
var import_extractor10 = require("@suss/extractor");
|
|
15548
|
+
var import_extractor11 = require("@suss/extractor");
|
|
15594
15549
|
var import_meta = {};
|
|
15595
15550
|
var ADAPTER_VERSION = "0.2.1";
|
|
15596
|
-
var stamp = (0,
|
|
15551
|
+
var stamp = (0, import_extractor10.createAdapterStamp)({
|
|
15597
15552
|
moduleUrl: import_meta.url,
|
|
15598
15553
|
version: ADAPTER_VERSION
|
|
15599
15554
|
});
|
|
@@ -15761,7 +15716,7 @@ function workspaceExpansionStamp(frameworks) {
|
|
|
15761
15716
|
const paths = frameworks.flatMap((pack) => pack.discovery).flatMap(
|
|
15762
15717
|
(pattern) => pattern.match.type === "packageExports" && pattern.match.packageJsonPath !== void 0 ? [pattern.match.packageJsonPath] : []
|
|
15763
15718
|
);
|
|
15764
|
-
return (0,
|
|
15719
|
+
return (0, import_extractor11.projectFileStamp)(paths);
|
|
15765
15720
|
}
|
|
15766
15721
|
function expandWorkspacePatterns(frameworks, anchor) {
|
|
15767
15722
|
const marked = frameworks.some(
|
|
@@ -15784,13 +15739,13 @@ var raise = (msg) => {
|
|
|
15784
15739
|
throw new Error(msg);
|
|
15785
15740
|
};
|
|
15786
15741
|
function bindingPatternNames(nameNode) {
|
|
15787
|
-
if (
|
|
15742
|
+
if (import_ts_morph68.Node.isObjectBindingPattern(nameNode)) {
|
|
15788
15743
|
return nameNode.getElements().map((e) => e.getName());
|
|
15789
15744
|
}
|
|
15790
|
-
if (
|
|
15745
|
+
if (import_ts_morph68.Node.isArrayBindingPattern(nameNode)) {
|
|
15791
15746
|
const names = [];
|
|
15792
15747
|
for (const element of nameNode.getElements()) {
|
|
15793
|
-
if (
|
|
15748
|
+
if (import_ts_morph68.Node.isOmittedExpression(element)) {
|
|
15794
15749
|
continue;
|
|
15795
15750
|
}
|
|
15796
15751
|
names.push(element.getName());
|
|
@@ -15820,7 +15775,7 @@ function objectParamInputs(param, position, mapping) {
|
|
|
15820
15775
|
}
|
|
15821
15776
|
function componentPropsParameters(param, mapping) {
|
|
15822
15777
|
const nameNode = param.getNameNode();
|
|
15823
|
-
if (!
|
|
15778
|
+
if (!import_ts_morph68.Node.isObjectBindingPattern(nameNode)) {
|
|
15824
15779
|
const type = param.getType();
|
|
15825
15780
|
return [
|
|
15826
15781
|
{
|
|
@@ -15850,7 +15805,7 @@ function bindingRole(element, name) {
|
|
|
15850
15805
|
if (property === void 0) {
|
|
15851
15806
|
return name;
|
|
15852
15807
|
}
|
|
15853
|
-
if (
|
|
15808
|
+
if (import_ts_morph68.Node.isStringLiteral(property)) {
|
|
15854
15809
|
return property.getLiteralValue();
|
|
15855
15810
|
}
|
|
15856
15811
|
return property.getText();
|
|
@@ -15882,7 +15837,7 @@ function extractParameters(func, inputMapping) {
|
|
|
15882
15837
|
const param = params[i];
|
|
15883
15838
|
const nameNode = param.getNameNode();
|
|
15884
15839
|
const boundNames = bindingPatternNames(nameNode);
|
|
15885
|
-
if (
|
|
15840
|
+
if (import_ts_morph68.Node.isObjectBindingPattern(nameNode)) {
|
|
15886
15841
|
for (const element of nameNode.getElements()) {
|
|
15887
15842
|
result.push({
|
|
15888
15843
|
name: element.getName(),
|
|
@@ -15949,7 +15904,7 @@ function extractDependencyCalls(func, barriers = NO_BARRIERS) {
|
|
|
15949
15904
|
traversal.skip();
|
|
15950
15905
|
return;
|
|
15951
15906
|
}
|
|
15952
|
-
if (!
|
|
15907
|
+
if (!import_ts_morph68.Node.isVariableDeclaration(node)) {
|
|
15953
15908
|
return;
|
|
15954
15909
|
}
|
|
15955
15910
|
const init = node.getInitializer();
|
|
@@ -15958,19 +15913,19 @@ function extractDependencyCalls(func, barriers = NO_BARRIERS) {
|
|
|
15958
15913
|
}
|
|
15959
15914
|
let isAsync = false;
|
|
15960
15915
|
let callExpr = init;
|
|
15961
|
-
if (
|
|
15916
|
+
if (import_ts_morph68.Node.isAwaitExpression(init)) {
|
|
15962
15917
|
isAsync = true;
|
|
15963
15918
|
callExpr = init.getExpression();
|
|
15964
15919
|
}
|
|
15965
|
-
if (!
|
|
15920
|
+
if (!import_ts_morph68.Node.isCallExpression(callExpr)) {
|
|
15966
15921
|
return;
|
|
15967
15922
|
}
|
|
15968
15923
|
const calleeName = callExpr.getExpression().getText();
|
|
15969
15924
|
const nameNode = node.getNameNode();
|
|
15970
|
-
const assignedTo =
|
|
15925
|
+
const assignedTo = import_ts_morph68.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
|
|
15971
15926
|
const declList = node.getParent();
|
|
15972
15927
|
const varStmt = declList?.getParent();
|
|
15973
|
-
const locationNode = varStmt !== void 0 &&
|
|
15928
|
+
const locationNode = varStmt !== void 0 && import_ts_morph68.Node.isVariableStatement(varStmt) ? varStmt : node;
|
|
15974
15929
|
results.push({
|
|
15975
15930
|
name: calleeName,
|
|
15976
15931
|
assignedTo,
|
|
@@ -16329,6 +16284,10 @@ function extractBindingPath(binding, callSite, pack, resolution) {
|
|
|
16329
16284
|
const arg = callSite.callExpression.getArguments()[p.position];
|
|
16330
16285
|
return arg === void 0 ? void 0 : pathFromArgument(arg, resolution);
|
|
16331
16286
|
}
|
|
16287
|
+
if (p.type === "fromArgumentProperty") {
|
|
16288
|
+
const arg = callSite.callExpression.getArguments()[p.position];
|
|
16289
|
+
return arg === void 0 ? void 0 : pathFromProperty(arg, p.property, resolution);
|
|
16290
|
+
}
|
|
16332
16291
|
return void 0;
|
|
16333
16292
|
}
|
|
16334
16293
|
function resolveContractField(callSite, pack, field, resolution) {
|
|
@@ -16407,7 +16366,7 @@ function computeSubUnitBarriers(unit, packs, ctx, tallies, file) {
|
|
|
16407
16366
|
}
|
|
16408
16367
|
} catch (err) {
|
|
16409
16368
|
process.stderr.write(
|
|
16410
|
-
(0,
|
|
16369
|
+
(0, import_extractor6.recordPackFailure)(tallies?.get(pack.name), {
|
|
16411
16370
|
pack: pack.name,
|
|
16412
16371
|
hook: "subUnits",
|
|
16413
16372
|
file,
|
|
@@ -16469,7 +16428,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16469
16428
|
}
|
|
16470
16429
|
} catch (err) {
|
|
16471
16430
|
process.stderr.write(
|
|
16472
|
-
(0,
|
|
16431
|
+
(0, import_extractor6.recordPackFailure)(tally, {
|
|
16473
16432
|
pack: pack.name,
|
|
16474
16433
|
hook: "discoverUnits",
|
|
16475
16434
|
file: sourceFile.getFilePath(),
|
|
@@ -16679,7 +16638,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16679
16638
|
});
|
|
16680
16639
|
}
|
|
16681
16640
|
}
|
|
16682
|
-
const summary = (0,
|
|
16641
|
+
const summary = (0, import_extractor12.assembleSummary)(raw, options);
|
|
16683
16642
|
if (options?.gapHandling !== "silent") {
|
|
16684
16643
|
for (const stop of unfollowedStopsOf(unit, wrappers)) {
|
|
16685
16644
|
summary.gaps.push((0, import_behavioral_ir2.unfollowedCallGap)(stop));
|
|
@@ -16724,20 +16683,23 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16724
16683
|
return summaries;
|
|
16725
16684
|
}
|
|
16726
16685
|
function stampWrappers(raw, unit, wrappers) {
|
|
16727
|
-
|
|
16728
|
-
|
|
16729
|
-
|
|
16730
|
-
|
|
16686
|
+
const applied = [
|
|
16687
|
+
...wrappers === void 0 || unit.registrationSubjectId === void 0 ? [] : wrappers.wrappersFor(unit.registrationSubjectId),
|
|
16688
|
+
...unit.routeWrappers ?? []
|
|
16689
|
+
];
|
|
16731
16690
|
if (applied.length === 0) {
|
|
16732
16691
|
return;
|
|
16733
16692
|
}
|
|
16734
|
-
raw.wrappers =
|
|
16693
|
+
raw.wrappers = applied;
|
|
16735
16694
|
for (const wrapper of applied) {
|
|
16736
16695
|
recordFileDependency(wrapper.file);
|
|
16737
16696
|
}
|
|
16738
16697
|
}
|
|
16739
16698
|
function unfollowedStopsOf(unit, wrappers) {
|
|
16740
|
-
const stops =
|
|
16699
|
+
const stops = [
|
|
16700
|
+
...unit.unfollowed === void 0 ? [] : [unit.unfollowed],
|
|
16701
|
+
...unit.routeUnfollowed ?? []
|
|
16702
|
+
];
|
|
16741
16703
|
if (wrappers === void 0 || unit.registrationSubjectId === void 0) {
|
|
16742
16704
|
return stops;
|
|
16743
16705
|
}
|
|
@@ -16884,9 +16846,9 @@ function findWrapperPathParam(summary, lookup) {
|
|
|
16884
16846
|
if (names.length === 0) {
|
|
16885
16847
|
return null;
|
|
16886
16848
|
}
|
|
16887
|
-
for (const call of func.getDescendantsOfKind(
|
|
16849
|
+
for (const call of func.getDescendantsOfKind(import_ts_morph68.SyntaxKind.CallExpression)) {
|
|
16888
16850
|
const first = call.getArguments()[0];
|
|
16889
|
-
if (first === void 0 || !
|
|
16851
|
+
if (first === void 0 || !import_ts_morph68.Node.isIdentifier(first)) {
|
|
16890
16852
|
continue;
|
|
16891
16853
|
}
|
|
16892
16854
|
const at = names.indexOf(first.getText());
|
|
@@ -16935,16 +16897,16 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
16935
16897
|
return out;
|
|
16936
16898
|
}
|
|
16937
16899
|
function wrapperNameNode(func) {
|
|
16938
|
-
if (
|
|
16900
|
+
if (import_ts_morph68.Node.isFunctionDeclaration(func) || import_ts_morph68.Node.isMethodDeclaration(func)) {
|
|
16939
16901
|
const name = func.getNameNode();
|
|
16940
|
-
if (name !== void 0 &&
|
|
16902
|
+
if (name !== void 0 && import_ts_morph68.Node.isIdentifier(name)) {
|
|
16941
16903
|
return name;
|
|
16942
16904
|
}
|
|
16943
16905
|
}
|
|
16944
16906
|
const parent = func.getParent();
|
|
16945
|
-
if (parent !== void 0 &&
|
|
16907
|
+
if (parent !== void 0 && import_ts_morph68.Node.isVariableDeclaration(parent)) {
|
|
16946
16908
|
const nameNode = parent.getNameNode();
|
|
16947
|
-
if (
|
|
16909
|
+
if (import_ts_morph68.Node.isIdentifier(nameNode)) {
|
|
16948
16910
|
return nameNode;
|
|
16949
16911
|
}
|
|
16950
16912
|
}
|
|
@@ -16953,10 +16915,10 @@ function wrapperNameNode(func) {
|
|
|
16953
16915
|
function enclosingCall(node) {
|
|
16954
16916
|
let current2 = node.getParent();
|
|
16955
16917
|
while (current2 !== void 0) {
|
|
16956
|
-
if (
|
|
16918
|
+
if (import_ts_morph68.Node.isCallExpression(current2)) {
|
|
16957
16919
|
return current2;
|
|
16958
16920
|
}
|
|
16959
|
-
if (
|
|
16921
|
+
if (import_ts_morph68.Node.isPropertyAccessExpression(current2)) {
|
|
16960
16922
|
current2 = current2.getParent();
|
|
16961
16923
|
continue;
|
|
16962
16924
|
}
|
|
@@ -16967,7 +16929,7 @@ function enclosingCall(node) {
|
|
|
16967
16929
|
function enclosingFunction(node) {
|
|
16968
16930
|
let current2 = node.getParent();
|
|
16969
16931
|
while (current2 !== void 0) {
|
|
16970
|
-
if (
|
|
16932
|
+
if (import_ts_morph68.Node.isFunctionDeclaration(current2) || import_ts_morph68.Node.isFunctionExpression(current2) || import_ts_morph68.Node.isArrowFunction(current2) || import_ts_morph68.Node.isMethodDeclaration(current2)) {
|
|
16971
16933
|
return current2;
|
|
16972
16934
|
}
|
|
16973
16935
|
current2 = current2.getParent();
|
|
@@ -16975,13 +16937,13 @@ function enclosingFunction(node) {
|
|
|
16975
16937
|
return null;
|
|
16976
16938
|
}
|
|
16977
16939
|
function callerName(func) {
|
|
16978
|
-
if (
|
|
16940
|
+
if (import_ts_morph68.Node.isFunctionDeclaration(func) || import_ts_morph68.Node.isMethodDeclaration(func)) {
|
|
16979
16941
|
return func.getName() ?? "anonymous";
|
|
16980
16942
|
}
|
|
16981
16943
|
const parent = func.getParent();
|
|
16982
|
-
if (parent !== void 0 &&
|
|
16944
|
+
if (parent !== void 0 && import_ts_morph68.Node.isVariableDeclaration(parent)) {
|
|
16983
16945
|
const nameNode = parent.getNameNode();
|
|
16984
|
-
if (
|
|
16946
|
+
if (import_ts_morph68.Node.isIdentifier(nameNode)) {
|
|
16985
16947
|
return nameNode.getText();
|
|
16986
16948
|
}
|
|
16987
16949
|
}
|
|
@@ -17022,7 +16984,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path15, options) {
|
|
|
17022
16984
|
path: path15,
|
|
17023
16985
|
recognition: wrapperBinding?.recognition ?? "unknown"
|
|
17024
16986
|
});
|
|
17025
|
-
const summary = (0,
|
|
16987
|
+
const summary = (0, import_extractor12.assembleSummary)(raw, options);
|
|
17026
16988
|
summary.metadata = {
|
|
17027
16989
|
...summary.metadata ?? {},
|
|
17028
16990
|
derivedFromWrapper: {
|
|
@@ -17034,7 +16996,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path15, options) {
|
|
|
17034
16996
|
return summary;
|
|
17035
16997
|
}
|
|
17036
16998
|
function named(summaries, workspace, runRoot) {
|
|
17037
|
-
const projectRoot = runRoot ?? commonDirectoryOf(summaries.map((s) => s.location.file));
|
|
16999
|
+
const projectRoot = runRoot ?? (0, import_extractor12.commonDirectoryOf)(summaries.map((s) => s.location.file));
|
|
17038
17000
|
nameSummaries(summaries, {
|
|
17039
17001
|
workspace: workspace ?? workspaceNameFor(projectRoot),
|
|
17040
17002
|
projectRoot
|
|
@@ -17080,7 +17042,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17080
17042
|
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ? import_node_path11.default.dirname(suppliedConfig.tsConfigFilePath) : void 0)
|
|
17081
17043
|
)
|
|
17082
17044
|
};
|
|
17083
|
-
const project = config.project ?? new
|
|
17045
|
+
const project = config.project ?? new import_ts_morph68.Project(
|
|
17084
17046
|
config.tsConfigFilePath !== void 0 ? {
|
|
17085
17047
|
tsConfigFilePath: config.tsConfigFilePath,
|
|
17086
17048
|
skipAddingFilesFromTsConfig: true
|
|
@@ -17092,7 +17054,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17092
17054
|
const cacheDir = declineWhenRunFromSource(
|
|
17093
17055
|
config.cacheDir === null ? null : config.cacheDir ?? (config.tsConfigFilePath !== void 0 ? import_node_path11.default.join(import_node_path11.default.dirname(config.tsConfigFilePath), ".suss", "cache") : null)
|
|
17094
17056
|
);
|
|
17095
|
-
const cache = (0,
|
|
17057
|
+
const cache = (0, import_extractor12.createCacheLayer)(cacheDir);
|
|
17096
17058
|
const packsDigest = `${computeAdapterPacksDigest(
|
|
17097
17059
|
config.frameworks.map(
|
|
17098
17060
|
(p) => p.version !== void 0 ? { name: p.name, version: p.version } : { name: p.name }
|
|
@@ -17127,11 +17089,15 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17127
17089
|
)
|
|
17128
17090
|
);
|
|
17129
17091
|
}
|
|
17130
|
-
return named(
|
|
17092
|
+
return named(
|
|
17093
|
+
(0, import_extractor12.composeWrappers)(summaries, config.extractorOptions ?? {}),
|
|
17094
|
+
config.workspace,
|
|
17095
|
+
runRoot
|
|
17096
|
+
);
|
|
17131
17097
|
},
|
|
17132
17098
|
async extractAll() {
|
|
17133
|
-
const timer = (0,
|
|
17134
|
-
const tallies = (0,
|
|
17099
|
+
const timer = (0, import_extractor9.createTimer)();
|
|
17100
|
+
const tallies = (0, import_extractor6.createPackTallies)(config.frameworks);
|
|
17135
17101
|
forgetUnreadableExportFiles();
|
|
17136
17102
|
forgetReassignedNamesUnstated();
|
|
17137
17103
|
const lazyEligible = !lazyBootstrapped && config.tsConfigFilePath !== void 0 && config.project === void 0;
|
|
@@ -17144,7 +17110,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17144
17110
|
let cacheFiles = null;
|
|
17145
17111
|
const adapterPacksDigest = cacheDir === null ? packsDigest : timer.time("cache.digest", () => {
|
|
17146
17112
|
cacheFiles = tsconfigFileList ?? project.getSourceFiles().map((sf) => sf.getFilePath());
|
|
17147
|
-
return (0,
|
|
17113
|
+
return (0, import_extractor12.runDigest)(packsDigest, config.frameworks, cacheFiles);
|
|
17148
17114
|
});
|
|
17149
17115
|
const cacheInput = {
|
|
17150
17116
|
// Empty when cacheDir is null: a no-op cache layer never reads
|
|
@@ -17338,7 +17304,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17338
17304
|
)
|
|
17339
17305
|
);
|
|
17340
17306
|
const closureFacts = {
|
|
17341
|
-
db: new
|
|
17307
|
+
db: new import_datalog5.Database(),
|
|
17342
17308
|
unitKeyBySummary: /* @__PURE__ */ new Map(),
|
|
17343
17309
|
...caching ? { filesByKey: /* @__PURE__ */ new Map() } : {}
|
|
17344
17310
|
};
|
|
@@ -17387,15 +17353,9 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17387
17353
|
"enrichRethrows",
|
|
17388
17354
|
() => enrichRethrows(merged.summaries, project, closureFacts)
|
|
17389
17355
|
);
|
|
17390
|
-
if (config.includeReachable !== false) {
|
|
17391
|
-
timer.time(
|
|
17392
|
-
"deriveBoundaryEffects",
|
|
17393
|
-
() => deriveBoundaryEffects(enriched, closureFacts)
|
|
17394
|
-
);
|
|
17395
|
-
}
|
|
17396
17356
|
timer.time(
|
|
17397
17357
|
"stampModuleImports",
|
|
17398
|
-
() => (0,
|
|
17358
|
+
() => (0, import_extractor12.stampModuleImports)(enriched, (file) => {
|
|
17399
17359
|
const imports = internalImportsOf(project, file);
|
|
17400
17360
|
return imports.length === 0 ? void 0 : imports;
|
|
17401
17361
|
})
|
|
@@ -17457,7 +17417,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17457
17417
|
});
|
|
17458
17418
|
const composed = timer.time(
|
|
17459
17419
|
"composeWrappers",
|
|
17460
|
-
() => (0,
|
|
17420
|
+
() => (0, import_extractor12.composeWrappers)(enriched, config.extractorOptions ?? {})
|
|
17461
17421
|
);
|
|
17462
17422
|
if (config.onTiming !== void 0) {
|
|
17463
17423
|
config.onTiming(timer.report());
|
|
@@ -17471,7 +17431,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17471
17431
|
filesWalked: walkList.length,
|
|
17472
17432
|
summaries: composed,
|
|
17473
17433
|
tsConfigFilePath: config.tsConfigFilePath,
|
|
17474
|
-
projectRoot: commonDirectoryOf(
|
|
17434
|
+
projectRoot: (0, import_extractor12.commonDirectoryOf)(
|
|
17475
17435
|
sourceFiles.map((f) => f.getFilePath())
|
|
17476
17436
|
),
|
|
17477
17437
|
filesWithUnreadableExports: unreadableExportFiles(),
|
|
@@ -17483,7 +17443,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17483
17443
|
return named(
|
|
17484
17444
|
composed,
|
|
17485
17445
|
config.workspace,
|
|
17486
|
-
runRoot ?? commonDirectoryOf(sourceFiles.map((f) => f.getFilePath()))
|
|
17446
|
+
runRoot ?? (0, import_extractor12.commonDirectoryOf)(sourceFiles.map((f) => f.getFilePath()))
|
|
17487
17447
|
);
|
|
17488
17448
|
}
|
|
17489
17449
|
};
|
|
@@ -17782,7 +17742,7 @@ function buildSubUnitSummary(subUnit, parent, invocationRecognizers, accessRecog
|
|
|
17782
17742
|
if (parent.identity.boundaryBinding !== null) {
|
|
17783
17743
|
raw.boundaryBinding = parent.identity.boundaryBinding;
|
|
17784
17744
|
}
|
|
17785
|
-
const summary = (0,
|
|
17745
|
+
const summary = (0, import_extractor12.assembleSummary)(raw, options);
|
|
17786
17746
|
if (subUnit.metadata !== void 0 && Object.keys(subUnit.metadata).length > 0) {
|
|
17787
17747
|
summary.metadata = {
|
|
17788
17748
|
...summary.metadata ?? {},
|
|
@@ -17796,7 +17756,7 @@ function buildSubUnitSummary(subUnit, parent, invocationRecognizers, accessRecog
|
|
|
17796
17756
|
// src/bootstrap/noTsconfigProject.ts
|
|
17797
17757
|
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
17798
17758
|
var import_node_path12 = __toESM(require("path"), 1);
|
|
17799
|
-
var
|
|
17759
|
+
var import_ts_morph69 = require("ts-morph");
|
|
17800
17760
|
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
17801
17761
|
".ts",
|
|
17802
17762
|
".tsx",
|
|
@@ -17844,12 +17804,12 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
17844
17804
|
return found;
|
|
17845
17805
|
}
|
|
17846
17806
|
function createProjectWithoutTsconfig(rootDir) {
|
|
17847
|
-
const project = new
|
|
17807
|
+
const project = new import_ts_morph69.Project({
|
|
17848
17808
|
skipAddingFilesFromTsConfig: true,
|
|
17849
17809
|
compilerOptions: {
|
|
17850
|
-
target:
|
|
17851
|
-
module:
|
|
17852
|
-
moduleResolution:
|
|
17810
|
+
target: import_ts_morph69.ScriptTarget.ES2022,
|
|
17811
|
+
module: import_ts_morph69.ModuleKind.ESNext,
|
|
17812
|
+
moduleResolution: import_ts_morph69.ModuleResolutionKind.Bundler,
|
|
17853
17813
|
allowJs: true,
|
|
17854
17814
|
checkJs: false,
|
|
17855
17815
|
noEmit: true,
|
|
@@ -17871,10 +17831,18 @@ function createProjectWithoutTsconfig(rootDir) {
|
|
|
17871
17831
|
}
|
|
17872
17832
|
return { project, files };
|
|
17873
17833
|
}
|
|
17834
|
+
var TSCONFIG_NAMES = [
|
|
17835
|
+
"tsconfig.json",
|
|
17836
|
+
"jsconfig.json",
|
|
17837
|
+
"tsconfig.base.json"
|
|
17838
|
+
];
|
|
17839
|
+
var WALK_UP_TSCONFIG_NAMES = ["tsconfig.json", "jsconfig.json"];
|
|
17874
17840
|
function findNearestTsconfig(startDir) {
|
|
17875
|
-
|
|
17841
|
+
const start = import_node_path12.default.resolve(startDir);
|
|
17842
|
+
let dir = start;
|
|
17876
17843
|
while (true) {
|
|
17877
|
-
|
|
17844
|
+
const names = dir === start ? TSCONFIG_NAMES : WALK_UP_TSCONFIG_NAMES;
|
|
17845
|
+
for (const name of names) {
|
|
17878
17846
|
const candidate = import_node_path12.default.join(dir, name);
|
|
17879
17847
|
if (import_node_fs5.default.existsSync(candidate)) {
|
|
17880
17848
|
return candidate;
|
|
@@ -17890,7 +17858,7 @@ function findNearestTsconfig(startDir) {
|
|
|
17890
17858
|
|
|
17891
17859
|
// src/facts/why.ts
|
|
17892
17860
|
var import_node_path13 = __toESM(require("path"), 1);
|
|
17893
|
-
var
|
|
17861
|
+
var import_ts_morph70 = require("ts-morph");
|
|
17894
17862
|
var import_resolution7 = require("@suss/resolution");
|
|
17895
17863
|
var JS_PHRASES = {
|
|
17896
17864
|
bind: ({ tuple, describe }) => ({
|
|
@@ -17904,7 +17872,7 @@ var TypeScriptWhySession = class {
|
|
|
17904
17872
|
constructor(options) {
|
|
17905
17873
|
this.root = import_node_path13.default.resolve(options.dir);
|
|
17906
17874
|
const tsconfig = findNearestTsconfig(this.root);
|
|
17907
|
-
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new
|
|
17875
|
+
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new import_ts_morph70.Project({ tsConfigFilePath: tsconfig });
|
|
17908
17876
|
this.store = new ResolutionStore();
|
|
17909
17877
|
}
|
|
17910
17878
|
/**
|
|
@@ -17919,7 +17887,7 @@ var TypeScriptWhySession = class {
|
|
|
17919
17887
|
}
|
|
17920
17888
|
let found = null;
|
|
17921
17889
|
sourceFile.forEachDescendant((node) => {
|
|
17922
|
-
if (
|
|
17890
|
+
if (import_ts_morph70.Node.isExpression(node) && node.getStartLineNumber() === line && node.getText() === text && (found === null || node.getWidth() <= found.getWidth())) {
|
|
17923
17891
|
found = node;
|
|
17924
17892
|
}
|
|
17925
17893
|
});
|
|
@@ -17937,7 +17905,7 @@ var TypeScriptWhySession = class {
|
|
|
17937
17905
|
return null;
|
|
17938
17906
|
}
|
|
17939
17907
|
for (const call of sourceFile.getDescendantsOfKind(
|
|
17940
|
-
|
|
17908
|
+
import_ts_morph70.SyntaxKind.CallExpression
|
|
17941
17909
|
)) {
|
|
17942
17910
|
const line = call.getStartLineNumber();
|
|
17943
17911
|
if (line < startLine || line > endLine) {
|
|
@@ -18011,21 +17979,21 @@ var TypeScriptWhySession = class {
|
|
|
18011
17979
|
}
|
|
18012
17980
|
};
|
|
18013
17981
|
function displayNameOf(node) {
|
|
18014
|
-
if (
|
|
17982
|
+
if (import_ts_morph70.Node.isIdentifier(node) || import_ts_morph70.Node.isPropertyAccessExpression(node)) {
|
|
18015
17983
|
return node.getText();
|
|
18016
17984
|
}
|
|
18017
|
-
if (
|
|
17985
|
+
if (import_ts_morph70.Node.isCallExpression(node) || import_ts_morph70.Node.isNewExpression(node)) {
|
|
18018
17986
|
return `${node.getExpression()?.getText() ?? "call"}(...)`;
|
|
18019
17987
|
}
|
|
18020
|
-
if (
|
|
17988
|
+
if (import_ts_morph70.Node.isFunctionDeclaration(node) || import_ts_morph70.Node.isClassDeclaration(node) || import_ts_morph70.Node.isMethodDeclaration(node) || import_ts_morph70.Node.isVariableDeclaration(node)) {
|
|
18021
17989
|
const name = node.getName();
|
|
18022
17990
|
if (name !== void 0) {
|
|
18023
17991
|
return name;
|
|
18024
17992
|
}
|
|
18025
17993
|
}
|
|
18026
|
-
if (
|
|
17994
|
+
if (import_ts_morph70.Node.isArrowFunction(node) || import_ts_morph70.Node.isFunctionExpression(node)) {
|
|
18027
17995
|
const parent = node.getParent();
|
|
18028
|
-
if (parent !== void 0 &&
|
|
17996
|
+
if (parent !== void 0 && import_ts_morph70.Node.isVariableDeclaration(parent)) {
|
|
18029
17997
|
return parent.getName();
|
|
18030
17998
|
}
|
|
18031
17999
|
}
|
|
@@ -18035,7 +18003,7 @@ function displayNameOf(node) {
|
|
|
18035
18003
|
|
|
18036
18004
|
// src/stubEvidence.ts
|
|
18037
18005
|
var import_node_path14 = __toESM(require("path"), 1);
|
|
18038
|
-
var
|
|
18006
|
+
var import_ts_morph71 = require("ts-morph");
|
|
18039
18007
|
function stubEvidenceIn(project, packageName, root) {
|
|
18040
18008
|
const resolution = new ResolutionStore();
|
|
18041
18009
|
const byExport = /* @__PURE__ */ new Map();
|
|
@@ -18062,7 +18030,7 @@ function stubEvidenceIn(project, packageName, root) {
|
|
|
18062
18030
|
);
|
|
18063
18031
|
}
|
|
18064
18032
|
function stubEvidence(options) {
|
|
18065
|
-
const project = new
|
|
18033
|
+
const project = new import_ts_morph71.Project(
|
|
18066
18034
|
options.tsConfigFilePath !== void 0 ? { tsConfigFilePath: options.tsConfigFilePath } : { compilerOptions: { allowJs: true } }
|
|
18067
18035
|
);
|
|
18068
18036
|
const root = options.tsConfigFilePath !== void 0 ? import_node_path14.default.dirname(options.tsConfigFilePath) : import_node_path14.default.resolve(options.directory ?? process.cwd());
|
|
@@ -18080,6 +18048,7 @@ function stubEvidence(options) {
|
|
|
18080
18048
|
GENERIC_TERMINALS,
|
|
18081
18049
|
NO_BARRIERS,
|
|
18082
18050
|
ResolutionStore,
|
|
18051
|
+
TSCONFIG_NAMES,
|
|
18083
18052
|
TypeScriptWhySession,
|
|
18084
18053
|
accessContextFor,
|
|
18085
18054
|
buildProjectHelperIndex,
|