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