@suss/adapter-typescript 0.24.4 → 0.26.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 +773 -796
- package/dist/index.js +176 -198
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
collectAncestorBranches: () => collectAncestorBranches,
|
|
42
42
|
collectClientFieldAccesses: () => collectClientFieldAccesses,
|
|
43
43
|
computeAdapterPacksDigest: () => computeAdapterPacksDigest,
|
|
44
|
-
computeContentHash: () =>
|
|
44
|
+
computeContentHash: () => import_extractor11.computeContentHash,
|
|
45
45
|
createProjectWithoutTsconfig: () => createProjectWithoutTsconfig,
|
|
46
46
|
createTsDiscoveryContext: () => createTsDiscoveryContext,
|
|
47
47
|
createTsSubUnitContext: () => createTsSubUnitContext,
|
|
@@ -81,10 +81,10 @@ var import_node_path11 = __toESM(require("path"), 1);
|
|
|
81
81
|
var import_ts_morph67 = require("ts-morph");
|
|
82
82
|
var import_behavioral_ir8 = require("@suss/behavioral-ir");
|
|
83
83
|
var import_datalog6 = require("@suss/datalog");
|
|
84
|
-
var
|
|
84
|
+
var import_extractor12 = require("@suss/extractor");
|
|
85
85
|
|
|
86
86
|
// src/assembly.ts
|
|
87
|
-
var
|
|
87
|
+
var import_ts_morph54 = require("ts-morph");
|
|
88
88
|
var import_extractor5 = require("@suss/extractor");
|
|
89
89
|
|
|
90
90
|
// src/conditions.ts
|
|
@@ -1544,7 +1544,7 @@ function degradedResult(func, terminalNodes, reason) {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
|
|
1546
1546
|
// src/resolve/invocationEffects.ts
|
|
1547
|
-
var
|
|
1547
|
+
var import_ts_morph42 = require("ts-morph");
|
|
1548
1548
|
var import_extractor4 = require("@suss/extractor");
|
|
1549
1549
|
|
|
1550
1550
|
// src/lines.ts
|
|
@@ -2402,7 +2402,7 @@ function reportUnreadableExports(file) {
|
|
|
2402
2402
|
}
|
|
2403
2403
|
|
|
2404
2404
|
// src/resolve/callOps.ts
|
|
2405
|
-
var
|
|
2405
|
+
var import_ts_morph41 = require("ts-morph");
|
|
2406
2406
|
|
|
2407
2407
|
// src/configuredCall.ts
|
|
2408
2408
|
var import_ts_morph12 = require("ts-morph");
|
|
@@ -2460,10 +2460,10 @@ function rootIdentifier(node) {
|
|
|
2460
2460
|
}
|
|
2461
2461
|
|
|
2462
2462
|
// src/parameterReads.ts
|
|
2463
|
-
var
|
|
2463
|
+
var import_ts_morph39 = require("ts-morph");
|
|
2464
2464
|
|
|
2465
2465
|
// src/resolve/functionBehind.ts
|
|
2466
|
-
var
|
|
2466
|
+
var import_ts_morph38 = require("ts-morph");
|
|
2467
2467
|
|
|
2468
2468
|
// src/facts/store.ts
|
|
2469
2469
|
var import_ts_morph16 = require("ts-morph");
|
|
@@ -4399,179 +4399,11 @@ function declarationOf(value) {
|
|
|
4399
4399
|
}
|
|
4400
4400
|
|
|
4401
4401
|
// src/discovery/clientCall.ts
|
|
4402
|
-
var
|
|
4402
|
+
var import_ts_morph19 = require("ts-morph");
|
|
4403
4403
|
|
|
4404
4404
|
// src/discovery/importScan.ts
|
|
4405
|
-
var import_node_path3 = __toESM(require("path"), 1);
|
|
4406
|
-
|
|
4407
|
-
// src/diagnostics.ts
|
|
4408
4405
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
4409
|
-
var import_ts_morph17 = require("ts-morph");
|
|
4410
4406
|
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
|
-
selfCollisions: tally.selfCollisions,
|
|
4532
|
-
summariesProduced: tally.summariesProduced,
|
|
4533
|
-
failures: tally.failures,
|
|
4534
|
-
helpersUnmatched: helpersWithNoCall(
|
|
4535
|
-
[...pack.discovery, ...args.contributedPatterns?.(pack.name) ?? []],
|
|
4536
|
-
tally.helpersMatched,
|
|
4537
|
-
args.projectRoot
|
|
4538
|
-
),
|
|
4539
|
-
summariesBound: counted.bound,
|
|
4540
|
-
providerSummaries: counted.providers,
|
|
4541
|
-
summariesWithBehavior: counted.withBehavior,
|
|
4542
|
-
declarations: pack.declarations ?? null
|
|
4543
|
-
};
|
|
4544
|
-
});
|
|
4545
|
-
return {
|
|
4546
|
-
filesInProject: args.filesInProject,
|
|
4547
|
-
filesWalked: args.filesWalked,
|
|
4548
|
-
packs: packFunnels,
|
|
4549
|
-
summaries: args.summaries.length,
|
|
4550
|
-
filesWithUnreadableExports: [...args.filesWithUnreadableExports ?? []],
|
|
4551
|
-
reassignedNamesUnstated: args.reassignedNamesUnstated ?? 0,
|
|
4552
|
-
emptyStage: args.summaries.length === 0 ? firstEmptyStage(packFunnels, args) : null
|
|
4553
|
-
};
|
|
4554
|
-
}
|
|
4555
|
-
function firstEmptyStage(packs, args) {
|
|
4556
|
-
if (args.filesInProject === 0) {
|
|
4557
|
-
return "tsconfig";
|
|
4558
|
-
}
|
|
4559
|
-
const gateFailed = packs.some(
|
|
4560
|
-
(p) => p.unresolvedGates.length > 0 && p.candidateFiles > 0
|
|
4561
|
-
);
|
|
4562
|
-
if (gateFailed) {
|
|
4563
|
-
return "gateResolution";
|
|
4564
|
-
}
|
|
4565
|
-
if (args.filesWalked === 0 || packs.every((p) => p.candidateFiles === 0)) {
|
|
4566
|
-
return "candidateFiles";
|
|
4567
|
-
}
|
|
4568
|
-
if (packs.every((p) => p.unitsDiscovered === 0)) {
|
|
4569
|
-
return "discovery";
|
|
4570
|
-
}
|
|
4571
|
-
return "assembly";
|
|
4572
|
-
}
|
|
4573
|
-
|
|
4574
|
-
// src/discovery/importScan.ts
|
|
4575
4407
|
function specifierMatches(specifier, moduleName, subpaths) {
|
|
4576
4408
|
if (specifier === moduleName) {
|
|
4577
4409
|
return true;
|
|
@@ -4662,8 +4494,8 @@ function resolvedModuleFile(project, importModule, resolution) {
|
|
|
4662
4494
|
}
|
|
4663
4495
|
function projectFileNamedBy(project, specifier) {
|
|
4664
4496
|
const files = project.getSourceFiles().filter((sf) => !sf.isDeclarationFile());
|
|
4665
|
-
const root = commonDirectoryOf(files.map((sf) => sf.getFilePath())) ?? "/";
|
|
4666
|
-
const target = withoutSourceExtension(
|
|
4497
|
+
const root = (0, import_extractor3.commonDirectoryOf)(files.map((sf) => sf.getFilePath())) ?? "/";
|
|
4498
|
+
const target = withoutSourceExtension(import_node_path2.default.resolve(root, specifier));
|
|
4667
4499
|
for (const candidate of files) {
|
|
4668
4500
|
if (withoutSourceExtension(candidate.getFilePath()) === target) {
|
|
4669
4501
|
return candidate;
|
|
@@ -4711,14 +4543,14 @@ function importedReferenceSpellings(sourceFile, importModule, importName) {
|
|
|
4711
4543
|
}
|
|
4712
4544
|
|
|
4713
4545
|
// src/discovery/resolveValue.ts
|
|
4714
|
-
var
|
|
4546
|
+
var import_ts_morph18 = require("ts-morph");
|
|
4715
4547
|
var import_values3 = require("@suss/values");
|
|
4716
4548
|
|
|
4717
4549
|
// src/values/evaluator.ts
|
|
4718
4550
|
var import_values2 = require("@suss/values");
|
|
4719
4551
|
|
|
4720
4552
|
// src/values/lowering.ts
|
|
4721
|
-
var
|
|
4553
|
+
var import_ts_morph17 = require("ts-morph");
|
|
4722
4554
|
var ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set([
|
|
4723
4555
|
"=",
|
|
4724
4556
|
"+=",
|
|
@@ -4782,11 +4614,11 @@ function typescriptLowering(options) {
|
|
|
4782
4614
|
},
|
|
4783
4615
|
callable: (node) => {
|
|
4784
4616
|
const call = peelValue(node);
|
|
4785
|
-
if (resolution === void 0 || !
|
|
4617
|
+
if (resolution === void 0 || !import_ts_morph17.Node.isCallExpression(call) && !import_ts_morph17.Node.isNewExpression(call)) {
|
|
4786
4618
|
return null;
|
|
4787
4619
|
}
|
|
4788
4620
|
const target = resolution.resolveCallable(call.getExpression());
|
|
4789
|
-
return target !== null &&
|
|
4621
|
+
return target !== null && import_ts_morph17.Node.isFunctionLikeDeclaration(target) ? target : null;
|
|
4790
4622
|
},
|
|
4791
4623
|
mutatedInNestedFunction: (root, name) => {
|
|
4792
4624
|
let mutated = mutatedByRoot.get(root);
|
|
@@ -4802,34 +4634,34 @@ function typescriptLowering(options) {
|
|
|
4802
4634
|
};
|
|
4803
4635
|
}
|
|
4804
4636
|
function placeholderName(expr) {
|
|
4805
|
-
if (
|
|
4637
|
+
if (import_ts_morph17.Node.isIdentifier(expr)) {
|
|
4806
4638
|
return expr.getText();
|
|
4807
4639
|
}
|
|
4808
|
-
if (
|
|
4640
|
+
if (import_ts_morph17.Node.isPropertyAccessExpression(expr)) {
|
|
4809
4641
|
return expr.getName();
|
|
4810
4642
|
}
|
|
4811
4643
|
return "param";
|
|
4812
4644
|
}
|
|
4813
4645
|
function expressionOf(node, originOf) {
|
|
4814
|
-
if (
|
|
4646
|
+
if (import_ts_morph17.Node.isStringLiteral(node) || import_ts_morph17.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
4815
4647
|
return { kind: "literal", value: node.getLiteralValue() };
|
|
4816
4648
|
}
|
|
4817
|
-
if (
|
|
4649
|
+
if (import_ts_morph17.Node.isNumericLiteral(node)) {
|
|
4818
4650
|
return { kind: "literal", value: node.getLiteralValue() };
|
|
4819
4651
|
}
|
|
4820
|
-
if (
|
|
4652
|
+
if (import_ts_morph17.Node.isTrueLiteral(node)) {
|
|
4821
4653
|
return { kind: "literal", value: true };
|
|
4822
4654
|
}
|
|
4823
|
-
if (
|
|
4655
|
+
if (import_ts_morph17.Node.isFalseLiteral(node)) {
|
|
4824
4656
|
return { kind: "literal", value: false };
|
|
4825
4657
|
}
|
|
4826
|
-
if (
|
|
4658
|
+
if (import_ts_morph17.Node.isNullLiteral(node)) {
|
|
4827
4659
|
return { kind: "literal", value: null };
|
|
4828
4660
|
}
|
|
4829
|
-
if (
|
|
4661
|
+
if (import_ts_morph17.Node.isIdentifier(node)) {
|
|
4830
4662
|
return node.getText() === "undefined" ? { kind: "literal", value: void 0 } : { kind: "name", text: node.getText() };
|
|
4831
4663
|
}
|
|
4832
|
-
if (
|
|
4664
|
+
if (import_ts_morph17.Node.isTemplateExpression(node)) {
|
|
4833
4665
|
return {
|
|
4834
4666
|
kind: "template",
|
|
4835
4667
|
parts: [
|
|
@@ -4841,32 +4673,32 @@ function expressionOf(node, originOf) {
|
|
|
4841
4673
|
]
|
|
4842
4674
|
};
|
|
4843
4675
|
}
|
|
4844
|
-
if (
|
|
4676
|
+
if (import_ts_morph17.Node.isPropertyAccessExpression(node)) {
|
|
4845
4677
|
return {
|
|
4846
4678
|
kind: "member",
|
|
4847
4679
|
object: node.getExpression(),
|
|
4848
4680
|
name: node.getName()
|
|
4849
4681
|
};
|
|
4850
4682
|
}
|
|
4851
|
-
if (
|
|
4683
|
+
if (import_ts_morph17.Node.isElementAccessExpression(node)) {
|
|
4852
4684
|
const index = node.getArgumentExpression();
|
|
4853
4685
|
return index === void 0 ? { kind: "opaque" } : { kind: "element", object: node.getExpression(), index };
|
|
4854
4686
|
}
|
|
4855
|
-
if (
|
|
4687
|
+
if (import_ts_morph17.Node.isArrayLiteralExpression(node)) {
|
|
4856
4688
|
return { kind: "array", items: node.getElements().map(elementOf) };
|
|
4857
4689
|
}
|
|
4858
|
-
if (
|
|
4690
|
+
if (import_ts_morph17.Node.isObjectLiteralExpression(node)) {
|
|
4859
4691
|
return { kind: "record", fields: node.getProperties().flatMap(fieldOf) };
|
|
4860
4692
|
}
|
|
4861
|
-
if (
|
|
4693
|
+
if (import_ts_morph17.Node.isCallExpression(node) || import_ts_morph17.Node.isNewExpression(node)) {
|
|
4862
4694
|
return {
|
|
4863
4695
|
kind: "call",
|
|
4864
4696
|
callee: calleeOf(node.getExpression(), originOf),
|
|
4865
4697
|
args: node.getArguments().map(elementOf),
|
|
4866
|
-
constructs:
|
|
4698
|
+
constructs: import_ts_morph17.Node.isNewExpression(node)
|
|
4867
4699
|
};
|
|
4868
4700
|
}
|
|
4869
|
-
if (
|
|
4701
|
+
if (import_ts_morph17.Node.isBinaryExpression(node)) {
|
|
4870
4702
|
const operator = node.getOperatorToken().getText();
|
|
4871
4703
|
return ASSIGNMENT_OPERATORS.has(operator) ? { kind: "opaque" } : {
|
|
4872
4704
|
kind: "operator",
|
|
@@ -4874,11 +4706,11 @@ function expressionOf(node, originOf) {
|
|
|
4874
4706
|
operands: [node.getLeft(), node.getRight()]
|
|
4875
4707
|
};
|
|
4876
4708
|
}
|
|
4877
|
-
if (
|
|
4709
|
+
if (import_ts_morph17.Node.isPrefixUnaryExpression(node)) {
|
|
4878
4710
|
const operator = node.getOperatorToken();
|
|
4879
|
-
return operator ===
|
|
4711
|
+
return operator === import_ts_morph17.SyntaxKind.ExclamationToken ? { kind: "operator", operator: "!", operands: [node.getOperand()] } : { kind: "opaque" };
|
|
4880
4712
|
}
|
|
4881
|
-
if (
|
|
4713
|
+
if (import_ts_morph17.Node.isConditionalExpression(node)) {
|
|
4882
4714
|
return {
|
|
4883
4715
|
kind: "conditional",
|
|
4884
4716
|
condition: node.getCondition(),
|
|
@@ -4886,23 +4718,23 @@ function expressionOf(node, originOf) {
|
|
|
4886
4718
|
whenFalse: node.getWhenFalse()
|
|
4887
4719
|
};
|
|
4888
4720
|
}
|
|
4889
|
-
if (
|
|
4721
|
+
if (import_ts_morph17.Node.isArrowFunction(node) || import_ts_morph17.Node.isFunctionExpression(node)) {
|
|
4890
4722
|
return { kind: "function", node };
|
|
4891
4723
|
}
|
|
4892
4724
|
return { kind: "opaque" };
|
|
4893
4725
|
}
|
|
4894
4726
|
function elementOf(node) {
|
|
4895
|
-
return
|
|
4727
|
+
return import_ts_morph17.Node.isSpreadElement(node) ? { kind: "spread", node: node.getExpression() } : { kind: "value", node };
|
|
4896
4728
|
}
|
|
4897
4729
|
function fieldOf(property) {
|
|
4898
|
-
if (
|
|
4730
|
+
if (import_ts_morph17.Node.isSpreadAssignment(property)) {
|
|
4899
4731
|
return [{ kind: "spread", node: property.getExpression() }];
|
|
4900
4732
|
}
|
|
4901
|
-
if (
|
|
4733
|
+
if (import_ts_morph17.Node.isShorthandPropertyAssignment(property)) {
|
|
4902
4734
|
const nameNode2 = property.getNameNode();
|
|
4903
4735
|
return [{ kind: "field", name: nameNode2.getText(), value: nameNode2 }];
|
|
4904
4736
|
}
|
|
4905
|
-
if (!
|
|
4737
|
+
if (!import_ts_morph17.Node.isPropertyAssignment(property)) {
|
|
4906
4738
|
return [];
|
|
4907
4739
|
}
|
|
4908
4740
|
const value = property.getInitializer();
|
|
@@ -4910,22 +4742,22 @@ function fieldOf(property) {
|
|
|
4910
4742
|
return [];
|
|
4911
4743
|
}
|
|
4912
4744
|
const nameNode = property.getNameNode();
|
|
4913
|
-
if (
|
|
4745
|
+
if (import_ts_morph17.Node.isComputedPropertyName(nameNode)) {
|
|
4914
4746
|
return [{ kind: "computed", name: nameNode.getExpression(), value }];
|
|
4915
4747
|
}
|
|
4916
|
-
const name =
|
|
4748
|
+
const name = import_ts_morph17.Node.isStringLiteral(nameNode) || import_ts_morph17.Node.isNumericLiteral(nameNode) ? String(nameNode.getLiteralValue()) : nameNode.getText();
|
|
4917
4749
|
return [{ kind: "field", name, value }];
|
|
4918
4750
|
}
|
|
4919
4751
|
function calleeOf(expression, originOf) {
|
|
4920
4752
|
const callee = peelValue(expression);
|
|
4921
|
-
if (
|
|
4753
|
+
if (import_ts_morph17.Node.isPropertyAccessExpression(callee)) {
|
|
4922
4754
|
return {
|
|
4923
4755
|
receiver: callee.getExpression(),
|
|
4924
4756
|
name: callee.getName(),
|
|
4925
4757
|
origin: () => originOf(callee)
|
|
4926
4758
|
};
|
|
4927
4759
|
}
|
|
4928
|
-
if (
|
|
4760
|
+
if (import_ts_morph17.Node.isIdentifier(callee)) {
|
|
4929
4761
|
return {
|
|
4930
4762
|
receiver: null,
|
|
4931
4763
|
name: callee.getText(),
|
|
@@ -4937,17 +4769,17 @@ function calleeOf(expression, originOf) {
|
|
|
4937
4769
|
function memberChainOf(node) {
|
|
4938
4770
|
const names = [];
|
|
4939
4771
|
let current2 = peelValue(node);
|
|
4940
|
-
while (
|
|
4772
|
+
while (import_ts_morph17.Node.isPropertyAccessExpression(current2)) {
|
|
4941
4773
|
names.unshift(current2.getName());
|
|
4942
4774
|
current2 = peelValue(current2.getExpression());
|
|
4943
4775
|
}
|
|
4944
|
-
if (!
|
|
4776
|
+
if (!import_ts_morph17.Node.isIdentifier(current2)) {
|
|
4945
4777
|
return null;
|
|
4946
4778
|
}
|
|
4947
4779
|
return { root: current2, names: [current2.getText(), ...names] };
|
|
4948
4780
|
}
|
|
4949
4781
|
function statementOf2(node) {
|
|
4950
|
-
if (
|
|
4782
|
+
if (import_ts_morph17.Node.isVariableStatement(node)) {
|
|
4951
4783
|
return {
|
|
4952
4784
|
kind: "declare",
|
|
4953
4785
|
bindings: node.getDeclarationList().getDeclarations().flatMap(
|
|
@@ -4958,9 +4790,9 @@ function statementOf2(node) {
|
|
|
4958
4790
|
)
|
|
4959
4791
|
};
|
|
4960
4792
|
}
|
|
4961
|
-
if (
|
|
4793
|
+
if (import_ts_morph17.Node.isExpressionStatement(node)) {
|
|
4962
4794
|
const expression = peelValue(node.getExpression());
|
|
4963
|
-
if (
|
|
4795
|
+
if (import_ts_morph17.Node.isBinaryExpression(expression)) {
|
|
4964
4796
|
const operator = expression.getOperatorToken().getText();
|
|
4965
4797
|
if (ASSIGNMENT_OPERATORS.has(operator)) {
|
|
4966
4798
|
return {
|
|
@@ -4973,7 +4805,7 @@ function statementOf2(node) {
|
|
|
4973
4805
|
}
|
|
4974
4806
|
return { kind: "expression", value: node.getExpression() };
|
|
4975
4807
|
}
|
|
4976
|
-
if (
|
|
4808
|
+
if (import_ts_morph17.Node.isIfStatement(node)) {
|
|
4977
4809
|
const otherwise = node.getElseStatement();
|
|
4978
4810
|
return {
|
|
4979
4811
|
kind: "branch",
|
|
@@ -4984,23 +4816,23 @@ function statementOf2(node) {
|
|
|
4984
4816
|
]
|
|
4985
4817
|
};
|
|
4986
4818
|
}
|
|
4987
|
-
if (
|
|
4819
|
+
if (import_ts_morph17.Node.isSwitchStatement(node)) {
|
|
4988
4820
|
return {
|
|
4989
4821
|
kind: "branch",
|
|
4990
4822
|
condition: null,
|
|
4991
4823
|
arms: node.getClauses().map((clause) => clause.getStatements())
|
|
4992
4824
|
};
|
|
4993
4825
|
}
|
|
4994
|
-
if (
|
|
4826
|
+
if (import_ts_morph17.Node.isIterationStatement(node)) {
|
|
4995
4827
|
return { kind: "loop", body: armOf(node.getStatement()) };
|
|
4996
4828
|
}
|
|
4997
|
-
if (
|
|
4829
|
+
if (import_ts_morph17.Node.isReturnStatement(node)) {
|
|
4998
4830
|
return { kind: "return", value: node.getExpression() ?? null };
|
|
4999
4831
|
}
|
|
5000
|
-
if (
|
|
4832
|
+
if (import_ts_morph17.Node.isBlock(node)) {
|
|
5001
4833
|
return { kind: "block", body: node.getStatements() };
|
|
5002
4834
|
}
|
|
5003
|
-
if (
|
|
4835
|
+
if (import_ts_morph17.Node.isTryStatement(node)) {
|
|
5004
4836
|
return {
|
|
5005
4837
|
kind: "block",
|
|
5006
4838
|
body: [
|
|
@@ -5012,31 +4844,31 @@ function statementOf2(node) {
|
|
|
5012
4844
|
return { kind: "opaque" };
|
|
5013
4845
|
}
|
|
5014
4846
|
function armOf(statement) {
|
|
5015
|
-
return
|
|
4847
|
+
return import_ts_morph17.Node.isBlock(statement) ? statement.getStatements() : [statement];
|
|
5016
4848
|
}
|
|
5017
4849
|
function declarationsOf2(nameNode, value) {
|
|
5018
|
-
if (
|
|
4850
|
+
if (import_ts_morph17.Node.isIdentifier(nameNode)) {
|
|
5019
4851
|
return [{ name: nameNode.getText(), value }];
|
|
5020
4852
|
}
|
|
5021
|
-
if (
|
|
4853
|
+
if (import_ts_morph17.Node.isObjectBindingPattern(nameNode) || import_ts_morph17.Node.isArrayBindingPattern(nameNode)) {
|
|
5022
4854
|
return nameNode.getElements().flatMap(
|
|
5023
|
-
(element) =>
|
|
4855
|
+
(element) => import_ts_morph17.Node.isBindingElement(element) ? declarationsOf2(element.getNameNode(), null) : []
|
|
5024
4856
|
);
|
|
5025
4857
|
}
|
|
5026
4858
|
return [];
|
|
5027
4859
|
}
|
|
5028
4860
|
function isRoot(node) {
|
|
5029
|
-
return
|
|
4861
|
+
return import_ts_morph17.Node.isSourceFile(node) || import_ts_morph17.Node.isFunctionLikeDeclaration(node);
|
|
5030
4862
|
}
|
|
5031
4863
|
function isStandaloneBlock(node) {
|
|
5032
4864
|
const parent = node.getParent();
|
|
5033
|
-
return parent !== void 0 && (
|
|
4865
|
+
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));
|
|
5034
4866
|
}
|
|
5035
4867
|
function isPathStatement(node) {
|
|
5036
|
-
if (
|
|
4868
|
+
if (import_ts_morph17.Node.isBlock(node)) {
|
|
5037
4869
|
return isStandaloneBlock(node);
|
|
5038
4870
|
}
|
|
5039
|
-
return
|
|
4871
|
+
return import_ts_morph17.Node.isStatement(node) && !import_ts_morph17.Node.isFunctionDeclaration(node);
|
|
5040
4872
|
}
|
|
5041
4873
|
function siteOf(node) {
|
|
5042
4874
|
const path15 = [];
|
|
@@ -5056,26 +4888,26 @@ function siteOf(node) {
|
|
|
5056
4888
|
}
|
|
5057
4889
|
}
|
|
5058
4890
|
function functionOf(node) {
|
|
5059
|
-
if (
|
|
4891
|
+
if (import_ts_morph17.Node.isSourceFile(node)) {
|
|
5060
4892
|
return { parameters: [], body: node.getStatements() };
|
|
5061
4893
|
}
|
|
5062
|
-
if (!
|
|
4894
|
+
if (!import_ts_morph17.Node.isFunctionLikeDeclaration(node)) {
|
|
5063
4895
|
return null;
|
|
5064
4896
|
}
|
|
5065
4897
|
const parameters = node.getParameters().flatMap((parameter) => {
|
|
5066
4898
|
const nameNode = parameter.getNameNode();
|
|
5067
|
-
return
|
|
4899
|
+
return import_ts_morph17.Node.isIdentifier(nameNode) ? [
|
|
5068
4900
|
{
|
|
5069
4901
|
name: nameNode.getText(),
|
|
5070
4902
|
default: parameter.getInitializer() ?? null
|
|
5071
4903
|
}
|
|
5072
4904
|
] : [];
|
|
5073
4905
|
});
|
|
5074
|
-
const body =
|
|
4906
|
+
const body = import_ts_morph17.Node.isBodied(node) ? node.getBody() : import_ts_morph17.Node.isBodyable(node) ? node.getBody() : void 0;
|
|
5075
4907
|
if (body === void 0) {
|
|
5076
4908
|
return { parameters, body: [] };
|
|
5077
4909
|
}
|
|
5078
|
-
return
|
|
4910
|
+
return import_ts_morph17.Node.isBlock(body) ? { parameters, body: body.getStatements() } : { parameters, body: { expression: body } };
|
|
5079
4911
|
}
|
|
5080
4912
|
function namesMutatedInNestedFunctions(root) {
|
|
5081
4913
|
const mutated = /* @__PURE__ */ new Set();
|
|
@@ -5088,21 +4920,21 @@ function namesMutatedInNestedFunctions(root) {
|
|
|
5088
4920
|
return mutated;
|
|
5089
4921
|
}
|
|
5090
4922
|
function writtenNameOf(node) {
|
|
5091
|
-
if (
|
|
4923
|
+
if (import_ts_morph17.Node.isBinaryExpression(node)) {
|
|
5092
4924
|
const target = peelValue(node.getLeft());
|
|
5093
|
-
return ASSIGNMENT_OPERATORS.has(node.getOperatorToken().getText()) &&
|
|
4925
|
+
return ASSIGNMENT_OPERATORS.has(node.getOperatorToken().getText()) && import_ts_morph17.Node.isIdentifier(target) ? target.getText() : null;
|
|
5094
4926
|
}
|
|
5095
|
-
if (
|
|
4927
|
+
if (import_ts_morph17.Node.isPostfixUnaryExpression(node) || import_ts_morph17.Node.isPrefixUnaryExpression(node)) {
|
|
5096
4928
|
const operand2 = peelValue(node.getOperand());
|
|
5097
|
-
return
|
|
4929
|
+
return import_ts_morph17.Node.isIdentifier(operand2) ? operand2.getText() : null;
|
|
5098
4930
|
}
|
|
5099
|
-
if (
|
|
4931
|
+
if (import_ts_morph17.Node.isCallExpression(node)) {
|
|
5100
4932
|
const callee = peelValue(node.getExpression());
|
|
5101
|
-
if (!
|
|
4933
|
+
if (!import_ts_morph17.Node.isPropertyAccessExpression(callee)) {
|
|
5102
4934
|
return null;
|
|
5103
4935
|
}
|
|
5104
4936
|
const receiver = peelValue(callee.getExpression());
|
|
5105
|
-
return MUTATING_METHODS.has(callee.getName()) &&
|
|
4937
|
+
return MUTATING_METHODS.has(callee.getName()) && import_ts_morph17.Node.isIdentifier(receiver) ? receiver.getText() : null;
|
|
5106
4938
|
}
|
|
5107
4939
|
return null;
|
|
5108
4940
|
}
|
|
@@ -5117,18 +4949,18 @@ function freeNamesOf(fn) {
|
|
|
5117
4949
|
const declared = /* @__PURE__ */ new Set();
|
|
5118
4950
|
const read2 = /* @__PURE__ */ new Set();
|
|
5119
4951
|
fn.forEachDescendant((descendant) => {
|
|
5120
|
-
if (!
|
|
4952
|
+
if (!import_ts_morph17.Node.isIdentifier(descendant)) {
|
|
5121
4953
|
return;
|
|
5122
4954
|
}
|
|
5123
4955
|
const parent = descendant.getParent();
|
|
5124
|
-
if (
|
|
4956
|
+
if (import_ts_morph17.Node.isPropertyAccessExpression(parent) && parent.getNameNode() === descendant) {
|
|
5125
4957
|
return;
|
|
5126
4958
|
}
|
|
5127
|
-
if (
|
|
4959
|
+
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)) {
|
|
5128
4960
|
declared.add(descendant.getText());
|
|
5129
4961
|
return;
|
|
5130
4962
|
}
|
|
5131
|
-
if (
|
|
4963
|
+
if (import_ts_morph17.Node.isPropertyAssignment(parent) && parent.getNameNode() === descendant) {
|
|
5132
4964
|
return;
|
|
5133
4965
|
}
|
|
5134
4966
|
read2.add(descendant.getText());
|
|
@@ -5292,13 +5124,13 @@ function evaluatedValue(node, resolution) {
|
|
|
5292
5124
|
|
|
5293
5125
|
// src/discovery/resolveValue.ts
|
|
5294
5126
|
function couldNameAValue(value) {
|
|
5295
|
-
return
|
|
5127
|
+
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);
|
|
5296
5128
|
}
|
|
5297
5129
|
function propertyValueOf(property) {
|
|
5298
|
-
if (
|
|
5130
|
+
if (import_ts_morph18.Node.isPropertyAssignment(property)) {
|
|
5299
5131
|
return property.getInitializer() ?? null;
|
|
5300
5132
|
}
|
|
5301
|
-
if (
|
|
5133
|
+
if (import_ts_morph18.Node.isShorthandPropertyAssignment(property)) {
|
|
5302
5134
|
return property.getNameNode();
|
|
5303
5135
|
}
|
|
5304
5136
|
return null;
|
|
@@ -5316,20 +5148,20 @@ function functionValueOf(value, resolution) {
|
|
|
5316
5148
|
if (resolved !== null) {
|
|
5317
5149
|
return toFunctionRoot(resolved);
|
|
5318
5150
|
}
|
|
5319
|
-
if (!
|
|
5151
|
+
if (!import_ts_morph18.Node.isCallExpression(written)) {
|
|
5320
5152
|
return null;
|
|
5321
5153
|
}
|
|
5322
5154
|
const returned = resolution.resolveReturnedCallable(written);
|
|
5323
5155
|
return returned === null ? null : toFunctionRoot(returned);
|
|
5324
5156
|
}
|
|
5325
5157
|
function propertyNameOf(property) {
|
|
5326
|
-
if (
|
|
5158
|
+
if (import_ts_morph18.Node.isPropertyAssignment(property) || import_ts_morph18.Node.isShorthandPropertyAssignment(property) || import_ts_morph18.Node.isMethodDeclaration(property)) {
|
|
5327
5159
|
return property.getName();
|
|
5328
5160
|
}
|
|
5329
5161
|
return null;
|
|
5330
5162
|
}
|
|
5331
5163
|
function propertyFunctionOf(property, resolution) {
|
|
5332
|
-
if (
|
|
5164
|
+
if (import_ts_morph18.Node.isMethodDeclaration(property)) {
|
|
5333
5165
|
return property;
|
|
5334
5166
|
}
|
|
5335
5167
|
const held = propertyValueOf(property);
|
|
@@ -5339,7 +5171,7 @@ function objectLiteralOf(value, resolution) {
|
|
|
5339
5171
|
return literalValueOf(
|
|
5340
5172
|
value,
|
|
5341
5173
|
resolution,
|
|
5342
|
-
(node) =>
|
|
5174
|
+
(node) => import_ts_morph18.Node.isObjectLiteralExpression(node)
|
|
5343
5175
|
);
|
|
5344
5176
|
}
|
|
5345
5177
|
function propertiesOf(object, resolution) {
|
|
@@ -5351,7 +5183,7 @@ function propertiesReached(object, resolution, seen) {
|
|
|
5351
5183
|
}
|
|
5352
5184
|
seen.add(object);
|
|
5353
5185
|
return object.getProperties().flatMap((property) => {
|
|
5354
|
-
if (!
|
|
5186
|
+
if (!import_ts_morph18.Node.isSpreadAssignment(property)) {
|
|
5355
5187
|
return [property];
|
|
5356
5188
|
}
|
|
5357
5189
|
const spread = objectLiteralOf(property.getExpression(), resolution);
|
|
@@ -5360,17 +5192,17 @@ function propertiesReached(object, resolution, seen) {
|
|
|
5360
5192
|
}
|
|
5361
5193
|
function writtenNodeOf(value, resolution) {
|
|
5362
5194
|
const written = factKeyOf(value);
|
|
5363
|
-
if (
|
|
5195
|
+
if (import_ts_morph18.Node.isNewExpression(written)) {
|
|
5364
5196
|
return written;
|
|
5365
5197
|
}
|
|
5366
|
-
if (
|
|
5198
|
+
if (import_ts_morph18.Node.isCallExpression(written)) {
|
|
5367
5199
|
return writtenThroughCall(written, resolution);
|
|
5368
5200
|
}
|
|
5369
5201
|
if (resolution === void 0 || !couldNameAValue(written)) {
|
|
5370
5202
|
return null;
|
|
5371
5203
|
}
|
|
5372
5204
|
const resolved = resolution.resolveWrittenValue(written);
|
|
5373
|
-
return resolved !== null &&
|
|
5205
|
+
return resolved !== null && import_ts_morph18.Node.isCallExpression(resolved) ? writtenThroughCall(resolved, resolution) : resolved;
|
|
5374
5206
|
}
|
|
5375
5207
|
function writtenThroughCall(call, resolution) {
|
|
5376
5208
|
if (resolution !== void 0 && resolution.resolveCallable(call.getExpression()) !== null) {
|
|
@@ -5396,7 +5228,7 @@ function arrayLiteralOf(value, resolution) {
|
|
|
5396
5228
|
return literalValueOf(
|
|
5397
5229
|
value,
|
|
5398
5230
|
resolution,
|
|
5399
|
-
(node) =>
|
|
5231
|
+
(node) => import_ts_morph18.Node.isArrayLiteralExpression(node)
|
|
5400
5232
|
);
|
|
5401
5233
|
}
|
|
5402
5234
|
function literalValueOf(value, resolution, isWanted) {
|
|
@@ -5419,26 +5251,26 @@ function discoverClientCalls(sourceFile, match, kind, resolution) {
|
|
|
5419
5251
|
if (!isGlobal) {
|
|
5420
5252
|
for (const varDecl of sourceFile.getVariableDeclarations()) {
|
|
5421
5253
|
const init = varDecl.getInitializer();
|
|
5422
|
-
if (init !== void 0 && (
|
|
5254
|
+
if (init !== void 0 && (import_ts_morph19.Node.isCallExpression(init) || import_ts_morph19.Node.isNewExpression(init)) && isCreationCall(init, match, resolution)) {
|
|
5423
5255
|
clientVarNames.add(varDecl.getName());
|
|
5424
5256
|
}
|
|
5425
5257
|
}
|
|
5426
5258
|
}
|
|
5427
5259
|
const methodFilter = match.methodFilter !== void 0 ? new Set(match.methodFilter) : null;
|
|
5428
5260
|
sourceFile.forEachDescendant((node) => {
|
|
5429
|
-
if (!
|
|
5261
|
+
if (!import_ts_morph19.Node.isCallExpression(node)) {
|
|
5430
5262
|
return;
|
|
5431
5263
|
}
|
|
5432
5264
|
const callee = node.getExpression();
|
|
5433
5265
|
let methodName = null;
|
|
5434
5266
|
let matched = false;
|
|
5435
|
-
if (isGlobal &&
|
|
5267
|
+
if (isGlobal && import_ts_morph19.Node.isIdentifier(callee)) {
|
|
5436
5268
|
if (callee.getText() === match.importName) {
|
|
5437
5269
|
matched = true;
|
|
5438
5270
|
}
|
|
5439
|
-
} else if (
|
|
5271
|
+
} else if (import_ts_morph19.Node.isPropertyAccessExpression(callee)) {
|
|
5440
5272
|
const subject = callee.getExpression();
|
|
5441
|
-
if (
|
|
5273
|
+
if (import_ts_morph19.Node.isIdentifier(subject) && (isClientImport(subject, match, resolution, true) || clientVarNames.has(subject.getText())) || resolvesToKnownInstance(subject, match, resolution)) {
|
|
5442
5274
|
methodName = callee.getName();
|
|
5443
5275
|
if (methodFilter === null || methodFilter.has(methodName)) {
|
|
5444
5276
|
matched = true;
|
|
@@ -5472,16 +5304,16 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
|
5472
5304
|
);
|
|
5473
5305
|
const constructedHere = /* @__PURE__ */ new Set();
|
|
5474
5306
|
sourceFile.forEachDescendant((node) => {
|
|
5475
|
-
if (
|
|
5307
|
+
if (import_ts_morph19.Node.isVariableDeclaration(node)) {
|
|
5476
5308
|
const init = node.getInitializer();
|
|
5477
|
-
if (init !== void 0 && (
|
|
5309
|
+
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)) {
|
|
5478
5310
|
constructedHere.add(node.getName());
|
|
5479
5311
|
}
|
|
5480
5312
|
return;
|
|
5481
5313
|
}
|
|
5482
|
-
if (
|
|
5314
|
+
if (import_ts_morph19.Node.isParameterDeclaration(node) && localName !== null && typedAsClient(node.getTypeNode(), localName)) {
|
|
5483
5315
|
const written = node.getNameNode();
|
|
5484
|
-
if (
|
|
5316
|
+
if (import_ts_morph19.Node.isIdentifier(written)) {
|
|
5485
5317
|
constructedHere.add(written.getText());
|
|
5486
5318
|
}
|
|
5487
5319
|
}
|
|
@@ -5492,10 +5324,10 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
|
5492
5324
|
importName: match.importName,
|
|
5493
5325
|
...match.factoryMethods === void 0 ? {} : { factoryMethods: match.factoryMethods }
|
|
5494
5326
|
};
|
|
5495
|
-
return (subject) => isClientImport(subject, match, resolution, true) ||
|
|
5327
|
+
return (subject) => isClientImport(subject, match, resolution, true) || import_ts_morph19.Node.isIdentifier(subject) && constructedHere.has(subject.getText()) || resolvesToKnownInstance(subject, full, resolution);
|
|
5496
5328
|
}
|
|
5497
5329
|
function typedAsClient(typeNode, localName) {
|
|
5498
|
-
if (typeNode === void 0 || !
|
|
5330
|
+
if (typeNode === void 0 || !import_ts_morph19.Node.isTypeReference(typeNode)) {
|
|
5499
5331
|
return false;
|
|
5500
5332
|
}
|
|
5501
5333
|
return typeNode.getTypeName().getText() === localName;
|
|
@@ -5505,27 +5337,27 @@ function resolvesToKnownInstance(subject, match, resolution) {
|
|
|
5505
5337
|
return false;
|
|
5506
5338
|
}
|
|
5507
5339
|
const written = writtenNodeOf(subject, resolution);
|
|
5508
|
-
if (written === null || !
|
|
5340
|
+
if (written === null || !import_ts_morph19.Node.isCallExpression(written) && !import_ts_morph19.Node.isNewExpression(written)) {
|
|
5509
5341
|
return false;
|
|
5510
5342
|
}
|
|
5511
5343
|
return isCreationCall(written, match, resolution);
|
|
5512
5344
|
}
|
|
5513
5345
|
function isCreationCall(call, match, resolution) {
|
|
5514
5346
|
const callee = call.getExpression();
|
|
5515
|
-
if (
|
|
5347
|
+
if (import_ts_morph19.Node.isIdentifier(callee)) {
|
|
5516
5348
|
return isClientImport(callee, match, resolution, false);
|
|
5517
5349
|
}
|
|
5518
|
-
if (!
|
|
5350
|
+
if (!import_ts_morph19.Node.isPropertyAccessExpression(callee)) {
|
|
5519
5351
|
return false;
|
|
5520
5352
|
}
|
|
5521
5353
|
const base = callee.getExpression();
|
|
5522
|
-
return
|
|
5354
|
+
return import_ts_morph19.Node.isIdentifier(base) && (match.factoryMethods?.includes(callee.getName()) ?? false) && isClientImport(base, match, resolution, false);
|
|
5523
5355
|
}
|
|
5524
5356
|
function isPathShaped(specifier) {
|
|
5525
5357
|
return specifier.startsWith(".") || specifier.startsWith("/");
|
|
5526
5358
|
}
|
|
5527
5359
|
function isClientImport(subject, match, resolution, strictDefaultName) {
|
|
5528
|
-
if (!
|
|
5360
|
+
if (!import_ts_morph19.Node.isIdentifier(subject)) {
|
|
5529
5361
|
return false;
|
|
5530
5362
|
}
|
|
5531
5363
|
if (resolution === void 0) {
|
|
@@ -5573,27 +5405,27 @@ function resolvedImportLocalName(sourceFile, importModule, importName, strictDef
|
|
|
5573
5405
|
return null;
|
|
5574
5406
|
}
|
|
5575
5407
|
function clientUnitName(enclosingFunc, methodName) {
|
|
5576
|
-
if (
|
|
5408
|
+
if (import_ts_morph19.Node.isFunctionDeclaration(enclosingFunc)) {
|
|
5577
5409
|
return enclosingFunc.getName() ?? methodName ?? "anonymous";
|
|
5578
5410
|
}
|
|
5579
|
-
if (
|
|
5411
|
+
if (import_ts_morph19.Node.isMethodDeclaration(enclosingFunc)) {
|
|
5580
5412
|
return enclosingFunc.getName();
|
|
5581
5413
|
}
|
|
5582
5414
|
const parent = enclosingFunc.getParent();
|
|
5583
|
-
if (parent !== void 0 &&
|
|
5415
|
+
if (parent !== void 0 && import_ts_morph19.Node.isVariableDeclaration(parent)) {
|
|
5584
5416
|
return parent.getName();
|
|
5585
5417
|
}
|
|
5586
|
-
if (parent !== void 0 &&
|
|
5418
|
+
if (parent !== void 0 && import_ts_morph19.Node.isPropertyAssignment(parent)) {
|
|
5587
5419
|
return parent.getName();
|
|
5588
5420
|
}
|
|
5589
5421
|
return methodName ?? "anonymous";
|
|
5590
5422
|
}
|
|
5591
5423
|
|
|
5592
5424
|
// src/discovery/decoratedMethod.ts
|
|
5593
|
-
var
|
|
5425
|
+
var import_ts_morph22 = require("ts-morph");
|
|
5594
5426
|
|
|
5595
5427
|
// src/discovery/decoratedMembers.ts
|
|
5596
|
-
var
|
|
5428
|
+
var import_ts_morph20 = require("ts-morph");
|
|
5597
5429
|
function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
|
|
5598
5430
|
const localToCanonical = /* @__PURE__ */ new Map();
|
|
5599
5431
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
@@ -5613,7 +5445,7 @@ function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
|
|
|
5613
5445
|
function decoratedCallablesOf(cls, decoratorNames) {
|
|
5614
5446
|
const callables = [];
|
|
5615
5447
|
for (const member of cls.getMembers()) {
|
|
5616
|
-
if (!
|
|
5448
|
+
if (!import_ts_morph20.Node.isMethodDeclaration(member) && !import_ts_morph20.Node.isPropertyDeclaration(member)) {
|
|
5617
5449
|
continue;
|
|
5618
5450
|
}
|
|
5619
5451
|
const func = callableOf(member);
|
|
@@ -5637,7 +5469,7 @@ function decoratedCallablesOf(cls, decoratorNames) {
|
|
|
5637
5469
|
return callables;
|
|
5638
5470
|
}
|
|
5639
5471
|
function callableOf(member) {
|
|
5640
|
-
if (
|
|
5472
|
+
if (import_ts_morph20.Node.isMethodDeclaration(member)) {
|
|
5641
5473
|
return toFunctionRoot(member);
|
|
5642
5474
|
}
|
|
5643
5475
|
const held = member.getInitializer();
|
|
@@ -5645,7 +5477,7 @@ function callableOf(member) {
|
|
|
5645
5477
|
}
|
|
5646
5478
|
|
|
5647
5479
|
// src/discovery/decoratorComposition.ts
|
|
5648
|
-
var
|
|
5480
|
+
var import_ts_morph21 = require("ts-morph");
|
|
5649
5481
|
function classDecoratorStandingFor(cls, names, modules, resolution) {
|
|
5650
5482
|
for (const candidate of names) {
|
|
5651
5483
|
const decorator = cls.getDecorator(candidate);
|
|
@@ -5683,7 +5515,7 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
|
|
|
5683
5515
|
if (wrapper === null) {
|
|
5684
5516
|
return atClass;
|
|
5685
5517
|
}
|
|
5686
|
-
for (const call of wrapper.getDescendantsOfKind(
|
|
5518
|
+
for (const call of wrapper.getDescendantsOfKind(import_ts_morph21.SyntaxKind.CallExpression)) {
|
|
5687
5519
|
const names = resolution.importedNamesOf(call.getExpression(), modules);
|
|
5688
5520
|
if (!names.includes(standsFor)) {
|
|
5689
5521
|
continue;
|
|
@@ -5694,10 +5526,10 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
|
|
|
5694
5526
|
return atClass;
|
|
5695
5527
|
}
|
|
5696
5528
|
function statesAValue(arg, wrapper) {
|
|
5697
|
-
const identifiers =
|
|
5529
|
+
const identifiers = import_ts_morph21.Node.isIdentifier(arg) ? [arg] : arg.getDescendantsOfKind(import_ts_morph21.SyntaxKind.Identifier);
|
|
5698
5530
|
return !identifiers.some(
|
|
5699
5531
|
(identifier) => identifier.getSymbol()?.getDeclarations().some(
|
|
5700
|
-
(declaration) =>
|
|
5532
|
+
(declaration) => import_ts_morph21.Node.isParameterDeclaration(declaration) && isWithin(declaration, wrapper)
|
|
5701
5533
|
)
|
|
5702
5534
|
);
|
|
5703
5535
|
}
|
|
@@ -5717,39 +5549,39 @@ function resolverTypeName(args) {
|
|
|
5717
5549
|
return args.typeMap[args.decoratorName] ?? args.classTypeName ?? null;
|
|
5718
5550
|
}
|
|
5719
5551
|
function resolveResolverClassTypeName(decoratorArg) {
|
|
5720
|
-
if (
|
|
5552
|
+
if (import_ts_morph22.Node.isArrowFunction(decoratorArg)) {
|
|
5721
5553
|
const body = decoratorArg.getBody();
|
|
5722
|
-
if (
|
|
5554
|
+
if (import_ts_morph22.Node.isIdentifier(body)) {
|
|
5723
5555
|
return body.getText();
|
|
5724
5556
|
}
|
|
5725
5557
|
return null;
|
|
5726
5558
|
}
|
|
5727
|
-
if (
|
|
5559
|
+
if (import_ts_morph22.Node.isStringLiteral(decoratorArg)) {
|
|
5728
5560
|
return decoratorArg.getLiteralValue();
|
|
5729
5561
|
}
|
|
5730
|
-
if (
|
|
5562
|
+
if (import_ts_morph22.Node.isIdentifier(decoratorArg)) {
|
|
5731
5563
|
return decoratorArg.getText();
|
|
5732
5564
|
}
|
|
5733
5565
|
return null;
|
|
5734
5566
|
}
|
|
5735
5567
|
function resolveOperationNameOverride(decorator) {
|
|
5736
|
-
if (!
|
|
5568
|
+
if (!import_ts_morph22.Node.isDecorator(decorator)) {
|
|
5737
5569
|
return null;
|
|
5738
5570
|
}
|
|
5739
5571
|
const args = decorator.getArguments();
|
|
5740
5572
|
for (const arg of args) {
|
|
5741
|
-
if (!
|
|
5573
|
+
if (!import_ts_morph22.Node.isObjectLiteralExpression(arg)) {
|
|
5742
5574
|
continue;
|
|
5743
5575
|
}
|
|
5744
5576
|
const prop = arg.getProperty("name");
|
|
5745
|
-
if (prop === void 0 || !
|
|
5577
|
+
if (prop === void 0 || !import_ts_morph22.Node.isPropertyAssignment(prop)) {
|
|
5746
5578
|
continue;
|
|
5747
5579
|
}
|
|
5748
5580
|
const init = prop.getInitializer();
|
|
5749
5581
|
if (init === void 0) {
|
|
5750
5582
|
continue;
|
|
5751
5583
|
}
|
|
5752
|
-
if (
|
|
5584
|
+
if (import_ts_morph22.Node.isStringLiteral(init) || import_ts_morph22.Node.isNoSubstitutionTemplateLiteral(init)) {
|
|
5753
5585
|
return init.getLiteralValue();
|
|
5754
5586
|
}
|
|
5755
5587
|
}
|
|
@@ -5802,9 +5634,9 @@ function discoverDecoratedMethods(sourceFile, match, kind, resolution) {
|
|
|
5802
5634
|
}
|
|
5803
5635
|
|
|
5804
5636
|
// src/discovery/decoratedRoute.ts
|
|
5805
|
-
var
|
|
5637
|
+
var import_ts_morph23 = require("ts-morph");
|
|
5806
5638
|
function resolveRoutePathArg(decorator, resolution) {
|
|
5807
|
-
if (!
|
|
5639
|
+
if (!import_ts_morph23.Node.isDecorator(decorator)) {
|
|
5808
5640
|
return "";
|
|
5809
5641
|
}
|
|
5810
5642
|
return routePathOf(decorator.getArguments(), resolution);
|
|
@@ -5832,7 +5664,7 @@ function declaredChannelOf(source, decorator, resolution) {
|
|
|
5832
5664
|
if (source.from === "unstated") {
|
|
5833
5665
|
return null;
|
|
5834
5666
|
}
|
|
5835
|
-
if (!
|
|
5667
|
+
if (!import_ts_morph23.Node.isDecorator(decorator)) {
|
|
5836
5668
|
return null;
|
|
5837
5669
|
}
|
|
5838
5670
|
const arg = decorator.getArguments()[source.position];
|
|
@@ -5843,7 +5675,7 @@ function declaredChannelOf(source, decorator, resolution) {
|
|
|
5843
5675
|
return text === null || text === "" ? null : text;
|
|
5844
5676
|
}
|
|
5845
5677
|
function literalStringOf(node, resolution) {
|
|
5846
|
-
if (
|
|
5678
|
+
if (import_ts_morph23.Node.isStringLiteral(node) || import_ts_morph23.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
5847
5679
|
return node.getLiteralValue();
|
|
5848
5680
|
}
|
|
5849
5681
|
const written = resolution?.resolveWrittenValue(node) ?? null;
|
|
@@ -5913,31 +5745,31 @@ function discoverDecoratedRoutes(sourceFile, match, kind, resolution, binding) {
|
|
|
5913
5745
|
var import_picomatch = __toESM(require("picomatch"), 1);
|
|
5914
5746
|
|
|
5915
5747
|
// src/discovery/namedExport.ts
|
|
5916
|
-
var
|
|
5748
|
+
var import_ts_morph24 = require("ts-morph");
|
|
5917
5749
|
function nameWrittenAt(expression) {
|
|
5918
|
-
if (
|
|
5750
|
+
if (import_ts_morph24.Node.isIdentifier(expression)) {
|
|
5919
5751
|
return expression.getText();
|
|
5920
5752
|
}
|
|
5921
|
-
if (
|
|
5753
|
+
if (import_ts_morph24.Node.isPropertyAccessExpression(expression)) {
|
|
5922
5754
|
return expression.getName();
|
|
5923
5755
|
}
|
|
5924
5756
|
return null;
|
|
5925
5757
|
}
|
|
5926
5758
|
function resolveDefaultExportName(decl, fn) {
|
|
5927
|
-
if (
|
|
5759
|
+
if (import_ts_morph24.Node.isFunctionDeclaration(fn) || import_ts_morph24.Node.isFunctionExpression(fn)) {
|
|
5928
5760
|
const n = fn.getName?.();
|
|
5929
5761
|
if (typeof n === "string" && n.length > 0) {
|
|
5930
5762
|
return n;
|
|
5931
5763
|
}
|
|
5932
5764
|
}
|
|
5933
|
-
if (
|
|
5765
|
+
if (import_ts_morph24.Node.isVariableDeclaration(decl)) {
|
|
5934
5766
|
const name = decl.getName();
|
|
5935
5767
|
if (name.length > 0) {
|
|
5936
5768
|
return name;
|
|
5937
5769
|
}
|
|
5938
5770
|
}
|
|
5939
5771
|
const binding = fn.getParent();
|
|
5940
|
-
if (binding !== void 0 &&
|
|
5772
|
+
if (binding !== void 0 && import_ts_morph24.Node.isVariableDeclaration(binding)) {
|
|
5941
5773
|
const name = binding.getName();
|
|
5942
5774
|
if (name.length > 0) {
|
|
5943
5775
|
return name;
|
|
@@ -5992,7 +5824,7 @@ function discoverNamedExports(sourceFile, match, kind, resolution) {
|
|
|
5992
5824
|
}
|
|
5993
5825
|
continue;
|
|
5994
5826
|
}
|
|
5995
|
-
if (
|
|
5827
|
+
if (import_ts_morph24.Node.isArrowFunction(init) || import_ts_morph24.Node.isFunctionExpression(init)) {
|
|
5996
5828
|
results.push({
|
|
5997
5829
|
func: init,
|
|
5998
5830
|
kind,
|
|
@@ -6101,13 +5933,13 @@ function discoverFileConventions(sourceFile, match, kind, resolution) {
|
|
|
6101
5933
|
}
|
|
6102
5934
|
|
|
6103
5935
|
// src/discovery/graphqlHookCall.ts
|
|
6104
|
-
var
|
|
5936
|
+
var import_ts_morph27 = require("ts-morph");
|
|
6105
5937
|
|
|
6106
5938
|
// src/discovery/graphqlShared.ts
|
|
6107
5939
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
6108
|
-
var
|
|
5940
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
6109
5941
|
var import_graphql = require("graphql");
|
|
6110
|
-
var
|
|
5942
|
+
var import_ts_morph25 = require("ts-morph");
|
|
6111
5943
|
var DOCUMENT_TAGS = /* @__PURE__ */ new Set(["gql", "graphql"]);
|
|
6112
5944
|
var UNQUALIFIED_DOCUMENT_TAG = "gql";
|
|
6113
5945
|
function parseGraphqlOperation(source) {
|
|
@@ -6173,10 +6005,10 @@ function startAssembly(resolution) {
|
|
|
6173
6005
|
};
|
|
6174
6006
|
}
|
|
6175
6007
|
function assembledTemplateText(template, assembly) {
|
|
6176
|
-
if (
|
|
6008
|
+
if (import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(template)) {
|
|
6177
6009
|
return innerTemplateText(template);
|
|
6178
6010
|
}
|
|
6179
|
-
if (!
|
|
6011
|
+
if (!import_ts_morph25.Node.isTemplateExpression(template)) {
|
|
6180
6012
|
return null;
|
|
6181
6013
|
}
|
|
6182
6014
|
let text = template.getHead().getLiteralText();
|
|
@@ -6312,7 +6144,7 @@ function collectDanglingSpreads(selectionSet, defined, dangling) {
|
|
|
6312
6144
|
}
|
|
6313
6145
|
}
|
|
6314
6146
|
function documentTextFromExpression(node, assembly) {
|
|
6315
|
-
if (
|
|
6147
|
+
if (import_ts_morph25.Node.isTaggedTemplateExpression(node)) {
|
|
6316
6148
|
if (!isDocumentTag(node.getTag())) {
|
|
6317
6149
|
return null;
|
|
6318
6150
|
}
|
|
@@ -6322,7 +6154,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
6322
6154
|
assembly.seen.add(node);
|
|
6323
6155
|
return assembledTemplateText(node.getTemplate(), assembly);
|
|
6324
6156
|
}
|
|
6325
|
-
if (!
|
|
6157
|
+
if (!import_ts_morph25.Node.isCallExpression(node)) {
|
|
6326
6158
|
return null;
|
|
6327
6159
|
}
|
|
6328
6160
|
if (!isDocumentTag(node.getExpression())) {
|
|
@@ -6333,7 +6165,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
6333
6165
|
return null;
|
|
6334
6166
|
}
|
|
6335
6167
|
const template = stripDocumentNodeCasts(first);
|
|
6336
|
-
if (!
|
|
6168
|
+
if (!import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(template) && !import_ts_morph25.Node.isTemplateExpression(template)) {
|
|
6337
6169
|
return null;
|
|
6338
6170
|
}
|
|
6339
6171
|
if (assembly.seen.has(node)) {
|
|
@@ -6343,7 +6175,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
6343
6175
|
return assembledTemplateText(template, assembly);
|
|
6344
6176
|
}
|
|
6345
6177
|
function isDocumentTag(tag) {
|
|
6346
|
-
if (!
|
|
6178
|
+
if (!import_ts_morph25.Node.isIdentifier(tag)) {
|
|
6347
6179
|
return false;
|
|
6348
6180
|
}
|
|
6349
6181
|
if (tag.getText() === UNQUALIFIED_DOCUMENT_TAG) {
|
|
@@ -6354,14 +6186,14 @@ function isDocumentTag(tag) {
|
|
|
6354
6186
|
return false;
|
|
6355
6187
|
}
|
|
6356
6188
|
for (const declaration of symbol.getDeclarations()) {
|
|
6357
|
-
if (
|
|
6189
|
+
if (import_ts_morph25.Node.isImportSpecifier(declaration) && DOCUMENT_TAGS.has(declaration.getName())) {
|
|
6358
6190
|
return true;
|
|
6359
6191
|
}
|
|
6360
6192
|
}
|
|
6361
6193
|
return false;
|
|
6362
6194
|
}
|
|
6363
6195
|
function resolveThroughFacts(arg, assembly) {
|
|
6364
|
-
if (assembly.resolution === void 0 || !
|
|
6196
|
+
if (assembly.resolution === void 0 || !import_ts_morph25.Node.isIdentifier(arg)) {
|
|
6365
6197
|
return null;
|
|
6366
6198
|
}
|
|
6367
6199
|
const written = assembly.resolution.resolveWrittenValue(arg);
|
|
@@ -6410,7 +6242,7 @@ function singleLine(text) {
|
|
|
6410
6242
|
return collapsed.length > 80 ? `${collapsed.slice(0, 79)}\u2026` : collapsed;
|
|
6411
6243
|
}
|
|
6412
6244
|
function importedVariableInitializers(identifier) {
|
|
6413
|
-
if (!
|
|
6245
|
+
if (!import_ts_morph25.Node.isIdentifier(identifier)) {
|
|
6414
6246
|
return [];
|
|
6415
6247
|
}
|
|
6416
6248
|
const symbol = identifier.getSymbol();
|
|
@@ -6420,7 +6252,7 @@ function importedVariableInitializers(identifier) {
|
|
|
6420
6252
|
const resolved = resolveAliasedSymbol(symbol) ?? symbol;
|
|
6421
6253
|
const inits = [];
|
|
6422
6254
|
for (const decl of resolved.getDeclarations()) {
|
|
6423
|
-
if (
|
|
6255
|
+
if (import_ts_morph25.Node.isVariableDeclaration(decl)) {
|
|
6424
6256
|
const init = decl.getInitializer();
|
|
6425
6257
|
if (init !== void 0) {
|
|
6426
6258
|
inits.push(init);
|
|
@@ -6434,7 +6266,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
6434
6266
|
if (direct !== null) {
|
|
6435
6267
|
return direct;
|
|
6436
6268
|
}
|
|
6437
|
-
if (!
|
|
6269
|
+
if (!import_ts_morph25.Node.isIdentifier(arg)) {
|
|
6438
6270
|
return null;
|
|
6439
6271
|
}
|
|
6440
6272
|
const symbol = arg.getSymbol();
|
|
@@ -6442,7 +6274,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
6442
6274
|
return null;
|
|
6443
6275
|
}
|
|
6444
6276
|
for (const decl of symbol.getDeclarations()) {
|
|
6445
|
-
if (
|
|
6277
|
+
if (import_ts_morph25.Node.isImportClause(decl) || import_ts_morph25.Node.isImportSpecifier(decl)) {
|
|
6446
6278
|
const fromGraphqlFile = resolveGraphqlFileImport(decl);
|
|
6447
6279
|
if (fromGraphqlFile !== null) {
|
|
6448
6280
|
return fromGraphqlFile;
|
|
@@ -6461,7 +6293,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
6461
6293
|
return null;
|
|
6462
6294
|
}
|
|
6463
6295
|
function resolveTypedDocumentSource(arg) {
|
|
6464
|
-
if (!
|
|
6296
|
+
if (!import_ts_morph25.Node.isIdentifier(arg)) {
|
|
6465
6297
|
return null;
|
|
6466
6298
|
}
|
|
6467
6299
|
for (const init of importedVariableInitializers(arg)) {
|
|
@@ -6474,7 +6306,7 @@ function resolveTypedDocumentSource(arg) {
|
|
|
6474
6306
|
}
|
|
6475
6307
|
function typedDocumentSourceOf(node) {
|
|
6476
6308
|
const inner = stripDocumentNodeCasts(node);
|
|
6477
|
-
if (!
|
|
6309
|
+
if (!import_ts_morph25.Node.isObjectLiteralExpression(inner)) {
|
|
6478
6310
|
return null;
|
|
6479
6311
|
}
|
|
6480
6312
|
const evaluated = evaluateObjectLiteralAsJson(inner);
|
|
@@ -6492,7 +6324,7 @@ function typedDocumentSourceOf(node) {
|
|
|
6492
6324
|
}
|
|
6493
6325
|
}
|
|
6494
6326
|
function resolveTypedDocumentHeader(arg) {
|
|
6495
|
-
if (!
|
|
6327
|
+
if (!import_ts_morph25.Node.isIdentifier(arg)) {
|
|
6496
6328
|
return null;
|
|
6497
6329
|
}
|
|
6498
6330
|
const reference = arg.getText();
|
|
@@ -6502,7 +6334,7 @@ function resolveTypedDocumentHeader(arg) {
|
|
|
6502
6334
|
}
|
|
6503
6335
|
const resolved = resolveAliasedSymbol(symbol) ?? symbol;
|
|
6504
6336
|
for (const decl of resolved.getDeclarations()) {
|
|
6505
|
-
if (!
|
|
6337
|
+
if (!import_ts_morph25.Node.isVariableDeclaration(decl)) {
|
|
6506
6338
|
continue;
|
|
6507
6339
|
}
|
|
6508
6340
|
const init = decl.getInitializer();
|
|
@@ -6535,10 +6367,10 @@ function resolveTypedDocumentHeader(arg) {
|
|
|
6535
6367
|
}
|
|
6536
6368
|
function documentNodeCastTypeArgs(node) {
|
|
6537
6369
|
let current2 = node;
|
|
6538
|
-
while (
|
|
6539
|
-
if (
|
|
6370
|
+
while (import_ts_morph25.Node.isAsExpression(current2) || import_ts_morph25.Node.isParenthesizedExpression(current2)) {
|
|
6371
|
+
if (import_ts_morph25.Node.isAsExpression(current2)) {
|
|
6540
6372
|
const typeNode = current2.getTypeNode();
|
|
6541
|
-
if (typeNode !== void 0 &&
|
|
6373
|
+
if (typeNode !== void 0 && import_ts_morph25.Node.isTypeReference(typeNode)) {
|
|
6542
6374
|
const name = typeNode.getTypeName().getText();
|
|
6543
6375
|
const simpleName = name.includes(".") ? name.split(".").pop() ?? name : name;
|
|
6544
6376
|
if (simpleName === "TypedDocumentNode" || simpleName === "DocumentNode") {
|
|
@@ -6551,7 +6383,7 @@ function documentNodeCastTypeArgs(node) {
|
|
|
6551
6383
|
return null;
|
|
6552
6384
|
}
|
|
6553
6385
|
function operationHeaderFromResultType(typeNode) {
|
|
6554
|
-
if (typeNode === void 0 || !
|
|
6386
|
+
if (typeNode === void 0 || !import_ts_morph25.Node.isTypeReference(typeNode)) {
|
|
6555
6387
|
return null;
|
|
6556
6388
|
}
|
|
6557
6389
|
const name = typeNode.getTypeName().getText();
|
|
@@ -6572,16 +6404,16 @@ function operationHeaderFromResultType(typeNode) {
|
|
|
6572
6404
|
}
|
|
6573
6405
|
function stripDocumentNodeCasts(node) {
|
|
6574
6406
|
let current2 = node;
|
|
6575
|
-
while (
|
|
6407
|
+
while (import_ts_morph25.Node.isAsExpression(current2) || import_ts_morph25.Node.isParenthesizedExpression(current2)) {
|
|
6576
6408
|
current2 = current2.getExpression();
|
|
6577
6409
|
}
|
|
6578
6410
|
return current2;
|
|
6579
6411
|
}
|
|
6580
6412
|
function evaluateObjectLiteralAsJson(node) {
|
|
6581
|
-
if (
|
|
6413
|
+
if (import_ts_morph25.Node.isStringLiteral(node) || import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
6582
6414
|
return node.getLiteralValue();
|
|
6583
6415
|
}
|
|
6584
|
-
if (
|
|
6416
|
+
if (import_ts_morph25.Node.isNumericLiteral(node)) {
|
|
6585
6417
|
return Number(node.getText());
|
|
6586
6418
|
}
|
|
6587
6419
|
const kind = node.getText();
|
|
@@ -6594,17 +6426,17 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
6594
6426
|
if (kind === "null") {
|
|
6595
6427
|
return null;
|
|
6596
6428
|
}
|
|
6597
|
-
if (
|
|
6429
|
+
if (import_ts_morph25.Node.isObjectLiteralExpression(node)) {
|
|
6598
6430
|
const out = {};
|
|
6599
6431
|
for (const prop of node.getProperties()) {
|
|
6600
|
-
if (!
|
|
6432
|
+
if (!import_ts_morph25.Node.isPropertyAssignment(prop)) {
|
|
6601
6433
|
return null;
|
|
6602
6434
|
}
|
|
6603
6435
|
const nameNode = prop.getNameNode();
|
|
6604
6436
|
let name;
|
|
6605
|
-
if (
|
|
6437
|
+
if (import_ts_morph25.Node.isIdentifier(nameNode)) {
|
|
6606
6438
|
name = nameNode.getText();
|
|
6607
|
-
} else if (
|
|
6439
|
+
} else if (import_ts_morph25.Node.isStringLiteral(nameNode) || import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(nameNode)) {
|
|
6608
6440
|
name = nameNode.getLiteralValue();
|
|
6609
6441
|
} else {
|
|
6610
6442
|
return null;
|
|
@@ -6621,7 +6453,7 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
6621
6453
|
}
|
|
6622
6454
|
return out;
|
|
6623
6455
|
}
|
|
6624
|
-
if (
|
|
6456
|
+
if (import_ts_morph25.Node.isArrayLiteralExpression(node)) {
|
|
6625
6457
|
const out = [];
|
|
6626
6458
|
for (const el of node.getElements()) {
|
|
6627
6459
|
const value = evaluateObjectLiteralAsJson(el);
|
|
@@ -6635,8 +6467,8 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
6635
6467
|
return void 0;
|
|
6636
6468
|
}
|
|
6637
6469
|
function resolveGraphqlFileImport(decl) {
|
|
6638
|
-
const importDecl =
|
|
6639
|
-
if (importDecl === null || importDecl === void 0 || !
|
|
6470
|
+
const importDecl = import_ts_morph25.Node.isImportSpecifier(decl) ? decl.getImportDeclaration() : import_ts_morph25.Node.isImportClause(decl) ? decl.getParent() : null;
|
|
6471
|
+
if (importDecl === null || importDecl === void 0 || !import_ts_morph25.Node.isImportDeclaration(importDecl)) {
|
|
6640
6472
|
return null;
|
|
6641
6473
|
}
|
|
6642
6474
|
const specifier = importDecl.getModuleSpecifierValue();
|
|
@@ -6644,8 +6476,8 @@ function resolveGraphqlFileImport(decl) {
|
|
|
6644
6476
|
return null;
|
|
6645
6477
|
}
|
|
6646
6478
|
const sourceFile = importDecl.getSourceFile();
|
|
6647
|
-
const baseDir =
|
|
6648
|
-
const absolute =
|
|
6479
|
+
const baseDir = import_node_path3.default.dirname(sourceFile.getFilePath());
|
|
6480
|
+
const absolute = import_node_path3.default.resolve(baseDir, specifier);
|
|
6649
6481
|
try {
|
|
6650
6482
|
return import_node_fs.default.readFileSync(absolute, "utf8");
|
|
6651
6483
|
} catch {
|
|
@@ -6655,7 +6487,7 @@ function resolveGraphqlFileImport(decl) {
|
|
|
6655
6487
|
function enclosingFunctionRoot(node) {
|
|
6656
6488
|
let current2 = node.getParent();
|
|
6657
6489
|
while (current2 !== void 0) {
|
|
6658
|
-
if (
|
|
6490
|
+
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)) {
|
|
6659
6491
|
return current2;
|
|
6660
6492
|
}
|
|
6661
6493
|
current2 = current2.getParent();
|
|
@@ -6663,18 +6495,18 @@ function enclosingFunctionRoot(node) {
|
|
|
6663
6495
|
return null;
|
|
6664
6496
|
}
|
|
6665
6497
|
function functionNameOrAnon(func) {
|
|
6666
|
-
if (
|
|
6498
|
+
if (import_ts_morph25.Node.isFunctionDeclaration(func) || import_ts_morph25.Node.isMethodDeclaration(func)) {
|
|
6667
6499
|
return func.getName() ?? "<anon>";
|
|
6668
6500
|
}
|
|
6669
6501
|
const parent = func.getParent();
|
|
6670
|
-
if (parent !== void 0 &&
|
|
6502
|
+
if (parent !== void 0 && import_ts_morph25.Node.isVariableDeclaration(parent)) {
|
|
6671
6503
|
return parent.getName();
|
|
6672
6504
|
}
|
|
6673
6505
|
return "<anon>";
|
|
6674
6506
|
}
|
|
6675
6507
|
|
|
6676
6508
|
// src/discovery/importedCalls.ts
|
|
6677
|
-
var
|
|
6509
|
+
var import_ts_morph26 = require("ts-morph");
|
|
6678
6510
|
function callsResolvingTo(sourceFile, resolution, spec) {
|
|
6679
6511
|
return [
|
|
6680
6512
|
...callsByOriginName(
|
|
@@ -6688,11 +6520,11 @@ function callsResolvingTo(sourceFile, resolution, spec) {
|
|
|
6688
6520
|
function callsByOriginName(sourceFile, resolution, module2, names) {
|
|
6689
6521
|
const candidates = [];
|
|
6690
6522
|
sourceFile.forEachDescendant((node) => {
|
|
6691
|
-
if (!
|
|
6523
|
+
if (!import_ts_morph26.Node.isCallExpression(node) && !import_ts_morph26.Node.isNewExpression(node)) {
|
|
6692
6524
|
return;
|
|
6693
6525
|
}
|
|
6694
6526
|
const callee = node.getExpression();
|
|
6695
|
-
if (
|
|
6527
|
+
if (import_ts_morph26.Node.isIdentifier(callee) && !declaredLocally(callee)) {
|
|
6696
6528
|
candidates.push(node);
|
|
6697
6529
|
}
|
|
6698
6530
|
});
|
|
@@ -6718,7 +6550,7 @@ function callsByOriginName(sourceFile, resolution, module2, names) {
|
|
|
6718
6550
|
function declaredLocally(callee) {
|
|
6719
6551
|
const declarations = callee.getSymbol()?.getDeclarations() ?? [];
|
|
6720
6552
|
return declarations.length > 0 && declarations.every(
|
|
6721
|
-
(declaration) => (
|
|
6553
|
+
(declaration) => (import_ts_morph26.Node.isFunctionDeclaration(declaration) || import_ts_morph26.Node.isClassDeclaration(declaration)) && !declaration.getSourceFile().isInNodeModules()
|
|
6722
6554
|
);
|
|
6723
6555
|
}
|
|
6724
6556
|
|
|
@@ -6736,7 +6568,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
|
|
|
6736
6568
|
);
|
|
6737
6569
|
const results = [];
|
|
6738
6570
|
for (const [node, canonical] of hookCalls) {
|
|
6739
|
-
if (!
|
|
6571
|
+
if (!import_ts_morph27.Node.isCallExpression(node)) {
|
|
6740
6572
|
continue;
|
|
6741
6573
|
}
|
|
6742
6574
|
const operationType = operationTypeByHook.get(canonical);
|
|
@@ -6773,7 +6605,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
|
|
|
6773
6605
|
}
|
|
6774
6606
|
|
|
6775
6607
|
// src/discovery/graphqlImperativeCall.ts
|
|
6776
|
-
var
|
|
6608
|
+
var import_ts_morph28 = require("ts-morph");
|
|
6777
6609
|
function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
6778
6610
|
const isTheClient = clientReceiverCheckFor(sourceFile, match, resolution);
|
|
6779
6611
|
const methodSpec = /* @__PURE__ */ new Map();
|
|
@@ -6785,11 +6617,11 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
6785
6617
|
}
|
|
6786
6618
|
const results = [];
|
|
6787
6619
|
sourceFile.forEachDescendant((node) => {
|
|
6788
|
-
if (!
|
|
6620
|
+
if (!import_ts_morph28.Node.isCallExpression(node)) {
|
|
6789
6621
|
return;
|
|
6790
6622
|
}
|
|
6791
6623
|
const callee = node.getExpression();
|
|
6792
|
-
if (!
|
|
6624
|
+
if (!import_ts_morph28.Node.isPropertyAccessExpression(callee)) {
|
|
6793
6625
|
return;
|
|
6794
6626
|
}
|
|
6795
6627
|
const methodName = callee.getName();
|
|
@@ -6801,7 +6633,7 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
6801
6633
|
return;
|
|
6802
6634
|
}
|
|
6803
6635
|
const args = node.getArguments();
|
|
6804
|
-
if (args.length === 0 || !
|
|
6636
|
+
if (args.length === 0 || !import_ts_morph28.Node.isObjectLiteralExpression(args[0])) {
|
|
6805
6637
|
return;
|
|
6806
6638
|
}
|
|
6807
6639
|
const config = args[0];
|
|
@@ -6837,16 +6669,16 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
6837
6669
|
return results;
|
|
6838
6670
|
}
|
|
6839
6671
|
function imperativeConfigValue(prop) {
|
|
6840
|
-
if (
|
|
6672
|
+
if (import_ts_morph28.Node.isPropertyAssignment(prop)) {
|
|
6841
6673
|
return prop.getInitializer() ?? null;
|
|
6842
6674
|
}
|
|
6843
|
-
if (
|
|
6675
|
+
if (import_ts_morph28.Node.isShorthandPropertyAssignment(prop)) {
|
|
6844
6676
|
const valueSymbol = prop.getValueSymbol();
|
|
6845
6677
|
if (valueSymbol === void 0) {
|
|
6846
6678
|
return null;
|
|
6847
6679
|
}
|
|
6848
6680
|
for (const decl of valueSymbol.getDeclarations()) {
|
|
6849
|
-
if (
|
|
6681
|
+
if (import_ts_morph28.Node.isVariableDeclaration(decl)) {
|
|
6850
6682
|
const init = decl.getInitializer();
|
|
6851
6683
|
if (init !== void 0) {
|
|
6852
6684
|
return init;
|
|
@@ -6859,7 +6691,7 @@ function imperativeConfigValue(prop) {
|
|
|
6859
6691
|
}
|
|
6860
6692
|
|
|
6861
6693
|
// src/discovery/jsxElementRoute.ts
|
|
6862
|
-
var
|
|
6694
|
+
var import_ts_morph29 = require("ts-morph");
|
|
6863
6695
|
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";
|
|
6864
6696
|
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";
|
|
6865
6697
|
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";
|
|
@@ -6891,7 +6723,7 @@ function discoverJsxElementRoutes(sourceFile, match, kind, resolution) {
|
|
|
6891
6723
|
}
|
|
6892
6724
|
return;
|
|
6893
6725
|
}
|
|
6894
|
-
if (
|
|
6726
|
+
if (import_ts_morph29.Node.isCallExpression(node) && callsAFactory(node, factoryNames)) {
|
|
6895
6727
|
results.push(
|
|
6896
6728
|
...unitsForRouteArray(node, match, elementsNames, kind, resolution)
|
|
6897
6729
|
);
|
|
@@ -6913,7 +6745,7 @@ function localNamesFor(sourceFile, match, exported) {
|
|
|
6913
6745
|
return local;
|
|
6914
6746
|
}
|
|
6915
6747
|
function asRouteJsx(node, routeNames) {
|
|
6916
|
-
if (!
|
|
6748
|
+
if (!import_ts_morph29.Node.isJsxSelfClosingElement(node) && !import_ts_morph29.Node.isJsxElement(node)) {
|
|
6917
6749
|
return null;
|
|
6918
6750
|
}
|
|
6919
6751
|
return isRouteJsx(node, routeNames) ? node : null;
|
|
@@ -6923,15 +6755,15 @@ function isRouteJsx(node, routeNames) {
|
|
|
6923
6755
|
return tag !== null && routeNames.has(tag.getText());
|
|
6924
6756
|
}
|
|
6925
6757
|
function tagNameOf(node) {
|
|
6926
|
-
const tag =
|
|
6927
|
-
return
|
|
6758
|
+
const tag = import_ts_morph29.Node.isJsxElement(node) ? node.getOpeningElement().getTagNameNode() : node.getTagNameNode();
|
|
6759
|
+
return import_ts_morph29.Node.isIdentifier(tag) ? tag : null;
|
|
6928
6760
|
}
|
|
6929
6761
|
function attributesOf(node) {
|
|
6930
|
-
return
|
|
6762
|
+
return import_ts_morph29.Node.isJsxElement(node) ? node.getOpeningElement().getAttributes() : node.getAttributes();
|
|
6931
6763
|
}
|
|
6932
6764
|
function attributeValueOf(node, name) {
|
|
6933
6765
|
for (const attribute of attributesOf(node)) {
|
|
6934
|
-
if (!
|
|
6766
|
+
if (!import_ts_morph29.Node.isJsxAttribute(attribute)) {
|
|
6935
6767
|
continue;
|
|
6936
6768
|
}
|
|
6937
6769
|
if (attribute.getNameNode().getText() !== name) {
|
|
@@ -6942,8 +6774,8 @@ function attributeValueOf(node, name) {
|
|
|
6942
6774
|
return null;
|
|
6943
6775
|
}
|
|
6944
6776
|
function literalStringOf2(value) {
|
|
6945
|
-
const unwrapped2 =
|
|
6946
|
-
if (
|
|
6777
|
+
const unwrapped2 = import_ts_morph29.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
|
|
6778
|
+
if (import_ts_morph29.Node.isStringLiteral(unwrapped2) || import_ts_morph29.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
|
|
6947
6779
|
return unwrapped2.getLiteralValue();
|
|
6948
6780
|
}
|
|
6949
6781
|
return null;
|
|
@@ -6963,8 +6795,8 @@ function elementTargetOfValue(value) {
|
|
|
6963
6795
|
if (value === null) {
|
|
6964
6796
|
return { kind: "absent" };
|
|
6965
6797
|
}
|
|
6966
|
-
const unwrapped2 =
|
|
6967
|
-
if (!
|
|
6798
|
+
const unwrapped2 = import_ts_morph29.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
|
|
6799
|
+
if (!import_ts_morph29.Node.isJsxSelfClosingElement(unwrapped2) && !import_ts_morph29.Node.isJsxElement(unwrapped2)) {
|
|
6968
6800
|
return { kind: "unreadable" };
|
|
6969
6801
|
}
|
|
6970
6802
|
const tag = tagNameOf(unwrapped2);
|
|
@@ -6976,7 +6808,7 @@ function elementTargetOfValue(value) {
|
|
|
6976
6808
|
function composedPrefixOf(node, match, routeNames) {
|
|
6977
6809
|
const enclosing = [];
|
|
6978
6810
|
for (const ancestor of node.getAncestors()) {
|
|
6979
|
-
if (
|
|
6811
|
+
if (import_ts_morph29.Node.isJsxElement(ancestor) && isRouteJsx(ancestor, routeNames)) {
|
|
6980
6812
|
enclosing.push(ancestor);
|
|
6981
6813
|
}
|
|
6982
6814
|
}
|
|
@@ -7092,14 +6924,14 @@ function abstention(at, kind, sentence, label) {
|
|
|
7092
6924
|
}
|
|
7093
6925
|
function callsAFactory(call, factoryNames) {
|
|
7094
6926
|
const callee = call.getExpression();
|
|
7095
|
-
return
|
|
6927
|
+
return import_ts_morph29.Node.isIdentifier(callee) && factoryNames.has(callee.getText());
|
|
7096
6928
|
}
|
|
7097
6929
|
function unitsForRouteArray(call, match, elementsNames, kind, resolution) {
|
|
7098
6930
|
const first = call.getArguments()[0];
|
|
7099
6931
|
if (first === void 0) {
|
|
7100
6932
|
return [];
|
|
7101
6933
|
}
|
|
7102
|
-
if (
|
|
6934
|
+
if (import_ts_morph29.Node.isJsxElement(first) || import_ts_morph29.Node.isJsxSelfClosingElement(first) || import_ts_morph29.Node.isCallExpression(first) && callsAFactory(first, elementsNames)) {
|
|
7103
6935
|
return [];
|
|
7104
6936
|
}
|
|
7105
6937
|
const array = arrayLiteralOf(first, resolution);
|
|
@@ -7124,7 +6956,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
|
|
|
7124
6956
|
const nestedIn = new Set(ancestry).add(array);
|
|
7125
6957
|
const results = [];
|
|
7126
6958
|
for (const element of array.getElements()) {
|
|
7127
|
-
if (
|
|
6959
|
+
if (import_ts_morph29.Node.isSpreadElement(element)) {
|
|
7128
6960
|
results.push(
|
|
7129
6961
|
abstention(
|
|
7130
6962
|
element,
|
|
@@ -7135,7 +6967,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
|
|
|
7135
6967
|
);
|
|
7136
6968
|
continue;
|
|
7137
6969
|
}
|
|
7138
|
-
if (!
|
|
6970
|
+
if (!import_ts_morph29.Node.isObjectLiteralExpression(element)) {
|
|
7139
6971
|
results.push(
|
|
7140
6972
|
abstention(
|
|
7141
6973
|
element,
|
|
@@ -7224,7 +7056,7 @@ function ownPathOfObject(object, match) {
|
|
|
7224
7056
|
}
|
|
7225
7057
|
if (match.indexAttribute !== void 0) {
|
|
7226
7058
|
const indexValue = routePropertyOf(object, match.indexAttribute);
|
|
7227
|
-
if (indexValue !== null &&
|
|
7059
|
+
if (indexValue !== null && import_ts_morph29.Node.isTrueLiteral(indexValue)) {
|
|
7228
7060
|
return { kind: "inherited" };
|
|
7229
7061
|
}
|
|
7230
7062
|
}
|
|
@@ -7238,27 +7070,27 @@ function objectLabelOf(target) {
|
|
|
7238
7070
|
return target.kind === "named" ? target.identifier.getText() : "declaration";
|
|
7239
7071
|
}
|
|
7240
7072
|
function labelOfExpression(node) {
|
|
7241
|
-
if (
|
|
7073
|
+
if (import_ts_morph29.Node.isIdentifier(node)) {
|
|
7242
7074
|
return node.getText();
|
|
7243
7075
|
}
|
|
7244
|
-
if (
|
|
7076
|
+
if (import_ts_morph29.Node.isCallExpression(node)) {
|
|
7245
7077
|
return node.getExpression().getText();
|
|
7246
7078
|
}
|
|
7247
7079
|
return node.getKindName();
|
|
7248
7080
|
}
|
|
7249
7081
|
|
|
7250
7082
|
// src/discovery/packageExports.ts
|
|
7251
|
-
var
|
|
7083
|
+
var import_ts_morph31 = require("ts-morph");
|
|
7252
7084
|
|
|
7253
7085
|
// src/packageExports.ts
|
|
7254
7086
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
7255
|
-
var
|
|
7087
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
7256
7088
|
function resolvePackageExports(packageJsonPath, opts = {}) {
|
|
7257
|
-
const absPkgJson =
|
|
7258
|
-
const pkgDir =
|
|
7089
|
+
const absPkgJson = import_node_path4.default.resolve(packageJsonPath);
|
|
7090
|
+
const pkgDir = import_node_path4.default.dirname(absPkgJson);
|
|
7259
7091
|
const raw = import_node_fs2.default.readFileSync(absPkgJson, "utf8");
|
|
7260
7092
|
const pkg = JSON.parse(raw);
|
|
7261
|
-
const packageName = pkg.name ??
|
|
7093
|
+
const packageName = pkg.name ?? import_node_path4.default.basename(pkgDir);
|
|
7262
7094
|
const warnings = [];
|
|
7263
7095
|
const entries = [];
|
|
7264
7096
|
const pushEntry = (subPath, distPath) => {
|
|
@@ -7277,7 +7109,7 @@ function resolvePackageExports(packageJsonPath, opts = {}) {
|
|
|
7277
7109
|
subPath,
|
|
7278
7110
|
exportPathPrefix: subPathToPrefix(subPath),
|
|
7279
7111
|
sourceFile: src,
|
|
7280
|
-
publishedFile:
|
|
7112
|
+
publishedFile: import_node_path4.default.resolve(pkgDir, distPath)
|
|
7281
7113
|
});
|
|
7282
7114
|
};
|
|
7283
7115
|
const exportsField = pkg.exports;
|
|
@@ -7319,12 +7151,12 @@ function resolvePackageExportsCached(packageJsonPath) {
|
|
|
7319
7151
|
return fresh;
|
|
7320
7152
|
}
|
|
7321
7153
|
function namedPackageDirAbove(start) {
|
|
7322
|
-
let at =
|
|
7154
|
+
let at = import_node_path4.default.resolve(start);
|
|
7323
7155
|
for (let up = 0; up < 12; up += 1) {
|
|
7324
7156
|
if (packageNameAt(at) !== null) {
|
|
7325
7157
|
return at;
|
|
7326
7158
|
}
|
|
7327
|
-
const parent =
|
|
7159
|
+
const parent = import_node_path4.default.dirname(at);
|
|
7328
7160
|
if (parent === at) {
|
|
7329
7161
|
break;
|
|
7330
7162
|
}
|
|
@@ -7335,7 +7167,7 @@ function namedPackageDirAbove(start) {
|
|
|
7335
7167
|
function packageNameAt(dir) {
|
|
7336
7168
|
try {
|
|
7337
7169
|
const manifest = JSON.parse(
|
|
7338
|
-
import_node_fs2.default.readFileSync(
|
|
7170
|
+
import_node_fs2.default.readFileSync(import_node_path4.default.join(dir, "package.json"), "utf8")
|
|
7339
7171
|
);
|
|
7340
7172
|
if (typeof manifest.name === "string" && manifest.name.length > 0) {
|
|
7341
7173
|
return manifest.name;
|
|
@@ -7385,7 +7217,7 @@ function resolveSourceFor(pkgDir, distPath, srcRoot) {
|
|
|
7385
7217
|
const stem = withoutDist.replace(/\.d\.ts$/, "").replace(/\.js$/, "").replace(/\.cjs$/, "").replace(/\.mjs$/, "").replace(/\.ts$/, "");
|
|
7386
7218
|
const candidates = [`${stem}.ts`, `${stem}.tsx`];
|
|
7387
7219
|
for (const candidate of candidates) {
|
|
7388
|
-
const abs =
|
|
7220
|
+
const abs = import_node_path4.default.resolve(pkgDir, candidate);
|
|
7389
7221
|
if (import_node_fs2.default.existsSync(abs)) {
|
|
7390
7222
|
return abs;
|
|
7391
7223
|
}
|
|
@@ -7394,20 +7226,20 @@ function resolveSourceFor(pkgDir, distPath, srcRoot) {
|
|
|
7394
7226
|
}
|
|
7395
7227
|
|
|
7396
7228
|
// src/resolve/sourceDeclaration.ts
|
|
7397
|
-
var
|
|
7229
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
7398
7230
|
function sourceDeclarationsBehind(decl, resolution, visited = /* @__PURE__ */ new Set()) {
|
|
7399
7231
|
const file = decl.getSourceFile();
|
|
7400
7232
|
if (!file.isDeclarationFile() || file.isInNodeModules()) {
|
|
7401
7233
|
return [decl];
|
|
7402
7234
|
}
|
|
7403
|
-
const packageDir = namedPackageDirAbove(
|
|
7235
|
+
const packageDir = namedPackageDirAbove(import_node_path5.default.dirname(file.getFilePath()));
|
|
7404
7236
|
if (packageDir === null || visited.has(packageDir)) {
|
|
7405
7237
|
return [decl];
|
|
7406
7238
|
}
|
|
7407
7239
|
visited.add(packageDir);
|
|
7408
7240
|
const project = file.getProject();
|
|
7409
7241
|
const { entries } = resolvePackageExportsCached(
|
|
7410
|
-
|
|
7242
|
+
import_node_path5.default.join(packageDir, "package.json")
|
|
7411
7243
|
);
|
|
7412
7244
|
const found = [];
|
|
7413
7245
|
for (const entry of entries) {
|
|
@@ -7440,13 +7272,13 @@ function sameDeclaration(a, b) {
|
|
|
7440
7272
|
}
|
|
7441
7273
|
|
|
7442
7274
|
// src/discovery/factorySurface.ts
|
|
7443
|
-
var
|
|
7275
|
+
var import_ts_morph30 = require("ts-morph");
|
|
7444
7276
|
var MAX_BUILDER_HOPS = 2;
|
|
7445
7277
|
function surfaceMethods(decl) {
|
|
7446
|
-
if (
|
|
7278
|
+
if (import_ts_morph30.Node.isClassDeclaration(decl)) {
|
|
7447
7279
|
return surfaceClassMethods(decl);
|
|
7448
7280
|
}
|
|
7449
|
-
if (
|
|
7281
|
+
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)) {
|
|
7450
7282
|
return surfaceFactoryReturnMethods(decl);
|
|
7451
7283
|
}
|
|
7452
7284
|
return [];
|
|
@@ -7455,7 +7287,7 @@ function surfaceClassMethods(cls) {
|
|
|
7455
7287
|
const out = [];
|
|
7456
7288
|
const seen = /* @__PURE__ */ new Set();
|
|
7457
7289
|
for (const method of cls.getInstanceMethods()) {
|
|
7458
|
-
if (method.hasModifier(
|
|
7290
|
+
if (method.hasModifier(import_ts_morph30.SyntaxKind.PrivateKeyword)) {
|
|
7459
7291
|
continue;
|
|
7460
7292
|
}
|
|
7461
7293
|
const name = method.getName();
|
|
@@ -7466,7 +7298,7 @@ function surfaceClassMethods(cls) {
|
|
|
7466
7298
|
out.push({ func: method, name });
|
|
7467
7299
|
}
|
|
7468
7300
|
for (const method of cls.getStaticMethods()) {
|
|
7469
|
-
if (method.hasModifier(
|
|
7301
|
+
if (method.hasModifier(import_ts_morph30.SyntaxKind.PrivateKeyword)) {
|
|
7470
7302
|
continue;
|
|
7471
7303
|
}
|
|
7472
7304
|
const name = method.getName();
|
|
@@ -7485,9 +7317,9 @@ function surfaceFactoryReturnMethods(fn) {
|
|
|
7485
7317
|
return out;
|
|
7486
7318
|
}
|
|
7487
7319
|
function collectFromFunctionReturns(fn, out, seen, depth) {
|
|
7488
|
-
if (
|
|
7320
|
+
if (import_ts_morph30.Node.isArrowFunction(fn)) {
|
|
7489
7321
|
const body2 = fn.getBody();
|
|
7490
|
-
if (
|
|
7322
|
+
if (import_ts_morph30.Node.isExpression(body2)) {
|
|
7491
7323
|
collectFromReturnValue(body2, out, seen, depth);
|
|
7492
7324
|
return;
|
|
7493
7325
|
}
|
|
@@ -7498,11 +7330,11 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
|
|
|
7498
7330
|
}
|
|
7499
7331
|
const returns = [];
|
|
7500
7332
|
body.forEachDescendant((node, traversal) => {
|
|
7501
|
-
if (
|
|
7333
|
+
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)) {
|
|
7502
7334
|
traversal.skip();
|
|
7503
7335
|
return;
|
|
7504
7336
|
}
|
|
7505
|
-
if (
|
|
7337
|
+
if (import_ts_morph30.Node.isReturnStatement(node)) {
|
|
7506
7338
|
returns.push(node);
|
|
7507
7339
|
}
|
|
7508
7340
|
});
|
|
@@ -7516,15 +7348,15 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
|
|
|
7516
7348
|
}
|
|
7517
7349
|
function collectFromReturnValue(node, out, seen, depth) {
|
|
7518
7350
|
const expr = peelParens(node);
|
|
7519
|
-
if (
|
|
7351
|
+
if (import_ts_morph30.Node.isObjectLiteralExpression(expr)) {
|
|
7520
7352
|
collectFromObjectLiteral(expr, out, seen);
|
|
7521
7353
|
return;
|
|
7522
7354
|
}
|
|
7523
|
-
if (depth >= MAX_BUILDER_HOPS || !
|
|
7355
|
+
if (depth >= MAX_BUILDER_HOPS || !import_ts_morph30.Node.isCallExpression(expr)) {
|
|
7524
7356
|
return;
|
|
7525
7357
|
}
|
|
7526
7358
|
const callee = expr.getExpression();
|
|
7527
|
-
if (!
|
|
7359
|
+
if (!import_ts_morph30.Node.isIdentifier(callee)) {
|
|
7528
7360
|
return;
|
|
7529
7361
|
}
|
|
7530
7362
|
const helper = sameFileFunctionBehind(callee);
|
|
@@ -7547,12 +7379,12 @@ function functionAmong(declarations, filePath) {
|
|
|
7547
7379
|
if (decl.getSourceFile().getFilePath() !== filePath) {
|
|
7548
7380
|
continue;
|
|
7549
7381
|
}
|
|
7550
|
-
if (
|
|
7382
|
+
if (import_ts_morph30.Node.isFunctionDeclaration(decl)) {
|
|
7551
7383
|
return decl;
|
|
7552
7384
|
}
|
|
7553
|
-
if (
|
|
7385
|
+
if (import_ts_morph30.Node.isVariableDeclaration(decl)) {
|
|
7554
7386
|
const init = decl.getInitializer();
|
|
7555
|
-
if (init !== void 0 && (
|
|
7387
|
+
if (init !== void 0 && (import_ts_morph30.Node.isArrowFunction(init) || import_ts_morph30.Node.isFunctionExpression(init))) {
|
|
7556
7388
|
return init;
|
|
7557
7389
|
}
|
|
7558
7390
|
}
|
|
@@ -7561,11 +7393,11 @@ function functionAmong(declarations, filePath) {
|
|
|
7561
7393
|
}
|
|
7562
7394
|
function collectFromObjectLiteral(node, out, seen) {
|
|
7563
7395
|
const e = peelParens(node);
|
|
7564
|
-
if (!
|
|
7396
|
+
if (!import_ts_morph30.Node.isObjectLiteralExpression(e)) {
|
|
7565
7397
|
return;
|
|
7566
7398
|
}
|
|
7567
7399
|
for (const prop of e.getProperties()) {
|
|
7568
|
-
if (
|
|
7400
|
+
if (import_ts_morph30.Node.isMethodDeclaration(prop)) {
|
|
7569
7401
|
const name = prop.getName();
|
|
7570
7402
|
if (seen.has(name)) {
|
|
7571
7403
|
continue;
|
|
@@ -7574,16 +7406,16 @@ function collectFromObjectLiteral(node, out, seen) {
|
|
|
7574
7406
|
out.push({ func: prop, name });
|
|
7575
7407
|
continue;
|
|
7576
7408
|
}
|
|
7577
|
-
if (
|
|
7409
|
+
if (import_ts_morph30.Node.isPropertyAssignment(prop)) {
|
|
7578
7410
|
const init = prop.getInitializer();
|
|
7579
7411
|
if (init === void 0) {
|
|
7580
7412
|
continue;
|
|
7581
7413
|
}
|
|
7582
7414
|
let v3 = init;
|
|
7583
|
-
while (
|
|
7415
|
+
while (import_ts_morph30.Node.isParenthesizedExpression(v3)) {
|
|
7584
7416
|
v3 = v3.getExpression();
|
|
7585
7417
|
}
|
|
7586
|
-
if (
|
|
7418
|
+
if (import_ts_morph30.Node.isArrowFunction(v3) || import_ts_morph30.Node.isFunctionExpression(v3)) {
|
|
7587
7419
|
const name = prop.getName();
|
|
7588
7420
|
if (seen.has(name)) {
|
|
7589
7421
|
continue;
|
|
@@ -7592,7 +7424,7 @@ function collectFromObjectLiteral(node, out, seen) {
|
|
|
7592
7424
|
out.push({ func: v3, name });
|
|
7593
7425
|
}
|
|
7594
7426
|
}
|
|
7595
|
-
if (
|
|
7427
|
+
if (import_ts_morph30.Node.isShorthandPropertyAssignment(prop)) {
|
|
7596
7428
|
collectShorthandFunction(prop, out, seen);
|
|
7597
7429
|
}
|
|
7598
7430
|
}
|
|
@@ -7655,9 +7487,9 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
|
|
|
7655
7487
|
(decl) => sourceDeclarationsBehind(decl, resolution)
|
|
7656
7488
|
);
|
|
7657
7489
|
for (const decl of candidates) {
|
|
7658
|
-
if (
|
|
7490
|
+
if (import_ts_morph31.Node.isVariableDeclaration(decl)) {
|
|
7659
7491
|
const init = decl.getInitializer();
|
|
7660
|
-
if (init !== void 0 && (
|
|
7492
|
+
if (init !== void 0 && (import_ts_morph31.Node.isArrowFunction(init) || import_ts_morph31.Node.isFunctionExpression(init))) {
|
|
7661
7493
|
results.push(buildUnit(init, kind, exportName, entry));
|
|
7662
7494
|
for (const m of surfaceMethods(init)) {
|
|
7663
7495
|
results.push(buildSurfacedUnit(m, kind, exportName, entry));
|
|
@@ -7667,7 +7499,7 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
|
|
|
7667
7499
|
}
|
|
7668
7500
|
continue;
|
|
7669
7501
|
}
|
|
7670
|
-
if (
|
|
7502
|
+
if (import_ts_morph31.Node.isClassDeclaration(decl)) {
|
|
7671
7503
|
for (const m of surfaceMethods(decl)) {
|
|
7672
7504
|
results.push(buildSurfacedUnit(m, kind, exportName, entry));
|
|
7673
7505
|
}
|
|
@@ -7712,7 +7544,7 @@ function buildSurfacedUnit(m, kind, parentExportName, entry) {
|
|
|
7712
7544
|
}
|
|
7713
7545
|
|
|
7714
7546
|
// src/discovery/packageImport.ts
|
|
7715
|
-
var
|
|
7547
|
+
var import_ts_morph32 = require("ts-morph");
|
|
7716
7548
|
function isLanguageLib(file) {
|
|
7717
7549
|
return /[\\/]typescript[\\/]lib[\\/]lib\..*\.d\.ts$/.test(file.getFilePath());
|
|
7718
7550
|
}
|
|
@@ -7733,13 +7565,13 @@ function splitPackageSpec(spec) {
|
|
|
7733
7565
|
};
|
|
7734
7566
|
}
|
|
7735
7567
|
function enclosingFunctionName(func) {
|
|
7736
|
-
if (
|
|
7568
|
+
if (import_ts_morph32.Node.isFunctionDeclaration(func) || import_ts_morph32.Node.isMethodDeclaration(func)) {
|
|
7737
7569
|
const n = func.getName?.();
|
|
7738
7570
|
if (typeof n === "string" && n.length > 0) {
|
|
7739
7571
|
return n;
|
|
7740
7572
|
}
|
|
7741
7573
|
}
|
|
7742
|
-
if (
|
|
7574
|
+
if (import_ts_morph32.Node.isFunctionExpression(func)) {
|
|
7743
7575
|
const n = func.getName();
|
|
7744
7576
|
if (typeof n === "string" && n.length > 0) {
|
|
7745
7577
|
return n;
|
|
@@ -7747,10 +7579,10 @@ function enclosingFunctionName(func) {
|
|
|
7747
7579
|
}
|
|
7748
7580
|
const parent = func.getParent();
|
|
7749
7581
|
if (parent !== void 0) {
|
|
7750
|
-
if (
|
|
7582
|
+
if (import_ts_morph32.Node.isVariableDeclaration(parent)) {
|
|
7751
7583
|
return parent.getName();
|
|
7752
7584
|
}
|
|
7753
|
-
if (
|
|
7585
|
+
if (import_ts_morph32.Node.isPropertyAssignment(parent)) {
|
|
7754
7586
|
return parent.getName();
|
|
7755
7587
|
}
|
|
7756
7588
|
}
|
|
@@ -7769,7 +7601,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7769
7601
|
const calls = [];
|
|
7770
7602
|
const candidates = /* @__PURE__ */ new Set();
|
|
7771
7603
|
sourceFile.forEachDescendant((node) => {
|
|
7772
|
-
if (!
|
|
7604
|
+
if (!import_ts_morph32.Node.isCallExpression(node)) {
|
|
7773
7605
|
return;
|
|
7774
7606
|
}
|
|
7775
7607
|
calls.push(node);
|
|
@@ -7777,7 +7609,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7777
7609
|
if (couldBePackageLinked(callee, packages)) {
|
|
7778
7610
|
candidates.add(callee);
|
|
7779
7611
|
}
|
|
7780
|
-
if (
|
|
7612
|
+
if (import_ts_morph32.Node.isPropertyAccessExpression(callee) && couldBePackageLinked(callee.getExpression(), packages)) {
|
|
7781
7613
|
candidates.add(callee.getExpression());
|
|
7782
7614
|
}
|
|
7783
7615
|
});
|
|
@@ -7799,7 +7631,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7799
7631
|
if (direct !== null) {
|
|
7800
7632
|
return direct;
|
|
7801
7633
|
}
|
|
7802
|
-
if (!
|
|
7634
|
+
if (!import_ts_morph32.Node.isPropertyAccessExpression(callee)) {
|
|
7803
7635
|
return null;
|
|
7804
7636
|
}
|
|
7805
7637
|
const subject = originOf(callee.getExpression());
|
|
@@ -7824,7 +7656,7 @@ function attributedCalls(sourceFile, packages, resolution) {
|
|
|
7824
7656
|
return results;
|
|
7825
7657
|
}
|
|
7826
7658
|
function couldBePackageLinked(value, packages) {
|
|
7827
|
-
if (!
|
|
7659
|
+
if (!import_ts_morph32.Node.isIdentifier(value)) {
|
|
7828
7660
|
return true;
|
|
7829
7661
|
}
|
|
7830
7662
|
const declarations = value.getSymbol()?.getDeclarations() ?? [];
|
|
@@ -7832,7 +7664,7 @@ function couldBePackageLinked(value, packages) {
|
|
|
7832
7664
|
return true;
|
|
7833
7665
|
}
|
|
7834
7666
|
return !declarations.every(
|
|
7835
|
-
(declaration) =>
|
|
7667
|
+
(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)
|
|
7836
7668
|
);
|
|
7837
7669
|
}
|
|
7838
7670
|
function importAimsElsewhere(declaration, packages) {
|
|
@@ -7885,7 +7717,7 @@ function discoverPackageImports(sourceFile, match, kind, resolution) {
|
|
|
7885
7717
|
}
|
|
7886
7718
|
|
|
7887
7719
|
// src/discovery/registrationCall.ts
|
|
7888
|
-
var
|
|
7720
|
+
var import_ts_morph33 = require("ts-morph");
|
|
7889
7721
|
var import_resolution3 = require("@suss/resolution");
|
|
7890
7722
|
|
|
7891
7723
|
// src/resolve/routePath.ts
|
|
@@ -7910,11 +7742,11 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7910
7742
|
return results;
|
|
7911
7743
|
}
|
|
7912
7744
|
sourceFile.forEachDescendant((node) => {
|
|
7913
|
-
if (!
|
|
7745
|
+
if (!import_ts_morph33.Node.isCallExpression(node)) {
|
|
7914
7746
|
return;
|
|
7915
7747
|
}
|
|
7916
7748
|
const callee = node.getExpression();
|
|
7917
|
-
if (!
|
|
7749
|
+
if (!import_ts_morph33.Node.isPropertyAccessExpression(callee)) {
|
|
7918
7750
|
return;
|
|
7919
7751
|
}
|
|
7920
7752
|
const methodName = callee.getName();
|
|
@@ -7951,12 +7783,12 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7951
7783
|
const registrationSubjectId = nodeId(subjectNode);
|
|
7952
7784
|
let foundObjectArg = false;
|
|
7953
7785
|
for (const arg of args) {
|
|
7954
|
-
if (!
|
|
7786
|
+
if (!import_ts_morph33.Node.isObjectLiteralExpression(arg)) {
|
|
7955
7787
|
continue;
|
|
7956
7788
|
}
|
|
7957
7789
|
foundObjectArg = true;
|
|
7958
7790
|
for (const prop of arg.getProperties()) {
|
|
7959
|
-
if (
|
|
7791
|
+
if (import_ts_morph33.Node.isMethodDeclaration(prop)) {
|
|
7960
7792
|
results.push({
|
|
7961
7793
|
func: prop,
|
|
7962
7794
|
kind,
|
|
@@ -7965,7 +7797,7 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7965
7797
|
});
|
|
7966
7798
|
continue;
|
|
7967
7799
|
}
|
|
7968
|
-
if (!
|
|
7800
|
+
if (!import_ts_morph33.Node.isPropertyAssignment(prop)) {
|
|
7969
7801
|
continue;
|
|
7970
7802
|
}
|
|
7971
7803
|
const propInit = prop.getInitializer();
|
|
@@ -8078,13 +7910,13 @@ function subjectNodeFor(subject, subjects, match, resolution) {
|
|
|
8078
7910
|
}
|
|
8079
7911
|
var NOT_A_ROUTABLE = { kind: "none" };
|
|
8080
7912
|
function receiverOf(subject, subjects, match, resolution) {
|
|
8081
|
-
if (
|
|
7913
|
+
if (import_ts_morph33.Node.isIdentifier(subject)) {
|
|
8082
7914
|
const known = subjects.get(subject.getText());
|
|
8083
7915
|
if (known !== void 0) {
|
|
8084
7916
|
return { kind: "routable", node: known };
|
|
8085
7917
|
}
|
|
8086
7918
|
}
|
|
8087
|
-
if (resolution === void 0 || !(
|
|
7919
|
+
if (resolution === void 0 || !(import_ts_morph33.Node.isIdentifier(subject) || import_ts_morph33.Node.isPropertyAccessExpression(subject))) {
|
|
8088
7920
|
return NOT_A_ROUTABLE;
|
|
8089
7921
|
}
|
|
8090
7922
|
const construction = resolution.subjectConstructionOf(
|
|
@@ -8124,18 +7956,18 @@ function collectMethodsCalledOnCallResults(sourceFile) {
|
|
|
8124
7956
|
const setToCalls = /* @__PURE__ */ new Set();
|
|
8125
7957
|
const calledOn = /* @__PURE__ */ new Map();
|
|
8126
7958
|
sourceFile.forEachDescendant((node) => {
|
|
8127
|
-
if (
|
|
7959
|
+
if (import_ts_morph33.Node.isVariableDeclaration(node)) {
|
|
8128
7960
|
const init = node.getInitializer();
|
|
8129
|
-
if (init !== void 0 &&
|
|
7961
|
+
if (init !== void 0 && import_ts_morph33.Node.isCallExpression(init)) {
|
|
8130
7962
|
setToCalls.add(node.getName());
|
|
8131
7963
|
}
|
|
8132
7964
|
return;
|
|
8133
7965
|
}
|
|
8134
|
-
if (!
|
|
7966
|
+
if (!import_ts_morph33.Node.isCallExpression(node)) {
|
|
8135
7967
|
return;
|
|
8136
7968
|
}
|
|
8137
7969
|
const callee = node.getExpression();
|
|
8138
|
-
if (!
|
|
7970
|
+
if (!import_ts_morph33.Node.isPropertyAccessExpression(callee) || !import_ts_morph33.Node.isIdentifier(callee.getExpression())) {
|
|
8139
7971
|
return;
|
|
8140
7972
|
}
|
|
8141
7973
|
const receiver = callee.getExpression().getText();
|
|
@@ -8162,18 +7994,18 @@ function registrationSubjectsOf(sourceFile, importModule, importName, resolution
|
|
|
8162
7994
|
return subjects;
|
|
8163
7995
|
}
|
|
8164
7996
|
sourceFile.forEachDescendant((node) => {
|
|
8165
|
-
if (
|
|
7997
|
+
if (import_ts_morph33.Node.isVariableDeclaration(node)) {
|
|
8166
7998
|
const init = node.getInitializer();
|
|
8167
7999
|
if (init === void 0) {
|
|
8168
8000
|
return;
|
|
8169
8001
|
}
|
|
8170
|
-
const calleeText =
|
|
8002
|
+
const calleeText = import_ts_morph33.Node.isCallExpression(init) || import_ts_morph33.Node.isNewExpression(init) ? init.getExpression().getText() : null;
|
|
8171
8003
|
if (calleeText !== null && spellings.includes(calleeText)) {
|
|
8172
8004
|
subjects.set(node.getName(), init);
|
|
8173
8005
|
}
|
|
8174
8006
|
return;
|
|
8175
8007
|
}
|
|
8176
|
-
if (!
|
|
8008
|
+
if (!import_ts_morph33.Node.isParameterDeclaration(node)) {
|
|
8177
8009
|
return;
|
|
8178
8010
|
}
|
|
8179
8011
|
const typeNode = node.getTypeNode();
|
|
@@ -8194,7 +8026,7 @@ function creationSiteBehind(parameter, resolution) {
|
|
|
8194
8026
|
return parameter;
|
|
8195
8027
|
}
|
|
8196
8028
|
const written = resolution.resolveWrittenValue(parameter);
|
|
8197
|
-
if (written === null || !(
|
|
8029
|
+
if (written === null || !(import_ts_morph33.Node.isCallExpression(written) || import_ts_morph33.Node.isNewExpression(written))) {
|
|
8198
8030
|
return parameter;
|
|
8199
8031
|
}
|
|
8200
8032
|
return written;
|
|
@@ -8237,7 +8069,7 @@ function unboundConstructionsOf(sourceFile, importModule, importName) {
|
|
|
8237
8069
|
}
|
|
8238
8070
|
const constructions = [];
|
|
8239
8071
|
sourceFile.forEachDescendant((node) => {
|
|
8240
|
-
if ((
|
|
8072
|
+
if ((import_ts_morph33.Node.isCallExpression(node) || import_ts_morph33.Node.isNewExpression(node)) && spellings.includes(node.getExpression().getText()) && !import_ts_morph33.Node.isVariableDeclaration(node.getParent())) {
|
|
8241
8073
|
constructions.push(node);
|
|
8242
8074
|
}
|
|
8243
8075
|
});
|
|
@@ -8255,11 +8087,11 @@ function discoverMountEdges(sourceFile, match, mount, knownSubjectIds, resolutio
|
|
|
8255
8087
|
}
|
|
8256
8088
|
const edges = [];
|
|
8257
8089
|
sourceFile.forEachDescendant((node) => {
|
|
8258
|
-
if (!
|
|
8090
|
+
if (!import_ts_morph33.Node.isCallExpression(node)) {
|
|
8259
8091
|
return;
|
|
8260
8092
|
}
|
|
8261
8093
|
const callee = node.getExpression();
|
|
8262
|
-
if (!
|
|
8094
|
+
if (!import_ts_morph33.Node.isPropertyAccessExpression(callee) || callee.getName() !== mount.method) {
|
|
8263
8095
|
return;
|
|
8264
8096
|
}
|
|
8265
8097
|
const subjectNode = subjectNodeFor(
|
|
@@ -8273,7 +8105,7 @@ function discoverMountEdges(sourceFile, match, mount, knownSubjectIds, resolutio
|
|
|
8273
8105
|
}
|
|
8274
8106
|
const args = node.getArguments();
|
|
8275
8107
|
const prefixArg = args[mount.prefixPosition];
|
|
8276
|
-
if (prefixArg === void 0 || !(
|
|
8108
|
+
if (prefixArg === void 0 || !(import_ts_morph33.Node.isStringLiteral(prefixArg) || import_ts_morph33.Node.isNoSubstitutionTemplateLiteral(prefixArg))) {
|
|
8277
8109
|
return;
|
|
8278
8110
|
}
|
|
8279
8111
|
const targetNodes = mountTargetsAmong(
|
|
@@ -8328,7 +8160,7 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8328
8160
|
} else {
|
|
8329
8161
|
const args = call.getArguments();
|
|
8330
8162
|
const arg = args[binding.method.position];
|
|
8331
|
-
if (arg === void 0 || !(
|
|
8163
|
+
if (arg === void 0 || !(import_ts_morph33.Node.isStringLiteral(arg) || import_ts_morph33.Node.isNoSubstitutionTemplateLiteral(arg))) {
|
|
8332
8164
|
return null;
|
|
8333
8165
|
}
|
|
8334
8166
|
method = arg.getLiteralValue().toUpperCase();
|
|
@@ -8339,7 +8171,7 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8339
8171
|
}
|
|
8340
8172
|
|
|
8341
8173
|
// src/discovery/registrationLoop.ts
|
|
8342
|
-
var
|
|
8174
|
+
var import_ts_morph34 = require("ts-morph");
|
|
8343
8175
|
function discoverRegistrationLoops(sourceFile, match, kind, resolution) {
|
|
8344
8176
|
const results = [];
|
|
8345
8177
|
const guard = receiverGuard(sourceFile, match.receiver, resolution);
|
|
@@ -8347,7 +8179,7 @@ function discoverRegistrationLoops(sourceFile, match, kind, resolution) {
|
|
|
8347
8179
|
return results;
|
|
8348
8180
|
}
|
|
8349
8181
|
sourceFile.forEachDescendant((node) => {
|
|
8350
|
-
if (!
|
|
8182
|
+
if (!import_ts_morph34.Node.isForOfStatement(node)) {
|
|
8351
8183
|
return;
|
|
8352
8184
|
}
|
|
8353
8185
|
const expanded = tryExpandLoop(node, match, kind, resolution, guard);
|
|
@@ -8410,13 +8242,13 @@ function tryExpandLoop(loop, match, kind, resolution, guard) {
|
|
|
8410
8242
|
}
|
|
8411
8243
|
function loopVariableName(loop) {
|
|
8412
8244
|
const initializer = loop.getInitializer();
|
|
8413
|
-
if (
|
|
8245
|
+
if (import_ts_morph34.Node.isVariableDeclarationList(initializer)) {
|
|
8414
8246
|
const decls = initializer.getDeclarations();
|
|
8415
8247
|
if (decls.length !== 1) {
|
|
8416
8248
|
return null;
|
|
8417
8249
|
}
|
|
8418
8250
|
const nameNode = decls[0]?.getNameNode();
|
|
8419
|
-
if (nameNode !== void 0 &&
|
|
8251
|
+
if (nameNode !== void 0 && import_ts_morph34.Node.isIdentifier(nameNode)) {
|
|
8420
8252
|
return nameNode.getText();
|
|
8421
8253
|
}
|
|
8422
8254
|
}
|
|
@@ -8429,14 +8261,14 @@ function bodyReferencesLoopVar(loop, name) {
|
|
|
8429
8261
|
if (referenced) {
|
|
8430
8262
|
return;
|
|
8431
8263
|
}
|
|
8432
|
-
if (!
|
|
8264
|
+
if (!import_ts_morph34.Node.isCallExpression(node)) {
|
|
8433
8265
|
return;
|
|
8434
8266
|
}
|
|
8435
8267
|
node.forEachDescendant((inner) => {
|
|
8436
8268
|
if (referenced) {
|
|
8437
8269
|
return;
|
|
8438
8270
|
}
|
|
8439
|
-
if (
|
|
8271
|
+
if (import_ts_morph34.Node.isIdentifier(inner) && inner.getText() === name) {
|
|
8440
8272
|
referenced = true;
|
|
8441
8273
|
}
|
|
8442
8274
|
});
|
|
@@ -8446,11 +8278,11 @@ function bodyReferencesLoopVar(loop, name) {
|
|
|
8446
8278
|
function bodyCallsOnRoutable(loop, guard, resolution) {
|
|
8447
8279
|
let found = false;
|
|
8448
8280
|
loop.getStatement().forEachDescendant((node) => {
|
|
8449
|
-
if (found || !
|
|
8281
|
+
if (found || !import_ts_morph34.Node.isCallExpression(node)) {
|
|
8450
8282
|
return;
|
|
8451
8283
|
}
|
|
8452
8284
|
const callee = node.getExpression();
|
|
8453
|
-
if (!
|
|
8285
|
+
if (!import_ts_morph34.Node.isPropertyAccessExpression(callee) && !import_ts_morph34.Node.isElementAccessExpression(callee)) {
|
|
8454
8286
|
return;
|
|
8455
8287
|
}
|
|
8456
8288
|
const subject = callee.getExpression();
|
|
@@ -8470,11 +8302,11 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
8470
8302
|
let path15 = null;
|
|
8471
8303
|
let handler = null;
|
|
8472
8304
|
for (const prop of element.getProperties()) {
|
|
8473
|
-
if (
|
|
8305
|
+
if (import_ts_morph34.Node.isMethodDeclaration(prop) && prop.getName() === shape.handlerKey) {
|
|
8474
8306
|
handler = { func: prop, name: shape.handlerKey };
|
|
8475
8307
|
continue;
|
|
8476
8308
|
}
|
|
8477
|
-
if (!
|
|
8309
|
+
if (!import_ts_morph34.Node.isPropertyAssignment(prop)) {
|
|
8478
8310
|
continue;
|
|
8479
8311
|
}
|
|
8480
8312
|
const name = prop.getName();
|
|
@@ -8497,22 +8329,22 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
8497
8329
|
return { method, path: path15, handler: handler.func, handlerName: handler.name };
|
|
8498
8330
|
}
|
|
8499
8331
|
function readStringLiteralValue(node) {
|
|
8500
|
-
if (
|
|
8332
|
+
if (import_ts_morph34.Node.isStringLiteral(node) || import_ts_morph34.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
8501
8333
|
return node.getLiteralValue();
|
|
8502
8334
|
}
|
|
8503
8335
|
return null;
|
|
8504
8336
|
}
|
|
8505
8337
|
function handlerName(value) {
|
|
8506
|
-
return
|
|
8338
|
+
return import_ts_morph34.Node.isIdentifier(value) ? value.getText() : value.getKindName();
|
|
8507
8339
|
}
|
|
8508
8340
|
|
|
8509
8341
|
// src/discovery/registrationTemplate.ts
|
|
8510
|
-
var
|
|
8511
|
-
var
|
|
8342
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
8343
|
+
var import_ts_morph36 = require("ts-morph");
|
|
8512
8344
|
var import_resolution4 = require("@suss/resolution");
|
|
8513
8345
|
|
|
8514
8346
|
// src/resolve/unfollowedCall.ts
|
|
8515
|
-
var
|
|
8347
|
+
var import_ts_morph35 = require("ts-morph");
|
|
8516
8348
|
var import_behavioral_ir2 = require("@suss/behavioral-ir");
|
|
8517
8349
|
function isInExternalCode(sourceFile) {
|
|
8518
8350
|
if (sourceFile.isDeclarationFile()) {
|
|
@@ -8521,38 +8353,38 @@ function isInExternalCode(sourceFile) {
|
|
|
8521
8353
|
return sourceFile.getFilePath().includes("/node_modules/");
|
|
8522
8354
|
}
|
|
8523
8355
|
function hasBody(fn) {
|
|
8524
|
-
if (
|
|
8356
|
+
if (import_ts_morph35.Node.isFunctionDeclaration(fn) || import_ts_morph35.Node.isMethodDeclaration(fn) || import_ts_morph35.Node.isFunctionExpression(fn)) {
|
|
8525
8357
|
return fn.getBody?.() !== void 0;
|
|
8526
8358
|
}
|
|
8527
8359
|
return true;
|
|
8528
8360
|
}
|
|
8529
8361
|
function isDeclaredShape(declaration) {
|
|
8530
|
-
return (
|
|
8362
|
+
return (import_ts_morph35.Node.isMethodSignature(declaration) || import_ts_morph35.Node.isPropertySignature(declaration)) && !isInExternalCode(declaration.getSourceFile());
|
|
8531
8363
|
}
|
|
8532
8364
|
function isExternalDeclaration(declaration) {
|
|
8533
8365
|
if (isInExternalCode(declaration.getSourceFile())) {
|
|
8534
8366
|
return true;
|
|
8535
8367
|
}
|
|
8536
|
-
if (
|
|
8537
|
-
const target = declaration.getFirstAncestorByKind(
|
|
8368
|
+
if (import_ts_morph35.Node.isImportSpecifier(declaration) || import_ts_morph35.Node.isImportClause(declaration) || import_ts_morph35.Node.isNamespaceImport(declaration)) {
|
|
8369
|
+
const target = declaration.getFirstAncestorByKind(import_ts_morph35.SyntaxKind.ImportDeclaration)?.getModuleSpecifierSourceFile();
|
|
8538
8370
|
return target === void 0 || isInExternalCode(target);
|
|
8539
8371
|
}
|
|
8540
8372
|
return declaresAnotherModule(declaration);
|
|
8541
8373
|
}
|
|
8542
8374
|
function declaresAnotherModule(declaration) {
|
|
8543
8375
|
const module2 = declaration.getFirstAncestorByKind(
|
|
8544
|
-
|
|
8376
|
+
import_ts_morph35.SyntaxKind.ModuleDeclaration
|
|
8545
8377
|
);
|
|
8546
|
-
return module2 !== void 0 &&
|
|
8378
|
+
return module2 !== void 0 && import_ts_morph35.Node.isStringLiteral(module2.getNameNode());
|
|
8547
8379
|
}
|
|
8548
8380
|
function statesShapeOnly(declaration) {
|
|
8549
8381
|
if (isExternalDeclaration(declaration)) {
|
|
8550
8382
|
return false;
|
|
8551
8383
|
}
|
|
8552
|
-
if (
|
|
8384
|
+
if (import_ts_morph35.Node.isMethodSignature(declaration) || import_ts_morph35.Node.isPropertySignature(declaration)) {
|
|
8553
8385
|
return true;
|
|
8554
8386
|
}
|
|
8555
|
-
if (
|
|
8387
|
+
if (import_ts_morph35.Node.isFunctionDeclaration(declaration) || import_ts_morph35.Node.isMethodDeclaration(declaration)) {
|
|
8556
8388
|
return declaration.getBody() === void 0;
|
|
8557
8389
|
}
|
|
8558
8390
|
return false;
|
|
@@ -8565,7 +8397,7 @@ function declarationsBehind(symbol) {
|
|
|
8565
8397
|
return behind.length > 0 ? behind : symbol.getDeclarations();
|
|
8566
8398
|
}
|
|
8567
8399
|
function isParameterOf(declaration, scanning) {
|
|
8568
|
-
return
|
|
8400
|
+
return import_ts_morph35.Node.isParameterDeclaration(declaration) && declaration.getParent() === scanning;
|
|
8569
8401
|
}
|
|
8570
8402
|
function parameterIndexOf(declarations, scanning) {
|
|
8571
8403
|
if (scanning === void 0) {
|
|
@@ -8657,20 +8489,20 @@ function subjectOfCall(sourceFile, args, match, resolution) {
|
|
|
8657
8489
|
}
|
|
8658
8490
|
function helperCallsOf(sourceFile, match, resolution) {
|
|
8659
8491
|
const module2 = match.importModule;
|
|
8660
|
-
if (module2 !== void 0 && !
|
|
8492
|
+
if (module2 !== void 0 && !import_node_path6.default.isAbsolute(module2)) {
|
|
8661
8493
|
const store = resolution ?? new ResolutionStore();
|
|
8662
8494
|
return callsResolvingTo(sourceFile, store, {
|
|
8663
8495
|
module: module2,
|
|
8664
8496
|
name: match.helperName
|
|
8665
|
-
}).filter(
|
|
8497
|
+
}).filter(import_ts_morph36.Node.isCallExpression);
|
|
8666
8498
|
}
|
|
8667
8499
|
const calls = [];
|
|
8668
8500
|
sourceFile.forEachDescendant((node) => {
|
|
8669
|
-
if (!
|
|
8501
|
+
if (!import_ts_morph36.Node.isCallExpression(node)) {
|
|
8670
8502
|
return;
|
|
8671
8503
|
}
|
|
8672
8504
|
const callee = node.getExpression();
|
|
8673
|
-
if (!
|
|
8505
|
+
if (!import_ts_morph36.Node.isIdentifier(callee) || callee.getText() !== match.helperName) {
|
|
8674
8506
|
return;
|
|
8675
8507
|
}
|
|
8676
8508
|
if (module2 === void 0 || declaredInModule(callee, module2)) {
|
|
@@ -8714,7 +8546,7 @@ function substitutePath(template, args) {
|
|
|
8714
8546
|
return result;
|
|
8715
8547
|
}
|
|
8716
8548
|
function readStringLiteral(node) {
|
|
8717
|
-
if (
|
|
8549
|
+
if (import_ts_morph36.Node.isStringLiteral(node) || import_ts_morph36.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
8718
8550
|
return node.getLiteralValue();
|
|
8719
8551
|
}
|
|
8720
8552
|
return null;
|
|
@@ -8737,7 +8569,7 @@ function resolveHandler(template, args, resolution) {
|
|
|
8737
8569
|
return readPropertyAsFunction(arg, prop, resolution);
|
|
8738
8570
|
}
|
|
8739
8571
|
function handlerName2(value) {
|
|
8740
|
-
return
|
|
8572
|
+
return import_ts_morph36.Node.isIdentifier(value) ? value.getText() : value.getKindName();
|
|
8741
8573
|
}
|
|
8742
8574
|
function readPropertyAsFunction(arg, prop, resolution) {
|
|
8743
8575
|
const obj = objectLiteralOf(arg, resolution);
|
|
@@ -8748,7 +8580,7 @@ function readPropertyAsFunction(arg, prop, resolution) {
|
|
|
8748
8580
|
if (propertyName(property) !== prop) {
|
|
8749
8581
|
continue;
|
|
8750
8582
|
}
|
|
8751
|
-
if (
|
|
8583
|
+
if (import_ts_morph36.Node.isMethodDeclaration(property)) {
|
|
8752
8584
|
return { func: property, name: prop };
|
|
8753
8585
|
}
|
|
8754
8586
|
const held = propertyValueOf(property);
|
|
@@ -8756,19 +8588,19 @@ function readPropertyAsFunction(arg, prop, resolution) {
|
|
|
8756
8588
|
return null;
|
|
8757
8589
|
}
|
|
8758
8590
|
const func = functionValueOf(held, resolution);
|
|
8759
|
-
return func === null ? null : { func, name:
|
|
8591
|
+
return func === null ? null : { func, name: import_ts_morph36.Node.isIdentifier(held) ? held.getText() : prop };
|
|
8760
8592
|
}
|
|
8761
8593
|
return null;
|
|
8762
8594
|
}
|
|
8763
8595
|
function propertyName(property) {
|
|
8764
|
-
if (
|
|
8596
|
+
if (import_ts_morph36.Node.isPropertyAssignment(property) || import_ts_morph36.Node.isShorthandPropertyAssignment(property) || import_ts_morph36.Node.isMethodDeclaration(property)) {
|
|
8765
8597
|
return property.getName();
|
|
8766
8598
|
}
|
|
8767
8599
|
return null;
|
|
8768
8600
|
}
|
|
8769
8601
|
|
|
8770
8602
|
// src/discovery/resolverMap.ts
|
|
8771
|
-
var
|
|
8603
|
+
var import_ts_morph37 = require("ts-morph");
|
|
8772
8604
|
function discoverResolverMaps(sourceFile, match, kind, resolution) {
|
|
8773
8605
|
const store = resolution ?? new ResolutionStore();
|
|
8774
8606
|
const mapProperty = match.mapProperty;
|
|
@@ -8779,7 +8611,7 @@ function discoverResolverMaps(sourceFile, match, kind, resolution) {
|
|
|
8779
8611
|
name: match.importName
|
|
8780
8612
|
})) {
|
|
8781
8613
|
const args = node.getArguments();
|
|
8782
|
-
if (args.length === 0 || !
|
|
8614
|
+
if (args.length === 0 || !import_ts_morph37.Node.isObjectLiteralExpression(args[0])) {
|
|
8783
8615
|
continue;
|
|
8784
8616
|
}
|
|
8785
8617
|
const config = args[0];
|
|
@@ -8833,7 +8665,7 @@ function resolverMapObject(prop, resolution) {
|
|
|
8833
8665
|
return held === null ? null : objectLiteralOf(held, resolution);
|
|
8834
8666
|
}
|
|
8835
8667
|
function extractTypeDefsSdl(config, resolution) {
|
|
8836
|
-
if (!
|
|
8668
|
+
if (!import_ts_morph37.Node.isObjectLiteralExpression(config)) {
|
|
8837
8669
|
return null;
|
|
8838
8670
|
}
|
|
8839
8671
|
const prop = config.getProperty("typeDefs");
|
|
@@ -8855,15 +8687,15 @@ function schemaSdlOf(expr, resolution) {
|
|
|
8855
8687
|
return resolved === null ? null : writtenSdl(resolved);
|
|
8856
8688
|
}
|
|
8857
8689
|
function writtenSdl(expr) {
|
|
8858
|
-
if (
|
|
8690
|
+
if (import_ts_morph37.Node.isStringLiteral(expr) || import_ts_morph37.Node.isNoSubstitutionTemplateLiteral(expr)) {
|
|
8859
8691
|
const value = expr.getLiteralValue();
|
|
8860
8692
|
return value === "" ? null : value;
|
|
8861
8693
|
}
|
|
8862
|
-
if (
|
|
8694
|
+
if (import_ts_morph37.Node.isTaggedTemplateExpression(expr)) {
|
|
8863
8695
|
const tag = expr.getTag();
|
|
8864
|
-
if (
|
|
8696
|
+
if (import_ts_morph37.Node.isIdentifier(tag) && tag.getText() === "gql") {
|
|
8865
8697
|
const template = expr.getTemplate();
|
|
8866
|
-
if (
|
|
8698
|
+
if (import_ts_morph37.Node.isNoSubstitutionTemplateLiteral(template)) {
|
|
8867
8699
|
return template.getLiteralValue();
|
|
8868
8700
|
}
|
|
8869
8701
|
}
|
|
@@ -9026,7 +8858,7 @@ function discoverUnits(sourceFile, patterns, resolution, mountPrefixes, expanded
|
|
|
9026
8858
|
// src/resolve/functionBehind.ts
|
|
9027
8859
|
function symbolBehind(node) {
|
|
9028
8860
|
const parent = node.getParent();
|
|
9029
|
-
if (parent !== void 0 &&
|
|
8861
|
+
if (parent !== void 0 && import_ts_morph38.Node.isShorthandPropertyAssignment(parent)) {
|
|
9030
8862
|
return parent.getValueSymbol();
|
|
9031
8863
|
}
|
|
9032
8864
|
return node.getSymbol();
|
|
@@ -9056,9 +8888,9 @@ function resolveDecl(decl, calleeName) {
|
|
|
9056
8888
|
}
|
|
9057
8889
|
return { func: fn, name: declName(decl) ?? calleeName };
|
|
9058
8890
|
}
|
|
9059
|
-
if (
|
|
8891
|
+
if (import_ts_morph38.Node.isVariableDeclaration(decl)) {
|
|
9060
8892
|
const init = decl.getInitializer();
|
|
9061
|
-
if (init !== void 0 && (
|
|
8893
|
+
if (init !== void 0 && (import_ts_morph38.Node.isArrowFunction(init) || import_ts_morph38.Node.isFunctionExpression(init))) {
|
|
9062
8894
|
return { func: init, name: decl.getName() };
|
|
9063
8895
|
}
|
|
9064
8896
|
return null;
|
|
@@ -9066,20 +8898,20 @@ function resolveDecl(decl, calleeName) {
|
|
|
9066
8898
|
return null;
|
|
9067
8899
|
}
|
|
9068
8900
|
function declName(decl) {
|
|
9069
|
-
if (
|
|
8901
|
+
if (import_ts_morph38.Node.isFunctionDeclaration(decl) || import_ts_morph38.Node.isMethodDeclaration(decl)) {
|
|
9070
8902
|
const n = decl.getName?.();
|
|
9071
8903
|
if (typeof n === "string" && n.length > 0) {
|
|
9072
8904
|
return n;
|
|
9073
8905
|
}
|
|
9074
8906
|
}
|
|
9075
|
-
if (
|
|
8907
|
+
if (import_ts_morph38.Node.isFunctionExpression(decl)) {
|
|
9076
8908
|
const n = decl.getName();
|
|
9077
8909
|
if (typeof n === "string" && n.length > 0) {
|
|
9078
8910
|
return n;
|
|
9079
8911
|
}
|
|
9080
8912
|
}
|
|
9081
8913
|
const parent = decl.getParent();
|
|
9082
|
-
if (parent !== void 0 &&
|
|
8914
|
+
if (parent !== void 0 && import_ts_morph38.Node.isVariableDeclaration(parent)) {
|
|
9083
8915
|
return parent.getName();
|
|
9084
8916
|
}
|
|
9085
8917
|
return null;
|
|
@@ -9091,14 +8923,14 @@ function pathAbove(reference) {
|
|
|
9091
8923
|
let current2 = reference;
|
|
9092
8924
|
for (; ; ) {
|
|
9093
8925
|
const parent = current2.getParent();
|
|
9094
|
-
if (parent !== void 0 &&
|
|
8926
|
+
if (parent !== void 0 && import_ts_morph39.Node.isPropertyAccessExpression(parent) && parent.getExpression() === current2) {
|
|
9095
8927
|
path15.push(parent.getName());
|
|
9096
8928
|
current2 = parent;
|
|
9097
8929
|
continue;
|
|
9098
8930
|
}
|
|
9099
|
-
if (parent !== void 0 &&
|
|
8931
|
+
if (parent !== void 0 && import_ts_morph39.Node.isElementAccessExpression(parent) && parent.getExpression() === current2) {
|
|
9100
8932
|
const argument = parent.getArgumentExpression();
|
|
9101
|
-
if (argument !== void 0 &&
|
|
8933
|
+
if (argument !== void 0 && import_ts_morph39.Node.isStringLiteral(argument)) {
|
|
9102
8934
|
path15.push(argument.getLiteralValue());
|
|
9103
8935
|
current2 = parent;
|
|
9104
8936
|
continue;
|
|
@@ -9108,11 +8940,11 @@ function pathAbove(reference) {
|
|
|
9108
8940
|
}
|
|
9109
8941
|
}
|
|
9110
8942
|
function declaresParameterOf(node, func) {
|
|
9111
|
-
if (
|
|
8943
|
+
if (import_ts_morph39.Node.isParameterDeclaration(node)) {
|
|
9112
8944
|
return node.getParent() === func;
|
|
9113
8945
|
}
|
|
9114
|
-
if (
|
|
9115
|
-
const parameter = node.getFirstAncestor(
|
|
8946
|
+
if (import_ts_morph39.Node.isBindingElement(node)) {
|
|
8947
|
+
const parameter = node.getFirstAncestor(import_ts_morph39.Node.isParameterDeclaration);
|
|
9116
8948
|
return parameter !== void 0 && parameter.getParent() === func;
|
|
9117
8949
|
}
|
|
9118
8950
|
return false;
|
|
@@ -9128,7 +8960,7 @@ function parameterReads(func, parameterNames2, barriers = NO_BARRIERS) {
|
|
|
9128
8960
|
traversal.skip();
|
|
9129
8961
|
return;
|
|
9130
8962
|
}
|
|
9131
|
-
if (!
|
|
8963
|
+
if (!import_ts_morph39.Node.isIdentifier(node) || !wanted.has(node.getText())) {
|
|
9132
8964
|
return;
|
|
9133
8965
|
}
|
|
9134
8966
|
const declarations = symbolBehind(node)?.getDeclarations() ?? [];
|
|
@@ -9151,7 +8983,7 @@ function parameterReads(func, parameterNames2, barriers = NO_BARRIERS) {
|
|
|
9151
8983
|
}
|
|
9152
8984
|
|
|
9153
8985
|
// src/resolve/readName.ts
|
|
9154
|
-
var
|
|
8986
|
+
var import_ts_morph40 = require("ts-morph");
|
|
9155
8987
|
var import_behavioral_ir3 = require("@suss/behavioral-ir");
|
|
9156
8988
|
var MAX_HELPER_HOPS = 2;
|
|
9157
8989
|
var UNNAMED_HOLE = "param";
|
|
@@ -9186,11 +9018,11 @@ function referenceIn(expr) {
|
|
|
9186
9018
|
function parameterPath(expr) {
|
|
9187
9019
|
const fields = [];
|
|
9188
9020
|
let step = expr;
|
|
9189
|
-
while (
|
|
9021
|
+
while (import_ts_morph40.Node.isPropertyAccessExpression(step)) {
|
|
9190
9022
|
fields.unshift(step.getName());
|
|
9191
9023
|
step = step.getExpression();
|
|
9192
9024
|
}
|
|
9193
|
-
if (!
|
|
9025
|
+
if (!import_ts_morph40.Node.isIdentifier(step) || !isParameter(step)) {
|
|
9194
9026
|
return null;
|
|
9195
9027
|
}
|
|
9196
9028
|
return { root: step.getText(), fields };
|
|
@@ -9198,7 +9030,7 @@ function parameterPath(expr) {
|
|
|
9198
9030
|
function isParameter(identifier) {
|
|
9199
9031
|
const declarations = identifier.getSymbol()?.getDeclarations() ?? [];
|
|
9200
9032
|
return declarations.some(
|
|
9201
|
-
(declaration) =>
|
|
9033
|
+
(declaration) => import_ts_morph40.Node.isParameterDeclaration(declaration)
|
|
9202
9034
|
);
|
|
9203
9035
|
}
|
|
9204
9036
|
function read(expr, ctx) {
|
|
@@ -9207,25 +9039,25 @@ function read(expr, ctx) {
|
|
|
9207
9039
|
}
|
|
9208
9040
|
const seen = new Set(ctx.seen).add(expr);
|
|
9209
9041
|
const inner = { ...ctx, seen };
|
|
9210
|
-
if (
|
|
9042
|
+
if (import_ts_morph40.Node.isStringLiteral(expr) || import_ts_morph40.Node.isNoSubstitutionTemplateLiteral(expr)) {
|
|
9211
9043
|
return expr.getLiteralValue();
|
|
9212
9044
|
}
|
|
9213
|
-
if (
|
|
9045
|
+
if (import_ts_morph40.Node.isNumericLiteral(expr)) {
|
|
9214
9046
|
return expr.getLiteralText();
|
|
9215
9047
|
}
|
|
9216
|
-
if (
|
|
9048
|
+
if (import_ts_morph40.Node.isTemplateExpression(expr)) {
|
|
9217
9049
|
return fromTemplate(expr, inner);
|
|
9218
9050
|
}
|
|
9219
|
-
if (
|
|
9051
|
+
if (import_ts_morph40.Node.isParenthesizedExpression(expr)) {
|
|
9220
9052
|
return read(peelParens(expr), inner);
|
|
9221
9053
|
}
|
|
9222
|
-
if (
|
|
9054
|
+
if (import_ts_morph40.Node.isBinaryExpression(expr)) {
|
|
9223
9055
|
return fromBinary(expr, inner);
|
|
9224
9056
|
}
|
|
9225
|
-
if (
|
|
9057
|
+
if (import_ts_morph40.Node.isCallExpression(expr)) {
|
|
9226
9058
|
return fromCall(expr, inner);
|
|
9227
9059
|
}
|
|
9228
|
-
if (
|
|
9060
|
+
if (import_ts_morph40.Node.isIdentifier(expr)) {
|
|
9229
9061
|
const only = boundOnce(expr, ctx);
|
|
9230
9062
|
if (only !== null) {
|
|
9231
9063
|
return read(only.node, { ...inner, bindings: only.scope });
|
|
@@ -9245,17 +9077,17 @@ function read(expr, ctx) {
|
|
|
9245
9077
|
}
|
|
9246
9078
|
function isFallbackBranch(node) {
|
|
9247
9079
|
let step = node.getParent();
|
|
9248
|
-
while (step !== void 0 &&
|
|
9080
|
+
while (step !== void 0 && import_ts_morph40.Node.isParenthesizedExpression(step)) {
|
|
9249
9081
|
step = step.getParent();
|
|
9250
9082
|
}
|
|
9251
|
-
if (step === void 0 || !
|
|
9083
|
+
if (step === void 0 || !import_ts_morph40.Node.isBinaryExpression(step)) {
|
|
9252
9084
|
return false;
|
|
9253
9085
|
}
|
|
9254
9086
|
const operator = step.getOperatorToken().getKind();
|
|
9255
|
-
return operator ===
|
|
9087
|
+
return operator === import_ts_morph40.SyntaxKind.BarBarToken || operator === import_ts_morph40.SyntaxKind.QuestionQuestionToken;
|
|
9256
9088
|
}
|
|
9257
9089
|
function fromTemplate(expr, ctx) {
|
|
9258
|
-
if (!
|
|
9090
|
+
if (!import_ts_morph40.Node.isTemplateExpression(expr)) {
|
|
9259
9091
|
return null;
|
|
9260
9092
|
}
|
|
9261
9093
|
let name = expr.getHead().getLiteralText();
|
|
@@ -9266,28 +9098,28 @@ function fromTemplate(expr, ctx) {
|
|
|
9266
9098
|
return name;
|
|
9267
9099
|
}
|
|
9268
9100
|
function fromBinary(expr, ctx) {
|
|
9269
|
-
if (!
|
|
9101
|
+
if (!import_ts_morph40.Node.isBinaryExpression(expr)) {
|
|
9270
9102
|
return null;
|
|
9271
9103
|
}
|
|
9272
9104
|
const operator = expr.getOperatorToken().getKind();
|
|
9273
|
-
if (operator ===
|
|
9105
|
+
if (operator === import_ts_morph40.SyntaxKind.BarBarToken || operator === import_ts_morph40.SyntaxKind.QuestionQuestionToken) {
|
|
9274
9106
|
return ctx.insideHole ? null : read(expr.getRight(), ctx);
|
|
9275
9107
|
}
|
|
9276
|
-
if (operator !==
|
|
9108
|
+
if (operator !== import_ts_morph40.SyntaxKind.PlusToken) {
|
|
9277
9109
|
return null;
|
|
9278
9110
|
}
|
|
9279
9111
|
const parts = { ...ctx, insideHole: true };
|
|
9280
9112
|
return readOrHole(expr.getLeft(), parts) + readOrHole(expr.getRight(), parts);
|
|
9281
9113
|
}
|
|
9282
9114
|
function fromCall(expr, ctx) {
|
|
9283
|
-
if (!
|
|
9115
|
+
if (!import_ts_morph40.Node.isCallExpression(expr)) {
|
|
9284
9116
|
return null;
|
|
9285
9117
|
}
|
|
9286
9118
|
const callee = expr.getExpression();
|
|
9287
|
-
if (
|
|
9119
|
+
if (import_ts_morph40.Node.isPropertyAccessExpression(callee) && callee.getName() === "join") {
|
|
9288
9120
|
return fromJoin(callee.getExpression(), expr.getArguments(), ctx);
|
|
9289
9121
|
}
|
|
9290
|
-
if (
|
|
9122
|
+
if (import_ts_morph40.Node.isIdentifier(callee) && callee.getText() === "String") {
|
|
9291
9123
|
const only = expr.getArguments()[0];
|
|
9292
9124
|
return only === void 0 ? null : readOrHole(only, ctx);
|
|
9293
9125
|
}
|
|
@@ -9306,7 +9138,7 @@ function fromCall(expr, ctx) {
|
|
|
9306
9138
|
}
|
|
9307
9139
|
function fromJoin(subject, args, ctx) {
|
|
9308
9140
|
const separator = args[0];
|
|
9309
|
-
if (separator === void 0 || !
|
|
9141
|
+
if (separator === void 0 || !import_ts_morph40.Node.isStringLiteral(separator)) {
|
|
9310
9142
|
return null;
|
|
9311
9143
|
}
|
|
9312
9144
|
const parts = elementsOf(subject, ctx);
|
|
@@ -9322,17 +9154,17 @@ function fromJoin(subject, args, ctx) {
|
|
|
9322
9154
|
).join(separator.getLiteralValue());
|
|
9323
9155
|
}
|
|
9324
9156
|
function elementsOf(subject, ctx) {
|
|
9325
|
-
if (
|
|
9157
|
+
if (import_ts_morph40.Node.isArrayLiteralExpression(subject)) {
|
|
9326
9158
|
return subject.getElements().map((element) => here(element, ctx));
|
|
9327
9159
|
}
|
|
9328
|
-
if (
|
|
9160
|
+
if (import_ts_morph40.Node.isCallExpression(subject)) {
|
|
9329
9161
|
const callee = subject.getExpression();
|
|
9330
|
-
if (
|
|
9162
|
+
if (import_ts_morph40.Node.isPropertyAccessExpression(callee) && callee.getName() === "map") {
|
|
9331
9163
|
return elementsOf(callee.getExpression(), ctx);
|
|
9332
9164
|
}
|
|
9333
9165
|
return null;
|
|
9334
9166
|
}
|
|
9335
|
-
if (!
|
|
9167
|
+
if (!import_ts_morph40.Node.isIdentifier(subject)) {
|
|
9336
9168
|
return null;
|
|
9337
9169
|
}
|
|
9338
9170
|
const bound = ctx.bindings.get(subject.getText());
|
|
@@ -9340,7 +9172,7 @@ function elementsOf(subject, ctx) {
|
|
|
9340
9172
|
return null;
|
|
9341
9173
|
}
|
|
9342
9174
|
const only = bound.length === 1 ? bound[0] : void 0;
|
|
9343
|
-
return only !== void 0 &&
|
|
9175
|
+
return only !== void 0 && import_ts_morph40.Node.isArrayLiteralExpression(only.node) ? only.node.getElements().map((element) => here(element, ctx)) : bound;
|
|
9344
9176
|
}
|
|
9345
9177
|
function singleReturnBody(callee, ctx) {
|
|
9346
9178
|
const declaration = declarationOf2(callee, ctx);
|
|
@@ -9355,22 +9187,22 @@ function singleReturnBody(callee, ctx) {
|
|
|
9355
9187
|
if (body === void 0) {
|
|
9356
9188
|
return null;
|
|
9357
9189
|
}
|
|
9358
|
-
if (
|
|
9190
|
+
if (import_ts_morph40.Node.isExpression(body)) {
|
|
9359
9191
|
return { parameters, returned: body };
|
|
9360
9192
|
}
|
|
9361
|
-
if (!
|
|
9193
|
+
if (!import_ts_morph40.Node.isBlock(body)) {
|
|
9362
9194
|
return null;
|
|
9363
9195
|
}
|
|
9364
9196
|
const statements = body.getStatements();
|
|
9365
9197
|
const only = statements[0];
|
|
9366
|
-
if (statements.length !== 1 || only === void 0 || !
|
|
9198
|
+
if (statements.length !== 1 || only === void 0 || !import_ts_morph40.Node.isReturnStatement(only)) {
|
|
9367
9199
|
return null;
|
|
9368
9200
|
}
|
|
9369
9201
|
const returned = only.getExpression();
|
|
9370
9202
|
return returned === void 0 ? null : { parameters, returned };
|
|
9371
9203
|
}
|
|
9372
9204
|
function declarationOf2(callee, ctx) {
|
|
9373
|
-
const symbol =
|
|
9205
|
+
const symbol = import_ts_morph40.Node.isPropertyAccessExpression(callee) ? callee.getNameNode().getSymbol() : callee.getSymbol();
|
|
9374
9206
|
const declarations = symbol?.getAliasedSymbol()?.getDeclarations() ?? symbol?.getDeclarations() ?? [];
|
|
9375
9207
|
for (const declaration of declarations) {
|
|
9376
9208
|
const callable = asCallable(declaration);
|
|
@@ -9382,14 +9214,14 @@ function declarationOf2(callee, ctx) {
|
|
|
9382
9214
|
return written === null || written === callee ? null : declarationOf2(written, { ...ctx, resolve: () => null });
|
|
9383
9215
|
}
|
|
9384
9216
|
function asCallable(declaration) {
|
|
9385
|
-
if (
|
|
9217
|
+
if (import_ts_morph40.Node.isFunctionDeclaration(declaration) || import_ts_morph40.Node.isMethodDeclaration(declaration) || import_ts_morph40.Node.isArrowFunction(declaration) || import_ts_morph40.Node.isFunctionExpression(declaration)) {
|
|
9386
9218
|
return declaration;
|
|
9387
9219
|
}
|
|
9388
|
-
if (!
|
|
9220
|
+
if (!import_ts_morph40.Node.isVariableDeclaration(declaration)) {
|
|
9389
9221
|
return null;
|
|
9390
9222
|
}
|
|
9391
9223
|
const initializer = declaration.getInitializer();
|
|
9392
|
-
if (initializer !== void 0 && (
|
|
9224
|
+
if (initializer !== void 0 && (import_ts_morph40.Node.isArrowFunction(initializer) || import_ts_morph40.Node.isFunctionExpression(initializer))) {
|
|
9393
9225
|
return initializer;
|
|
9394
9226
|
}
|
|
9395
9227
|
return null;
|
|
@@ -9411,7 +9243,7 @@ function here(node, ctx) {
|
|
|
9411
9243
|
return { node, scope: ctx.bindings };
|
|
9412
9244
|
}
|
|
9413
9245
|
function boundOnce(expr, ctx) {
|
|
9414
|
-
const bound =
|
|
9246
|
+
const bound = import_ts_morph40.Node.isIdentifier(expr) ? ctx.bindings.get(expr.getText()) : void 0;
|
|
9415
9247
|
return bound !== void 0 && bound.length === 1 ? bound[0] : null;
|
|
9416
9248
|
}
|
|
9417
9249
|
function readOrHole(expr, ctx) {
|
|
@@ -9423,10 +9255,10 @@ function holeName(expr, ctx) {
|
|
|
9423
9255
|
if (bound !== null) {
|
|
9424
9256
|
return holeName(bound.node, { ...ctx, bindings: bound.scope });
|
|
9425
9257
|
}
|
|
9426
|
-
if (
|
|
9258
|
+
if (import_ts_morph40.Node.isIdentifier(expr)) {
|
|
9427
9259
|
return expr.getText();
|
|
9428
9260
|
}
|
|
9429
|
-
if (
|
|
9261
|
+
if (import_ts_morph40.Node.isPropertyAccessExpression(expr)) {
|
|
9430
9262
|
return expr.getName();
|
|
9431
9263
|
}
|
|
9432
9264
|
return UNNAMED_HOLE;
|
|
@@ -9453,8 +9285,8 @@ function madeFromNamed(origin, made) {
|
|
|
9453
9285
|
return origin.named.includes(constructorName(made));
|
|
9454
9286
|
}
|
|
9455
9287
|
function constructorName(made) {
|
|
9456
|
-
const expression =
|
|
9457
|
-
return
|
|
9288
|
+
const expression = import_ts_morph41.Node.isNewExpression(made) || import_ts_morph41.Node.isCallExpression(made) ? made.getExpression() : made;
|
|
9289
|
+
return import_ts_morph41.Node.isPropertyAccessExpression(expression) ? expression.getName() : expression.getText();
|
|
9458
9290
|
}
|
|
9459
9291
|
var CALL_ORIGIN = {
|
|
9460
9292
|
declaredBy: ORIGIN.declaredBy,
|
|
@@ -9468,7 +9300,7 @@ var CALL_ORIGIN = {
|
|
|
9468
9300
|
};
|
|
9469
9301
|
function madeBy(receiver) {
|
|
9470
9302
|
const made = madeExpression(receiver);
|
|
9471
|
-
const expression =
|
|
9303
|
+
const expression = import_ts_morph41.Node.isNewExpression(made) || import_ts_morph41.Node.isCallExpression(made) ? made.getExpression() : made;
|
|
9472
9304
|
return rootIdentifier(expression) ?? expression;
|
|
9473
9305
|
}
|
|
9474
9306
|
function madeExpression(receiver) {
|
|
@@ -9476,7 +9308,7 @@ function madeExpression(receiver) {
|
|
|
9476
9308
|
return receiver.expression;
|
|
9477
9309
|
}
|
|
9478
9310
|
const written = receiver.resolve(receiver.callee.getExpression());
|
|
9479
|
-
if (written === null || !
|
|
9311
|
+
if (written === null || !import_ts_morph41.Node.isNewExpression(written) && !import_ts_morph41.Node.isCallExpression(written)) {
|
|
9480
9312
|
return receiver.callee;
|
|
9481
9313
|
}
|
|
9482
9314
|
return written;
|
|
@@ -9484,7 +9316,7 @@ function madeExpression(receiver) {
|
|
|
9484
9316
|
function callOpsFor(call, resolveWrittenValue, originatesFrom, anchorCallsOf) {
|
|
9485
9317
|
const resolve2 = resolveWrittenValue ?? (() => null);
|
|
9486
9318
|
const expression = calleeOf3(call);
|
|
9487
|
-
const callee =
|
|
9319
|
+
const callee = import_ts_morph41.Node.isPropertyAccessExpression(expression) ? expression : null;
|
|
9488
9320
|
let args = null;
|
|
9489
9321
|
const argumentsOf = () => {
|
|
9490
9322
|
args ??= argumentsIn(call);
|
|
@@ -9507,7 +9339,7 @@ function callOpsFor(call, resolveWrittenValue, originatesFrom, anchorCallsOf) {
|
|
|
9507
9339
|
argumentCount: () => argumentsOf().length,
|
|
9508
9340
|
nameAt: (index, unsettled) => nameAt(argumentsOf()[index], unsettled, resolve2),
|
|
9509
9341
|
calleeText: () => expression.getText(),
|
|
9510
|
-
namedCallee: () =>
|
|
9342
|
+
namedCallee: () => import_ts_morph41.Node.isIdentifier(expression),
|
|
9511
9343
|
parameterReadsAt: (index) => selectorReadsOf(argumentsOf()[index]),
|
|
9512
9344
|
receiver: () => callee === null ? null : opsOverCall(callee.getExpression(), resolve2),
|
|
9513
9345
|
argument: (index) => opsOverCall(argumentsOf()[index], resolve2),
|
|
@@ -9532,7 +9364,7 @@ function anchorCallBehind(subject, origin, resolve2, originatesFrom, anchorCalls
|
|
|
9532
9364
|
return null;
|
|
9533
9365
|
}
|
|
9534
9366
|
const found = anchorCallsOf(subject, (candidate) => {
|
|
9535
|
-
if (!
|
|
9367
|
+
if (!import_ts_morph41.Node.isCallExpression(candidate) && !import_ts_morph41.Node.isNewExpression(candidate)) {
|
|
9536
9368
|
return false;
|
|
9537
9369
|
}
|
|
9538
9370
|
const candidateCallee = calleeOf3(candidate);
|
|
@@ -9547,7 +9379,7 @@ function anchorCallBehind(subject, origin, resolve2, originatesFrom, anchorCalls
|
|
|
9547
9379
|
if (distinct.length !== 1 || only === void 0) {
|
|
9548
9380
|
return null;
|
|
9549
9381
|
}
|
|
9550
|
-
if (!
|
|
9382
|
+
if (!import_ts_morph41.Node.isCallExpression(only) && !import_ts_morph41.Node.isNewExpression(only)) {
|
|
9551
9383
|
return null;
|
|
9552
9384
|
}
|
|
9553
9385
|
return callOpsFor(only, resolve2, originatesFrom, anchorCallsOf);
|
|
@@ -9567,7 +9399,7 @@ function valueOpsFor(value, resolve2) {
|
|
|
9567
9399
|
asArg: () => effectArgOf(written()),
|
|
9568
9400
|
property: (name) => {
|
|
9569
9401
|
const object = written();
|
|
9570
|
-
const inside =
|
|
9402
|
+
const inside = import_ts_morph41.Node.isObjectLiteralExpression(object) ? initializerOf(object, name) : null;
|
|
9571
9403
|
return inside === null ? null : valueOpsFor(inside, resolve2);
|
|
9572
9404
|
},
|
|
9573
9405
|
parts: () => literalParts(written()),
|
|
@@ -9580,7 +9412,7 @@ function literalParts(value) {
|
|
|
9580
9412
|
if (whole !== null) {
|
|
9581
9413
|
return [whole];
|
|
9582
9414
|
}
|
|
9583
|
-
if (!
|
|
9415
|
+
if (!import_ts_morph41.Node.isTemplateExpression(written)) {
|
|
9584
9416
|
return null;
|
|
9585
9417
|
}
|
|
9586
9418
|
return [
|
|
@@ -9590,26 +9422,26 @@ function literalParts(value) {
|
|
|
9590
9422
|
}
|
|
9591
9423
|
function templateHoles(value, resolve2) {
|
|
9592
9424
|
const written = untagged(value);
|
|
9593
|
-
if (!
|
|
9425
|
+
if (!import_ts_morph41.Node.isTemplateExpression(written)) {
|
|
9594
9426
|
return [];
|
|
9595
9427
|
}
|
|
9596
9428
|
return written.getTemplateSpans().map((span) => opsOverCall(span.getExpression(), resolve2));
|
|
9597
9429
|
}
|
|
9598
9430
|
function untagged(value) {
|
|
9599
|
-
return
|
|
9431
|
+
return import_ts_morph41.Node.isTaggedTemplateExpression(value) ? value.getTemplate() : value;
|
|
9600
9432
|
}
|
|
9601
9433
|
function entriesOf(value, unsettled, resolve2) {
|
|
9602
|
-
if (!
|
|
9434
|
+
if (!import_ts_morph41.Node.isObjectLiteralExpression(value)) {
|
|
9603
9435
|
return [];
|
|
9604
9436
|
}
|
|
9605
9437
|
const found = [];
|
|
9606
9438
|
for (const written of value.getProperties()) {
|
|
9607
|
-
if (
|
|
9439
|
+
if (import_ts_morph41.Node.isShorthandPropertyAssignment(written)) {
|
|
9608
9440
|
const name = written.getNameNode();
|
|
9609
9441
|
found.push({ key: name.getText(), value: valueOpsFor(name, resolve2) });
|
|
9610
9442
|
continue;
|
|
9611
9443
|
}
|
|
9612
|
-
if (!
|
|
9444
|
+
if (!import_ts_morph41.Node.isPropertyAssignment(written)) {
|
|
9613
9445
|
continue;
|
|
9614
9446
|
}
|
|
9615
9447
|
const stated = written.getInitializer();
|
|
@@ -9622,35 +9454,35 @@ function entriesOf(value, unsettled, resolve2) {
|
|
|
9622
9454
|
}
|
|
9623
9455
|
function entryKey(written, unsettled, resolve2) {
|
|
9624
9456
|
const name = written.getNameNode();
|
|
9625
|
-
if (
|
|
9457
|
+
if (import_ts_morph41.Node.isComputedPropertyName(name)) {
|
|
9626
9458
|
return readName(name.getExpression(), { resolve: resolve2, unsettled });
|
|
9627
9459
|
}
|
|
9628
9460
|
return unquoted(written.getName());
|
|
9629
9461
|
}
|
|
9630
9462
|
function itemsOf(value, resolve2) {
|
|
9631
|
-
if (!
|
|
9463
|
+
if (!import_ts_morph41.Node.isArrayLiteralExpression(value)) {
|
|
9632
9464
|
return [];
|
|
9633
9465
|
}
|
|
9634
9466
|
return value.getElements().map((element) => valueOpsFor(element, resolve2));
|
|
9635
9467
|
}
|
|
9636
9468
|
function literalText(value) {
|
|
9637
|
-
return
|
|
9469
|
+
return import_ts_morph41.Node.isStringLiteral(value) || import_ts_morph41.Node.isNoSubstitutionTemplateLiteral(value) ? value.getLiteralValue() : null;
|
|
9638
9470
|
}
|
|
9639
9471
|
function literalFlag(value) {
|
|
9640
|
-
if (
|
|
9641
|
-
return
|
|
9472
|
+
if (import_ts_morph41.Node.isTrueLiteral(value) || import_ts_morph41.Node.isFalseLiteral(value)) {
|
|
9473
|
+
return import_ts_morph41.Node.isTrueLiteral(value);
|
|
9642
9474
|
}
|
|
9643
|
-
return
|
|
9475
|
+
return import_ts_morph41.Node.isNumericLiteral(value) ? value.getLiteralValue() !== 0 : null;
|
|
9644
9476
|
}
|
|
9645
9477
|
function unquoted(name) {
|
|
9646
9478
|
return name.replace(/^["']|["']$/g, "");
|
|
9647
9479
|
}
|
|
9648
9480
|
function selectorReadsOf(argument) {
|
|
9649
|
-
if (argument === void 0 || !
|
|
9481
|
+
if (argument === void 0 || !import_ts_morph41.Node.isArrowFunction(argument) && !import_ts_morph41.Node.isFunctionExpression(argument)) {
|
|
9650
9482
|
return null;
|
|
9651
9483
|
}
|
|
9652
9484
|
const parameter = argument.getParameters()[0];
|
|
9653
|
-
if (parameter === void 0 || !
|
|
9485
|
+
if (parameter === void 0 || !import_ts_morph41.Node.isIdentifier(parameter.getNameNode())) {
|
|
9654
9486
|
return null;
|
|
9655
9487
|
}
|
|
9656
9488
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -9667,17 +9499,17 @@ function opsOverCall(value, resolve2) {
|
|
|
9667
9499
|
return callOpsFor(written, resolve2);
|
|
9668
9500
|
}
|
|
9669
9501
|
function isCalled(value) {
|
|
9670
|
-
return
|
|
9502
|
+
return import_ts_morph41.Node.isCallExpression(value) || import_ts_morph41.Node.isNewExpression(value) || import_ts_morph41.Node.isTaggedTemplateExpression(value);
|
|
9671
9503
|
}
|
|
9672
9504
|
function calleeOf3(call) {
|
|
9673
|
-
return
|
|
9505
|
+
return import_ts_morph41.Node.isTaggedTemplateExpression(call) ? call.getTag() : call.getExpression();
|
|
9674
9506
|
}
|
|
9675
9507
|
function argumentsIn(call) {
|
|
9676
|
-
return
|
|
9508
|
+
return import_ts_morph41.Node.isTaggedTemplateExpression(call) ? [call.getTemplate()] : call.getArguments();
|
|
9677
9509
|
}
|
|
9678
9510
|
function settled(value, resolve2) {
|
|
9679
9511
|
const step = unwrapped(value ?? null);
|
|
9680
|
-
if (step === null || !
|
|
9512
|
+
if (step === null || !import_ts_morph41.Node.isIdentifier(step)) {
|
|
9681
9513
|
return step;
|
|
9682
9514
|
}
|
|
9683
9515
|
return unwrapped(resolve2(step));
|
|
@@ -9704,11 +9536,11 @@ function objectAt(argument, resolve2) {
|
|
|
9704
9536
|
if (isCalled(written)) {
|
|
9705
9537
|
return objectAt(argumentsIn(written)[0], resolve2);
|
|
9706
9538
|
}
|
|
9707
|
-
return
|
|
9539
|
+
return import_ts_morph41.Node.isObjectLiteralExpression(written) ? written : null;
|
|
9708
9540
|
}
|
|
9709
9541
|
function initializerOf(object, property) {
|
|
9710
9542
|
for (const written of object.getProperties()) {
|
|
9711
|
-
if (
|
|
9543
|
+
if (import_ts_morph41.Node.isPropertyAssignment(written) && written.getName() === property) {
|
|
9712
9544
|
return written.getInitializer() ?? null;
|
|
9713
9545
|
}
|
|
9714
9546
|
}
|
|
@@ -9738,7 +9570,7 @@ function invocationContextFor(call, resolveWrittenValue, originatesFrom, anchorC
|
|
|
9738
9570
|
};
|
|
9739
9571
|
}
|
|
9740
9572
|
function isImportedFrom(identifier, expectedModule, originatesFrom) {
|
|
9741
|
-
if (!
|
|
9573
|
+
if (!import_ts_morph42.Node.isIdentifier(identifier)) {
|
|
9742
9574
|
return false;
|
|
9743
9575
|
}
|
|
9744
9576
|
const symbol = identifier.getSymbol();
|
|
@@ -9759,7 +9591,7 @@ function isImportedFrom(identifier, expectedModule, originatesFrom) {
|
|
|
9759
9591
|
);
|
|
9760
9592
|
}
|
|
9761
9593
|
function methodDeclaredIn(callee, expectedModule, resolve2, originatesFrom) {
|
|
9762
|
-
if (!
|
|
9594
|
+
if (!import_ts_morph42.Node.isPropertyAccessExpression(callee)) {
|
|
9763
9595
|
return false;
|
|
9764
9596
|
}
|
|
9765
9597
|
const declarations = callee.getNameNode().getSymbol()?.getDeclarations();
|
|
@@ -9779,37 +9611,37 @@ function maker(written) {
|
|
|
9779
9611
|
if (written === null) {
|
|
9780
9612
|
return null;
|
|
9781
9613
|
}
|
|
9782
|
-
if (
|
|
9614
|
+
if (import_ts_morph42.Node.isNewExpression(written) || import_ts_morph42.Node.isCallExpression(written)) {
|
|
9783
9615
|
return written.getExpression();
|
|
9784
9616
|
}
|
|
9785
9617
|
return null;
|
|
9786
9618
|
}
|
|
9787
9619
|
function rootIdentifier2(expression) {
|
|
9788
9620
|
let root = expression;
|
|
9789
|
-
while (
|
|
9621
|
+
while (import_ts_morph42.Node.isPropertyAccessExpression(root)) {
|
|
9790
9622
|
root = root.getExpression();
|
|
9791
9623
|
}
|
|
9792
9624
|
return root;
|
|
9793
9625
|
}
|
|
9794
9626
|
function importSpecifierMatches(decl, expectedModule) {
|
|
9795
|
-
if (
|
|
9627
|
+
if (import_ts_morph42.Node.isImportSpecifier(decl)) {
|
|
9796
9628
|
return decl.getImportDeclaration().getModuleSpecifierValue() === expectedModule;
|
|
9797
9629
|
}
|
|
9798
|
-
const owner =
|
|
9799
|
-
if (!
|
|
9630
|
+
const owner = import_ts_morph42.Node.isNamespaceImport(decl) ? decl.getParent() : decl;
|
|
9631
|
+
if (!import_ts_morph42.Node.isImportClause(owner)) {
|
|
9800
9632
|
return false;
|
|
9801
9633
|
}
|
|
9802
9634
|
const importDecl = owner.getParent();
|
|
9803
|
-
return
|
|
9635
|
+
return import_ts_morph42.Node.isImportDeclaration(importDecl) && importDecl.getModuleSpecifierValue() === expectedModule;
|
|
9804
9636
|
}
|
|
9805
9637
|
function extractInvocationEffects(func, barriers = NO_BARRIERS) {
|
|
9806
9638
|
const calls = [];
|
|
9807
9639
|
func.forEachDescendant((node, traversal) => {
|
|
9808
|
-
if (isDescentStop(node, func, barriers) ||
|
|
9640
|
+
if (isDescentStop(node, func, barriers) || import_ts_morph42.Node.isDecorator(node)) {
|
|
9809
9641
|
traversal.skip();
|
|
9810
9642
|
return;
|
|
9811
9643
|
}
|
|
9812
|
-
if (
|
|
9644
|
+
if (import_ts_morph42.Node.isCallExpression(node)) {
|
|
9813
9645
|
calls.push(node);
|
|
9814
9646
|
}
|
|
9815
9647
|
});
|
|
@@ -9833,10 +9665,10 @@ function invocationAt(call, func) {
|
|
|
9833
9665
|
}
|
|
9834
9666
|
function isAwaited(call) {
|
|
9835
9667
|
let current2 = call.getParent();
|
|
9836
|
-
while (current2 !== void 0 &&
|
|
9668
|
+
while (current2 !== void 0 && import_ts_morph42.Node.isParenthesizedExpression(current2)) {
|
|
9837
9669
|
current2 = current2.getParent();
|
|
9838
9670
|
}
|
|
9839
|
-
return current2 !== void 0 &&
|
|
9671
|
+
return current2 !== void 0 && import_ts_morph42.Node.isAwaitExpression(current2);
|
|
9840
9672
|
}
|
|
9841
9673
|
function runInvocationRecognizers(func, recognizers, barriers = NO_BARRIERS, resolveWrittenValue, originatesFrom, anchorCallsOf) {
|
|
9842
9674
|
if (recognizers.length === 0) {
|
|
@@ -9849,7 +9681,7 @@ function runInvocationRecognizers(func, recognizers, barriers = NO_BARRIERS, res
|
|
|
9849
9681
|
traversal.skip();
|
|
9850
9682
|
return;
|
|
9851
9683
|
}
|
|
9852
|
-
if (!
|
|
9684
|
+
if (!import_ts_morph42.Node.isCallExpression(node)) {
|
|
9853
9685
|
return;
|
|
9854
9686
|
}
|
|
9855
9687
|
const ctx = invocationContextFor(
|
|
@@ -9911,7 +9743,7 @@ function runAccessRecognizersAtModuleScope(sourceFile, recognizers, resolveWritt
|
|
|
9911
9743
|
}
|
|
9912
9744
|
function accessContextFor(node, sourceFile, resolveWrittenValue = () => null, originatesFrom, anchorCallsOf) {
|
|
9913
9745
|
const given = { access: node, sourceFile, resolveWrittenValue };
|
|
9914
|
-
if (
|
|
9746
|
+
if (import_ts_morph42.Node.isPropertyAccessExpression(node)) {
|
|
9915
9747
|
return given;
|
|
9916
9748
|
}
|
|
9917
9749
|
let ops;
|
|
@@ -9940,7 +9772,7 @@ function dispatchAccessRecognizers(root, recognizers, isStop, resolveWrittenValu
|
|
|
9940
9772
|
traversal.skip();
|
|
9941
9773
|
return;
|
|
9942
9774
|
}
|
|
9943
|
-
if (!
|
|
9775
|
+
if (!import_ts_morph42.Node.isPropertyAccessExpression(node) && !import_ts_morph42.Node.isCallExpression(node) && !import_ts_morph42.Node.isTaggedTemplateExpression(node)) {
|
|
9944
9776
|
return;
|
|
9945
9777
|
}
|
|
9946
9778
|
const ctx = accessContextFor(
|
|
@@ -9996,35 +9828,35 @@ function extractArg(node, depth) {
|
|
|
9996
9828
|
return extractArg(bare, depth);
|
|
9997
9829
|
}
|
|
9998
9830
|
}
|
|
9999
|
-
if (
|
|
9831
|
+
if (import_ts_morph42.Node.isStringLiteral(node) || import_ts_morph42.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
10000
9832
|
return { kind: "string", value: node.getLiteralValue() };
|
|
10001
9833
|
}
|
|
10002
|
-
if (
|
|
9834
|
+
if (import_ts_morph42.Node.isNumericLiteral(node)) {
|
|
10003
9835
|
return { kind: "number", value: node.getLiteralValue() };
|
|
10004
9836
|
}
|
|
10005
|
-
if (
|
|
9837
|
+
if (import_ts_morph42.Node.isTrueLiteral(node)) {
|
|
10006
9838
|
return { kind: "boolean", value: true };
|
|
10007
9839
|
}
|
|
10008
|
-
if (
|
|
9840
|
+
if (import_ts_morph42.Node.isFalseLiteral(node)) {
|
|
10009
9841
|
return { kind: "boolean", value: false };
|
|
10010
9842
|
}
|
|
10011
|
-
if (
|
|
9843
|
+
if (import_ts_morph42.Node.isTemplateExpression(node)) {
|
|
10012
9844
|
return { kind: "template", sourceText: node.getText() };
|
|
10013
9845
|
}
|
|
10014
|
-
if (
|
|
9846
|
+
if (import_ts_morph42.Node.isIdentifier(node)) {
|
|
10015
9847
|
const inlined = inlineModuleBinding(node, depth);
|
|
10016
9848
|
if (inlined !== null) {
|
|
10017
9849
|
return inlined;
|
|
10018
9850
|
}
|
|
10019
9851
|
return { kind: "identifier", name: node.getText() };
|
|
10020
9852
|
}
|
|
10021
|
-
if (
|
|
9853
|
+
if (import_ts_morph42.Node.isPropertyAccessExpression(node) || import_ts_morph42.Node.isElementAccessExpression(node)) {
|
|
10022
9854
|
return { kind: "identifier", name: node.getText() };
|
|
10023
9855
|
}
|
|
10024
9856
|
if (depth <= 0) {
|
|
10025
9857
|
return null;
|
|
10026
9858
|
}
|
|
10027
|
-
if (
|
|
9859
|
+
if (import_ts_morph42.Node.isCallExpression(node)) {
|
|
10028
9860
|
const element = mapCallbackReturn(node);
|
|
10029
9861
|
if (element !== null) {
|
|
10030
9862
|
return { kind: "array", items: [extractArg(element, depth - 1)] };
|
|
@@ -10035,19 +9867,19 @@ function extractArg(node, depth) {
|
|
|
10035
9867
|
args: node.getArguments().map((a) => extractArg(a, depth - 1))
|
|
10036
9868
|
};
|
|
10037
9869
|
}
|
|
10038
|
-
if (
|
|
9870
|
+
if (import_ts_morph42.Node.isNewExpression(node)) {
|
|
10039
9871
|
return {
|
|
10040
9872
|
kind: "call",
|
|
10041
9873
|
callee: node.getExpression().getText(),
|
|
10042
9874
|
args: node.getArguments().map((a) => extractArg(a, depth - 1))
|
|
10043
9875
|
};
|
|
10044
9876
|
}
|
|
10045
|
-
if (
|
|
9877
|
+
if (import_ts_morph42.Node.isObjectLiteralExpression(node)) {
|
|
10046
9878
|
const fields = {};
|
|
10047
9879
|
for (const prop of node.getProperties()) {
|
|
10048
|
-
if (
|
|
9880
|
+
if (import_ts_morph42.Node.isShorthandPropertyAssignment(prop)) {
|
|
10049
9881
|
const nameNode2 = prop.getNameNode();
|
|
10050
|
-
if (
|
|
9882
|
+
if (import_ts_morph42.Node.isIdentifier(nameNode2)) {
|
|
10051
9883
|
fields[nameNode2.getText()] = {
|
|
10052
9884
|
kind: "identifier",
|
|
10053
9885
|
name: nameNode2.getText()
|
|
@@ -10055,14 +9887,14 @@ function extractArg(node, depth) {
|
|
|
10055
9887
|
}
|
|
10056
9888
|
continue;
|
|
10057
9889
|
}
|
|
10058
|
-
if (!
|
|
9890
|
+
if (!import_ts_morph42.Node.isPropertyAssignment(prop)) {
|
|
10059
9891
|
continue;
|
|
10060
9892
|
}
|
|
10061
9893
|
const nameNode = prop.getNameNode();
|
|
10062
|
-
if (!
|
|
9894
|
+
if (!import_ts_morph42.Node.isIdentifier(nameNode) && !import_ts_morph42.Node.isStringLiteral(nameNode) && !import_ts_morph42.Node.isNoSubstitutionTemplateLiteral(nameNode)) {
|
|
10063
9895
|
continue;
|
|
10064
9896
|
}
|
|
10065
|
-
const name =
|
|
9897
|
+
const name = import_ts_morph42.Node.isIdentifier(nameNode) ? nameNode.getText() : nameNode.getLiteralValue();
|
|
10066
9898
|
const initializer = prop.getInitializer();
|
|
10067
9899
|
if (initializer === void 0) {
|
|
10068
9900
|
continue;
|
|
@@ -10071,7 +9903,7 @@ function extractArg(node, depth) {
|
|
|
10071
9903
|
}
|
|
10072
9904
|
return { kind: "object", fields };
|
|
10073
9905
|
}
|
|
10074
|
-
if (
|
|
9906
|
+
if (import_ts_morph42.Node.isArrayLiteralExpression(node)) {
|
|
10075
9907
|
const items = node.getElements().map((el) => extractArg(el, depth - 1));
|
|
10076
9908
|
return { kind: "array", items };
|
|
10077
9909
|
}
|
|
@@ -10079,20 +9911,20 @@ function extractArg(node, depth) {
|
|
|
10079
9911
|
}
|
|
10080
9912
|
function mapCallbackReturn(call) {
|
|
10081
9913
|
const callee = call.getExpression();
|
|
10082
|
-
if (!
|
|
9914
|
+
if (!import_ts_morph42.Node.isPropertyAccessExpression(callee) || callee.getName() !== "map") {
|
|
10083
9915
|
return null;
|
|
10084
9916
|
}
|
|
10085
9917
|
const callback = call.getArguments()[0];
|
|
10086
|
-
if (callback === void 0 || !(
|
|
9918
|
+
if (callback === void 0 || !(import_ts_morph42.Node.isArrowFunction(callback) || import_ts_morph42.Node.isFunctionExpression(callback))) {
|
|
10087
9919
|
return null;
|
|
10088
9920
|
}
|
|
10089
9921
|
const body = callback.getBody();
|
|
10090
|
-
if (!
|
|
9922
|
+
if (!import_ts_morph42.Node.isBlock(body)) {
|
|
10091
9923
|
return body;
|
|
10092
9924
|
}
|
|
10093
9925
|
const statements = body.getStatements();
|
|
10094
9926
|
const only = statements.length === 1 ? statements[0] : void 0;
|
|
10095
|
-
return only !== void 0 &&
|
|
9927
|
+
return only !== void 0 && import_ts_morph42.Node.isReturnStatement(only) ? only.getExpression() ?? null : null;
|
|
10096
9928
|
}
|
|
10097
9929
|
function collectPreconditions(node, root) {
|
|
10098
9930
|
return collectAncestorConditionInfosBelow(node, root).map(
|
|
@@ -10103,7 +9935,7 @@ function runsOnEveryPath(node, root) {
|
|
|
10103
9935
|
let current2 = node;
|
|
10104
9936
|
while (current2 !== void 0 && current2 !== root) {
|
|
10105
9937
|
const parent = current2.getParent();
|
|
10106
|
-
if (parent !== void 0 &&
|
|
9938
|
+
if (parent !== void 0 && import_ts_morph42.Node.isTryStatement(parent) && parent.getFinallyBlock() === current2) {
|
|
10107
9939
|
return true;
|
|
10108
9940
|
}
|
|
10109
9941
|
current2 = parent;
|
|
@@ -10126,7 +9958,7 @@ function withPreconditions(effect, preconditions) {
|
|
|
10126
9958
|
};
|
|
10127
9959
|
}
|
|
10128
9960
|
function inlineModuleBinding(ident, depth) {
|
|
10129
|
-
if (!
|
|
9961
|
+
if (!import_ts_morph42.Node.isIdentifier(ident)) {
|
|
10130
9962
|
return null;
|
|
10131
9963
|
}
|
|
10132
9964
|
const symbol = ident.getSymbol();
|
|
@@ -10134,7 +9966,7 @@ function inlineModuleBinding(ident, depth) {
|
|
|
10134
9966
|
return null;
|
|
10135
9967
|
}
|
|
10136
9968
|
for (const decl of symbol.getDeclarations()) {
|
|
10137
|
-
if (!
|
|
9969
|
+
if (!import_ts_morph42.Node.isVariableDeclaration(decl)) {
|
|
10138
9970
|
continue;
|
|
10139
9971
|
}
|
|
10140
9972
|
if (!isModuleScoped(decl)) {
|
|
@@ -10155,10 +9987,10 @@ function inlineModuleBinding(ident, depth) {
|
|
|
10155
9987
|
function isModuleScoped(decl) {
|
|
10156
9988
|
let current2 = decl.getParent();
|
|
10157
9989
|
while (current2 !== void 0) {
|
|
10158
|
-
if (
|
|
9990
|
+
if (import_ts_morph42.Node.isSourceFile(current2)) {
|
|
10159
9991
|
return true;
|
|
10160
9992
|
}
|
|
10161
|
-
if (
|
|
9993
|
+
if (import_ts_morph42.Node.isVariableDeclarationList(current2) || import_ts_morph42.Node.isVariableStatement(current2)) {
|
|
10162
9994
|
current2 = current2.getParent();
|
|
10163
9995
|
continue;
|
|
10164
9996
|
}
|
|
@@ -10172,7 +10004,7 @@ function unwrapCasts(node) {
|
|
|
10172
10004
|
function enclosingStatementLine(node) {
|
|
10173
10005
|
let current2 = node;
|
|
10174
10006
|
while (current2 !== void 0) {
|
|
10175
|
-
if (
|
|
10007
|
+
if (import_ts_morph42.Node.isStatement(current2)) {
|
|
10176
10008
|
return startLineOf(current2);
|
|
10177
10009
|
}
|
|
10178
10010
|
current2 = current2.getParent();
|
|
@@ -10181,19 +10013,19 @@ function enclosingStatementLine(node) {
|
|
|
10181
10013
|
}
|
|
10182
10014
|
|
|
10183
10015
|
// src/terminals/index.ts
|
|
10184
|
-
var
|
|
10016
|
+
var import_ts_morph53 = require("ts-morph");
|
|
10185
10017
|
|
|
10186
10018
|
// src/terminals/continuation.ts
|
|
10187
|
-
var
|
|
10019
|
+
var import_ts_morph44 = require("ts-morph");
|
|
10188
10020
|
|
|
10189
10021
|
// src/terminals/shared.ts
|
|
10190
|
-
var
|
|
10022
|
+
var import_ts_morph43 = require("ts-morph");
|
|
10191
10023
|
function parameterPositionOf(identifier, func) {
|
|
10192
|
-
if (!
|
|
10024
|
+
if (!import_ts_morph43.Node.isIdentifier(identifier)) {
|
|
10193
10025
|
return null;
|
|
10194
10026
|
}
|
|
10195
10027
|
const declaration = identifier.getSymbol()?.getDeclarations()[0];
|
|
10196
|
-
if (declaration === void 0 || !
|
|
10028
|
+
if (declaration === void 0 || !import_ts_morph43.Node.isParameterDeclaration(declaration)) {
|
|
10197
10029
|
return null;
|
|
10198
10030
|
}
|
|
10199
10031
|
const params = func.getParameters();
|
|
@@ -10210,17 +10042,17 @@ function returnPositionOf(value) {
|
|
|
10210
10042
|
if (parent === void 0) {
|
|
10211
10043
|
return null;
|
|
10212
10044
|
}
|
|
10213
|
-
if (
|
|
10045
|
+
if (import_ts_morph43.Node.isReturnStatement(parent)) {
|
|
10214
10046
|
return parent;
|
|
10215
10047
|
}
|
|
10216
|
-
if (
|
|
10048
|
+
if (import_ts_morph43.Node.isArrowFunction(parent)) {
|
|
10217
10049
|
return parent.getBody() === current2 ? current2 : null;
|
|
10218
10050
|
}
|
|
10219
10051
|
if (passesValueThrough(parent)) {
|
|
10220
10052
|
current2 = parent;
|
|
10221
10053
|
continue;
|
|
10222
10054
|
}
|
|
10223
|
-
if (
|
|
10055
|
+
if (import_ts_morph43.Node.isConditionalExpression(parent) && (parent.getWhenTrue() === current2 || parent.getWhenFalse() === current2)) {
|
|
10224
10056
|
current2 = parent;
|
|
10225
10057
|
continue;
|
|
10226
10058
|
}
|
|
@@ -10230,7 +10062,7 @@ function returnPositionOf(value) {
|
|
|
10230
10062
|
|
|
10231
10063
|
// src/terminals/continuation.ts
|
|
10232
10064
|
function tryMatchParameterCall(node, func, pattern, match) {
|
|
10233
|
-
if (!
|
|
10065
|
+
if (!import_ts_morph44.Node.isCallExpression(node)) {
|
|
10234
10066
|
return null;
|
|
10235
10067
|
}
|
|
10236
10068
|
const callee = node.getExpression();
|
|
@@ -10253,15 +10085,15 @@ function tryMatchParameterCall(node, func, pattern, match) {
|
|
|
10253
10085
|
}
|
|
10254
10086
|
|
|
10255
10087
|
// src/terminals/extract.ts
|
|
10256
|
-
var
|
|
10088
|
+
var import_ts_morph47 = require("ts-morph");
|
|
10257
10089
|
var import_values5 = require("@suss/values");
|
|
10258
10090
|
|
|
10259
10091
|
// src/shapes/shapes.ts
|
|
10260
|
-
var
|
|
10092
|
+
var import_ts_morph46 = require("ts-morph");
|
|
10261
10093
|
|
|
10262
10094
|
// src/shapes/typeShapes.ts
|
|
10263
10095
|
var import_node_crypto = require("crypto");
|
|
10264
|
-
var
|
|
10096
|
+
var import_ts_morph45 = require("ts-morph");
|
|
10265
10097
|
|
|
10266
10098
|
// src/shapes/definitions.ts
|
|
10267
10099
|
var current = null;
|
|
@@ -10612,7 +10444,7 @@ function refFromType(type, ctx) {
|
|
|
10612
10444
|
}
|
|
10613
10445
|
return { type: "ref", name: withoutImportQualifiers(type.getText()) };
|
|
10614
10446
|
}
|
|
10615
|
-
var PRINTED_NAME_FLAGS =
|
|
10447
|
+
var PRINTED_NAME_FLAGS = import_ts_morph45.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | import_ts_morph45.TypeFormatFlags.UseTypeOfFunction | import_ts_morph45.TypeFormatFlags.NoTruncation | import_ts_morph45.TypeFormatFlags.WriteTypeArgumentsOfSignature;
|
|
10616
10448
|
function printedTypeName(type, ctx) {
|
|
10617
10449
|
return withoutImportQualifiers(
|
|
10618
10450
|
type.getText(ctx.enclosing, PRINTED_NAME_FLAGS)
|
|
@@ -10722,60 +10554,60 @@ function extractShapeWithArguments(node, substitutions) {
|
|
|
10722
10554
|
}
|
|
10723
10555
|
function extractShapeInner(node) {
|
|
10724
10556
|
const unwrapped2 = peelSyntax(node);
|
|
10725
|
-
if (boundArguments !== null &&
|
|
10557
|
+
if (boundArguments !== null && import_ts_morph46.Node.isIdentifier(unwrapped2)) {
|
|
10726
10558
|
const argument = boundArguments.get(unwrapped2.getText());
|
|
10727
10559
|
if (argument !== void 0 && argument !== unwrapped2) {
|
|
10728
10560
|
return extractShape(argument);
|
|
10729
10561
|
}
|
|
10730
10562
|
}
|
|
10731
|
-
if (
|
|
10563
|
+
if (import_ts_morph46.Node.isObjectLiteralExpression(unwrapped2)) {
|
|
10732
10564
|
return shapeFromObjectLiteral(unwrapped2);
|
|
10733
10565
|
}
|
|
10734
|
-
if (
|
|
10566
|
+
if (import_ts_morph46.Node.isArrayLiteralExpression(unwrapped2)) {
|
|
10735
10567
|
return shapeFromArrayLiteral(unwrapped2);
|
|
10736
10568
|
}
|
|
10737
|
-
if (
|
|
10569
|
+
if (import_ts_morph46.Node.isStringLiteral(unwrapped2) || import_ts_morph46.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
|
|
10738
10570
|
return { type: "literal", value: unwrapped2.getLiteralValue() };
|
|
10739
10571
|
}
|
|
10740
|
-
if (
|
|
10572
|
+
if (import_ts_morph46.Node.isTemplateExpression(unwrapped2)) {
|
|
10741
10573
|
return { type: "text" };
|
|
10742
10574
|
}
|
|
10743
|
-
if (
|
|
10575
|
+
if (import_ts_morph46.Node.isNumericLiteral(unwrapped2)) {
|
|
10744
10576
|
return numericLiteralShape(
|
|
10745
10577
|
unwrapped2.getLiteralValue(),
|
|
10746
10578
|
unwrapped2.getText()
|
|
10747
10579
|
);
|
|
10748
10580
|
}
|
|
10749
|
-
if (
|
|
10581
|
+
if (import_ts_morph46.Node.isPrefixUnaryExpression(unwrapped2)) {
|
|
10750
10582
|
const op = unwrapped2.getOperatorToken();
|
|
10751
|
-
if (op ===
|
|
10583
|
+
if (op === import_ts_morph46.SyntaxKind.MinusToken || op === import_ts_morph46.SyntaxKind.PlusToken) {
|
|
10752
10584
|
const inner = unwrapped2.getOperand();
|
|
10753
|
-
if (
|
|
10585
|
+
if (import_ts_morph46.Node.isNumericLiteral(inner)) {
|
|
10754
10586
|
const v3 = inner.getLiteralValue();
|
|
10755
|
-
const signed = op ===
|
|
10587
|
+
const signed = op === import_ts_morph46.SyntaxKind.MinusToken ? -v3 : v3;
|
|
10756
10588
|
const rawBody = inner.getText();
|
|
10757
|
-
const raw = op ===
|
|
10589
|
+
const raw = op === import_ts_morph46.SyntaxKind.MinusToken ? `-${rawBody}` : rawBody;
|
|
10758
10590
|
return numericLiteralShape(signed, raw);
|
|
10759
10591
|
}
|
|
10760
10592
|
}
|
|
10761
10593
|
}
|
|
10762
|
-
if (
|
|
10594
|
+
if (import_ts_morph46.Node.isBigIntLiteral(unwrapped2)) {
|
|
10763
10595
|
return { type: "ref", name: "bigint" };
|
|
10764
10596
|
}
|
|
10765
10597
|
const kind = unwrapped2.getKind();
|
|
10766
|
-
if (kind ===
|
|
10598
|
+
if (kind === import_ts_morph46.SyntaxKind.TrueKeyword) {
|
|
10767
10599
|
return { type: "literal", value: true };
|
|
10768
10600
|
}
|
|
10769
|
-
if (kind ===
|
|
10601
|
+
if (kind === import_ts_morph46.SyntaxKind.FalseKeyword) {
|
|
10770
10602
|
return { type: "literal", value: false };
|
|
10771
10603
|
}
|
|
10772
|
-
if (kind ===
|
|
10604
|
+
if (kind === import_ts_morph46.SyntaxKind.NullKeyword) {
|
|
10773
10605
|
return { type: "null" };
|
|
10774
10606
|
}
|
|
10775
|
-
if (
|
|
10607
|
+
if (import_ts_morph46.Node.isIdentifier(unwrapped2) && unwrapped2.getText() === "undefined") {
|
|
10776
10608
|
return { type: "undefined" };
|
|
10777
10609
|
}
|
|
10778
|
-
if (
|
|
10610
|
+
if (import_ts_morph46.Node.isConditionalExpression(unwrapped2)) {
|
|
10779
10611
|
const whenTrue = extractShape(unwrapped2.getWhenTrue());
|
|
10780
10612
|
const whenFalse = extractShape(unwrapped2.getWhenFalse());
|
|
10781
10613
|
const variants = [];
|
|
@@ -10806,7 +10638,7 @@ function shapeFromArrayLiteral(arr) {
|
|
|
10806
10638
|
}
|
|
10807
10639
|
const shapes = [];
|
|
10808
10640
|
for (const el of elements) {
|
|
10809
|
-
if (
|
|
10641
|
+
if (import_ts_morph46.Node.isSpreadElement(el)) {
|
|
10810
10642
|
const inner = el.getExpression();
|
|
10811
10643
|
const innerShape = extractShape(inner);
|
|
10812
10644
|
if (innerShape?.type === "array") {
|
|
@@ -10825,7 +10657,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10825
10657
|
const properties = {};
|
|
10826
10658
|
const unresolvedSpreads = [];
|
|
10827
10659
|
for (const prop of obj.getProperties()) {
|
|
10828
|
-
if (
|
|
10660
|
+
if (import_ts_morph46.Node.isPropertyAssignment(prop)) {
|
|
10829
10661
|
const name = propertyName2(prop);
|
|
10830
10662
|
if (name === null) {
|
|
10831
10663
|
continue;
|
|
@@ -10841,7 +10673,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10841
10673
|
};
|
|
10842
10674
|
continue;
|
|
10843
10675
|
}
|
|
10844
|
-
if (
|
|
10676
|
+
if (import_ts_morph46.Node.isShorthandPropertyAssignment(prop)) {
|
|
10845
10677
|
const name = prop.getName();
|
|
10846
10678
|
const valueExpr = prop.getNameNode();
|
|
10847
10679
|
properties[name] = extractShape(valueExpr) ?? {
|
|
@@ -10850,7 +10682,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10850
10682
|
};
|
|
10851
10683
|
continue;
|
|
10852
10684
|
}
|
|
10853
|
-
if (
|
|
10685
|
+
if (import_ts_morph46.Node.isSpreadAssignment(prop)) {
|
|
10854
10686
|
const expr = prop.getExpression();
|
|
10855
10687
|
const spreadShape = extractShape(expr);
|
|
10856
10688
|
if (spreadShape?.type === "record") {
|
|
@@ -10869,7 +10701,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10869
10701
|
}
|
|
10870
10702
|
function propertyName2(prop) {
|
|
10871
10703
|
const nameNode = prop.getNameNode();
|
|
10872
|
-
if (
|
|
10704
|
+
if (import_ts_morph46.Node.isIdentifier(nameNode) || import_ts_morph46.Node.isStringLiteral(nameNode) || import_ts_morph46.Node.isNoSubstitutionTemplateLiteral(nameNode) || import_ts_morph46.Node.isNumericLiteral(nameNode)) {
|
|
10873
10705
|
return nameNode.getText().replace(/^["']|["']$/g, "");
|
|
10874
10706
|
}
|
|
10875
10707
|
return null;
|
|
@@ -10900,15 +10732,15 @@ function unwrapAs(node) {
|
|
|
10900
10732
|
}
|
|
10901
10733
|
function unwrapJsonStringify(node) {
|
|
10902
10734
|
const outer = unwrapAs(node);
|
|
10903
|
-
if (!
|
|
10735
|
+
if (!import_ts_morph47.Node.isCallExpression(outer)) {
|
|
10904
10736
|
return node;
|
|
10905
10737
|
}
|
|
10906
10738
|
const callee = outer.getExpression();
|
|
10907
|
-
if (!
|
|
10739
|
+
if (!import_ts_morph47.Node.isPropertyAccessExpression(callee) || callee.getName() !== "stringify") {
|
|
10908
10740
|
return node;
|
|
10909
10741
|
}
|
|
10910
10742
|
const receiver = callee.getExpression();
|
|
10911
|
-
if (!
|
|
10743
|
+
if (!import_ts_morph47.Node.isIdentifier(receiver) || receiver.getText() !== "JSON") {
|
|
10912
10744
|
return node;
|
|
10913
10745
|
}
|
|
10914
10746
|
const args = outer.getArguments();
|
|
@@ -10918,7 +10750,7 @@ function unwrapJsonStringify(node) {
|
|
|
10918
10750
|
return unwrapAs(args[0]);
|
|
10919
10751
|
}
|
|
10920
10752
|
function substituted(value, ctx) {
|
|
10921
|
-
if (ctx.substitutions === void 0 || !
|
|
10753
|
+
if (ctx.substitutions === void 0 || !import_ts_morph47.Node.isIdentifier(value)) {
|
|
10922
10754
|
return value;
|
|
10923
10755
|
}
|
|
10924
10756
|
return ctx.substitutions.get(value.getText()) ?? value;
|
|
@@ -10962,10 +10794,10 @@ function statusFromProperty(obj, name, ctx) {
|
|
|
10962
10794
|
if (prop === void 0) {
|
|
10963
10795
|
return null;
|
|
10964
10796
|
}
|
|
10965
|
-
if (
|
|
10797
|
+
if (import_ts_morph47.Node.isShorthandPropertyAssignment(prop)) {
|
|
10966
10798
|
return { type: "dynamic", sourceText: prop.getName() };
|
|
10967
10799
|
}
|
|
10968
|
-
if (!
|
|
10800
|
+
if (!import_ts_morph47.Node.isPropertyAssignment(prop)) {
|
|
10969
10801
|
return null;
|
|
10970
10802
|
}
|
|
10971
10803
|
const value = prop.getInitializer();
|
|
@@ -10988,7 +10820,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
10988
10820
|
return null;
|
|
10989
10821
|
}
|
|
10990
10822
|
const first = ctx.throwCallArgs?.[0];
|
|
10991
|
-
if (first !== void 0 &&
|
|
10823
|
+
if (first !== void 0 && import_ts_morph47.Node.isNumericLiteral(first)) {
|
|
10992
10824
|
const value = first.getLiteralValue();
|
|
10993
10825
|
if (value >= 100 && value <= 599) {
|
|
10994
10826
|
return { type: "literal", value };
|
|
@@ -11001,7 +10833,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
11001
10833
|
return null;
|
|
11002
10834
|
}
|
|
11003
10835
|
const arg = ctx.throwCallArgs[sc.position];
|
|
11004
|
-
if (arg === void 0 || !
|
|
10836
|
+
if (arg === void 0 || !import_ts_morph47.Node.isNewExpression(arg)) {
|
|
11005
10837
|
return null;
|
|
11006
10838
|
}
|
|
11007
10839
|
const ctorText = arg.getExpression().getText();
|
|
@@ -11010,7 +10842,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
11010
10842
|
if (sc.from === "argumentProperty") {
|
|
11011
10843
|
const args = ctx.throwCallArgs ?? ctx.calls?.[0]?.getArguments();
|
|
11012
10844
|
const arg = args?.[sc.position];
|
|
11013
|
-
if (arg === void 0 || !
|
|
10845
|
+
if (arg === void 0 || !import_ts_morph47.Node.isObjectLiteralExpression(arg)) {
|
|
11014
10846
|
return null;
|
|
11015
10847
|
}
|
|
11016
10848
|
return statusFromProperty(arg, sc.name, ctx);
|
|
@@ -11020,8 +10852,8 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
11020
10852
|
return null;
|
|
11021
10853
|
}
|
|
11022
10854
|
for (const prop of ctx.returnedObj.getProperties()) {
|
|
11023
|
-
if (!
|
|
11024
|
-
if (
|
|
10855
|
+
if (!import_ts_morph47.Node.isPropertyAssignment(prop)) {
|
|
10856
|
+
if (import_ts_morph47.Node.isShorthandPropertyAssignment(prop)) {
|
|
11025
10857
|
if (prop.getName() === sc.name) {
|
|
11026
10858
|
const resolved = ctx.substitutions?.get(prop.getName());
|
|
11027
10859
|
if (resolved !== void 0) {
|
|
@@ -11079,8 +10911,8 @@ function extractBody(ctx) {
|
|
|
11079
10911
|
return null;
|
|
11080
10912
|
}
|
|
11081
10913
|
for (const prop of ctx.returnedObj.getProperties()) {
|
|
11082
|
-
if (!
|
|
11083
|
-
if (
|
|
10914
|
+
if (!import_ts_morph47.Node.isPropertyAssignment(prop)) {
|
|
10915
|
+
if (import_ts_morph47.Node.isShorthandPropertyAssignment(prop)) {
|
|
11084
10916
|
if (prop.getName() === b.name) {
|
|
11085
10917
|
const resolved = ctx.substitutions?.get(prop.getName());
|
|
11086
10918
|
if (resolved !== void 0) {
|
|
@@ -11135,16 +10967,16 @@ function extractBody(ctx) {
|
|
|
11135
10967
|
}
|
|
11136
10968
|
|
|
11137
10969
|
// src/terminals/jsx.ts
|
|
11138
|
-
var
|
|
10970
|
+
var import_ts_morph48 = require("ts-morph");
|
|
11139
10971
|
function tryMatchJsxReturn(node, pattern) {
|
|
11140
10972
|
let expr;
|
|
11141
10973
|
let source;
|
|
11142
|
-
if (
|
|
10974
|
+
if (import_ts_morph48.Node.isReturnStatement(node)) {
|
|
11143
10975
|
expr = node.getExpression();
|
|
11144
10976
|
source = node;
|
|
11145
|
-
} else if (
|
|
10977
|
+
} else if (import_ts_morph48.Node.isArrowFunction(node)) {
|
|
11146
10978
|
const body = node.getBody();
|
|
11147
|
-
if (body !== void 0 && !
|
|
10979
|
+
if (body !== void 0 && !import_ts_morph48.Node.isBlock(body)) {
|
|
11148
10980
|
expr = body;
|
|
11149
10981
|
source = body;
|
|
11150
10982
|
}
|
|
@@ -11175,14 +11007,14 @@ function tryMatchJsxReturn(node, pattern) {
|
|
|
11175
11007
|
return { node, source, terminal };
|
|
11176
11008
|
}
|
|
11177
11009
|
function componentTargetOf(tagNode) {
|
|
11178
|
-
if (!
|
|
11010
|
+
if (!import_ts_morph48.Node.isIdentifier(tagNode) || !/^[A-Z]/.test(tagNode.getText())) {
|
|
11179
11011
|
return null;
|
|
11180
11012
|
}
|
|
11181
11013
|
const target = functionTargetOf(tagNode);
|
|
11182
11014
|
return target === null ? null : { file: target.file, name: target.name };
|
|
11183
11015
|
}
|
|
11184
11016
|
function jsxToRenderNode(node) {
|
|
11185
|
-
if (
|
|
11017
|
+
if (import_ts_morph48.Node.isJsxElement(node)) {
|
|
11186
11018
|
const opening = node.getOpeningElement();
|
|
11187
11019
|
const tag = opening.getTagNameNode().getText();
|
|
11188
11020
|
const attrs = collectJsxAttributes(opening);
|
|
@@ -11196,7 +11028,7 @@ function jsxToRenderNode(node) {
|
|
|
11196
11028
|
...target !== null ? { target } : {}
|
|
11197
11029
|
};
|
|
11198
11030
|
}
|
|
11199
|
-
if (
|
|
11031
|
+
if (import_ts_morph48.Node.isJsxSelfClosingElement(node)) {
|
|
11200
11032
|
const tag = node.getTagNameNode().getText();
|
|
11201
11033
|
const attrs = collectJsxAttributes(node);
|
|
11202
11034
|
const target = componentTargetOf(node.getTagNameNode());
|
|
@@ -11208,11 +11040,11 @@ function jsxToRenderNode(node) {
|
|
|
11208
11040
|
...target !== null ? { target } : {}
|
|
11209
11041
|
};
|
|
11210
11042
|
}
|
|
11211
|
-
if (
|
|
11043
|
+
if (import_ts_morph48.Node.isJsxFragment(node)) {
|
|
11212
11044
|
const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
|
|
11213
11045
|
return { type: "element", tag: "Fragment", children };
|
|
11214
11046
|
}
|
|
11215
|
-
if (
|
|
11047
|
+
if (import_ts_morph48.Node.isParenthesizedExpression(node)) {
|
|
11216
11048
|
return jsxToRenderNode(node.getExpression());
|
|
11217
11049
|
}
|
|
11218
11050
|
return null;
|
|
@@ -11220,12 +11052,12 @@ function jsxToRenderNode(node) {
|
|
|
11220
11052
|
function collectJsxAttributes(opening) {
|
|
11221
11053
|
const entries = {};
|
|
11222
11054
|
for (const attr of opening.getAttributes()) {
|
|
11223
|
-
if (
|
|
11055
|
+
if (import_ts_morph48.Node.isJsxSpreadAttribute(attr)) {
|
|
11224
11056
|
const exprText = attr.getExpression().getText();
|
|
11225
11057
|
entries[`...${exprText}`] = exprText;
|
|
11226
11058
|
continue;
|
|
11227
11059
|
}
|
|
11228
|
-
if (!
|
|
11060
|
+
if (!import_ts_morph48.Node.isJsxAttribute(attr)) {
|
|
11229
11061
|
continue;
|
|
11230
11062
|
}
|
|
11231
11063
|
const name = attr.getNameNode().getText();
|
|
@@ -11234,7 +11066,7 @@ function collectJsxAttributes(opening) {
|
|
|
11234
11066
|
entries[name] = "";
|
|
11235
11067
|
continue;
|
|
11236
11068
|
}
|
|
11237
|
-
if (
|
|
11069
|
+
if (import_ts_morph48.Node.isJsxExpression(initializer)) {
|
|
11238
11070
|
const inner = initializer.getExpression();
|
|
11239
11071
|
entries[name] = inner !== void 0 ? inner.getText() : "";
|
|
11240
11072
|
continue;
|
|
@@ -11244,30 +11076,30 @@ function collectJsxAttributes(opening) {
|
|
|
11244
11076
|
return Object.keys(entries).length > 0 ? entries : null;
|
|
11245
11077
|
}
|
|
11246
11078
|
function jsxChildToRenderNode(child) {
|
|
11247
|
-
if (
|
|
11079
|
+
if (import_ts_morph48.Node.isJsxText(child)) {
|
|
11248
11080
|
const text = child.getLiteralText().trim();
|
|
11249
11081
|
if (text.length === 0) {
|
|
11250
11082
|
return null;
|
|
11251
11083
|
}
|
|
11252
11084
|
return { type: "text", value: text };
|
|
11253
11085
|
}
|
|
11254
|
-
if (
|
|
11086
|
+
if (import_ts_morph48.Node.isJsxExpression(child)) {
|
|
11255
11087
|
const inner = child.getExpression();
|
|
11256
11088
|
if (inner === void 0) {
|
|
11257
11089
|
return null;
|
|
11258
11090
|
}
|
|
11259
11091
|
return jsxExpressionToRenderNode(inner);
|
|
11260
11092
|
}
|
|
11261
|
-
if (
|
|
11093
|
+
if (import_ts_morph48.Node.isJsxElement(child) || import_ts_morph48.Node.isJsxSelfClosingElement(child) || import_ts_morph48.Node.isJsxFragment(child)) {
|
|
11262
11094
|
return jsxToRenderNode(child);
|
|
11263
11095
|
}
|
|
11264
11096
|
return null;
|
|
11265
11097
|
}
|
|
11266
11098
|
function jsxExpressionToRenderNode(expr) {
|
|
11267
|
-
if (
|
|
11099
|
+
if (import_ts_morph48.Node.isParenthesizedExpression(expr)) {
|
|
11268
11100
|
return jsxExpressionToRenderNode(expr.getExpression());
|
|
11269
11101
|
}
|
|
11270
|
-
if (
|
|
11102
|
+
if (import_ts_morph48.Node.isBinaryExpression(expr)) {
|
|
11271
11103
|
const op = expr.getOperatorToken().getText();
|
|
11272
11104
|
if (op === "&&") {
|
|
11273
11105
|
const right = renderAlternative(peelParens(expr.getRight()));
|
|
@@ -11281,7 +11113,7 @@ function jsxExpressionToRenderNode(expr) {
|
|
|
11281
11113
|
}
|
|
11282
11114
|
}
|
|
11283
11115
|
}
|
|
11284
|
-
if (
|
|
11116
|
+
if (import_ts_morph48.Node.isConditionalExpression(expr)) {
|
|
11285
11117
|
const truthy = renderAlternative(peelParens(expr.getWhenTrue()));
|
|
11286
11118
|
const falsy = renderAlternative(peelParens(expr.getWhenFalse()));
|
|
11287
11119
|
if (truthy.kind === "jsx") {
|
|
@@ -11304,16 +11136,16 @@ function jsxExpressionToRenderNode(expr) {
|
|
|
11304
11136
|
return { type: "expression", sourceText: expr.getText() };
|
|
11305
11137
|
}
|
|
11306
11138
|
function renderAlternative(node) {
|
|
11307
|
-
if (
|
|
11139
|
+
if (import_ts_morph48.Node.isNullLiteral(node)) {
|
|
11308
11140
|
return { kind: "noRender" };
|
|
11309
11141
|
}
|
|
11310
|
-
if (
|
|
11142
|
+
if (import_ts_morph48.Node.isFalseLiteral(node)) {
|
|
11311
11143
|
return { kind: "noRender" };
|
|
11312
11144
|
}
|
|
11313
|
-
if (
|
|
11145
|
+
if (import_ts_morph48.Node.isIdentifier(node) && node.getText() === "undefined") {
|
|
11314
11146
|
return { kind: "noRender" };
|
|
11315
11147
|
}
|
|
11316
|
-
if (
|
|
11148
|
+
if (import_ts_morph48.Node.isJsxElement(node) || import_ts_morph48.Node.isJsxSelfClosingElement(node) || import_ts_morph48.Node.isJsxFragment(node)) {
|
|
11317
11149
|
const tree = jsxToRenderNode(node);
|
|
11318
11150
|
if (tree !== null) {
|
|
11319
11151
|
return { kind: "jsx", node: tree };
|
|
@@ -11323,13 +11155,13 @@ function renderAlternative(node) {
|
|
|
11323
11155
|
}
|
|
11324
11156
|
|
|
11325
11157
|
// src/terminals/returns.ts
|
|
11326
|
-
var
|
|
11158
|
+
var import_ts_morph51 = require("ts-morph");
|
|
11327
11159
|
|
|
11328
11160
|
// src/terminals/helperResolution.ts
|
|
11329
|
-
var
|
|
11161
|
+
var import_ts_morph49 = require("ts-morph");
|
|
11330
11162
|
function resolveHelperReturn(call, resolveCallee2) {
|
|
11331
11163
|
const callee = call.getExpression();
|
|
11332
|
-
if (!
|
|
11164
|
+
if (!import_ts_morph49.Node.isIdentifier(callee)) {
|
|
11333
11165
|
return { kind: "notLocal" };
|
|
11334
11166
|
}
|
|
11335
11167
|
const helper = memoizedLocalHelper(callee, resolveCallee2);
|
|
@@ -11359,16 +11191,16 @@ function guardsAbove(returnValue) {
|
|
|
11359
11191
|
let child = returnValue;
|
|
11360
11192
|
let current2 = returnValue.getParent();
|
|
11361
11193
|
while (current2 !== void 0) {
|
|
11362
|
-
if (
|
|
11194
|
+
if (import_ts_morph49.Node.isIfStatement(current2)) {
|
|
11363
11195
|
guards.push({
|
|
11364
11196
|
condition: current2.getExpression(),
|
|
11365
11197
|
whenTrue: current2.getThenStatement() === child
|
|
11366
11198
|
});
|
|
11367
11199
|
}
|
|
11368
|
-
if (
|
|
11200
|
+
if (import_ts_morph49.Node.isBlock(current2)) {
|
|
11369
11201
|
guards.push(...earlyReturnGuardsBefore(current2, child));
|
|
11370
11202
|
}
|
|
11371
|
-
if (
|
|
11203
|
+
if (import_ts_morph49.Node.isFunctionDeclaration(current2) || import_ts_morph49.Node.isArrowFunction(current2) || import_ts_morph49.Node.isFunctionExpression(current2)) {
|
|
11372
11204
|
break;
|
|
11373
11205
|
}
|
|
11374
11206
|
child = current2;
|
|
@@ -11377,7 +11209,7 @@ function guardsAbove(returnValue) {
|
|
|
11377
11209
|
return guards;
|
|
11378
11210
|
}
|
|
11379
11211
|
function earlyReturnGuardsBefore(block, child) {
|
|
11380
|
-
if (!
|
|
11212
|
+
if (!import_ts_morph49.Node.isBlock(block)) {
|
|
11381
11213
|
return [];
|
|
11382
11214
|
}
|
|
11383
11215
|
const guards = [];
|
|
@@ -11385,7 +11217,7 @@ function earlyReturnGuardsBefore(block, child) {
|
|
|
11385
11217
|
if (statement === child) {
|
|
11386
11218
|
break;
|
|
11387
11219
|
}
|
|
11388
|
-
if (!
|
|
11220
|
+
if (!import_ts_morph49.Node.isIfStatement(statement) || statement.getElseStatement()) {
|
|
11389
11221
|
continue;
|
|
11390
11222
|
}
|
|
11391
11223
|
if (alwaysReturns(statement.getThenStatement())) {
|
|
@@ -11395,10 +11227,10 @@ function earlyReturnGuardsBefore(block, child) {
|
|
|
11395
11227
|
return guards;
|
|
11396
11228
|
}
|
|
11397
11229
|
function alwaysReturns(statement) {
|
|
11398
|
-
if (
|
|
11230
|
+
if (import_ts_morph49.Node.isReturnStatement(statement) || import_ts_morph49.Node.isThrowStatement(statement)) {
|
|
11399
11231
|
return true;
|
|
11400
11232
|
}
|
|
11401
|
-
if (!
|
|
11233
|
+
if (!import_ts_morph49.Node.isBlock(statement)) {
|
|
11402
11234
|
return false;
|
|
11403
11235
|
}
|
|
11404
11236
|
const statements = statement.getStatements();
|
|
@@ -11416,7 +11248,7 @@ var COMPARISONS = {
|
|
|
11416
11248
|
"!=": (a, b) => a !== b
|
|
11417
11249
|
};
|
|
11418
11250
|
function evaluateComparison(condition, substitutions) {
|
|
11419
|
-
if (!
|
|
11251
|
+
if (!import_ts_morph49.Node.isBinaryExpression(condition)) {
|
|
11420
11252
|
return null;
|
|
11421
11253
|
}
|
|
11422
11254
|
const left = numberFor(condition.getLeft(), substitutions);
|
|
@@ -11428,8 +11260,8 @@ function evaluateComparison(condition, substitutions) {
|
|
|
11428
11260
|
return compare === void 0 ? null : compare(left, right);
|
|
11429
11261
|
}
|
|
11430
11262
|
function numberFor(node, substitutions) {
|
|
11431
|
-
const resolved =
|
|
11432
|
-
return
|
|
11263
|
+
const resolved = import_ts_morph49.Node.isIdentifier(node) && substitutions.has(node.getText()) ? substitutions.get(node.getText()) : node;
|
|
11264
|
+
return import_ts_morph49.Node.isNumericLiteral(resolved) ? Number(resolved.getText()) : null;
|
|
11433
11265
|
}
|
|
11434
11266
|
var helperBySymbol = /* @__PURE__ */ new WeakMap();
|
|
11435
11267
|
function memoizedLocalHelper(callee, resolveCallee2) {
|
|
@@ -11516,12 +11348,12 @@ function declarationsFor(callee, resolveCallee2) {
|
|
|
11516
11348
|
return (aliased ?? symbol).getDeclarations();
|
|
11517
11349
|
}
|
|
11518
11350
|
function asFunctionLike(declaration) {
|
|
11519
|
-
if (
|
|
11351
|
+
if (import_ts_morph49.Node.isFunctionDeclaration(declaration) || import_ts_morph49.Node.isArrowFunction(declaration) || import_ts_morph49.Node.isFunctionExpression(declaration)) {
|
|
11520
11352
|
return declaration;
|
|
11521
11353
|
}
|
|
11522
|
-
if (
|
|
11354
|
+
if (import_ts_morph49.Node.isVariableDeclaration(declaration)) {
|
|
11523
11355
|
const initializer = declaration.getInitializer();
|
|
11524
|
-
if (initializer !== void 0 && (
|
|
11356
|
+
if (initializer !== void 0 && (import_ts_morph49.Node.isArrowFunction(initializer) || import_ts_morph49.Node.isFunctionExpression(initializer))) {
|
|
11525
11357
|
return initializer;
|
|
11526
11358
|
}
|
|
11527
11359
|
}
|
|
@@ -11532,13 +11364,13 @@ function returnedObjects(fn) {
|
|
|
11532
11364
|
if (body === void 0) {
|
|
11533
11365
|
return [];
|
|
11534
11366
|
}
|
|
11535
|
-
if (!
|
|
11367
|
+
if (!import_ts_morph49.Node.isBlock(body)) {
|
|
11536
11368
|
const expression = peelParens(body);
|
|
11537
|
-
return
|
|
11369
|
+
return import_ts_morph49.Node.isObjectLiteralExpression(expression) ? [expression] : [];
|
|
11538
11370
|
}
|
|
11539
11371
|
const found = [];
|
|
11540
11372
|
for (const statement of body.getDescendantsOfKind(
|
|
11541
|
-
|
|
11373
|
+
import_ts_morph49.SyntaxKind.ReturnStatement
|
|
11542
11374
|
)) {
|
|
11543
11375
|
if (enclosingFunctionOf(statement) !== body) {
|
|
11544
11376
|
continue;
|
|
@@ -11548,7 +11380,7 @@ function returnedObjects(fn) {
|
|
|
11548
11380
|
continue;
|
|
11549
11381
|
}
|
|
11550
11382
|
const unwrapped2 = peelParens(expression);
|
|
11551
|
-
if (
|
|
11383
|
+
if (import_ts_morph49.Node.isObjectLiteralExpression(unwrapped2)) {
|
|
11552
11384
|
found.push(unwrapped2);
|
|
11553
11385
|
}
|
|
11554
11386
|
}
|
|
@@ -11557,7 +11389,7 @@ function returnedObjects(fn) {
|
|
|
11557
11389
|
function enclosingFunctionOf(node) {
|
|
11558
11390
|
let current2 = node.getParent();
|
|
11559
11391
|
while (current2 !== void 0) {
|
|
11560
|
-
if (
|
|
11392
|
+
if (import_ts_morph49.Node.isFunctionDeclaration(current2) || import_ts_morph49.Node.isArrowFunction(current2) || import_ts_morph49.Node.isFunctionExpression(current2) || import_ts_morph49.Node.isMethodDeclaration(current2)) {
|
|
11561
11393
|
return current2.getBody();
|
|
11562
11394
|
}
|
|
11563
11395
|
current2 = current2.getParent();
|
|
@@ -11576,7 +11408,7 @@ function bindArguments(callArgs, params) {
|
|
|
11576
11408
|
}
|
|
11577
11409
|
|
|
11578
11410
|
// src/terminals/statusBranches.ts
|
|
11579
|
-
var
|
|
11411
|
+
var import_ts_morph50 = require("ts-morph");
|
|
11580
11412
|
var import_values6 = require("@suss/values");
|
|
11581
11413
|
function statusChoicesOf(argument, resolution) {
|
|
11582
11414
|
const chosen = asConditional(argument);
|
|
@@ -11600,10 +11432,10 @@ function asConditional(node) {
|
|
|
11600
11432
|
if (direct !== null) {
|
|
11601
11433
|
return direct;
|
|
11602
11434
|
}
|
|
11603
|
-
if (!
|
|
11435
|
+
if (!import_ts_morph50.Node.isIdentifier(node)) {
|
|
11604
11436
|
return null;
|
|
11605
11437
|
}
|
|
11606
|
-
const declaration = node.getSymbol()?.getDeclarations().find(
|
|
11438
|
+
const declaration = node.getSymbol()?.getDeclarations().find(import_ts_morph50.Node.isVariableDeclaration);
|
|
11607
11439
|
if (declaration === void 0) {
|
|
11608
11440
|
return null;
|
|
11609
11441
|
}
|
|
@@ -11614,7 +11446,7 @@ function asConditional(node) {
|
|
|
11614
11446
|
const only = written.values[0];
|
|
11615
11447
|
return only === void 0 ? null : toConditional(only);
|
|
11616
11448
|
}
|
|
11617
|
-
var toConditional = (node) =>
|
|
11449
|
+
var toConditional = (node) => import_ts_morph50.Node.isConditionalExpression(node) ? node : null;
|
|
11618
11450
|
function numberOf(node, resolution) {
|
|
11619
11451
|
const value = (0, import_values6.constantOf)(evaluatedValue(node, resolution));
|
|
11620
11452
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
@@ -11631,7 +11463,7 @@ function unwrapMethodChain(call, match, func) {
|
|
|
11631
11463
|
for (let i = methodChain.length - 1; i >= 0; i--) {
|
|
11632
11464
|
const expectedMethod = methodChain[i];
|
|
11633
11465
|
const callee = current2.getExpression();
|
|
11634
|
-
if (!
|
|
11466
|
+
if (!import_ts_morph51.Node.isPropertyAccessExpression(callee)) {
|
|
11635
11467
|
return null;
|
|
11636
11468
|
}
|
|
11637
11469
|
if (callee.getName() !== expectedMethod) {
|
|
@@ -11647,7 +11479,7 @@ function unwrapMethodChain(call, match, func) {
|
|
|
11647
11479
|
return null;
|
|
11648
11480
|
}
|
|
11649
11481
|
} else {
|
|
11650
|
-
if (!
|
|
11482
|
+
if (!import_ts_morph51.Node.isCallExpression(subject)) {
|
|
11651
11483
|
return null;
|
|
11652
11484
|
}
|
|
11653
11485
|
current2 = subject;
|
|
@@ -11657,9 +11489,9 @@ function unwrapMethodChain(call, match, func) {
|
|
|
11657
11489
|
}
|
|
11658
11490
|
function withoutPassThroughCalls(subject, passThrough) {
|
|
11659
11491
|
let current2 = subject;
|
|
11660
|
-
while (
|
|
11492
|
+
while (import_ts_morph51.Node.isCallExpression(current2)) {
|
|
11661
11493
|
const callee = current2.getExpression();
|
|
11662
|
-
if (!
|
|
11494
|
+
if (!import_ts_morph51.Node.isPropertyAccessExpression(callee) || !passThrough.includes(callee.getName())) {
|
|
11663
11495
|
break;
|
|
11664
11496
|
}
|
|
11665
11497
|
current2 = callee.getExpression();
|
|
@@ -11671,12 +11503,12 @@ function returnedValueOf(returnStatement) {
|
|
|
11671
11503
|
return written === void 0 ? null : unwrapValue(written);
|
|
11672
11504
|
}
|
|
11673
11505
|
function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
11674
|
-
if (
|
|
11506
|
+
if (import_ts_morph51.Node.isObjectLiteralExpression(node)) {
|
|
11675
11507
|
const source = returnPositionOf(node);
|
|
11676
11508
|
if (source === null) {
|
|
11677
11509
|
return [];
|
|
11678
11510
|
}
|
|
11679
|
-
if (
|
|
11511
|
+
if (import_ts_morph51.Node.isReturnStatement(source) && returnedValueOf(source) === node) {
|
|
11680
11512
|
return [];
|
|
11681
11513
|
}
|
|
11682
11514
|
const terminal = terminalFromReturnedObject(
|
|
@@ -11689,14 +11521,14 @@ function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
|
11689
11521
|
);
|
|
11690
11522
|
return terminal === null ? [] : [{ ...terminal, source }];
|
|
11691
11523
|
}
|
|
11692
|
-
if (!
|
|
11524
|
+
if (!import_ts_morph51.Node.isReturnStatement(node)) {
|
|
11693
11525
|
return [];
|
|
11694
11526
|
}
|
|
11695
11527
|
const returned = returnedValueOf(node);
|
|
11696
11528
|
if (returned === null) {
|
|
11697
11529
|
return [];
|
|
11698
11530
|
}
|
|
11699
|
-
if (
|
|
11531
|
+
if (import_ts_morph51.Node.isObjectLiteralExpression(returned)) {
|
|
11700
11532
|
const terminal = terminalFromReturnedObject(
|
|
11701
11533
|
returned,
|
|
11702
11534
|
node,
|
|
@@ -11707,7 +11539,7 @@ function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
|
11707
11539
|
);
|
|
11708
11540
|
return terminal === null ? [] : [terminal];
|
|
11709
11541
|
}
|
|
11710
|
-
if (!
|
|
11542
|
+
if (!import_ts_morph51.Node.isCallExpression(returned)) {
|
|
11711
11543
|
return [];
|
|
11712
11544
|
}
|
|
11713
11545
|
const resolved = resolveHelperReturn(returned, resolveCallee2);
|
|
@@ -11744,7 +11576,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11744
11576
|
if (required !== void 0 && required.length > 0) {
|
|
11745
11577
|
const presentNames = /* @__PURE__ */ new Set();
|
|
11746
11578
|
for (const prop of obj.getProperties()) {
|
|
11747
|
-
if (
|
|
11579
|
+
if (import_ts_morph51.Node.isPropertyAssignment(prop) || import_ts_morph51.Node.isShorthandPropertyAssignment(prop)) {
|
|
11748
11580
|
presentNames.add(prop.getName());
|
|
11749
11581
|
}
|
|
11750
11582
|
}
|
|
@@ -11770,7 +11602,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11770
11602
|
// When a helper built the value, the anchor is the caller's own
|
|
11771
11603
|
// return, so it doubles as the provenance. A value reached any other
|
|
11772
11604
|
// way leaves this unset and its caller fills it in.
|
|
11773
|
-
...
|
|
11605
|
+
...import_ts_morph51.Node.isReturnStatement(anchor) ? { source: anchor } : {},
|
|
11774
11606
|
terminal: {
|
|
11775
11607
|
kind: pattern.kind,
|
|
11776
11608
|
statusCode,
|
|
@@ -11789,7 +11621,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11789
11621
|
};
|
|
11790
11622
|
}
|
|
11791
11623
|
function tryMatchParameterMethodCall(node, func, pattern, match, resolution) {
|
|
11792
|
-
if (!
|
|
11624
|
+
if (!import_ts_morph51.Node.isCallExpression(node)) {
|
|
11793
11625
|
return [];
|
|
11794
11626
|
}
|
|
11795
11627
|
const result = unwrapMethodChain(node, match, func);
|
|
@@ -11849,7 +11681,7 @@ function statusArgument(calls, extraction) {
|
|
|
11849
11681
|
}
|
|
11850
11682
|
function returnCoveredByParameterMethodCall(expr, func, patterns) {
|
|
11851
11683
|
const current2 = unwrapValue(expr);
|
|
11852
|
-
if (!
|
|
11684
|
+
if (!import_ts_morph51.Node.isCallExpression(current2)) {
|
|
11853
11685
|
return false;
|
|
11854
11686
|
}
|
|
11855
11687
|
for (const pattern of patterns) {
|
|
@@ -11865,7 +11697,7 @@ function returnCoveredByParameterMethodCall(expr, func, patterns) {
|
|
|
11865
11697
|
}
|
|
11866
11698
|
function tryMatchReturnStatement(node, pattern, func, allPatterns) {
|
|
11867
11699
|
const match = pattern.match.type === "returnStatement" ? pattern.match : null;
|
|
11868
|
-
if (
|
|
11700
|
+
if (import_ts_morph51.Node.isReturnStatement(node)) {
|
|
11869
11701
|
const expr = node.getExpression();
|
|
11870
11702
|
if (match?.excludeCallReturns === true) {
|
|
11871
11703
|
if (expr === void 0) {
|
|
@@ -11884,9 +11716,9 @@ function tryMatchReturnStatement(node, pattern, func, allPatterns) {
|
|
|
11884
11716
|
}
|
|
11885
11717
|
return buildReturnTerminal(node, pattern, body);
|
|
11886
11718
|
}
|
|
11887
|
-
if (
|
|
11719
|
+
if (import_ts_morph51.Node.isArrowFunction(node)) {
|
|
11888
11720
|
const body = node.getBody();
|
|
11889
|
-
if (body === void 0 ||
|
|
11721
|
+
if (body === void 0 || import_ts_morph51.Node.isBlock(body)) {
|
|
11890
11722
|
return null;
|
|
11891
11723
|
}
|
|
11892
11724
|
const shape = extractShape(body);
|
|
@@ -11944,20 +11776,20 @@ function unresolvedTerminal(kind, node) {
|
|
|
11944
11776
|
};
|
|
11945
11777
|
}
|
|
11946
11778
|
function calleeSubject(callee) {
|
|
11947
|
-
if (
|
|
11779
|
+
if (import_ts_morph51.Node.isIdentifier(callee)) {
|
|
11948
11780
|
return callee;
|
|
11949
11781
|
}
|
|
11950
|
-
if (
|
|
11782
|
+
if (import_ts_morph51.Node.isPropertyAccessExpression(callee)) {
|
|
11951
11783
|
const subject = callee.getExpression();
|
|
11952
|
-
return
|
|
11784
|
+
return import_ts_morph51.Node.isIdentifier(subject) ? subject : null;
|
|
11953
11785
|
}
|
|
11954
11786
|
return null;
|
|
11955
11787
|
}
|
|
11956
11788
|
function tryMatchFunctionCall(node, pattern, match, resolution, originatesFrom) {
|
|
11957
|
-
if (!
|
|
11789
|
+
if (!import_ts_morph51.Node.isCallExpression(node) && !import_ts_morph51.Node.isNewExpression(node)) {
|
|
11958
11790
|
return null;
|
|
11959
11791
|
}
|
|
11960
|
-
if (
|
|
11792
|
+
if (import_ts_morph51.Node.isNewExpression(node) && returnPositionOf(node) === null) {
|
|
11961
11793
|
return null;
|
|
11962
11794
|
}
|
|
11963
11795
|
const callee = node.getExpression();
|
|
@@ -11996,9 +11828,9 @@ function tryMatchFunctionCall(node, pattern, match, resolution, originatesFrom)
|
|
|
11996
11828
|
}
|
|
11997
11829
|
|
|
11998
11830
|
// src/terminals/throws.ts
|
|
11999
|
-
var
|
|
11831
|
+
var import_ts_morph52 = require("ts-morph");
|
|
12000
11832
|
function tryMatchThrowExpression(node, pattern, match, resolution) {
|
|
12001
|
-
if (!
|
|
11833
|
+
if (!import_ts_morph52.Node.isThrowStatement(node)) {
|
|
12002
11834
|
return null;
|
|
12003
11835
|
}
|
|
12004
11836
|
const thrownExpr = node.getExpression();
|
|
@@ -12040,17 +11872,17 @@ function extractThrowMessage(callArgs) {
|
|
|
12040
11872
|
return null;
|
|
12041
11873
|
}
|
|
12042
11874
|
for (const arg of callArgs) {
|
|
12043
|
-
if (
|
|
11875
|
+
if (import_ts_morph52.Node.isStringLiteral(arg) || import_ts_morph52.Node.isNoSubstitutionTemplateLiteral(arg)) {
|
|
12044
11876
|
return arg.getLiteralValue();
|
|
12045
11877
|
}
|
|
12046
|
-
if (
|
|
11878
|
+
if (import_ts_morph52.Node.isTemplateExpression(arg)) {
|
|
12047
11879
|
return arg.getText();
|
|
12048
11880
|
}
|
|
12049
11881
|
}
|
|
12050
11882
|
return null;
|
|
12051
11883
|
}
|
|
12052
11884
|
function classifyThrownExpression(thrown, constructorPattern) {
|
|
12053
|
-
if (
|
|
11885
|
+
if (import_ts_morph52.Node.isCallExpression(thrown) || import_ts_morph52.Node.isNewExpression(thrown)) {
|
|
12054
11886
|
const calleeText = thrown.getExpression().getText();
|
|
12055
11887
|
if (constructorPattern !== void 0 && !calleeText.startsWith(constructorPattern)) {
|
|
12056
11888
|
return null;
|
|
@@ -12137,9 +11969,9 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolution, origi
|
|
|
12137
11969
|
}
|
|
12138
11970
|
}
|
|
12139
11971
|
});
|
|
12140
|
-
if (results.length === 0 &&
|
|
11972
|
+
if (results.length === 0 && import_ts_morph53.Node.isArrowFunction(func)) {
|
|
12141
11973
|
const body = func.getBody();
|
|
12142
|
-
if (body !== void 0 && !
|
|
11974
|
+
if (body !== void 0 && !import_ts_morph53.Node.isBlock(body)) {
|
|
12143
11975
|
for (const pattern of patterns) {
|
|
12144
11976
|
let found = null;
|
|
12145
11977
|
if (pattern.match.type === "parameterMethodCall") {
|
|
@@ -12174,7 +12006,7 @@ function functionMayFallThrough(func) {
|
|
|
12174
12006
|
if (body === void 0) {
|
|
12175
12007
|
return false;
|
|
12176
12008
|
}
|
|
12177
|
-
if (!
|
|
12009
|
+
if (!import_ts_morph53.Node.isBlock(body)) {
|
|
12178
12010
|
return false;
|
|
12179
12011
|
}
|
|
12180
12012
|
const statements = body.getStatements();
|
|
@@ -12182,7 +12014,7 @@ function functionMayFallThrough(func) {
|
|
|
12182
12014
|
return true;
|
|
12183
12015
|
}
|
|
12184
12016
|
const last = statements[statements.length - 1];
|
|
12185
|
-
if (
|
|
12017
|
+
if (import_ts_morph53.Node.isReturnStatement(last) || import_ts_morph53.Node.isThrowStatement(last)) {
|
|
12186
12018
|
return false;
|
|
12187
12019
|
}
|
|
12188
12020
|
return true;
|
|
@@ -12230,7 +12062,7 @@ function writesTerminal(call, terminalNodes) {
|
|
|
12230
12062
|
}
|
|
12231
12063
|
}
|
|
12232
12064
|
function isReceiverOf(node, parent) {
|
|
12233
|
-
return (
|
|
12065
|
+
return (import_ts_morph54.Node.isPropertyAccessExpression(parent) || import_ts_morph54.Node.isElementAccessExpression(parent) || import_ts_morph54.Node.isCallExpression(parent)) && parent.getExpression() === node;
|
|
12234
12066
|
}
|
|
12235
12067
|
var isDefaultConditionList = (conditions) => conditions.length === 0 || conditions.every(
|
|
12236
12068
|
(c) => c.source === "earlyReturn" || c.source === "earlyThrow"
|
|
@@ -12240,7 +12072,7 @@ function bodyContentOf(func) {
|
|
|
12240
12072
|
if (body === void 0) {
|
|
12241
12073
|
return "absent";
|
|
12242
12074
|
}
|
|
12243
|
-
if (!
|
|
12075
|
+
if (!import_ts_morph54.Node.isBlock(body)) {
|
|
12244
12076
|
return "statements";
|
|
12245
12077
|
}
|
|
12246
12078
|
return body.getStatements().length === 0 ? "empty" : "statements";
|
|
@@ -12256,7 +12088,7 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
|
|
|
12256
12088
|
claimed.add(source);
|
|
12257
12089
|
}
|
|
12258
12090
|
}
|
|
12259
|
-
if (
|
|
12091
|
+
if (import_ts_morph54.Node.isArrowFunction(func) && import_ts_morph54.Node.isExpression(body)) {
|
|
12260
12092
|
return claimed.has(body) ? 0 : 1;
|
|
12261
12093
|
}
|
|
12262
12094
|
let unmatched = 0;
|
|
@@ -12269,7 +12101,7 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
|
|
|
12269
12101
|
traversal.skip();
|
|
12270
12102
|
return;
|
|
12271
12103
|
}
|
|
12272
|
-
if (!
|
|
12104
|
+
if (!import_ts_morph54.Node.isReturnStatement(node)) {
|
|
12273
12105
|
return;
|
|
12274
12106
|
}
|
|
12275
12107
|
if (node.getExpression() === void 0) {
|
|
@@ -12422,7 +12254,7 @@ function accountFor(site, terminalNodes, branches) {
|
|
|
12422
12254
|
}
|
|
12423
12255
|
|
|
12424
12256
|
// src/bootstrap/sourceFileLookup.ts
|
|
12425
|
-
var
|
|
12257
|
+
var import_ts_morph55 = require("ts-morph");
|
|
12426
12258
|
function createSourceFileLookup(project) {
|
|
12427
12259
|
const all = project.getSourceFiles();
|
|
12428
12260
|
const byAbs = /* @__PURE__ */ new Map();
|
|
@@ -12484,7 +12316,7 @@ function spanKey(span) {
|
|
|
12484
12316
|
function indexFunctions(sf) {
|
|
12485
12317
|
const index = /* @__PURE__ */ new Map();
|
|
12486
12318
|
sf.forEachDescendant((node) => {
|
|
12487
|
-
if (!
|
|
12319
|
+
if (!import_ts_morph55.Node.isFunctionDeclaration(node) && !import_ts_morph55.Node.isFunctionExpression(node) && !import_ts_morph55.Node.isArrowFunction(node) && !import_ts_morph55.Node.isMethodDeclaration(node)) {
|
|
12488
12320
|
return;
|
|
12489
12321
|
}
|
|
12490
12322
|
const bySpan = spanKey({ start: node.getStart(), end: node.getEnd() });
|
|
@@ -12498,13 +12330,13 @@ function indexFunctions(sf) {
|
|
|
12498
12330
|
}
|
|
12499
12331
|
|
|
12500
12332
|
// src/contract.ts
|
|
12501
|
-
var
|
|
12333
|
+
var import_ts_morph56 = require("ts-morph");
|
|
12502
12334
|
var import_behavioral_ir4 = require("@suss/behavioral-ir");
|
|
12503
12335
|
function extractDeclaredBody(node) {
|
|
12504
12336
|
if (node === void 0) {
|
|
12505
12337
|
return null;
|
|
12506
12338
|
}
|
|
12507
|
-
if (!
|
|
12339
|
+
if (!import_ts_morph56.Node.isCallExpression(node)) {
|
|
12508
12340
|
return null;
|
|
12509
12341
|
}
|
|
12510
12342
|
const typeArgs = node.getTypeArguments();
|
|
@@ -12518,10 +12350,10 @@ function resolveHandlerPropNode(func) {
|
|
|
12518
12350
|
if (parent === void 0) {
|
|
12519
12351
|
return null;
|
|
12520
12352
|
}
|
|
12521
|
-
if (
|
|
12353
|
+
if (import_ts_morph56.Node.isPropertyAssignment(parent)) {
|
|
12522
12354
|
return parent;
|
|
12523
12355
|
}
|
|
12524
|
-
if (
|
|
12356
|
+
if (import_ts_morph56.Node.isMethodDeclaration(func)) {
|
|
12525
12357
|
return func;
|
|
12526
12358
|
}
|
|
12527
12359
|
return null;
|
|
@@ -12533,11 +12365,11 @@ function findRouterCall(unit) {
|
|
|
12533
12365
|
return null;
|
|
12534
12366
|
}
|
|
12535
12367
|
const handlersObj = propNode.getParent();
|
|
12536
|
-
if (handlersObj === void 0 || !
|
|
12368
|
+
if (handlersObj === void 0 || !import_ts_morph56.Node.isObjectLiteralExpression(handlersObj)) {
|
|
12537
12369
|
return null;
|
|
12538
12370
|
}
|
|
12539
12371
|
const routerCall = handlersObj.getParent();
|
|
12540
|
-
if (routerCall === void 0 || !
|
|
12372
|
+
if (routerCall === void 0 || !import_ts_morph56.Node.isCallExpression(routerCall)) {
|
|
12541
12373
|
return null;
|
|
12542
12374
|
}
|
|
12543
12375
|
const args = routerCall.getArguments();
|
|
@@ -12550,17 +12382,17 @@ function findRouterCall(unit) {
|
|
|
12550
12382
|
};
|
|
12551
12383
|
}
|
|
12552
12384
|
function resolveContractObject(contractArg, resolution) {
|
|
12553
|
-
if (
|
|
12385
|
+
if (import_ts_morph56.Node.isObjectLiteralExpression(contractArg)) {
|
|
12554
12386
|
return contractArg;
|
|
12555
12387
|
}
|
|
12556
|
-
if (
|
|
12388
|
+
if (import_ts_morph56.Node.isPropertyAccessExpression(contractArg)) {
|
|
12557
12389
|
const base = resolveContractObject(contractArg.getExpression(), resolution);
|
|
12558
|
-
if (base === null || !
|
|
12390
|
+
if (base === null || !import_ts_morph56.Node.isObjectLiteralExpression(base)) {
|
|
12559
12391
|
return null;
|
|
12560
12392
|
}
|
|
12561
12393
|
const propName = contractArg.getName();
|
|
12562
12394
|
for (const prop of base.getProperties()) {
|
|
12563
|
-
if (!
|
|
12395
|
+
if (!import_ts_morph56.Node.isPropertyAssignment(prop)) {
|
|
12564
12396
|
continue;
|
|
12565
12397
|
}
|
|
12566
12398
|
if (prop.getName() !== propName) {
|
|
@@ -12570,20 +12402,20 @@ function resolveContractObject(contractArg, resolution) {
|
|
|
12570
12402
|
if (value === void 0) {
|
|
12571
12403
|
return null;
|
|
12572
12404
|
}
|
|
12573
|
-
if (
|
|
12405
|
+
if (import_ts_morph56.Node.isObjectLiteralExpression(value)) {
|
|
12574
12406
|
return value;
|
|
12575
12407
|
}
|
|
12576
|
-
if (
|
|
12408
|
+
if (import_ts_morph56.Node.isIdentifier(value) || import_ts_morph56.Node.isPropertyAccessExpression(value)) {
|
|
12577
12409
|
return resolveContractObject(value, resolution);
|
|
12578
12410
|
}
|
|
12579
|
-
if (
|
|
12411
|
+
if (import_ts_morph56.Node.isCallExpression(value)) {
|
|
12580
12412
|
return unwrapContractInit(value);
|
|
12581
12413
|
}
|
|
12582
12414
|
return null;
|
|
12583
12415
|
}
|
|
12584
12416
|
return null;
|
|
12585
12417
|
}
|
|
12586
|
-
if (!
|
|
12418
|
+
if (!import_ts_morph56.Node.isIdentifier(contractArg)) {
|
|
12587
12419
|
return null;
|
|
12588
12420
|
}
|
|
12589
12421
|
const symbol = contractArg.getSymbol();
|
|
@@ -12595,7 +12427,7 @@ function resolveContractObject(contractArg, resolution) {
|
|
|
12595
12427
|
return null;
|
|
12596
12428
|
}
|
|
12597
12429
|
const decl = decls[0];
|
|
12598
|
-
if (
|
|
12430
|
+
if (import_ts_morph56.Node.isImportSpecifier(decl)) {
|
|
12599
12431
|
const importDecl = decl.getImportDeclaration();
|
|
12600
12432
|
const sourceFile = importDecl.getModuleSpecifierSourceFile();
|
|
12601
12433
|
if (sourceFile !== void 0 && resolution !== void 0) {
|
|
@@ -12604,14 +12436,14 @@ function resolveContractObject(contractArg, resolution) {
|
|
|
12604
12436
|
);
|
|
12605
12437
|
if (exported !== void 0 && exported.length > 0) {
|
|
12606
12438
|
const exportedDecl = exported[0];
|
|
12607
|
-
if (
|
|
12439
|
+
if (import_ts_morph56.Node.isVariableDeclaration(exportedDecl)) {
|
|
12608
12440
|
return unwrapContractInit(exportedDecl.getInitializer());
|
|
12609
12441
|
}
|
|
12610
12442
|
}
|
|
12611
12443
|
}
|
|
12612
12444
|
return null;
|
|
12613
12445
|
}
|
|
12614
|
-
if (
|
|
12446
|
+
if (import_ts_morph56.Node.isVariableDeclaration(decl)) {
|
|
12615
12447
|
return unwrapContractInit(decl.getInitializer());
|
|
12616
12448
|
}
|
|
12617
12449
|
return null;
|
|
@@ -12621,39 +12453,39 @@ function unwrapContractInit(init) {
|
|
|
12621
12453
|
return null;
|
|
12622
12454
|
}
|
|
12623
12455
|
const node = peelSyntax(init);
|
|
12624
|
-
if (
|
|
12456
|
+
if (import_ts_morph56.Node.isCallExpression(node)) {
|
|
12625
12457
|
const args = node.getArguments();
|
|
12626
|
-
if (args.length > 0 &&
|
|
12458
|
+
if (args.length > 0 && import_ts_morph56.Node.isObjectLiteralExpression(args[0])) {
|
|
12627
12459
|
return args[0];
|
|
12628
12460
|
}
|
|
12629
12461
|
return null;
|
|
12630
12462
|
}
|
|
12631
|
-
if (
|
|
12463
|
+
if (import_ts_morph56.Node.isObjectLiteralExpression(node)) {
|
|
12632
12464
|
return node;
|
|
12633
12465
|
}
|
|
12634
12466
|
return null;
|
|
12635
12467
|
}
|
|
12636
12468
|
function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
12637
|
-
if (!
|
|
12469
|
+
if (!import_ts_morph56.Node.isObjectLiteralExpression(endpointNode)) {
|
|
12638
12470
|
return null;
|
|
12639
12471
|
}
|
|
12640
12472
|
const responses = [];
|
|
12641
12473
|
let method;
|
|
12642
12474
|
let path15;
|
|
12643
12475
|
for (const prop of endpointNode.getProperties()) {
|
|
12644
|
-
if (!
|
|
12476
|
+
if (!import_ts_morph56.Node.isPropertyAssignment(prop)) {
|
|
12645
12477
|
continue;
|
|
12646
12478
|
}
|
|
12647
12479
|
const propName = prop.getName();
|
|
12648
12480
|
if (propName === pattern.methodProperty) {
|
|
12649
12481
|
const val = prop.getInitializer();
|
|
12650
|
-
if (val !== void 0 &&
|
|
12482
|
+
if (val !== void 0 && import_ts_morph56.Node.isStringLiteral(val)) {
|
|
12651
12483
|
method = val.getLiteralValue();
|
|
12652
12484
|
}
|
|
12653
12485
|
}
|
|
12654
12486
|
if (propName === pattern.pathProperty) {
|
|
12655
12487
|
const val = prop.getInitializer();
|
|
12656
|
-
if (val !== void 0 &&
|
|
12488
|
+
if (val !== void 0 && import_ts_morph56.Node.isStringLiteral(val)) {
|
|
12657
12489
|
path15 = val.getLiteralValue();
|
|
12658
12490
|
}
|
|
12659
12491
|
}
|
|
@@ -12662,7 +12494,7 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12662
12494
|
const val = written === void 0 ? null : objectLiteralOf(written, resolution);
|
|
12663
12495
|
if (val !== null) {
|
|
12664
12496
|
for (const respProp of propertiesOf(val, resolution)) {
|
|
12665
|
-
if (!
|
|
12497
|
+
if (!import_ts_morph56.Node.isPropertyAssignment(respProp)) {
|
|
12666
12498
|
continue;
|
|
12667
12499
|
}
|
|
12668
12500
|
const statusStr = respProp.getName();
|
|
@@ -12712,11 +12544,11 @@ function readContract(unit, pattern, framework, resolution) {
|
|
|
12712
12544
|
return null;
|
|
12713
12545
|
}
|
|
12714
12546
|
const contractObj = resolveContractObject(routerInfo.contractArg, resolution);
|
|
12715
|
-
if (contractObj === null || !
|
|
12547
|
+
if (contractObj === null || !import_ts_morph56.Node.isObjectLiteralExpression(contractObj)) {
|
|
12716
12548
|
return null;
|
|
12717
12549
|
}
|
|
12718
12550
|
for (const prop of contractObj.getProperties()) {
|
|
12719
|
-
if (!
|
|
12551
|
+
if (!import_ts_morph56.Node.isPropertyAssignment(prop)) {
|
|
12720
12552
|
continue;
|
|
12721
12553
|
}
|
|
12722
12554
|
if (prop.getName() !== routerInfo.handlerName) {
|
|
@@ -12741,7 +12573,7 @@ function endpointFromRegistrationArgument(unit, position, resolution) {
|
|
|
12741
12573
|
return null;
|
|
12742
12574
|
}
|
|
12743
12575
|
const call = func.getParent();
|
|
12744
|
-
if (call === void 0 || !
|
|
12576
|
+
if (call === void 0 || !import_ts_morph56.Node.isCallExpression(call)) {
|
|
12745
12577
|
return null;
|
|
12746
12578
|
}
|
|
12747
12579
|
const args = call.getArguments();
|
|
@@ -12753,24 +12585,24 @@ function endpointFromRegistrationArgument(unit, position, resolution) {
|
|
|
12753
12585
|
return null;
|
|
12754
12586
|
}
|
|
12755
12587
|
let node = arg;
|
|
12756
|
-
while (
|
|
12588
|
+
while (import_ts_morph56.Node.isAsExpression(node)) {
|
|
12757
12589
|
node = node.getExpression();
|
|
12758
12590
|
}
|
|
12759
|
-
if (
|
|
12591
|
+
if (import_ts_morph56.Node.isObjectLiteralExpression(node)) {
|
|
12760
12592
|
return node;
|
|
12761
12593
|
}
|
|
12762
|
-
if (
|
|
12594
|
+
if (import_ts_morph56.Node.isCallExpression(node)) {
|
|
12763
12595
|
return unwrapContractInit(node);
|
|
12764
12596
|
}
|
|
12765
12597
|
return resolveContractObject(node, resolution);
|
|
12766
12598
|
}
|
|
12767
12599
|
function readContractForClientCall(callExpression, methodName, pattern, framework, resolution) {
|
|
12768
|
-
const callee =
|
|
12769
|
-
if (callee === null || !
|
|
12600
|
+
const callee = import_ts_morph56.Node.isCallExpression(callExpression) ? callExpression.getExpression() : null;
|
|
12601
|
+
if (callee === null || !import_ts_morph56.Node.isPropertyAccessExpression(callee)) {
|
|
12770
12602
|
return null;
|
|
12771
12603
|
}
|
|
12772
12604
|
const clientIdentifier = callee.getExpression();
|
|
12773
|
-
if (!
|
|
12605
|
+
if (!import_ts_morph56.Node.isIdentifier(clientIdentifier)) {
|
|
12774
12606
|
return null;
|
|
12775
12607
|
}
|
|
12776
12608
|
const symbol = clientIdentifier.getSymbol();
|
|
@@ -12782,11 +12614,11 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12782
12614
|
return null;
|
|
12783
12615
|
}
|
|
12784
12616
|
const decl = decls[0];
|
|
12785
|
-
if (!
|
|
12617
|
+
if (!import_ts_morph56.Node.isVariableDeclaration(decl)) {
|
|
12786
12618
|
return null;
|
|
12787
12619
|
}
|
|
12788
12620
|
const init = decl.getInitializer();
|
|
12789
|
-
if (init === void 0 || !
|
|
12621
|
+
if (init === void 0 || !import_ts_morph56.Node.isCallExpression(init)) {
|
|
12790
12622
|
return null;
|
|
12791
12623
|
}
|
|
12792
12624
|
const args = init.getArguments();
|
|
@@ -12794,11 +12626,11 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12794
12626
|
return null;
|
|
12795
12627
|
}
|
|
12796
12628
|
const contractObj = resolveContractObject(args[0], resolution);
|
|
12797
|
-
if (contractObj === null || !
|
|
12629
|
+
if (contractObj === null || !import_ts_morph56.Node.isObjectLiteralExpression(contractObj)) {
|
|
12798
12630
|
return null;
|
|
12799
12631
|
}
|
|
12800
12632
|
for (const prop of contractObj.getProperties()) {
|
|
12801
|
-
if (!
|
|
12633
|
+
if (!import_ts_morph56.Node.isPropertyAssignment(prop)) {
|
|
12802
12634
|
continue;
|
|
12803
12635
|
}
|
|
12804
12636
|
if (prop.getName() !== methodName) {
|
|
@@ -12818,6 +12650,154 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12818
12650
|
return null;
|
|
12819
12651
|
}
|
|
12820
12652
|
|
|
12653
|
+
// src/diagnostics.ts
|
|
12654
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
12655
|
+
var import_ts_morph57 = require("ts-morph");
|
|
12656
|
+
var import_extractor6 = require("@suss/extractor");
|
|
12657
|
+
var DEFAULT_RESOLUTION = {
|
|
12658
|
+
moduleResolution: import_ts_morph57.ts.ModuleResolutionKind.Bundler,
|
|
12659
|
+
target: import_ts_morph57.ts.ScriptTarget.ESNext,
|
|
12660
|
+
module: import_ts_morph57.ts.ModuleKind.ESNext
|
|
12661
|
+
};
|
|
12662
|
+
function resolutionContext(args) {
|
|
12663
|
+
if (args.tsConfigFilePath !== void 0) {
|
|
12664
|
+
const configFile = import_ts_morph57.ts.readConfigFile(
|
|
12665
|
+
args.tsConfigFilePath,
|
|
12666
|
+
import_ts_morph57.ts.sys.readFile
|
|
12667
|
+
);
|
|
12668
|
+
if (configFile.error !== void 0) {
|
|
12669
|
+
return null;
|
|
12670
|
+
}
|
|
12671
|
+
const dir = import_node_path7.default.dirname(args.tsConfigFilePath);
|
|
12672
|
+
const parsed = import_ts_morph57.ts.parseJsonConfigFileContent(
|
|
12673
|
+
configFile.config,
|
|
12674
|
+
import_ts_morph57.ts.sys,
|
|
12675
|
+
dir,
|
|
12676
|
+
/*existingOptions*/
|
|
12677
|
+
void 0,
|
|
12678
|
+
args.tsConfigFilePath
|
|
12679
|
+
);
|
|
12680
|
+
return {
|
|
12681
|
+
containingFile: import_node_path7.default.join(dir, "index.ts"),
|
|
12682
|
+
options: parsed.options
|
|
12683
|
+
};
|
|
12684
|
+
}
|
|
12685
|
+
if (args.projectRoot === void 0 || !import_node_path7.default.isAbsolute(args.projectRoot)) {
|
|
12686
|
+
return null;
|
|
12687
|
+
}
|
|
12688
|
+
return {
|
|
12689
|
+
containingFile: import_node_path7.default.join(args.projectRoot, "index.ts"),
|
|
12690
|
+
options: DEFAULT_RESOLUTION
|
|
12691
|
+
};
|
|
12692
|
+
}
|
|
12693
|
+
function unresolvedGatesFor(gates, args) {
|
|
12694
|
+
if (gates.length === 0) {
|
|
12695
|
+
return [];
|
|
12696
|
+
}
|
|
12697
|
+
const context = resolutionContext(args);
|
|
12698
|
+
if (context === null) {
|
|
12699
|
+
return [];
|
|
12700
|
+
}
|
|
12701
|
+
const unresolved = [];
|
|
12702
|
+
for (const gate of gates) {
|
|
12703
|
+
const resolved = import_ts_morph57.ts.resolveModuleName(
|
|
12704
|
+
gate,
|
|
12705
|
+
context.containingFile,
|
|
12706
|
+
context.options,
|
|
12707
|
+
import_ts_morph57.ts.sys
|
|
12708
|
+
);
|
|
12709
|
+
if (resolved.resolvedModule === void 0) {
|
|
12710
|
+
unresolved.push(gate);
|
|
12711
|
+
}
|
|
12712
|
+
}
|
|
12713
|
+
return unresolved;
|
|
12714
|
+
}
|
|
12715
|
+
function helpersWithNoCall(patterns, matched, projectRoot) {
|
|
12716
|
+
const missing = [];
|
|
12717
|
+
for (const pattern of patterns) {
|
|
12718
|
+
if (pattern.match.type !== "registrationTemplate" || matched.has(pattern.match.helperName)) {
|
|
12719
|
+
continue;
|
|
12720
|
+
}
|
|
12721
|
+
const from = pattern.match.importModule;
|
|
12722
|
+
missing.push(
|
|
12723
|
+
from === void 0 ? pattern.match.helperName : `${pattern.match.helperName} from ${shortModule(from, projectRoot)}`
|
|
12724
|
+
);
|
|
12725
|
+
}
|
|
12726
|
+
return missing;
|
|
12727
|
+
}
|
|
12728
|
+
function shortModule(module2, projectRoot) {
|
|
12729
|
+
if (projectRoot === void 0 || !import_node_path7.default.isAbsolute(module2)) {
|
|
12730
|
+
return module2;
|
|
12731
|
+
}
|
|
12732
|
+
return import_node_path7.default.relative(projectRoot, module2);
|
|
12733
|
+
}
|
|
12734
|
+
function buildExtractionReport(args) {
|
|
12735
|
+
const bySummary = (0, import_extractor6.summaryCountsByPack)(args.summaries);
|
|
12736
|
+
const packFunnels = args.packs.map((pack) => {
|
|
12737
|
+
const gates = packIsUngated(pack) ? [] : collectPackGates(pack);
|
|
12738
|
+
const tally = args.tallies.get(pack.name) ?? (0, import_extractor6.emptyTally)();
|
|
12739
|
+
const counted = bySummary.get(pack.name) ?? {
|
|
12740
|
+
bound: 0,
|
|
12741
|
+
providers: 0,
|
|
12742
|
+
withBehavior: 0
|
|
12743
|
+
};
|
|
12744
|
+
return {
|
|
12745
|
+
pack: pack.name,
|
|
12746
|
+
version: pack.version ?? null,
|
|
12747
|
+
discovers: pack.discovery.length > 0 || pack.discoverUnits !== void 0,
|
|
12748
|
+
recognizes: (pack.invocationRecognizers?.length ?? 0) > 0 || (pack.accessRecognizers?.length ?? 0) > 0,
|
|
12749
|
+
gates,
|
|
12750
|
+
unresolvedGates: unresolvedGatesFor(gates, {
|
|
12751
|
+
tsConfigFilePath: args.tsConfigFilePath,
|
|
12752
|
+
projectRoot: args.projectRoot
|
|
12753
|
+
}),
|
|
12754
|
+
candidateFiles: tally.candidateFiles,
|
|
12755
|
+
unitsDiscovered: tally.unitsDiscovered,
|
|
12756
|
+
unitsInGatedFiles: tally.unitsInGatedFiles,
|
|
12757
|
+
effectsRecognized: tally.effectsRecognized,
|
|
12758
|
+
unitsClaimed: tally.unitsClaimed,
|
|
12759
|
+
summariesProduced: tally.summariesProduced,
|
|
12760
|
+
failures: tally.failures,
|
|
12761
|
+
helpersUnmatched: helpersWithNoCall(
|
|
12762
|
+
[...pack.discovery, ...args.contributedPatterns?.(pack.name) ?? []],
|
|
12763
|
+
tally.helpersMatched,
|
|
12764
|
+
args.projectRoot
|
|
12765
|
+
),
|
|
12766
|
+
summariesBound: counted.bound,
|
|
12767
|
+
providerSummaries: counted.providers,
|
|
12768
|
+
summariesWithBehavior: counted.withBehavior,
|
|
12769
|
+
declarations: pack.declarations ?? null
|
|
12770
|
+
};
|
|
12771
|
+
});
|
|
12772
|
+
return {
|
|
12773
|
+
filesInProject: args.filesInProject,
|
|
12774
|
+
filesWalked: args.filesWalked,
|
|
12775
|
+
packs: packFunnels,
|
|
12776
|
+
summaries: args.summaries.length,
|
|
12777
|
+
filesWithUnreadableExports: [...args.filesWithUnreadableExports ?? []],
|
|
12778
|
+
reassignedNamesUnstated: args.reassignedNamesUnstated ?? 0,
|
|
12779
|
+
emptyStage: args.summaries.length === 0 ? firstEmptyStage(packFunnels, args) : null
|
|
12780
|
+
};
|
|
12781
|
+
}
|
|
12782
|
+
function firstEmptyStage(packs, args) {
|
|
12783
|
+
if (args.filesInProject === 0) {
|
|
12784
|
+
return "tsconfig";
|
|
12785
|
+
}
|
|
12786
|
+
const gateFailed = packs.some(
|
|
12787
|
+
(p) => p.unresolvedGates.length > 0 && p.candidateFiles > 0
|
|
12788
|
+
);
|
|
12789
|
+
if (gateFailed) {
|
|
12790
|
+
return "gateResolution";
|
|
12791
|
+
}
|
|
12792
|
+
if (args.filesWalked === 0 || packs.every((p) => p.candidateFiles === 0)) {
|
|
12793
|
+
return "candidateFiles";
|
|
12794
|
+
}
|
|
12795
|
+
if (packs.every((p) => p.unitsDiscovered === 0)) {
|
|
12796
|
+
return "discovery";
|
|
12797
|
+
}
|
|
12798
|
+
return "assembly";
|
|
12799
|
+
}
|
|
12800
|
+
|
|
12821
12801
|
// src/discovery/filenameRoute.ts
|
|
12822
12802
|
function routePathFromFile(filePath, convention) {
|
|
12823
12803
|
const belowRoot = segmentsBelowRoot(filePath, convention.root);
|
|
@@ -14144,7 +14124,7 @@ function scalarOrRef(node) {
|
|
|
14144
14124
|
}
|
|
14145
14125
|
|
|
14146
14126
|
// src/moduleInit.ts
|
|
14147
|
-
var
|
|
14127
|
+
var import_extractor7 = require("@suss/extractor");
|
|
14148
14128
|
function moduleInitName(sourceFile) {
|
|
14149
14129
|
return sourceFile.getBaseName();
|
|
14150
14130
|
}
|
|
@@ -14152,8 +14132,8 @@ function moduleInitSummary(sourceFile, effects, options) {
|
|
|
14152
14132
|
if (effects.length === 0) {
|
|
14153
14133
|
return null;
|
|
14154
14134
|
}
|
|
14155
|
-
return (0,
|
|
14156
|
-
(0,
|
|
14135
|
+
return (0, import_extractor7.assembleSummary)(
|
|
14136
|
+
(0, import_extractor7.moduleInitStructure)({
|
|
14157
14137
|
name: moduleInitName(sourceFile),
|
|
14158
14138
|
file: sourceFile.getFilePath(),
|
|
14159
14139
|
range: { start: 0, end: sourceFile.getEnd() },
|
|
@@ -14310,7 +14290,7 @@ function deriveBoundaryEffects(summaries, facts) {
|
|
|
14310
14290
|
var import_ts_morph63 = require("ts-morph");
|
|
14311
14291
|
var import_behavioral_ir6 = require("@suss/behavioral-ir");
|
|
14312
14292
|
var import_datalog4 = require("@suss/datalog");
|
|
14313
|
-
var
|
|
14293
|
+
var import_extractor8 = require("@suss/extractor");
|
|
14314
14294
|
var GENERIC_TERMINALS = [
|
|
14315
14295
|
{ kind: "return", match: { type: "returnStatement" }, extraction: {} },
|
|
14316
14296
|
{ kind: "throw", match: { type: "throwExpression" }, extraction: {} },
|
|
@@ -14523,7 +14503,7 @@ function extractReachableSummary(candidate, options, recognizers) {
|
|
|
14523
14503
|
transport: "in-process",
|
|
14524
14504
|
recognition: "reachable"
|
|
14525
14505
|
});
|
|
14526
|
-
return (0,
|
|
14506
|
+
return (0, import_extractor8.assembleSummary)(raw, options);
|
|
14527
14507
|
}
|
|
14528
14508
|
var REACHABLE_RULES = [
|
|
14529
14509
|
(0, import_datalog4.rule)("reachable", [(0, import_datalog4.variable)("f")], [(0, import_datalog4.lit)("entry", (0, import_datalog4.variable)("f"))]),
|
|
@@ -15587,14 +15567,14 @@ function idFor(workspace, file, summary) {
|
|
|
15587
15567
|
}
|
|
15588
15568
|
|
|
15589
15569
|
// src/timing.ts
|
|
15590
|
-
var
|
|
15570
|
+
var import_extractor9 = require("@suss/extractor");
|
|
15591
15571
|
|
|
15592
15572
|
// src/version.ts
|
|
15593
|
-
var import_extractor9 = require("@suss/extractor");
|
|
15594
15573
|
var import_extractor10 = require("@suss/extractor");
|
|
15574
|
+
var import_extractor11 = require("@suss/extractor");
|
|
15595
15575
|
var import_meta = {};
|
|
15596
15576
|
var ADAPTER_VERSION = "0.2.1";
|
|
15597
|
-
var stamp = (0,
|
|
15577
|
+
var stamp = (0, import_extractor10.createAdapterStamp)({
|
|
15598
15578
|
moduleUrl: import_meta.url,
|
|
15599
15579
|
version: ADAPTER_VERSION
|
|
15600
15580
|
});
|
|
@@ -15762,7 +15742,7 @@ function workspaceExpansionStamp(frameworks) {
|
|
|
15762
15742
|
const paths = frameworks.flatMap((pack) => pack.discovery).flatMap(
|
|
15763
15743
|
(pattern) => pattern.match.type === "packageExports" && pattern.match.packageJsonPath !== void 0 ? [pattern.match.packageJsonPath] : []
|
|
15764
15744
|
);
|
|
15765
|
-
return (0,
|
|
15745
|
+
return (0, import_extractor11.projectFileStamp)(paths);
|
|
15766
15746
|
}
|
|
15767
15747
|
function expandWorkspacePatterns(frameworks, anchor) {
|
|
15768
15748
|
const marked = frameworks.some(
|
|
@@ -16408,7 +16388,7 @@ function computeSubUnitBarriers(unit, packs, ctx, tallies, file) {
|
|
|
16408
16388
|
}
|
|
16409
16389
|
} catch (err) {
|
|
16410
16390
|
process.stderr.write(
|
|
16411
|
-
(0,
|
|
16391
|
+
(0, import_extractor6.recordPackFailure)(tallies?.get(pack.name), {
|
|
16412
16392
|
pack: pack.name,
|
|
16413
16393
|
hook: "subUnits",
|
|
16414
16394
|
file,
|
|
@@ -16470,7 +16450,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16470
16450
|
}
|
|
16471
16451
|
} catch (err) {
|
|
16472
16452
|
process.stderr.write(
|
|
16473
|
-
(0,
|
|
16453
|
+
(0, import_extractor6.recordPackFailure)(tally, {
|
|
16474
16454
|
pack: pack.name,
|
|
16475
16455
|
hook: "discoverUnits",
|
|
16476
16456
|
file: sourceFile.getFilePath(),
|
|
@@ -16483,9 +16463,6 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16483
16463
|
const claimKey = unitDedupKey(unit);
|
|
16484
16464
|
const claimant = claimed.get(claimKey);
|
|
16485
16465
|
if (claimant !== void 0) {
|
|
16486
|
-
if (claimant.pack === pack.name && claimant.file === sourceFile.getFilePath() && tally !== void 0) {
|
|
16487
|
-
tally.selfCollisions += 1;
|
|
16488
|
-
}
|
|
16489
16466
|
if (claimant.file !== sourceFile.getFilePath()) {
|
|
16490
16467
|
recordFileDependency(claimant.file);
|
|
16491
16468
|
}
|
|
@@ -16683,7 +16660,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16683
16660
|
});
|
|
16684
16661
|
}
|
|
16685
16662
|
}
|
|
16686
|
-
const summary = (0,
|
|
16663
|
+
const summary = (0, import_extractor12.assembleSummary)(raw, options);
|
|
16687
16664
|
if (options?.gapHandling !== "silent") {
|
|
16688
16665
|
for (const stop of unfollowedStopsOf(unit, wrappers)) {
|
|
16689
16666
|
summary.gaps.push((0, import_behavioral_ir2.unfollowedCallGap)(stop));
|
|
@@ -17026,7 +17003,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path15, options) {
|
|
|
17026
17003
|
path: path15,
|
|
17027
17004
|
recognition: wrapperBinding?.recognition ?? "unknown"
|
|
17028
17005
|
});
|
|
17029
|
-
const summary = (0,
|
|
17006
|
+
const summary = (0, import_extractor12.assembleSummary)(raw, options);
|
|
17030
17007
|
summary.metadata = {
|
|
17031
17008
|
...summary.metadata ?? {},
|
|
17032
17009
|
derivedFromWrapper: {
|
|
@@ -17038,7 +17015,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path15, options) {
|
|
|
17038
17015
|
return summary;
|
|
17039
17016
|
}
|
|
17040
17017
|
function named(summaries, workspace, runRoot) {
|
|
17041
|
-
const projectRoot = runRoot ?? commonDirectoryOf(summaries.map((s) => s.location.file));
|
|
17018
|
+
const projectRoot = runRoot ?? (0, import_extractor12.commonDirectoryOf)(summaries.map((s) => s.location.file));
|
|
17042
17019
|
nameSummaries(summaries, {
|
|
17043
17020
|
workspace: workspace ?? workspaceNameFor(projectRoot),
|
|
17044
17021
|
projectRoot
|
|
@@ -17096,7 +17073,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17096
17073
|
const cacheDir = declineWhenRunFromSource(
|
|
17097
17074
|
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)
|
|
17098
17075
|
);
|
|
17099
|
-
const cache = (0,
|
|
17076
|
+
const cache = (0, import_extractor12.createCacheLayer)(cacheDir);
|
|
17100
17077
|
const packsDigest = `${computeAdapterPacksDigest(
|
|
17101
17078
|
config.frameworks.map(
|
|
17102
17079
|
(p) => p.version !== void 0 ? { name: p.name, version: p.version } : { name: p.name }
|
|
@@ -17134,8 +17111,8 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17134
17111
|
return named(summaries, config.workspace, runRoot);
|
|
17135
17112
|
},
|
|
17136
17113
|
async extractAll() {
|
|
17137
|
-
const timer = (0,
|
|
17138
|
-
const tallies = (0,
|
|
17114
|
+
const timer = (0, import_extractor9.createTimer)();
|
|
17115
|
+
const tallies = (0, import_extractor6.createPackTallies)(config.frameworks);
|
|
17139
17116
|
forgetUnreadableExportFiles();
|
|
17140
17117
|
forgetReassignedNamesUnstated();
|
|
17141
17118
|
const lazyEligible = !lazyBootstrapped && config.tsConfigFilePath !== void 0 && config.project === void 0;
|
|
@@ -17148,7 +17125,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17148
17125
|
let cacheFiles = null;
|
|
17149
17126
|
const adapterPacksDigest = cacheDir === null ? packsDigest : timer.time("cache.digest", () => {
|
|
17150
17127
|
cacheFiles = tsconfigFileList ?? project.getSourceFiles().map((sf) => sf.getFilePath());
|
|
17151
|
-
return (0,
|
|
17128
|
+
return (0, import_extractor12.runDigest)(packsDigest, config.frameworks, cacheFiles);
|
|
17152
17129
|
});
|
|
17153
17130
|
const cacheInput = {
|
|
17154
17131
|
// Empty when cacheDir is null: a no-op cache layer never reads
|
|
@@ -17399,7 +17376,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17399
17376
|
}
|
|
17400
17377
|
timer.time(
|
|
17401
17378
|
"stampModuleImports",
|
|
17402
|
-
() => (0,
|
|
17379
|
+
() => (0, import_extractor12.stampModuleImports)(enriched, (file) => {
|
|
17403
17380
|
const imports = internalImportsOf(project, file);
|
|
17404
17381
|
return imports.length === 0 ? void 0 : imports;
|
|
17405
17382
|
})
|
|
@@ -17461,7 +17438,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17461
17438
|
});
|
|
17462
17439
|
const composed = timer.time(
|
|
17463
17440
|
"composeWrappers",
|
|
17464
|
-
() => (0,
|
|
17441
|
+
() => (0, import_extractor12.composeWrappers)(enriched, config.extractorOptions ?? {})
|
|
17465
17442
|
);
|
|
17466
17443
|
if (config.onTiming !== void 0) {
|
|
17467
17444
|
config.onTiming(timer.report());
|
|
@@ -17475,7 +17452,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17475
17452
|
filesWalked: walkList.length,
|
|
17476
17453
|
summaries: composed,
|
|
17477
17454
|
tsConfigFilePath: config.tsConfigFilePath,
|
|
17478
|
-
projectRoot: commonDirectoryOf(
|
|
17455
|
+
projectRoot: (0, import_extractor12.commonDirectoryOf)(
|
|
17479
17456
|
sourceFiles.map((f) => f.getFilePath())
|
|
17480
17457
|
),
|
|
17481
17458
|
filesWithUnreadableExports: unreadableExportFiles(),
|
|
@@ -17487,7 +17464,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17487
17464
|
return named(
|
|
17488
17465
|
composed,
|
|
17489
17466
|
config.workspace,
|
|
17490
|
-
runRoot ?? commonDirectoryOf(sourceFiles.map((f) => f.getFilePath()))
|
|
17467
|
+
runRoot ?? (0, import_extractor12.commonDirectoryOf)(sourceFiles.map((f) => f.getFilePath()))
|
|
17491
17468
|
);
|
|
17492
17469
|
}
|
|
17493
17470
|
};
|
|
@@ -17786,7 +17763,7 @@ function buildSubUnitSummary(subUnit, parent, invocationRecognizers, accessRecog
|
|
|
17786
17763
|
if (parent.identity.boundaryBinding !== null) {
|
|
17787
17764
|
raw.boundaryBinding = parent.identity.boundaryBinding;
|
|
17788
17765
|
}
|
|
17789
|
-
const summary = (0,
|
|
17766
|
+
const summary = (0, import_extractor12.assembleSummary)(raw, options);
|
|
17790
17767
|
if (subUnit.metadata !== void 0 && Object.keys(subUnit.metadata).length > 0) {
|
|
17791
17768
|
summary.metadata = {
|
|
17792
17769
|
...summary.metadata ?? {},
|