@suss/adapter-typescript 0.22.1 → 0.22.3

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.js CHANGED
@@ -3,7 +3,7 @@ import path10 from "path";
3
3
  import {
4
4
  Node as Node64,
5
5
  Project,
6
- SyntaxKind as SyntaxKind11
6
+ SyntaxKind as SyntaxKind12
7
7
  } from "ts-morph";
8
8
  import {
9
9
  functionCallBinding as functionCallBinding2,
@@ -664,14 +664,14 @@ function parseConditionExpression(expr, depth = 0) {
664
664
  if (expr.getOperatorToken() !== SyntaxKind2.ExclamationToken) {
665
665
  return null;
666
666
  }
667
- const operand = expr.getOperand();
668
- const inner = parseConditionExpression(operand, depth);
667
+ const operand2 = expr.getOperand();
668
+ const inner = parseConditionExpression(operand2, depth);
669
669
  if (inner === null) {
670
670
  return {
671
671
  type: "negation",
672
672
  operand: {
673
673
  type: "opaque",
674
- sourceText: operand.getText(),
674
+ sourceText: operand2.getText(),
675
675
  reason: "complexExpression"
676
676
  }
677
677
  };
@@ -735,8 +735,8 @@ function parseConditionExpression(expr, depth = 0) {
735
735
  const rightIsNull = isNullOrUndefined(right);
736
736
  if (leftIsNull || rightIsNull) {
737
737
  const subject = resolveSubject(leftIsNull ? right : left);
738
- const negated = op === "neq";
739
- return { type: "nullCheck", subject, negated };
738
+ const negated2 = op === "neq";
739
+ return { type: "nullCheck", subject, negated: negated2 };
740
740
  }
741
741
  }
742
742
  if (Node5.isTypeOfExpression(left) && Node5.isStringLiteral(right) && (opText === "===" || opText === "==")) {
@@ -2583,7 +2583,7 @@ function isNotYetPlaceholder(value) {
2583
2583
  return value.getKind() === SyntaxKind3.NullKeyword || Node13.isIdentifier(value) && value.getText() === "undefined";
2584
2584
  }
2585
2585
  function isConstruction(value) {
2586
- return Node13.isCallExpression(value) || Node13.isNewExpression(value);
2586
+ return Node13.isCallExpression(value) || Node13.isNewExpression(value) || Node13.isObjectLiteralExpression(value) || Node13.isArrayLiteralExpression(value);
2587
2587
  }
2588
2588
  function sourceOf(node) {
2589
2589
  return node.getText().replace(/\s+/g, " ").trim();
@@ -3054,10 +3054,10 @@ function emitValue(db, table, value) {
3054
3054
  }
3055
3055
  return id;
3056
3056
  }
3057
- const fallback = asFallbackExpression(expression);
3058
- if (fallback !== null) {
3059
- fact(db, "fallbackBranch", id, emitValue(db, table, fallback.getLeft()));
3060
- fact(db, "fallbackBranch", id, emitValue(db, table, fallback.getRight()));
3057
+ const fallback2 = asFallbackExpression(expression);
3058
+ if (fallback2 !== null) {
3059
+ fact(db, "fallbackBranch", id, emitValue(db, table, fallback2.getLeft()));
3060
+ fact(db, "fallbackBranch", id, emitValue(db, table, fallback2.getRight()));
3061
3061
  return id;
3062
3062
  }
3063
3063
  if (Node14.isCallExpression(expression) || Node14.isNewExpression(expression)) {
@@ -3145,9 +3145,9 @@ function emitBindingElementFacts(db, table, element) {
3145
3145
  property.getText()
3146
3146
  );
3147
3147
  }
3148
- const fallback = element.getInitializer();
3149
- if (fallback !== void 0) {
3150
- fact(db, "binds", id, emitValue(db, table, fallback));
3148
+ const fallback2 = element.getInitializer();
3149
+ if (fallback2 !== void 0) {
3150
+ fact(db, "binds", id, emitValue(db, table, fallback2));
3151
3151
  }
3152
3152
  return id;
3153
3153
  }
@@ -4352,7 +4352,7 @@ function declarationOf(value) {
4352
4352
  }
4353
4353
 
4354
4354
  // src/discovery/clientCall.ts
4355
- import { Node as Node17 } from "ts-morph";
4355
+ import { Node as Node18 } from "ts-morph";
4356
4356
 
4357
4357
  // src/discovery/importScan.ts
4358
4358
  import path3 from "path";
@@ -4381,8 +4381,8 @@ function commonDirectoryOf(files) {
4381
4381
  }
4382
4382
  shared = shared.slice(0, i);
4383
4383
  }
4384
- const joined = shared.join(path2.sep);
4385
- return joined.length > 1 ? joined : void 0;
4384
+ const joined2 = shared.join(path2.sep);
4385
+ return joined2.length > 1 ? joined2 : void 0;
4386
4386
  }
4387
4387
  var DEFAULT_RESOLUTION = {
4388
4388
  moduleResolution: ts3.ModuleResolutionKind.Bundler,
@@ -4647,17 +4647,631 @@ function resolveImportedLocalName(sourceFile, importModule, importName) {
4647
4647
  }
4648
4648
  return null;
4649
4649
  }
4650
+ function importedReferenceSpellings(sourceFile, importModule, importName) {
4651
+ const spellings = [];
4652
+ const localName = resolveImportedLocalName(
4653
+ sourceFile,
4654
+ importModule,
4655
+ importName
4656
+ );
4657
+ if (localName !== null) {
4658
+ spellings.push(localName);
4659
+ }
4660
+ if (!sourceFile.getFullText().includes(`.${importName}`)) {
4661
+ return spellings;
4662
+ }
4663
+ for (const root of importedRootsOf(sourceFile, [importModule])) {
4664
+ if (root !== importName) {
4665
+ spellings.push(`${root}.${importName}`);
4666
+ }
4667
+ }
4668
+ return spellings;
4669
+ }
4670
+
4671
+ // src/discovery/resolveValue.ts
4672
+ import { Node as Node17 } from "ts-morph";
4673
+ import { force as force2, literalOf } from "@suss/values";
4674
+
4675
+ // src/values/evaluator.ts
4676
+ import { Evaluator, force } from "@suss/values";
4677
+
4678
+ // src/values/lowering.ts
4679
+ import { Node as Node16, SyntaxKind as SyntaxKind5 } from "ts-morph";
4680
+ var ASSIGNMENT_OPERATORS = /* @__PURE__ */ new Set([
4681
+ "=",
4682
+ "+=",
4683
+ "-=",
4684
+ "*=",
4685
+ "/=",
4686
+ "??=",
4687
+ "||=",
4688
+ "&&="
4689
+ ]);
4690
+ var MUTATING_METHODS = /* @__PURE__ */ new Set([
4691
+ "push",
4692
+ "pop",
4693
+ "shift",
4694
+ "unshift",
4695
+ "splice",
4696
+ "sort",
4697
+ "reverse",
4698
+ "fill",
4699
+ "copyWithin"
4700
+ ]);
4701
+ function typescriptLowering(options) {
4702
+ const { resolution, rows } = options;
4703
+ const rowModules = [
4704
+ ...new Set(
4705
+ rows.flatMap((row) => row.kind === "callee" ? [row.origin.module] : [])
4706
+ )
4707
+ ];
4708
+ const mutatedByRoot = /* @__PURE__ */ new Map();
4709
+ const originOf = (callee) => {
4710
+ const chain = memberChainOf(callee);
4711
+ if (chain === null) {
4712
+ return null;
4713
+ }
4714
+ const name = chain.names[chain.names.length - 1] ?? null;
4715
+ if (name === null) {
4716
+ return null;
4717
+ }
4718
+ const origins = resolution?.importOriginsOf(chain.root, rowModules) ?? [];
4719
+ const first = origins[0];
4720
+ if (first !== void 0) {
4721
+ return { module: first.module, name };
4722
+ }
4723
+ const local = resolution !== void 0 && resolution.resolveCallable(callee) !== null;
4724
+ if (chain.names.length > 1 || local) {
4725
+ return null;
4726
+ }
4727
+ return { module: "global", name };
4728
+ };
4729
+ return {
4730
+ expression: (node) => expressionOf(peelValue(node), originOf),
4731
+ statement: statementOf2,
4732
+ siteOf,
4733
+ functionOf,
4734
+ writtenTo: (node) => {
4735
+ if (resolution === void 0) {
4736
+ return null;
4737
+ }
4738
+ const target = peelValue(node);
4739
+ return resolution.resolveWrittenValue(target) ?? resolution.resolveObject(target);
4740
+ },
4741
+ callable: (node) => {
4742
+ const call = peelValue(node);
4743
+ if (resolution === void 0 || !Node16.isCallExpression(call) && !Node16.isNewExpression(call)) {
4744
+ return null;
4745
+ }
4746
+ const target = resolution.resolveCallable(call.getExpression());
4747
+ return target !== null && Node16.isFunctionLikeDeclaration(target) ? target : null;
4748
+ },
4749
+ mutatedInNestedFunction: (root, name) => {
4750
+ let mutated = mutatedByRoot.get(root);
4751
+ if (mutated === void 0) {
4752
+ mutated = namesMutatedInNestedFunctions(root);
4753
+ mutatedByRoot.set(root, mutated);
4754
+ }
4755
+ return mutated.has(name);
4756
+ },
4757
+ freeNamesOf,
4758
+ holeNameOf: placeholderName,
4759
+ rows
4760
+ };
4761
+ }
4762
+ function placeholderName(expr) {
4763
+ if (Node16.isIdentifier(expr)) {
4764
+ return expr.getText();
4765
+ }
4766
+ if (Node16.isPropertyAccessExpression(expr)) {
4767
+ return expr.getName();
4768
+ }
4769
+ return "param";
4770
+ }
4771
+ function expressionOf(node, originOf) {
4772
+ if (Node16.isStringLiteral(node) || Node16.isNoSubstitutionTemplateLiteral(node)) {
4773
+ return { kind: "literal", value: node.getLiteralValue() };
4774
+ }
4775
+ if (Node16.isNumericLiteral(node)) {
4776
+ return { kind: "literal", value: node.getLiteralValue() };
4777
+ }
4778
+ if (Node16.isTrueLiteral(node)) {
4779
+ return { kind: "literal", value: true };
4780
+ }
4781
+ if (Node16.isFalseLiteral(node)) {
4782
+ return { kind: "literal", value: false };
4783
+ }
4784
+ if (Node16.isNullLiteral(node)) {
4785
+ return { kind: "literal", value: null };
4786
+ }
4787
+ if (Node16.isIdentifier(node)) {
4788
+ return node.getText() === "undefined" ? { kind: "literal", value: void 0 } : { kind: "name", text: node.getText() };
4789
+ }
4790
+ if (Node16.isTemplateExpression(node)) {
4791
+ return {
4792
+ kind: "template",
4793
+ parts: [
4794
+ { text: node.getHead().getLiteralText() },
4795
+ ...node.getTemplateSpans().flatMap((span) => [
4796
+ { expression: span.getExpression() },
4797
+ { text: span.getLiteral().getLiteralText() }
4798
+ ])
4799
+ ]
4800
+ };
4801
+ }
4802
+ if (Node16.isPropertyAccessExpression(node)) {
4803
+ return {
4804
+ kind: "member",
4805
+ object: node.getExpression(),
4806
+ name: node.getName()
4807
+ };
4808
+ }
4809
+ if (Node16.isElementAccessExpression(node)) {
4810
+ const index = node.getArgumentExpression();
4811
+ return index === void 0 ? { kind: "opaque" } : { kind: "element", object: node.getExpression(), index };
4812
+ }
4813
+ if (Node16.isArrayLiteralExpression(node)) {
4814
+ return { kind: "array", items: node.getElements().map(elementOf) };
4815
+ }
4816
+ if (Node16.isObjectLiteralExpression(node)) {
4817
+ return { kind: "record", fields: node.getProperties().flatMap(fieldOf) };
4818
+ }
4819
+ if (Node16.isCallExpression(node) || Node16.isNewExpression(node)) {
4820
+ return {
4821
+ kind: "call",
4822
+ callee: calleeOf(node.getExpression(), originOf),
4823
+ args: node.getArguments().map(elementOf),
4824
+ constructs: Node16.isNewExpression(node)
4825
+ };
4826
+ }
4827
+ if (Node16.isBinaryExpression(node)) {
4828
+ const operator = node.getOperatorToken().getText();
4829
+ return ASSIGNMENT_OPERATORS.has(operator) ? { kind: "opaque" } : {
4830
+ kind: "operator",
4831
+ operator,
4832
+ operands: [node.getLeft(), node.getRight()]
4833
+ };
4834
+ }
4835
+ if (Node16.isPrefixUnaryExpression(node)) {
4836
+ const operator = node.getOperatorToken();
4837
+ return operator === SyntaxKind5.ExclamationToken ? { kind: "operator", operator: "!", operands: [node.getOperand()] } : { kind: "opaque" };
4838
+ }
4839
+ if (Node16.isConditionalExpression(node)) {
4840
+ return {
4841
+ kind: "conditional",
4842
+ condition: node.getCondition(),
4843
+ whenTrue: node.getWhenTrue(),
4844
+ whenFalse: node.getWhenFalse()
4845
+ };
4846
+ }
4847
+ if (Node16.isArrowFunction(node) || Node16.isFunctionExpression(node)) {
4848
+ return { kind: "function", node };
4849
+ }
4850
+ return { kind: "opaque" };
4851
+ }
4852
+ function elementOf(node) {
4853
+ return Node16.isSpreadElement(node) ? { kind: "spread", node: node.getExpression() } : { kind: "value", node };
4854
+ }
4855
+ function fieldOf(property) {
4856
+ if (Node16.isSpreadAssignment(property)) {
4857
+ return [{ kind: "spread", node: property.getExpression() }];
4858
+ }
4859
+ if (Node16.isShorthandPropertyAssignment(property)) {
4860
+ const nameNode2 = property.getNameNode();
4861
+ return [{ kind: "field", name: nameNode2.getText(), value: nameNode2 }];
4862
+ }
4863
+ if (!Node16.isPropertyAssignment(property)) {
4864
+ return [];
4865
+ }
4866
+ const value = property.getInitializer();
4867
+ if (value === void 0) {
4868
+ return [];
4869
+ }
4870
+ const nameNode = property.getNameNode();
4871
+ if (Node16.isComputedPropertyName(nameNode)) {
4872
+ return [{ kind: "computed", name: nameNode.getExpression(), value }];
4873
+ }
4874
+ const name = Node16.isStringLiteral(nameNode) || Node16.isNumericLiteral(nameNode) ? String(nameNode.getLiteralValue()) : nameNode.getText();
4875
+ return [{ kind: "field", name, value }];
4876
+ }
4877
+ function calleeOf(expression, originOf) {
4878
+ const callee = peelValue(expression);
4879
+ if (Node16.isPropertyAccessExpression(callee)) {
4880
+ return {
4881
+ receiver: callee.getExpression(),
4882
+ name: callee.getName(),
4883
+ origin: () => originOf(callee)
4884
+ };
4885
+ }
4886
+ if (Node16.isIdentifier(callee)) {
4887
+ return {
4888
+ receiver: null,
4889
+ name: callee.getText(),
4890
+ origin: () => originOf(callee)
4891
+ };
4892
+ }
4893
+ return { receiver: null, name: null, origin: () => null };
4894
+ }
4895
+ function memberChainOf(node) {
4896
+ const names = [];
4897
+ let current2 = peelValue(node);
4898
+ while (Node16.isPropertyAccessExpression(current2)) {
4899
+ names.unshift(current2.getName());
4900
+ current2 = peelValue(current2.getExpression());
4901
+ }
4902
+ if (!Node16.isIdentifier(current2)) {
4903
+ return null;
4904
+ }
4905
+ return { root: current2, names: [current2.getText(), ...names] };
4906
+ }
4907
+ function statementOf2(node) {
4908
+ if (Node16.isVariableStatement(node)) {
4909
+ return {
4910
+ kind: "declare",
4911
+ bindings: node.getDeclarationList().getDeclarations().flatMap(
4912
+ (declaration) => declarationsOf2(
4913
+ declaration.getNameNode(),
4914
+ declaration.getInitializer() ?? null
4915
+ )
4916
+ )
4917
+ };
4918
+ }
4919
+ if (Node16.isExpressionStatement(node)) {
4920
+ const expression = peelValue(node.getExpression());
4921
+ if (Node16.isBinaryExpression(expression)) {
4922
+ const operator = expression.getOperatorToken().getText();
4923
+ if (ASSIGNMENT_OPERATORS.has(operator)) {
4924
+ return {
4925
+ kind: "assign",
4926
+ target: expression.getLeft(),
4927
+ operator: operator === "=" ? null : operator.slice(0, -1),
4928
+ value: expression.getRight()
4929
+ };
4930
+ }
4931
+ }
4932
+ return { kind: "expression", value: node.getExpression() };
4933
+ }
4934
+ if (Node16.isIfStatement(node)) {
4935
+ const otherwise = node.getElseStatement();
4936
+ return {
4937
+ kind: "branch",
4938
+ condition: node.getExpression(),
4939
+ arms: [
4940
+ armOf(node.getThenStatement()),
4941
+ otherwise === void 0 ? [] : armOf(otherwise)
4942
+ ]
4943
+ };
4944
+ }
4945
+ if (Node16.isSwitchStatement(node)) {
4946
+ return {
4947
+ kind: "branch",
4948
+ condition: null,
4949
+ arms: node.getClauses().map((clause) => clause.getStatements())
4950
+ };
4951
+ }
4952
+ if (Node16.isIterationStatement(node)) {
4953
+ return { kind: "loop", body: armOf(node.getStatement()) };
4954
+ }
4955
+ if (Node16.isReturnStatement(node)) {
4956
+ return { kind: "return", value: node.getExpression() ?? null };
4957
+ }
4958
+ if (Node16.isBlock(node)) {
4959
+ return { kind: "block", body: node.getStatements() };
4960
+ }
4961
+ if (Node16.isTryStatement(node)) {
4962
+ return {
4963
+ kind: "block",
4964
+ body: [
4965
+ ...node.getTryBlock().getStatements(),
4966
+ ...node.getFinallyBlock()?.getStatements() ?? []
4967
+ ]
4968
+ };
4969
+ }
4970
+ return { kind: "opaque" };
4971
+ }
4972
+ function armOf(statement) {
4973
+ return Node16.isBlock(statement) ? statement.getStatements() : [statement];
4974
+ }
4975
+ function declarationsOf2(nameNode, value) {
4976
+ if (Node16.isIdentifier(nameNode)) {
4977
+ return [{ name: nameNode.getText(), value }];
4978
+ }
4979
+ if (Node16.isObjectBindingPattern(nameNode) || Node16.isArrayBindingPattern(nameNode)) {
4980
+ return nameNode.getElements().flatMap(
4981
+ (element) => Node16.isBindingElement(element) ? declarationsOf2(element.getNameNode(), null) : []
4982
+ );
4983
+ }
4984
+ return [];
4985
+ }
4986
+ function isRoot(node) {
4987
+ return Node16.isSourceFile(node) || Node16.isFunctionLikeDeclaration(node);
4988
+ }
4989
+ function isStandaloneBlock(node) {
4990
+ const parent = node.getParent();
4991
+ return parent !== void 0 && (Node16.isBlock(parent) || Node16.isSourceFile(parent) || Node16.isModuleBlock(parent) || Node16.isCaseClause(parent) || Node16.isDefaultClause(parent));
4992
+ }
4993
+ function isPathStatement(node) {
4994
+ if (Node16.isBlock(node)) {
4995
+ return isStandaloneBlock(node);
4996
+ }
4997
+ return Node16.isStatement(node) && !Node16.isFunctionDeclaration(node);
4998
+ }
4999
+ function siteOf(node) {
5000
+ const path14 = [];
5001
+ let current2 = node;
5002
+ for (; ; ) {
5003
+ const parent = current2.getParent();
5004
+ if (parent === void 0) {
5005
+ return null;
5006
+ }
5007
+ if (isPathStatement(current2)) {
5008
+ path14.unshift(current2);
5009
+ }
5010
+ if (isRoot(parent)) {
5011
+ return { root: parent, path: path14 };
5012
+ }
5013
+ current2 = parent;
5014
+ }
5015
+ }
5016
+ function functionOf(node) {
5017
+ if (Node16.isSourceFile(node)) {
5018
+ return { parameters: [], body: node.getStatements() };
5019
+ }
5020
+ if (!Node16.isFunctionLikeDeclaration(node)) {
5021
+ return null;
5022
+ }
5023
+ const parameters = node.getParameters().flatMap((parameter) => {
5024
+ const nameNode = parameter.getNameNode();
5025
+ return Node16.isIdentifier(nameNode) ? [
5026
+ {
5027
+ name: nameNode.getText(),
5028
+ default: parameter.getInitializer() ?? null
5029
+ }
5030
+ ] : [];
5031
+ });
5032
+ const body = Node16.isBodied(node) ? node.getBody() : Node16.isBodyable(node) ? node.getBody() : void 0;
5033
+ if (body === void 0) {
5034
+ return { parameters, body: [] };
5035
+ }
5036
+ return Node16.isBlock(body) ? { parameters, body: body.getStatements() } : { parameters, body: { expression: body } };
5037
+ }
5038
+ function namesMutatedInNestedFunctions(root) {
5039
+ const mutated = /* @__PURE__ */ new Set();
5040
+ root.forEachDescendant((descendant) => {
5041
+ const written = writtenNameOf(descendant);
5042
+ if (written !== null && enclosingRootOf(descendant) !== root) {
5043
+ mutated.add(written);
5044
+ }
5045
+ });
5046
+ return mutated;
5047
+ }
5048
+ function writtenNameOf(node) {
5049
+ if (Node16.isBinaryExpression(node)) {
5050
+ const target = peelValue(node.getLeft());
5051
+ return ASSIGNMENT_OPERATORS.has(node.getOperatorToken().getText()) && Node16.isIdentifier(target) ? target.getText() : null;
5052
+ }
5053
+ if (Node16.isPostfixUnaryExpression(node) || Node16.isPrefixUnaryExpression(node)) {
5054
+ const operand2 = peelValue(node.getOperand());
5055
+ return Node16.isIdentifier(operand2) ? operand2.getText() : null;
5056
+ }
5057
+ if (Node16.isCallExpression(node)) {
5058
+ const callee = peelValue(node.getExpression());
5059
+ if (!Node16.isPropertyAccessExpression(callee)) {
5060
+ return null;
5061
+ }
5062
+ const receiver = peelValue(callee.getExpression());
5063
+ return MUTATING_METHODS.has(callee.getName()) && Node16.isIdentifier(receiver) ? receiver.getText() : null;
5064
+ }
5065
+ return null;
5066
+ }
5067
+ function enclosingRootOf(node) {
5068
+ let current2 = node.getParent();
5069
+ while (current2 !== void 0 && !isRoot(current2)) {
5070
+ current2 = current2.getParent();
5071
+ }
5072
+ return current2;
5073
+ }
5074
+ function freeNamesOf(fn) {
5075
+ const declared = /* @__PURE__ */ new Set();
5076
+ const read2 = /* @__PURE__ */ new Set();
5077
+ fn.forEachDescendant((descendant) => {
5078
+ if (!Node16.isIdentifier(descendant)) {
5079
+ return;
5080
+ }
5081
+ const parent = descendant.getParent();
5082
+ if (Node16.isPropertyAccessExpression(parent) && parent.getNameNode() === descendant) {
5083
+ return;
5084
+ }
5085
+ if (Node16.isVariableDeclaration(parent) || Node16.isParameterDeclaration(parent) || Node16.isBindingElement(parent) || Node16.isFunctionDeclaration(parent)) {
5086
+ declared.add(descendant.getText());
5087
+ return;
5088
+ }
5089
+ if (Node16.isPropertyAssignment(parent) && parent.getNameNode() === descendant) {
5090
+ return;
5091
+ }
5092
+ read2.add(descendant.getText());
5093
+ });
5094
+ return [...read2].filter((name) => !declared.has(name));
5095
+ }
5096
+
5097
+ // src/values/rows.ts
5098
+ import {
5099
+ appended,
5100
+ concat,
5101
+ constant,
5102
+ equals,
5103
+ extended,
5104
+ fallback,
5105
+ isPresent,
5106
+ joined,
5107
+ joinedPath,
5108
+ negated,
5109
+ operand,
5110
+ plus,
5111
+ readableFallback,
5112
+ truthOf
5113
+ } from "@suss/values";
5114
+ var PATH_MODULES = ["path", "node:path", "path/posix", "node:path/posix"];
5115
+ var operatorRows = [
5116
+ {
5117
+ kind: "operator",
5118
+ operator: "+",
5119
+ arity: 2,
5120
+ apply: ([a, b]) => plus(operand(a), operand(b))
5121
+ },
5122
+ {
5123
+ kind: "operator",
5124
+ operator: "===",
5125
+ arity: 2,
5126
+ apply: ([a, b]) => equals(operand(a), operand(b))
5127
+ },
5128
+ {
5129
+ kind: "operator",
5130
+ operator: "==",
5131
+ arity: 2,
5132
+ apply: ([a, b]) => equals(operand(a), operand(b))
5133
+ },
5134
+ {
5135
+ kind: "operator",
5136
+ operator: "!==",
5137
+ arity: 2,
5138
+ apply: ([a, b]) => negated(equals(operand(a), operand(b)))
5139
+ },
5140
+ {
5141
+ kind: "operator",
5142
+ operator: "!=",
5143
+ arity: 2,
5144
+ apply: ([a, b]) => negated(equals(operand(a), operand(b)))
5145
+ },
5146
+ {
5147
+ kind: "operator",
5148
+ operator: "!",
5149
+ arity: 1,
5150
+ apply: ([a]) => negated(operand(a))
5151
+ },
5152
+ {
5153
+ kind: "operator",
5154
+ operator: "??",
5155
+ arity: 2,
5156
+ apply: ([a, b]) => readableFallback(operand(a), operand(b), isPresent)
5157
+ },
5158
+ {
5159
+ kind: "operator",
5160
+ operator: "||",
5161
+ arity: 2,
5162
+ apply: ([a, b]) => readableFallback(operand(a), operand(b), truthOf)
5163
+ },
5164
+ {
5165
+ kind: "operator",
5166
+ operator: "&&",
5167
+ arity: 2,
5168
+ apply: ([a, b]) => fallback(operand(a), operand(b), (left) => {
5169
+ const truth = truthOf(left);
5170
+ return truth === null ? null : !truth;
5171
+ })
5172
+ }
5173
+ ];
5174
+ var stringRows = [
5175
+ {
5176
+ kind: "method",
5177
+ method: "toString",
5178
+ on: "string",
5179
+ apply: () => ({ result: "receiver" })
5180
+ },
5181
+ {
5182
+ kind: "method",
5183
+ method: "toString",
5184
+ on: "constant",
5185
+ apply: ({ receiver }) => ({ result: concat([operand(receiver)]) })
5186
+ },
5187
+ {
5188
+ kind: "method",
5189
+ method: "concat",
5190
+ on: "string",
5191
+ apply: ({ receiver, args }) => ({
5192
+ result: concat([operand(receiver), ...args])
5193
+ })
5194
+ }
5195
+ ];
5196
+ var sequenceRows = ["sequence", "unbounded"].flatMap((on) => [
5197
+ {
5198
+ kind: "method",
5199
+ method: "push",
5200
+ on,
5201
+ apply: ({ receiver, args }) => ({
5202
+ result: constant(0),
5203
+ receiver: appended(operand(receiver), args)
5204
+ })
5205
+ },
5206
+ {
5207
+ kind: "method",
5208
+ method: "concat",
5209
+ on,
5210
+ apply: ({ receiver, args, contentOf }) => ({
5211
+ result: args.reduce(
5212
+ (sequence, other) => extended(sequence, contentOf(other)),
5213
+ operand(receiver)
5214
+ )
5215
+ })
5216
+ },
5217
+ {
5218
+ kind: "method",
5219
+ method: "join",
5220
+ on,
5221
+ apply: ({ receiver, args }) => ({
5222
+ result: joined(operand(receiver), args[0])
5223
+ })
5224
+ }
5225
+ ]);
5226
+ var calleeRows = [
5227
+ {
5228
+ kind: "callee",
5229
+ origin: { module: "global", name: "String" },
5230
+ apply: ({ args }) => ({ result: concat([operand(args[0])]) })
5231
+ },
5232
+ ...PATH_MODULES.map(
5233
+ (module) => ({
5234
+ kind: "callee",
5235
+ origin: { module, name: "join" },
5236
+ apply: ({ args }) => ({ result: joinedPath(args) })
5237
+ })
5238
+ )
5239
+ ];
5240
+ var typescriptRows = [
5241
+ ...operatorRows,
5242
+ ...stringRows,
5243
+ ...sequenceRows,
5244
+ ...calleeRows
5245
+ ];
5246
+
5247
+ // src/values/evaluator.ts
5248
+ var evaluators = /* @__PURE__ */ new WeakMap();
5249
+ function evaluatorFor(node, resolution) {
5250
+ const key = resolution ?? node.getProject();
5251
+ let evaluator = evaluators.get(key);
5252
+ if (evaluator === void 0) {
5253
+ evaluator = new Evaluator(
5254
+ typescriptLowering(
5255
+ resolution === void 0 ? { rows: typescriptRows } : { resolution, rows: typescriptRows }
5256
+ )
5257
+ );
5258
+ evaluators.set(key, evaluator);
5259
+ }
5260
+ return evaluator;
5261
+ }
5262
+ function evaluatedValue(node, resolution) {
5263
+ return force(evaluatorFor(node, resolution).evaluate(node));
5264
+ }
4650
5265
 
4651
5266
  // src/discovery/resolveValue.ts
4652
- import { Node as Node16 } from "ts-morph";
4653
5267
  function couldNameAValue(value) {
4654
- return Node16.isIdentifier(value) || Node16.isPropertyAccessExpression(value) || Node16.isElementAccessExpression(value) || Node16.isCallExpression(value);
5268
+ return Node17.isIdentifier(value) || Node17.isPropertyAccessExpression(value) || Node17.isElementAccessExpression(value) || Node17.isCallExpression(value);
4655
5269
  }
4656
5270
  function propertyValueOf(property) {
4657
- if (Node16.isPropertyAssignment(property)) {
5271
+ if (Node17.isPropertyAssignment(property)) {
4658
5272
  return property.getInitializer() ?? null;
4659
5273
  }
4660
- if (Node16.isShorthandPropertyAssignment(property)) {
5274
+ if (Node17.isShorthandPropertyAssignment(property)) {
4661
5275
  return property.getNameNode();
4662
5276
  }
4663
5277
  return null;
@@ -4678,7 +5292,7 @@ function objectLiteralOf(value, resolution) {
4678
5292
  return literalValueOf(
4679
5293
  value,
4680
5294
  resolution,
4681
- (node) => Node16.isObjectLiteralExpression(node)
5295
+ (node) => Node17.isObjectLiteralExpression(node)
4682
5296
  );
4683
5297
  }
4684
5298
  function propertiesOf(object, resolution) {
@@ -4690,7 +5304,7 @@ function propertiesReached(object, resolution, seen) {
4690
5304
  }
4691
5305
  seen.add(object);
4692
5306
  return object.getProperties().flatMap((property) => {
4693
- if (!Node16.isSpreadAssignment(property)) {
5307
+ if (!Node17.isSpreadAssignment(property)) {
4694
5308
  return [property];
4695
5309
  }
4696
5310
  const spread = objectLiteralOf(property.getExpression(), resolution);
@@ -4699,17 +5313,17 @@ function propertiesReached(object, resolution, seen) {
4699
5313
  }
4700
5314
  function writtenNodeOf(value, resolution) {
4701
5315
  const written = factKeyOf(value);
4702
- if (Node16.isNewExpression(written)) {
5316
+ if (Node17.isNewExpression(written)) {
4703
5317
  return written;
4704
5318
  }
4705
- if (Node16.isCallExpression(written)) {
5319
+ if (Node17.isCallExpression(written)) {
4706
5320
  return writtenThroughCall(written, resolution);
4707
5321
  }
4708
5322
  if (resolution === void 0 || !couldNameAValue(written)) {
4709
5323
  return null;
4710
5324
  }
4711
5325
  const resolved = resolution.resolveWrittenValue(written);
4712
- return resolved !== null && Node16.isCallExpression(resolved) ? writtenThroughCall(resolved, resolution) : resolved;
5326
+ return resolved !== null && Node17.isCallExpression(resolved) ? writtenThroughCall(resolved, resolution) : resolved;
4713
5327
  }
4714
5328
  function writtenThroughCall(call, resolution) {
4715
5329
  if (resolution !== void 0 && resolution.resolveCallable(call.getExpression()) !== null) {
@@ -4721,24 +5335,21 @@ function writtenThroughCall(call, resolution) {
4721
5335
  return call;
4722
5336
  }
4723
5337
  function stringValueOf(value, resolution) {
4724
- const written = factKeyOf(value);
4725
- if (isStringNode(written)) {
4726
- return written.getLiteralValue();
4727
- }
4728
- if (resolution === void 0 || !couldNameAValue(written)) {
5338
+ return literalOf(evaluatedValue(value, resolution));
5339
+ }
5340
+ function stringPropertyOf(object, name, resolution) {
5341
+ const record2 = evaluatedValue(object, resolution);
5342
+ if (record2.kind !== "record") {
4729
5343
  return null;
4730
5344
  }
4731
- const resolved = resolution.resolveWrittenValue(written);
4732
- return resolved !== null && isStringNode(resolved) ? resolved.getLiteralValue() : null;
4733
- }
4734
- function isStringNode(node) {
4735
- return Node16.isStringLiteral(node) || Node16.isNoSubstitutionTemplateLiteral(node);
5345
+ const field = record2.fields.get(name);
5346
+ return field === void 0 ? null : literalOf(force2(field.value));
4736
5347
  }
4737
5348
  function arrayLiteralOf(value, resolution) {
4738
5349
  return literalValueOf(
4739
5350
  value,
4740
5351
  resolution,
4741
- (node) => Node16.isArrayLiteralExpression(node)
5352
+ (node) => Node17.isArrayLiteralExpression(node)
4742
5353
  );
4743
5354
  }
4744
5355
  function literalValueOf(value, resolution, isWanted) {
@@ -4761,26 +5372,26 @@ function discoverClientCalls(sourceFile, match, kind, resolution) {
4761
5372
  if (!isGlobal) {
4762
5373
  for (const varDecl of sourceFile.getVariableDeclarations()) {
4763
5374
  const init = varDecl.getInitializer();
4764
- if (init !== void 0 && (Node17.isCallExpression(init) || Node17.isNewExpression(init)) && isCreationCall(init, match, resolution)) {
5375
+ if (init !== void 0 && (Node18.isCallExpression(init) || Node18.isNewExpression(init)) && isCreationCall(init, match, resolution)) {
4765
5376
  clientVarNames.add(varDecl.getName());
4766
5377
  }
4767
5378
  }
4768
5379
  }
4769
5380
  const methodFilter = match.methodFilter !== void 0 ? new Set(match.methodFilter) : null;
4770
5381
  sourceFile.forEachDescendant((node) => {
4771
- if (!Node17.isCallExpression(node)) {
5382
+ if (!Node18.isCallExpression(node)) {
4772
5383
  return;
4773
5384
  }
4774
5385
  const callee = node.getExpression();
4775
5386
  let methodName = null;
4776
5387
  let matched = false;
4777
- if (isGlobal && Node17.isIdentifier(callee)) {
5388
+ if (isGlobal && Node18.isIdentifier(callee)) {
4778
5389
  if (callee.getText() === match.importName) {
4779
5390
  matched = true;
4780
5391
  }
4781
- } else if (Node17.isPropertyAccessExpression(callee)) {
5392
+ } else if (Node18.isPropertyAccessExpression(callee)) {
4782
5393
  const subject = callee.getExpression();
4783
- if (Node17.isIdentifier(subject) && (isClientImport(subject, match, resolution, true) || clientVarNames.has(subject.getText())) || resolvesToKnownInstance(subject, match, resolution)) {
5394
+ if (Node18.isIdentifier(subject) && (isClientImport(subject, match, resolution, true) || clientVarNames.has(subject.getText())) || resolvesToKnownInstance(subject, match, resolution)) {
4784
5395
  methodName = callee.getName();
4785
5396
  if (methodFilter === null || methodFilter.has(methodName)) {
4786
5397
  matched = true;
@@ -4814,16 +5425,16 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
4814
5425
  );
4815
5426
  const constructedHere = /* @__PURE__ */ new Set();
4816
5427
  sourceFile.forEachDescendant((node) => {
4817
- if (Node17.isVariableDeclaration(node)) {
5428
+ if (Node18.isVariableDeclaration(node)) {
4818
5429
  const init = node.getInitializer();
4819
- if (init !== void 0 && (Node17.isCallExpression(init) || Node17.isNewExpression(init)) && isCreationCall(init, match, resolution) || localName !== null && typedAsClient(node.getTypeNode(), localName)) {
5430
+ if (init !== void 0 && (Node18.isCallExpression(init) || Node18.isNewExpression(init)) && isCreationCall(init, match, resolution) || localName !== null && typedAsClient(node.getTypeNode(), localName)) {
4820
5431
  constructedHere.add(node.getName());
4821
5432
  }
4822
5433
  return;
4823
5434
  }
4824
- if (Node17.isParameterDeclaration(node) && localName !== null && typedAsClient(node.getTypeNode(), localName)) {
5435
+ if (Node18.isParameterDeclaration(node) && localName !== null && typedAsClient(node.getTypeNode(), localName)) {
4825
5436
  const written = node.getNameNode();
4826
- if (Node17.isIdentifier(written)) {
5437
+ if (Node18.isIdentifier(written)) {
4827
5438
  constructedHere.add(written.getText());
4828
5439
  }
4829
5440
  }
@@ -4834,10 +5445,10 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
4834
5445
  importName: match.importName,
4835
5446
  ...match.factoryMethods === void 0 ? {} : { factoryMethods: match.factoryMethods }
4836
5447
  };
4837
- return (subject) => isClientImport(subject, match, resolution, true) || Node17.isIdentifier(subject) && constructedHere.has(subject.getText()) || resolvesToKnownInstance(subject, full, resolution);
5448
+ return (subject) => isClientImport(subject, match, resolution, true) || Node18.isIdentifier(subject) && constructedHere.has(subject.getText()) || resolvesToKnownInstance(subject, full, resolution);
4838
5449
  }
4839
5450
  function typedAsClient(typeNode, localName) {
4840
- if (typeNode === void 0 || !Node17.isTypeReference(typeNode)) {
5451
+ if (typeNode === void 0 || !Node18.isTypeReference(typeNode)) {
4841
5452
  return false;
4842
5453
  }
4843
5454
  return typeNode.getTypeName().getText() === localName;
@@ -4847,27 +5458,27 @@ function resolvesToKnownInstance(subject, match, resolution) {
4847
5458
  return false;
4848
5459
  }
4849
5460
  const written = writtenNodeOf(subject, resolution);
4850
- if (written === null || !Node17.isCallExpression(written) && !Node17.isNewExpression(written)) {
5461
+ if (written === null || !Node18.isCallExpression(written) && !Node18.isNewExpression(written)) {
4851
5462
  return false;
4852
5463
  }
4853
5464
  return isCreationCall(written, match, resolution);
4854
5465
  }
4855
5466
  function isCreationCall(call, match, resolution) {
4856
5467
  const callee = call.getExpression();
4857
- if (Node17.isIdentifier(callee)) {
5468
+ if (Node18.isIdentifier(callee)) {
4858
5469
  return isClientImport(callee, match, resolution, false);
4859
5470
  }
4860
- if (!Node17.isPropertyAccessExpression(callee)) {
5471
+ if (!Node18.isPropertyAccessExpression(callee)) {
4861
5472
  return false;
4862
5473
  }
4863
5474
  const base = callee.getExpression();
4864
- return Node17.isIdentifier(base) && (match.factoryMethods?.includes(callee.getName()) ?? false) && isClientImport(base, match, resolution, false);
5475
+ return Node18.isIdentifier(base) && (match.factoryMethods?.includes(callee.getName()) ?? false) && isClientImport(base, match, resolution, false);
4865
5476
  }
4866
5477
  function isPathShaped(specifier) {
4867
5478
  return specifier.startsWith(".") || specifier.startsWith("/");
4868
5479
  }
4869
5480
  function isClientImport(subject, match, resolution, strictDefaultName) {
4870
- if (!Node17.isIdentifier(subject)) {
5481
+ if (!Node18.isIdentifier(subject)) {
4871
5482
  return false;
4872
5483
  }
4873
5484
  if (resolution === void 0) {
@@ -4915,27 +5526,27 @@ function resolvedImportLocalName(sourceFile, importModule, importName, strictDef
4915
5526
  return null;
4916
5527
  }
4917
5528
  function clientUnitName(enclosingFunc, methodName) {
4918
- if (Node17.isFunctionDeclaration(enclosingFunc)) {
5529
+ if (Node18.isFunctionDeclaration(enclosingFunc)) {
4919
5530
  return enclosingFunc.getName() ?? methodName ?? "anonymous";
4920
5531
  }
4921
- if (Node17.isMethodDeclaration(enclosingFunc)) {
5532
+ if (Node18.isMethodDeclaration(enclosingFunc)) {
4922
5533
  return enclosingFunc.getName();
4923
5534
  }
4924
5535
  const parent = enclosingFunc.getParent();
4925
- if (parent !== void 0 && Node17.isVariableDeclaration(parent)) {
5536
+ if (parent !== void 0 && Node18.isVariableDeclaration(parent)) {
4926
5537
  return parent.getName();
4927
5538
  }
4928
- if (parent !== void 0 && Node17.isPropertyAssignment(parent)) {
5539
+ if (parent !== void 0 && Node18.isPropertyAssignment(parent)) {
4929
5540
  return parent.getName();
4930
5541
  }
4931
5542
  return methodName ?? "anonymous";
4932
5543
  }
4933
5544
 
4934
5545
  // src/discovery/decoratedMethod.ts
4935
- import { Node as Node20 } from "ts-morph";
5546
+ import { Node as Node21 } from "ts-morph";
4936
5547
 
4937
5548
  // src/discovery/decoratedMembers.ts
4938
- import { Node as Node18 } from "ts-morph";
5549
+ import { Node as Node19 } from "ts-morph";
4939
5550
  function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
4940
5551
  const localToCanonical = /* @__PURE__ */ new Map();
4941
5552
  for (const importDecl of sourceFile.getImportDeclarations()) {
@@ -4955,7 +5566,7 @@ function importedDecoratorLocals(sourceFile, acceptedModules, canonicalNames) {
4955
5566
  function decoratedCallablesOf(cls, decoratorNames) {
4956
5567
  const callables = [];
4957
5568
  for (const member of cls.getMembers()) {
4958
- if (!Node18.isMethodDeclaration(member) && !Node18.isPropertyDeclaration(member)) {
5569
+ if (!Node19.isMethodDeclaration(member) && !Node19.isPropertyDeclaration(member)) {
4959
5570
  continue;
4960
5571
  }
4961
5572
  const func = callableOf(member);
@@ -4979,7 +5590,7 @@ function decoratedCallablesOf(cls, decoratorNames) {
4979
5590
  return callables;
4980
5591
  }
4981
5592
  function callableOf(member) {
4982
- if (Node18.isMethodDeclaration(member)) {
5593
+ if (Node19.isMethodDeclaration(member)) {
4983
5594
  return toFunctionRoot(member);
4984
5595
  }
4985
5596
  const held = member.getInitializer();
@@ -4987,7 +5598,7 @@ function callableOf(member) {
4987
5598
  }
4988
5599
 
4989
5600
  // src/discovery/decoratorComposition.ts
4990
- import { Node as Node19, SyntaxKind as SyntaxKind5 } from "ts-morph";
5601
+ import { Node as Node20, SyntaxKind as SyntaxKind6 } from "ts-morph";
4991
5602
  function classDecoratorStandingFor(cls, names, modules, resolution) {
4992
5603
  for (const candidate of names) {
4993
5604
  const decorator = cls.getDecorator(candidate);
@@ -5003,7 +5614,7 @@ function classDecoratorStandingFor(cls, names, modules, resolution) {
5003
5614
  return null;
5004
5615
  }
5005
5616
  for (const decorator of cls.getDecorators()) {
5006
- const applied = resolution.importedNamesOf(calleeOf(decorator), modules);
5617
+ const applied = resolution.importedNamesOf(calleeOf2(decorator), modules);
5007
5618
  const standsFor = names.find((name) => applied.includes(name));
5008
5619
  if (standsFor === void 0) {
5009
5620
  continue;
@@ -5021,11 +5632,11 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
5021
5632
  if (atClass.length > 0) {
5022
5633
  return atClass;
5023
5634
  }
5024
- const wrapper = resolution.resolveCallable(calleeOf(decorator));
5635
+ const wrapper = resolution.resolveCallable(calleeOf2(decorator));
5025
5636
  if (wrapper === null) {
5026
5637
  return atClass;
5027
5638
  }
5028
- for (const call of wrapper.getDescendantsOfKind(SyntaxKind5.CallExpression)) {
5639
+ for (const call of wrapper.getDescendantsOfKind(SyntaxKind6.CallExpression)) {
5029
5640
  const names = resolution.importedNamesOf(call.getExpression(), modules);
5030
5641
  if (!names.includes(standsFor)) {
5031
5642
  continue;
@@ -5036,17 +5647,17 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
5036
5647
  return atClass;
5037
5648
  }
5038
5649
  function statesAValue(arg, wrapper) {
5039
- const identifiers = Node19.isIdentifier(arg) ? [arg] : arg.getDescendantsOfKind(SyntaxKind5.Identifier);
5650
+ const identifiers = Node20.isIdentifier(arg) ? [arg] : arg.getDescendantsOfKind(SyntaxKind6.Identifier);
5040
5651
  return !identifiers.some(
5041
5652
  (identifier) => identifier.getSymbol()?.getDeclarations().some(
5042
- (declaration) => Node19.isParameterDeclaration(declaration) && isWithin(declaration, wrapper)
5653
+ (declaration) => Node20.isParameterDeclaration(declaration) && isWithin(declaration, wrapper)
5043
5654
  )
5044
5655
  );
5045
5656
  }
5046
5657
  function isWithin(node, container) {
5047
5658
  return node.getSourceFile() === container.getSourceFile() && node.getStart() >= container.getStart() && node.getEnd() <= container.getEnd();
5048
5659
  }
5049
- function calleeOf(decorator) {
5660
+ function calleeOf2(decorator) {
5050
5661
  const call = decorator.getCallExpression();
5051
5662
  if (call !== void 0) {
5052
5663
  return call.getExpression();
@@ -5059,39 +5670,39 @@ function resolverTypeName(args) {
5059
5670
  return args.typeMap[args.decoratorName] ?? args.classTypeName ?? null;
5060
5671
  }
5061
5672
  function resolveResolverClassTypeName(decoratorArg) {
5062
- if (Node20.isArrowFunction(decoratorArg)) {
5673
+ if (Node21.isArrowFunction(decoratorArg)) {
5063
5674
  const body = decoratorArg.getBody();
5064
- if (Node20.isIdentifier(body)) {
5675
+ if (Node21.isIdentifier(body)) {
5065
5676
  return body.getText();
5066
5677
  }
5067
5678
  return null;
5068
5679
  }
5069
- if (Node20.isStringLiteral(decoratorArg)) {
5680
+ if (Node21.isStringLiteral(decoratorArg)) {
5070
5681
  return decoratorArg.getLiteralValue();
5071
5682
  }
5072
- if (Node20.isIdentifier(decoratorArg)) {
5683
+ if (Node21.isIdentifier(decoratorArg)) {
5073
5684
  return decoratorArg.getText();
5074
5685
  }
5075
5686
  return null;
5076
5687
  }
5077
5688
  function resolveOperationNameOverride(decorator) {
5078
- if (!Node20.isDecorator(decorator)) {
5689
+ if (!Node21.isDecorator(decorator)) {
5079
5690
  return null;
5080
5691
  }
5081
5692
  const args = decorator.getArguments();
5082
5693
  for (const arg of args) {
5083
- if (!Node20.isObjectLiteralExpression(arg)) {
5694
+ if (!Node21.isObjectLiteralExpression(arg)) {
5084
5695
  continue;
5085
5696
  }
5086
5697
  const prop = arg.getProperty("name");
5087
- if (prop === void 0 || !Node20.isPropertyAssignment(prop)) {
5698
+ if (prop === void 0 || !Node21.isPropertyAssignment(prop)) {
5088
5699
  continue;
5089
5700
  }
5090
5701
  const init = prop.getInitializer();
5091
5702
  if (init === void 0) {
5092
5703
  continue;
5093
5704
  }
5094
- if (Node20.isStringLiteral(init) || Node20.isNoSubstitutionTemplateLiteral(init)) {
5705
+ if (Node21.isStringLiteral(init) || Node21.isNoSubstitutionTemplateLiteral(init)) {
5095
5706
  return init.getLiteralValue();
5096
5707
  }
5097
5708
  }
@@ -5144,9 +5755,9 @@ function discoverDecoratedMethods(sourceFile, match, kind, resolution) {
5144
5755
  }
5145
5756
 
5146
5757
  // src/discovery/decoratedRoute.ts
5147
- import { Node as Node21 } from "ts-morph";
5758
+ import { Node as Node22 } from "ts-morph";
5148
5759
  function resolveRoutePathArg(decorator, resolution) {
5149
- if (!Node21.isDecorator(decorator)) {
5760
+ if (!Node22.isDecorator(decorator)) {
5150
5761
  return "";
5151
5762
  }
5152
5763
  return routePathOf(decorator.getArguments(), resolution);
@@ -5174,7 +5785,7 @@ function declaredChannelOf(source, decorator, resolution) {
5174
5785
  if (source.from === "unstated") {
5175
5786
  return null;
5176
5787
  }
5177
- if (!Node21.isDecorator(decorator)) {
5788
+ if (!Node22.isDecorator(decorator)) {
5178
5789
  return null;
5179
5790
  }
5180
5791
  const arg = decorator.getArguments()[source.position];
@@ -5185,7 +5796,7 @@ function declaredChannelOf(source, decorator, resolution) {
5185
5796
  return text === null || text === "" ? null : text;
5186
5797
  }
5187
5798
  function literalStringOf(node, resolution) {
5188
- if (Node21.isStringLiteral(node) || Node21.isNoSubstitutionTemplateLiteral(node)) {
5799
+ if (Node22.isStringLiteral(node) || Node22.isNoSubstitutionTemplateLiteral(node)) {
5189
5800
  return node.getLiteralValue();
5190
5801
  }
5191
5802
  const written = resolution?.resolveWrittenValue(node) ?? null;
@@ -5256,32 +5867,32 @@ import picomatch from "picomatch";
5256
5867
 
5257
5868
  // src/discovery/namedExport.ts
5258
5869
  import {
5259
- Node as Node22
5870
+ Node as Node23
5260
5871
  } from "ts-morph";
5261
5872
  function nameWrittenAt(expression) {
5262
- if (Node22.isIdentifier(expression)) {
5873
+ if (Node23.isIdentifier(expression)) {
5263
5874
  return expression.getText();
5264
5875
  }
5265
- if (Node22.isPropertyAccessExpression(expression)) {
5876
+ if (Node23.isPropertyAccessExpression(expression)) {
5266
5877
  return expression.getName();
5267
5878
  }
5268
5879
  return null;
5269
5880
  }
5270
5881
  function resolveDefaultExportName(decl, fn) {
5271
- if (Node22.isFunctionDeclaration(fn) || Node22.isFunctionExpression(fn)) {
5882
+ if (Node23.isFunctionDeclaration(fn) || Node23.isFunctionExpression(fn)) {
5272
5883
  const n = fn.getName?.();
5273
5884
  if (typeof n === "string" && n.length > 0) {
5274
5885
  return n;
5275
5886
  }
5276
5887
  }
5277
- if (Node22.isVariableDeclaration(decl)) {
5888
+ if (Node23.isVariableDeclaration(decl)) {
5278
5889
  const name = decl.getName();
5279
5890
  if (name.length > 0) {
5280
5891
  return name;
5281
5892
  }
5282
5893
  }
5283
5894
  const binding = fn.getParent();
5284
- if (binding !== void 0 && Node22.isVariableDeclaration(binding)) {
5895
+ if (binding !== void 0 && Node23.isVariableDeclaration(binding)) {
5285
5896
  const name = binding.getName();
5286
5897
  if (name.length > 0) {
5287
5898
  return name;
@@ -5336,7 +5947,7 @@ function discoverNamedExports(sourceFile, match, kind, resolution) {
5336
5947
  }
5337
5948
  continue;
5338
5949
  }
5339
- if (Node22.isArrowFunction(init) || Node22.isFunctionExpression(init)) {
5950
+ if (Node23.isArrowFunction(init) || Node23.isFunctionExpression(init)) {
5340
5951
  results.push({
5341
5952
  func: init,
5342
5953
  kind,
@@ -5445,7 +6056,7 @@ function discoverFileConventions(sourceFile, match, kind, resolution) {
5445
6056
  }
5446
6057
 
5447
6058
  // src/discovery/graphqlHookCall.ts
5448
- import { Node as Node25 } from "ts-morph";
6059
+ import { Node as Node26 } from "ts-morph";
5449
6060
 
5450
6061
  // src/discovery/graphqlShared.ts
5451
6062
  import fs2 from "fs";
@@ -5455,7 +6066,7 @@ import {
5455
6066
  parse as graphqlParse,
5456
6067
  print as graphqlPrint
5457
6068
  } from "graphql";
5458
- import { Node as Node23 } from "ts-morph";
6069
+ import { Node as Node24 } from "ts-morph";
5459
6070
  var DOCUMENT_TAGS = /* @__PURE__ */ new Set(["gql", "graphql"]);
5460
6071
  var UNQUALIFIED_DOCUMENT_TAG = "gql";
5461
6072
  function parseGraphqlOperation(source) {
@@ -5521,10 +6132,10 @@ function startAssembly(resolution) {
5521
6132
  };
5522
6133
  }
5523
6134
  function assembledTemplateText(template, assembly) {
5524
- if (Node23.isNoSubstitutionTemplateLiteral(template)) {
6135
+ if (Node24.isNoSubstitutionTemplateLiteral(template)) {
5525
6136
  return innerTemplateText(template);
5526
6137
  }
5527
- if (!Node23.isTemplateExpression(template)) {
6138
+ if (!Node24.isTemplateExpression(template)) {
5528
6139
  return null;
5529
6140
  }
5530
6141
  let text = template.getHead().getLiteralText();
@@ -5660,7 +6271,7 @@ function collectDanglingSpreads(selectionSet, defined, dangling) {
5660
6271
  }
5661
6272
  }
5662
6273
  function documentTextFromExpression(node, assembly) {
5663
- if (Node23.isTaggedTemplateExpression(node)) {
6274
+ if (Node24.isTaggedTemplateExpression(node)) {
5664
6275
  if (!isDocumentTag(node.getTag())) {
5665
6276
  return null;
5666
6277
  }
@@ -5670,7 +6281,7 @@ function documentTextFromExpression(node, assembly) {
5670
6281
  assembly.seen.add(node);
5671
6282
  return assembledTemplateText(node.getTemplate(), assembly);
5672
6283
  }
5673
- if (!Node23.isCallExpression(node)) {
6284
+ if (!Node24.isCallExpression(node)) {
5674
6285
  return null;
5675
6286
  }
5676
6287
  if (!isDocumentTag(node.getExpression())) {
@@ -5681,7 +6292,7 @@ function documentTextFromExpression(node, assembly) {
5681
6292
  return null;
5682
6293
  }
5683
6294
  const template = stripDocumentNodeCasts(first);
5684
- if (!Node23.isNoSubstitutionTemplateLiteral(template) && !Node23.isTemplateExpression(template)) {
6295
+ if (!Node24.isNoSubstitutionTemplateLiteral(template) && !Node24.isTemplateExpression(template)) {
5685
6296
  return null;
5686
6297
  }
5687
6298
  if (assembly.seen.has(node)) {
@@ -5691,7 +6302,7 @@ function documentTextFromExpression(node, assembly) {
5691
6302
  return assembledTemplateText(template, assembly);
5692
6303
  }
5693
6304
  function isDocumentTag(tag) {
5694
- if (!Node23.isIdentifier(tag)) {
6305
+ if (!Node24.isIdentifier(tag)) {
5695
6306
  return false;
5696
6307
  }
5697
6308
  if (tag.getText() === UNQUALIFIED_DOCUMENT_TAG) {
@@ -5702,14 +6313,14 @@ function isDocumentTag(tag) {
5702
6313
  return false;
5703
6314
  }
5704
6315
  for (const declaration of symbol.getDeclarations()) {
5705
- if (Node23.isImportSpecifier(declaration) && DOCUMENT_TAGS.has(declaration.getName())) {
6316
+ if (Node24.isImportSpecifier(declaration) && DOCUMENT_TAGS.has(declaration.getName())) {
5706
6317
  return true;
5707
6318
  }
5708
6319
  }
5709
6320
  return false;
5710
6321
  }
5711
6322
  function resolveThroughFacts(arg, assembly) {
5712
- if (assembly.resolution === void 0 || !Node23.isIdentifier(arg)) {
6323
+ if (assembly.resolution === void 0 || !Node24.isIdentifier(arg)) {
5713
6324
  return null;
5714
6325
  }
5715
6326
  const written = assembly.resolution.resolveWrittenValue(arg);
@@ -5758,7 +6369,7 @@ function singleLine(text) {
5758
6369
  return collapsed.length > 80 ? `${collapsed.slice(0, 79)}\u2026` : collapsed;
5759
6370
  }
5760
6371
  function importedVariableInitializers(identifier) {
5761
- if (!Node23.isIdentifier(identifier)) {
6372
+ if (!Node24.isIdentifier(identifier)) {
5762
6373
  return [];
5763
6374
  }
5764
6375
  const symbol = identifier.getSymbol();
@@ -5768,7 +6379,7 @@ function importedVariableInitializers(identifier) {
5768
6379
  const resolved = resolveAliasedSymbol(symbol) ?? symbol;
5769
6380
  const inits = [];
5770
6381
  for (const decl of resolved.getDeclarations()) {
5771
- if (Node23.isVariableDeclaration(decl)) {
6382
+ if (Node24.isVariableDeclaration(decl)) {
5772
6383
  const init = decl.getInitializer();
5773
6384
  if (init !== void 0) {
5774
6385
  inits.push(init);
@@ -5782,7 +6393,7 @@ function resolveGqlTemplateText(arg, assembly) {
5782
6393
  if (direct !== null) {
5783
6394
  return direct;
5784
6395
  }
5785
- if (!Node23.isIdentifier(arg)) {
6396
+ if (!Node24.isIdentifier(arg)) {
5786
6397
  return null;
5787
6398
  }
5788
6399
  const symbol = arg.getSymbol();
@@ -5790,7 +6401,7 @@ function resolveGqlTemplateText(arg, assembly) {
5790
6401
  return null;
5791
6402
  }
5792
6403
  for (const decl of symbol.getDeclarations()) {
5793
- if (Node23.isImportClause(decl) || Node23.isImportSpecifier(decl)) {
6404
+ if (Node24.isImportClause(decl) || Node24.isImportSpecifier(decl)) {
5794
6405
  const fromGraphqlFile = resolveGraphqlFileImport(decl);
5795
6406
  if (fromGraphqlFile !== null) {
5796
6407
  return fromGraphqlFile;
@@ -5809,7 +6420,7 @@ function resolveGqlTemplateText(arg, assembly) {
5809
6420
  return null;
5810
6421
  }
5811
6422
  function resolveTypedDocumentSource(arg) {
5812
- if (!Node23.isIdentifier(arg)) {
6423
+ if (!Node24.isIdentifier(arg)) {
5813
6424
  return null;
5814
6425
  }
5815
6426
  for (const init of importedVariableInitializers(arg)) {
@@ -5822,7 +6433,7 @@ function resolveTypedDocumentSource(arg) {
5822
6433
  }
5823
6434
  function typedDocumentSourceOf(node) {
5824
6435
  const inner = stripDocumentNodeCasts(node);
5825
- if (!Node23.isObjectLiteralExpression(inner)) {
6436
+ if (!Node24.isObjectLiteralExpression(inner)) {
5826
6437
  return null;
5827
6438
  }
5828
6439
  const evaluated = evaluateObjectLiteralAsJson(inner);
@@ -5840,7 +6451,7 @@ function typedDocumentSourceOf(node) {
5840
6451
  }
5841
6452
  }
5842
6453
  function resolveTypedDocumentHeader(arg) {
5843
- if (!Node23.isIdentifier(arg)) {
6454
+ if (!Node24.isIdentifier(arg)) {
5844
6455
  return null;
5845
6456
  }
5846
6457
  const reference = arg.getText();
@@ -5850,7 +6461,7 @@ function resolveTypedDocumentHeader(arg) {
5850
6461
  }
5851
6462
  const resolved = resolveAliasedSymbol(symbol) ?? symbol;
5852
6463
  for (const decl of resolved.getDeclarations()) {
5853
- if (!Node23.isVariableDeclaration(decl)) {
6464
+ if (!Node24.isVariableDeclaration(decl)) {
5854
6465
  continue;
5855
6466
  }
5856
6467
  const init = decl.getInitializer();
@@ -5883,10 +6494,10 @@ function resolveTypedDocumentHeader(arg) {
5883
6494
  }
5884
6495
  function documentNodeCastTypeArgs(node) {
5885
6496
  let current2 = node;
5886
- while (Node23.isAsExpression(current2) || Node23.isParenthesizedExpression(current2)) {
5887
- if (Node23.isAsExpression(current2)) {
6497
+ while (Node24.isAsExpression(current2) || Node24.isParenthesizedExpression(current2)) {
6498
+ if (Node24.isAsExpression(current2)) {
5888
6499
  const typeNode = current2.getTypeNode();
5889
- if (typeNode !== void 0 && Node23.isTypeReference(typeNode)) {
6500
+ if (typeNode !== void 0 && Node24.isTypeReference(typeNode)) {
5890
6501
  const name = typeNode.getTypeName().getText();
5891
6502
  const simpleName = name.includes(".") ? name.split(".").pop() ?? name : name;
5892
6503
  if (simpleName === "TypedDocumentNode" || simpleName === "DocumentNode") {
@@ -5899,7 +6510,7 @@ function documentNodeCastTypeArgs(node) {
5899
6510
  return null;
5900
6511
  }
5901
6512
  function operationHeaderFromResultType(typeNode) {
5902
- if (typeNode === void 0 || !Node23.isTypeReference(typeNode)) {
6513
+ if (typeNode === void 0 || !Node24.isTypeReference(typeNode)) {
5903
6514
  return null;
5904
6515
  }
5905
6516
  const name = typeNode.getTypeName().getText();
@@ -5920,16 +6531,16 @@ function operationHeaderFromResultType(typeNode) {
5920
6531
  }
5921
6532
  function stripDocumentNodeCasts(node) {
5922
6533
  let current2 = node;
5923
- while (Node23.isAsExpression(current2) || Node23.isParenthesizedExpression(current2)) {
6534
+ while (Node24.isAsExpression(current2) || Node24.isParenthesizedExpression(current2)) {
5924
6535
  current2 = current2.getExpression();
5925
6536
  }
5926
6537
  return current2;
5927
6538
  }
5928
6539
  function evaluateObjectLiteralAsJson(node) {
5929
- if (Node23.isStringLiteral(node) || Node23.isNoSubstitutionTemplateLiteral(node)) {
6540
+ if (Node24.isStringLiteral(node) || Node24.isNoSubstitutionTemplateLiteral(node)) {
5930
6541
  return node.getLiteralValue();
5931
6542
  }
5932
- if (Node23.isNumericLiteral(node)) {
6543
+ if (Node24.isNumericLiteral(node)) {
5933
6544
  return Number(node.getText());
5934
6545
  }
5935
6546
  const kind = node.getText();
@@ -5942,17 +6553,17 @@ function evaluateObjectLiteralAsJson(node) {
5942
6553
  if (kind === "null") {
5943
6554
  return null;
5944
6555
  }
5945
- if (Node23.isObjectLiteralExpression(node)) {
6556
+ if (Node24.isObjectLiteralExpression(node)) {
5946
6557
  const out = {};
5947
6558
  for (const prop of node.getProperties()) {
5948
- if (!Node23.isPropertyAssignment(prop)) {
6559
+ if (!Node24.isPropertyAssignment(prop)) {
5949
6560
  return null;
5950
6561
  }
5951
6562
  const nameNode = prop.getNameNode();
5952
6563
  let name;
5953
- if (Node23.isIdentifier(nameNode)) {
6564
+ if (Node24.isIdentifier(nameNode)) {
5954
6565
  name = nameNode.getText();
5955
- } else if (Node23.isStringLiteral(nameNode) || Node23.isNoSubstitutionTemplateLiteral(nameNode)) {
6566
+ } else if (Node24.isStringLiteral(nameNode) || Node24.isNoSubstitutionTemplateLiteral(nameNode)) {
5956
6567
  name = nameNode.getLiteralValue();
5957
6568
  } else {
5958
6569
  return null;
@@ -5969,7 +6580,7 @@ function evaluateObjectLiteralAsJson(node) {
5969
6580
  }
5970
6581
  return out;
5971
6582
  }
5972
- if (Node23.isArrayLiteralExpression(node)) {
6583
+ if (Node24.isArrayLiteralExpression(node)) {
5973
6584
  const out = [];
5974
6585
  for (const el of node.getElements()) {
5975
6586
  const value = evaluateObjectLiteralAsJson(el);
@@ -5983,8 +6594,8 @@ function evaluateObjectLiteralAsJson(node) {
5983
6594
  return void 0;
5984
6595
  }
5985
6596
  function resolveGraphqlFileImport(decl) {
5986
- const importDecl = Node23.isImportSpecifier(decl) ? decl.getImportDeclaration() : Node23.isImportClause(decl) ? decl.getParent() : null;
5987
- if (importDecl === null || importDecl === void 0 || !Node23.isImportDeclaration(importDecl)) {
6597
+ const importDecl = Node24.isImportSpecifier(decl) ? decl.getImportDeclaration() : Node24.isImportClause(decl) ? decl.getParent() : null;
6598
+ if (importDecl === null || importDecl === void 0 || !Node24.isImportDeclaration(importDecl)) {
5988
6599
  return null;
5989
6600
  }
5990
6601
  const specifier = importDecl.getModuleSpecifierValue();
@@ -6003,7 +6614,7 @@ function resolveGraphqlFileImport(decl) {
6003
6614
  function enclosingFunctionRoot(node) {
6004
6615
  let current2 = node.getParent();
6005
6616
  while (current2 !== void 0) {
6006
- if (Node23.isFunctionDeclaration(current2) || Node23.isFunctionExpression(current2) || Node23.isArrowFunction(current2) || Node23.isMethodDeclaration(current2)) {
6617
+ if (Node24.isFunctionDeclaration(current2) || Node24.isFunctionExpression(current2) || Node24.isArrowFunction(current2) || Node24.isMethodDeclaration(current2)) {
6007
6618
  return current2;
6008
6619
  }
6009
6620
  current2 = current2.getParent();
@@ -6011,18 +6622,18 @@ function enclosingFunctionRoot(node) {
6011
6622
  return null;
6012
6623
  }
6013
6624
  function functionNameOrAnon(func) {
6014
- if (Node23.isFunctionDeclaration(func) || Node23.isMethodDeclaration(func)) {
6625
+ if (Node24.isFunctionDeclaration(func) || Node24.isMethodDeclaration(func)) {
6015
6626
  return func.getName() ?? "<anon>";
6016
6627
  }
6017
6628
  const parent = func.getParent();
6018
- if (parent !== void 0 && Node23.isVariableDeclaration(parent)) {
6629
+ if (parent !== void 0 && Node24.isVariableDeclaration(parent)) {
6019
6630
  return parent.getName();
6020
6631
  }
6021
6632
  return "<anon>";
6022
6633
  }
6023
6634
 
6024
6635
  // src/discovery/importedCalls.ts
6025
- import { Node as Node24 } from "ts-morph";
6636
+ import { Node as Node25 } from "ts-morph";
6026
6637
  function callsResolvingTo(sourceFile, resolution, spec) {
6027
6638
  return [
6028
6639
  ...callsByOriginName(
@@ -6036,11 +6647,11 @@ function callsResolvingTo(sourceFile, resolution, spec) {
6036
6647
  function callsByOriginName(sourceFile, resolution, module, names) {
6037
6648
  const candidates = [];
6038
6649
  sourceFile.forEachDescendant((node) => {
6039
- if (!Node24.isCallExpression(node) && !Node24.isNewExpression(node)) {
6650
+ if (!Node25.isCallExpression(node) && !Node25.isNewExpression(node)) {
6040
6651
  return;
6041
6652
  }
6042
6653
  const callee = node.getExpression();
6043
- if (Node24.isIdentifier(callee) && !declaredLocally(callee)) {
6654
+ if (Node25.isIdentifier(callee) && !declaredLocally(callee)) {
6044
6655
  candidates.push(node);
6045
6656
  }
6046
6657
  });
@@ -6066,7 +6677,7 @@ function callsByOriginName(sourceFile, resolution, module, names) {
6066
6677
  function declaredLocally(callee) {
6067
6678
  const declarations = callee.getSymbol()?.getDeclarations() ?? [];
6068
6679
  return declarations.length > 0 && declarations.every(
6069
- (declaration) => (Node24.isFunctionDeclaration(declaration) || Node24.isClassDeclaration(declaration)) && !declaration.getSourceFile().isInNodeModules()
6680
+ (declaration) => (Node25.isFunctionDeclaration(declaration) || Node25.isClassDeclaration(declaration)) && !declaration.getSourceFile().isInNodeModules()
6070
6681
  );
6071
6682
  }
6072
6683
 
@@ -6084,7 +6695,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
6084
6695
  );
6085
6696
  const results = [];
6086
6697
  for (const [node, canonical] of hookCalls) {
6087
- if (!Node25.isCallExpression(node)) {
6698
+ if (!Node26.isCallExpression(node)) {
6088
6699
  continue;
6089
6700
  }
6090
6701
  const operationType = operationTypeByHook.get(canonical);
@@ -6121,7 +6732,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
6121
6732
  }
6122
6733
 
6123
6734
  // src/discovery/graphqlImperativeCall.ts
6124
- import { Node as Node26 } from "ts-morph";
6735
+ import { Node as Node27 } from "ts-morph";
6125
6736
  function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
6126
6737
  const isTheClient = clientReceiverCheckFor(sourceFile, match, resolution);
6127
6738
  const methodSpec = /* @__PURE__ */ new Map();
@@ -6133,11 +6744,11 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
6133
6744
  }
6134
6745
  const results = [];
6135
6746
  sourceFile.forEachDescendant((node) => {
6136
- if (!Node26.isCallExpression(node)) {
6747
+ if (!Node27.isCallExpression(node)) {
6137
6748
  return;
6138
6749
  }
6139
6750
  const callee = node.getExpression();
6140
- if (!Node26.isPropertyAccessExpression(callee)) {
6751
+ if (!Node27.isPropertyAccessExpression(callee)) {
6141
6752
  return;
6142
6753
  }
6143
6754
  const methodName = callee.getName();
@@ -6149,7 +6760,7 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
6149
6760
  return;
6150
6761
  }
6151
6762
  const args = node.getArguments();
6152
- if (args.length === 0 || !Node26.isObjectLiteralExpression(args[0])) {
6763
+ if (args.length === 0 || !Node27.isObjectLiteralExpression(args[0])) {
6153
6764
  return;
6154
6765
  }
6155
6766
  const config = args[0];
@@ -6185,16 +6796,16 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
6185
6796
  return results;
6186
6797
  }
6187
6798
  function imperativeConfigValue(prop) {
6188
- if (Node26.isPropertyAssignment(prop)) {
6799
+ if (Node27.isPropertyAssignment(prop)) {
6189
6800
  return prop.getInitializer() ?? null;
6190
6801
  }
6191
- if (Node26.isShorthandPropertyAssignment(prop)) {
6802
+ if (Node27.isShorthandPropertyAssignment(prop)) {
6192
6803
  const valueSymbol = prop.getValueSymbol();
6193
6804
  if (valueSymbol === void 0) {
6194
6805
  return null;
6195
6806
  }
6196
6807
  for (const decl of valueSymbol.getDeclarations()) {
6197
- if (Node26.isVariableDeclaration(decl)) {
6808
+ if (Node27.isVariableDeclaration(decl)) {
6198
6809
  const init = decl.getInitializer();
6199
6810
  if (init !== void 0) {
6200
6811
  return init;
@@ -6207,7 +6818,7 @@ function imperativeConfigValue(prop) {
6207
6818
  }
6208
6819
 
6209
6820
  // src/discovery/jsxElementRoute.ts
6210
- import { Node as Node27 } from "ts-morph";
6821
+ import { Node as Node28 } from "ts-morph";
6211
6822
  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";
6212
6823
  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";
6213
6824
  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";
@@ -6239,7 +6850,7 @@ function discoverJsxElementRoutes(sourceFile, match, kind, resolution) {
6239
6850
  }
6240
6851
  return;
6241
6852
  }
6242
- if (Node27.isCallExpression(node) && callsAFactory(node, factoryNames)) {
6853
+ if (Node28.isCallExpression(node) && callsAFactory(node, factoryNames)) {
6243
6854
  results.push(
6244
6855
  ...unitsForRouteArray(node, match, elementsNames, kind, resolution)
6245
6856
  );
@@ -6261,7 +6872,7 @@ function localNamesFor(sourceFile, match, exported) {
6261
6872
  return local;
6262
6873
  }
6263
6874
  function asRouteJsx(node, routeNames) {
6264
- if (!Node27.isJsxSelfClosingElement(node) && !Node27.isJsxElement(node)) {
6875
+ if (!Node28.isJsxSelfClosingElement(node) && !Node28.isJsxElement(node)) {
6265
6876
  return null;
6266
6877
  }
6267
6878
  return isRouteJsx(node, routeNames) ? node : null;
@@ -6271,15 +6882,15 @@ function isRouteJsx(node, routeNames) {
6271
6882
  return tag !== null && routeNames.has(tag.getText());
6272
6883
  }
6273
6884
  function tagNameOf(node) {
6274
- const tag = Node27.isJsxElement(node) ? node.getOpeningElement().getTagNameNode() : node.getTagNameNode();
6275
- return Node27.isIdentifier(tag) ? tag : null;
6885
+ const tag = Node28.isJsxElement(node) ? node.getOpeningElement().getTagNameNode() : node.getTagNameNode();
6886
+ return Node28.isIdentifier(tag) ? tag : null;
6276
6887
  }
6277
6888
  function attributesOf(node) {
6278
- return Node27.isJsxElement(node) ? node.getOpeningElement().getAttributes() : node.getAttributes();
6889
+ return Node28.isJsxElement(node) ? node.getOpeningElement().getAttributes() : node.getAttributes();
6279
6890
  }
6280
6891
  function attributeValueOf(node, name) {
6281
6892
  for (const attribute of attributesOf(node)) {
6282
- if (!Node27.isJsxAttribute(attribute)) {
6893
+ if (!Node28.isJsxAttribute(attribute)) {
6283
6894
  continue;
6284
6895
  }
6285
6896
  if (attribute.getNameNode().getText() !== name) {
@@ -6290,8 +6901,8 @@ function attributeValueOf(node, name) {
6290
6901
  return null;
6291
6902
  }
6292
6903
  function literalStringOf2(value) {
6293
- const unwrapped2 = Node27.isJsxExpression(value) ? value.getExpression() ?? value : value;
6294
- if (Node27.isStringLiteral(unwrapped2) || Node27.isNoSubstitutionTemplateLiteral(unwrapped2)) {
6904
+ const unwrapped2 = Node28.isJsxExpression(value) ? value.getExpression() ?? value : value;
6905
+ if (Node28.isStringLiteral(unwrapped2) || Node28.isNoSubstitutionTemplateLiteral(unwrapped2)) {
6295
6906
  return unwrapped2.getLiteralValue();
6296
6907
  }
6297
6908
  return null;
@@ -6311,8 +6922,8 @@ function elementTargetOfValue(value) {
6311
6922
  if (value === null) {
6312
6923
  return { kind: "absent" };
6313
6924
  }
6314
- const unwrapped2 = Node27.isJsxExpression(value) ? value.getExpression() ?? value : value;
6315
- if (!Node27.isJsxSelfClosingElement(unwrapped2) && !Node27.isJsxElement(unwrapped2)) {
6925
+ const unwrapped2 = Node28.isJsxExpression(value) ? value.getExpression() ?? value : value;
6926
+ if (!Node28.isJsxSelfClosingElement(unwrapped2) && !Node28.isJsxElement(unwrapped2)) {
6316
6927
  return { kind: "unreadable" };
6317
6928
  }
6318
6929
  const tag = tagNameOf(unwrapped2);
@@ -6324,7 +6935,7 @@ function elementTargetOfValue(value) {
6324
6935
  function composedPrefixOf(node, match, routeNames) {
6325
6936
  const enclosing = [];
6326
6937
  for (const ancestor of node.getAncestors()) {
6327
- if (Node27.isJsxElement(ancestor) && isRouteJsx(ancestor, routeNames)) {
6938
+ if (Node28.isJsxElement(ancestor) && isRouteJsx(ancestor, routeNames)) {
6328
6939
  enclosing.push(ancestor);
6329
6940
  }
6330
6941
  }
@@ -6440,14 +7051,14 @@ function abstention(at, kind, sentence, label) {
6440
7051
  }
6441
7052
  function callsAFactory(call, factoryNames) {
6442
7053
  const callee = call.getExpression();
6443
- return Node27.isIdentifier(callee) && factoryNames.has(callee.getText());
7054
+ return Node28.isIdentifier(callee) && factoryNames.has(callee.getText());
6444
7055
  }
6445
7056
  function unitsForRouteArray(call, match, elementsNames, kind, resolution) {
6446
7057
  const first = call.getArguments()[0];
6447
7058
  if (first === void 0) {
6448
7059
  return [];
6449
7060
  }
6450
- if (Node27.isJsxElement(first) || Node27.isJsxSelfClosingElement(first) || Node27.isCallExpression(first) && callsAFactory(first, elementsNames)) {
7061
+ if (Node28.isJsxElement(first) || Node28.isJsxSelfClosingElement(first) || Node28.isCallExpression(first) && callsAFactory(first, elementsNames)) {
6451
7062
  return [];
6452
7063
  }
6453
7064
  const array = arrayLiteralOf(first, resolution);
@@ -6472,7 +7083,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
6472
7083
  const nestedIn = new Set(ancestry).add(array);
6473
7084
  const results = [];
6474
7085
  for (const element of array.getElements()) {
6475
- if (Node27.isSpreadElement(element)) {
7086
+ if (Node28.isSpreadElement(element)) {
6476
7087
  results.push(
6477
7088
  abstention(
6478
7089
  element,
@@ -6483,7 +7094,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
6483
7094
  );
6484
7095
  continue;
6485
7096
  }
6486
- if (!Node27.isObjectLiteralExpression(element)) {
7097
+ if (!Node28.isObjectLiteralExpression(element)) {
6487
7098
  results.push(
6488
7099
  abstention(
6489
7100
  element,
@@ -6572,7 +7183,7 @@ function ownPathOfObject(object, match) {
6572
7183
  }
6573
7184
  if (match.indexAttribute !== void 0) {
6574
7185
  const indexValue = routePropertyOf(object, match.indexAttribute);
6575
- if (indexValue !== null && Node27.isTrueLiteral(indexValue)) {
7186
+ if (indexValue !== null && Node28.isTrueLiteral(indexValue)) {
6576
7187
  return { kind: "inherited" };
6577
7188
  }
6578
7189
  }
@@ -6586,17 +7197,17 @@ function objectLabelOf(target) {
6586
7197
  return target.kind === "named" ? target.identifier.getText() : "declaration";
6587
7198
  }
6588
7199
  function labelOfExpression(node) {
6589
- if (Node27.isIdentifier(node)) {
7200
+ if (Node28.isIdentifier(node)) {
6590
7201
  return node.getText();
6591
7202
  }
6592
- if (Node27.isCallExpression(node)) {
7203
+ if (Node28.isCallExpression(node)) {
6593
7204
  return node.getExpression().getText();
6594
7205
  }
6595
7206
  return node.getKindName();
6596
7207
  }
6597
7208
 
6598
7209
  // src/discovery/packageExports.ts
6599
- import { Node as Node29 } from "ts-morph";
7210
+ import { Node as Node30 } from "ts-morph";
6600
7211
 
6601
7212
  // src/packageExports.ts
6602
7213
  import fs3 from "fs";
@@ -6788,13 +7399,13 @@ function sameDeclaration(a, b) {
6788
7399
  }
6789
7400
 
6790
7401
  // src/discovery/factorySurface.ts
6791
- import { Node as Node28, SyntaxKind as SyntaxKind6 } from "ts-morph";
7402
+ import { Node as Node29, SyntaxKind as SyntaxKind7 } from "ts-morph";
6792
7403
  var MAX_BUILDER_HOPS = 2;
6793
7404
  function surfaceMethods(decl) {
6794
- if (Node28.isClassDeclaration(decl)) {
7405
+ if (Node29.isClassDeclaration(decl)) {
6795
7406
  return surfaceClassMethods(decl);
6796
7407
  }
6797
- if (Node28.isFunctionDeclaration(decl) || Node28.isFunctionExpression(decl) || Node28.isArrowFunction(decl) || Node28.isMethodDeclaration(decl)) {
7408
+ if (Node29.isFunctionDeclaration(decl) || Node29.isFunctionExpression(decl) || Node29.isArrowFunction(decl) || Node29.isMethodDeclaration(decl)) {
6798
7409
  return surfaceFactoryReturnMethods(decl);
6799
7410
  }
6800
7411
  return [];
@@ -6803,7 +7414,7 @@ function surfaceClassMethods(cls) {
6803
7414
  const out = [];
6804
7415
  const seen = /* @__PURE__ */ new Set();
6805
7416
  for (const method of cls.getInstanceMethods()) {
6806
- if (method.hasModifier(SyntaxKind6.PrivateKeyword)) {
7417
+ if (method.hasModifier(SyntaxKind7.PrivateKeyword)) {
6807
7418
  continue;
6808
7419
  }
6809
7420
  const name = method.getName();
@@ -6814,7 +7425,7 @@ function surfaceClassMethods(cls) {
6814
7425
  out.push({ func: method, name });
6815
7426
  }
6816
7427
  for (const method of cls.getStaticMethods()) {
6817
- if (method.hasModifier(SyntaxKind6.PrivateKeyword)) {
7428
+ if (method.hasModifier(SyntaxKind7.PrivateKeyword)) {
6818
7429
  continue;
6819
7430
  }
6820
7431
  const name = method.getName();
@@ -6833,9 +7444,9 @@ function surfaceFactoryReturnMethods(fn) {
6833
7444
  return out;
6834
7445
  }
6835
7446
  function collectFromFunctionReturns(fn, out, seen, depth) {
6836
- if (Node28.isArrowFunction(fn)) {
7447
+ if (Node29.isArrowFunction(fn)) {
6837
7448
  const body2 = fn.getBody();
6838
- if (Node28.isExpression(body2)) {
7449
+ if (Node29.isExpression(body2)) {
6839
7450
  collectFromReturnValue(body2, out, seen, depth);
6840
7451
  return;
6841
7452
  }
@@ -6846,11 +7457,11 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
6846
7457
  }
6847
7458
  const returns = [];
6848
7459
  body.forEachDescendant((node, traversal) => {
6849
- if (Node28.isFunctionDeclaration(node) || Node28.isFunctionExpression(node) || Node28.isArrowFunction(node) || Node28.isMethodDeclaration(node) || Node28.isConstructorDeclaration(node) || Node28.isGetAccessorDeclaration(node) || Node28.isSetAccessorDeclaration(node)) {
7460
+ if (Node29.isFunctionDeclaration(node) || Node29.isFunctionExpression(node) || Node29.isArrowFunction(node) || Node29.isMethodDeclaration(node) || Node29.isConstructorDeclaration(node) || Node29.isGetAccessorDeclaration(node) || Node29.isSetAccessorDeclaration(node)) {
6850
7461
  traversal.skip();
6851
7462
  return;
6852
7463
  }
6853
- if (Node28.isReturnStatement(node)) {
7464
+ if (Node29.isReturnStatement(node)) {
6854
7465
  returns.push(node);
6855
7466
  }
6856
7467
  });
@@ -6864,15 +7475,15 @@ function collectFromFunctionReturns(fn, out, seen, depth) {
6864
7475
  }
6865
7476
  function collectFromReturnValue(node, out, seen, depth) {
6866
7477
  const expr = peelParens(node);
6867
- if (Node28.isObjectLiteralExpression(expr)) {
7478
+ if (Node29.isObjectLiteralExpression(expr)) {
6868
7479
  collectFromObjectLiteral(expr, out, seen);
6869
7480
  return;
6870
7481
  }
6871
- if (depth >= MAX_BUILDER_HOPS || !Node28.isCallExpression(expr)) {
7482
+ if (depth >= MAX_BUILDER_HOPS || !Node29.isCallExpression(expr)) {
6872
7483
  return;
6873
7484
  }
6874
7485
  const callee = expr.getExpression();
6875
- if (!Node28.isIdentifier(callee)) {
7486
+ if (!Node29.isIdentifier(callee)) {
6876
7487
  return;
6877
7488
  }
6878
7489
  const helper = sameFileFunctionBehind(callee);
@@ -6895,12 +7506,12 @@ function functionAmong(declarations, filePath) {
6895
7506
  if (decl.getSourceFile().getFilePath() !== filePath) {
6896
7507
  continue;
6897
7508
  }
6898
- if (Node28.isFunctionDeclaration(decl)) {
7509
+ if (Node29.isFunctionDeclaration(decl)) {
6899
7510
  return decl;
6900
7511
  }
6901
- if (Node28.isVariableDeclaration(decl)) {
7512
+ if (Node29.isVariableDeclaration(decl)) {
6902
7513
  const init = decl.getInitializer();
6903
- if (init !== void 0 && (Node28.isArrowFunction(init) || Node28.isFunctionExpression(init))) {
7514
+ if (init !== void 0 && (Node29.isArrowFunction(init) || Node29.isFunctionExpression(init))) {
6904
7515
  return init;
6905
7516
  }
6906
7517
  }
@@ -6909,11 +7520,11 @@ function functionAmong(declarations, filePath) {
6909
7520
  }
6910
7521
  function collectFromObjectLiteral(node, out, seen) {
6911
7522
  const e = peelParens(node);
6912
- if (!Node28.isObjectLiteralExpression(e)) {
7523
+ if (!Node29.isObjectLiteralExpression(e)) {
6913
7524
  return;
6914
7525
  }
6915
7526
  for (const prop of e.getProperties()) {
6916
- if (Node28.isMethodDeclaration(prop)) {
7527
+ if (Node29.isMethodDeclaration(prop)) {
6917
7528
  const name = prop.getName();
6918
7529
  if (seen.has(name)) {
6919
7530
  continue;
@@ -6922,16 +7533,16 @@ function collectFromObjectLiteral(node, out, seen) {
6922
7533
  out.push({ func: prop, name });
6923
7534
  continue;
6924
7535
  }
6925
- if (Node28.isPropertyAssignment(prop)) {
7536
+ if (Node29.isPropertyAssignment(prop)) {
6926
7537
  const init = prop.getInitializer();
6927
7538
  if (init === void 0) {
6928
7539
  continue;
6929
7540
  }
6930
7541
  let v3 = init;
6931
- while (Node28.isParenthesizedExpression(v3)) {
7542
+ while (Node29.isParenthesizedExpression(v3)) {
6932
7543
  v3 = v3.getExpression();
6933
7544
  }
6934
- if (Node28.isArrowFunction(v3) || Node28.isFunctionExpression(v3)) {
7545
+ if (Node29.isArrowFunction(v3) || Node29.isFunctionExpression(v3)) {
6935
7546
  const name = prop.getName();
6936
7547
  if (seen.has(name)) {
6937
7548
  continue;
@@ -6940,7 +7551,7 @@ function collectFromObjectLiteral(node, out, seen) {
6940
7551
  out.push({ func: v3, name });
6941
7552
  }
6942
7553
  }
6943
- if (Node28.isShorthandPropertyAssignment(prop)) {
7554
+ if (Node29.isShorthandPropertyAssignment(prop)) {
6944
7555
  collectShorthandFunction(prop, out, seen);
6945
7556
  }
6946
7557
  }
@@ -7003,9 +7614,9 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
7003
7614
  (decl) => sourceDeclarationsBehind(decl, resolution)
7004
7615
  );
7005
7616
  for (const decl of candidates) {
7006
- if (Node29.isVariableDeclaration(decl)) {
7617
+ if (Node30.isVariableDeclaration(decl)) {
7007
7618
  const init = decl.getInitializer();
7008
- if (init !== void 0 && (Node29.isArrowFunction(init) || Node29.isFunctionExpression(init))) {
7619
+ if (init !== void 0 && (Node30.isArrowFunction(init) || Node30.isFunctionExpression(init))) {
7009
7620
  results.push(buildUnit(init, kind, exportName, entry));
7010
7621
  for (const m of surfaceMethods(init)) {
7011
7622
  results.push(buildSurfacedUnit(m, kind, exportName, entry));
@@ -7015,7 +7626,7 @@ function discoverPackageExports(sourceFile, match, kind, resolution) {
7015
7626
  }
7016
7627
  continue;
7017
7628
  }
7018
- if (Node29.isClassDeclaration(decl)) {
7629
+ if (Node30.isClassDeclaration(decl)) {
7019
7630
  for (const m of surfaceMethods(decl)) {
7020
7631
  results.push(buildSurfacedUnit(m, kind, exportName, entry));
7021
7632
  }
@@ -7061,7 +7672,7 @@ function buildSurfacedUnit(m, kind, parentExportName, entry) {
7061
7672
 
7062
7673
  // src/discovery/packageImport.ts
7063
7674
  import {
7064
- Node as Node30
7675
+ Node as Node31
7065
7676
  } from "ts-morph";
7066
7677
  function isLanguageLib(file) {
7067
7678
  return /[\\/]typescript[\\/]lib[\\/]lib\..*\.d\.ts$/.test(file.getFilePath());
@@ -7083,13 +7694,13 @@ function splitPackageSpec(spec) {
7083
7694
  };
7084
7695
  }
7085
7696
  function enclosingFunctionName(func) {
7086
- if (Node30.isFunctionDeclaration(func) || Node30.isMethodDeclaration(func)) {
7697
+ if (Node31.isFunctionDeclaration(func) || Node31.isMethodDeclaration(func)) {
7087
7698
  const n = func.getName?.();
7088
7699
  if (typeof n === "string" && n.length > 0) {
7089
7700
  return n;
7090
7701
  }
7091
7702
  }
7092
- if (Node30.isFunctionExpression(func)) {
7703
+ if (Node31.isFunctionExpression(func)) {
7093
7704
  const n = func.getName();
7094
7705
  if (typeof n === "string" && n.length > 0) {
7095
7706
  return n;
@@ -7097,10 +7708,10 @@ function enclosingFunctionName(func) {
7097
7708
  }
7098
7709
  const parent = func.getParent();
7099
7710
  if (parent !== void 0) {
7100
- if (Node30.isVariableDeclaration(parent)) {
7711
+ if (Node31.isVariableDeclaration(parent)) {
7101
7712
  return parent.getName();
7102
7713
  }
7103
- if (Node30.isPropertyAssignment(parent)) {
7714
+ if (Node31.isPropertyAssignment(parent)) {
7104
7715
  return parent.getName();
7105
7716
  }
7106
7717
  }
@@ -7119,7 +7730,7 @@ function attributedCalls(sourceFile, packages, resolution) {
7119
7730
  const calls = [];
7120
7731
  const candidates = /* @__PURE__ */ new Set();
7121
7732
  sourceFile.forEachDescendant((node) => {
7122
- if (!Node30.isCallExpression(node)) {
7733
+ if (!Node31.isCallExpression(node)) {
7123
7734
  return;
7124
7735
  }
7125
7736
  calls.push(node);
@@ -7127,7 +7738,7 @@ function attributedCalls(sourceFile, packages, resolution) {
7127
7738
  if (couldBePackageLinked(callee, packages)) {
7128
7739
  candidates.add(callee);
7129
7740
  }
7130
- if (Node30.isPropertyAccessExpression(callee) && couldBePackageLinked(callee.getExpression(), packages)) {
7741
+ if (Node31.isPropertyAccessExpression(callee) && couldBePackageLinked(callee.getExpression(), packages)) {
7131
7742
  candidates.add(callee.getExpression());
7132
7743
  }
7133
7744
  });
@@ -7149,7 +7760,7 @@ function attributedCalls(sourceFile, packages, resolution) {
7149
7760
  if (direct !== null) {
7150
7761
  return direct;
7151
7762
  }
7152
- if (!Node30.isPropertyAccessExpression(callee)) {
7763
+ if (!Node31.isPropertyAccessExpression(callee)) {
7153
7764
  return null;
7154
7765
  }
7155
7766
  const subject = originOf(callee.getExpression());
@@ -7174,7 +7785,7 @@ function attributedCalls(sourceFile, packages, resolution) {
7174
7785
  return results;
7175
7786
  }
7176
7787
  function couldBePackageLinked(value, packages) {
7177
- if (!Node30.isIdentifier(value)) {
7788
+ if (!Node31.isIdentifier(value)) {
7178
7789
  return true;
7179
7790
  }
7180
7791
  const declarations = value.getSymbol()?.getDeclarations() ?? [];
@@ -7182,7 +7793,7 @@ function couldBePackageLinked(value, packages) {
7182
7793
  return true;
7183
7794
  }
7184
7795
  return !declarations.every(
7185
- (declaration) => Node30.isFunctionDeclaration(declaration) || Node30.isMethodDeclaration(declaration) || Node30.isClassDeclaration(declaration) || Node30.isImportSpecifier(declaration) && importAimsElsewhere(declaration, packages)
7796
+ (declaration) => Node31.isFunctionDeclaration(declaration) || Node31.isMethodDeclaration(declaration) || Node31.isClassDeclaration(declaration) || Node31.isImportSpecifier(declaration) && importAimsElsewhere(declaration, packages)
7186
7797
  );
7187
7798
  }
7188
7799
  function importAimsElsewhere(declaration, packages) {
@@ -7239,156 +7850,9 @@ import { Node as Node32 } from "ts-morph";
7239
7850
  import { joinMountedPath } from "@suss/resolution";
7240
7851
 
7241
7852
  // src/resolve/routePath.ts
7242
- import { Node as Node31 } from "ts-morph";
7243
- import { patternHole } from "@suss/behavioral-ir";
7244
- var URL_SCHEME = /^[a-zA-Z][a-zA-Z\d+.-]*:\/\//;
7245
- var URL_ORIGIN = /^[a-zA-Z][a-zA-Z\d+.-]*:\/\/[^/]*/;
7246
- var PROTOCOL_RELATIVE = /^\/\//;
7247
- var PROTOCOL_RELATIVE_ORIGIN = /^\/\/[^/]*/;
7248
- function isAbsoluteUrlLiteral(text) {
7249
- return URL_SCHEME.test(text) || PROTOCOL_RELATIVE.test(text);
7250
- }
7251
- function stripOriginManually(text) {
7252
- if (URL_SCHEME.test(text)) {
7253
- return text.replace(URL_ORIGIN, "");
7254
- }
7255
- if (PROTOCOL_RELATIVE.test(text)) {
7256
- return text.replace(PROTOCOL_RELATIVE_ORIGIN, "");
7257
- }
7258
- return text;
7259
- }
7260
- function stripQueryAndFragment(text) {
7261
- const idx = text.search(/[?#]/);
7262
- return idx === -1 ? text : text.slice(0, idx);
7263
- }
7264
- var SUBSTITUTION = "\uFFFF";
7265
- var AUTHORITY_OPENER = /^(?:[-+.\uFFFFa-zA-Z0-9]+:\/\/|\/\/)/;
7266
- function originEndOf(flattened) {
7267
- const opener = AUTHORITY_OPENER.exec(flattened);
7268
- if (opener === null) {
7269
- return 0;
7270
- }
7271
- const slash = flattened.indexOf("/", opener[0].length);
7272
- return slash === -1 ? flattened.length : slash;
7273
- }
7274
- function appendPathText(path14, text) {
7275
- const idx = text.search(/[?#]/);
7276
- if (idx === -1) {
7277
- return { path: path14 + text, stop: false };
7278
- }
7279
- return { path: path14 + text.slice(0, idx), stop: true };
7280
- }
7281
- function parseAbsoluteUrl(text) {
7282
- try {
7283
- return new URL(text);
7284
- } catch {
7285
- }
7286
- if (!PROTOCOL_RELATIVE.test(text)) {
7287
- return void 0;
7288
- }
7289
- try {
7290
- return new URL(`https:${text}`);
7291
- } catch {
7292
- return void 0;
7293
- }
7294
- }
7295
- function pathnameOfAbsoluteLiteral(text) {
7296
- const parsed = parseAbsoluteUrl(text);
7297
- if (parsed !== void 0) {
7298
- return parsed.pathname;
7299
- }
7300
- return stripQueryAndFragment(stripOriginManually(text));
7301
- }
7302
- function pathFromLiteralUrl(text) {
7303
- const path14 = isAbsoluteUrlLiteral(text) ? pathnameOfAbsoluteLiteral(text) : stripQueryAndFragment(text);
7304
- return path14 === "" ? void 0 : path14;
7305
- }
7306
- function pathFromTemplateUrl(arg, resolution) {
7307
- const headText = arg.getHead().getLiteralText();
7308
- const spans = arg.getTemplateSpans();
7309
- const tails = spans.map((span) => span.getLiteral().getLiteralText());
7310
- const originEnd = originEndOf([headText, ...tails].join(SUBSTITUTION));
7311
- const head = appendPathText("", headText.slice(originEnd));
7312
- let path14 = head.path;
7313
- let stop = head.stop;
7314
- let at = headText.length;
7315
- for (let i = 0; i < spans.length && !stop; i++) {
7316
- const span = spans[i];
7317
- const tailText = tails[i];
7318
- if (span === void 0 || tailText === void 0) {
7319
- continue;
7320
- }
7321
- if (at >= originEnd) {
7322
- path14 += holeText(span.getExpression(), resolution);
7323
- }
7324
- at += SUBSTITUTION.length;
7325
- const appended = appendPathText(
7326
- path14,
7327
- tailText.slice(Math.max(0, originEnd - at))
7328
- );
7329
- path14 = appended.path;
7330
- stop = appended.stop;
7331
- at += tailText.length;
7332
- }
7333
- return path14 === "" ? void 0 : path14;
7334
- }
7335
- function pathFromUrlNode(node, resolution) {
7336
- if (Node31.isStringLiteral(node)) {
7337
- return pathFromLiteralUrl(node.getLiteralValue());
7338
- }
7339
- if (Node31.isNoSubstitutionTemplateLiteral(node)) {
7340
- return pathFromLiteralUrl(node.getLiteralValue());
7341
- }
7342
- if (Node31.isTemplateExpression(node)) {
7343
- return pathFromTemplateUrl(node, resolution);
7344
- }
7345
- if (Node31.isBinaryExpression(node)) {
7346
- const joined = joinedStringOf(node, resolution);
7347
- return joined === void 0 ? void 0 : pathFromLiteralUrl(joined);
7348
- }
7349
- return void 0;
7350
- }
7351
- function joinedStringOf(node, resolution) {
7352
- if (Node31.isStringLiteral(node) || Node31.isNoSubstitutionTemplateLiteral(node)) {
7353
- return node.getLiteralValue();
7354
- }
7355
- if (Node31.isBinaryExpression(node) && node.getOperatorToken().getText() === "+") {
7356
- const left = joinedStringOf(node.getLeft(), resolution);
7357
- const right = joinedStringOf(node.getRight(), resolution);
7358
- return left === void 0 || right === void 0 ? void 0 : left + right;
7359
- }
7360
- const written = resolution?.resolveWrittenValue(node) ?? null;
7361
- return written === null || written === node ? void 0 : joinedStringOf(written, resolution);
7362
- }
7363
- function placeholderName(expr) {
7364
- if (Node31.isIdentifier(expr)) {
7365
- return expr.getText();
7366
- }
7367
- if (Node31.isPropertyAccessExpression(expr)) {
7368
- return expr.getName();
7369
- }
7370
- return "param";
7371
- }
7372
- function holeText(expr, resolution) {
7373
- const written = resolution?.resolveWrittenValue(expr) ?? null;
7374
- if (written === null) {
7375
- return patternHole(placeholderName(expr));
7376
- }
7377
- if (emptyStringLiteral(written)) {
7378
- return "";
7379
- }
7380
- return pathFromUrlNode(written, resolution) ?? patternHole(placeholderName(expr));
7381
- }
7382
- function emptyStringLiteral(node) {
7383
- return (Node31.isStringLiteral(node) || Node31.isNoSubstitutionTemplateLiteral(node)) && node.getLiteralValue() === "";
7384
- }
7853
+ import { pathOf } from "@suss/values";
7385
7854
  function pathFromArgument(arg, resolution) {
7386
- const written = pathFromUrlNode(arg, resolution);
7387
- if (written !== void 0) {
7388
- return written;
7389
- }
7390
- const resolved = resolution?.resolveWrittenValue(arg) ?? null;
7391
- return resolved !== null ? pathFromUrlNode(resolved, resolution) : void 0;
7855
+ return pathOf(evaluatedValue(arg, resolution));
7392
7856
  }
7393
7857
 
7394
7858
  // src/discovery/registrationCall.ts
@@ -7649,13 +8113,13 @@ function collectMethodsCalledOnCallResults(sourceFile) {
7649
8113
  return called;
7650
8114
  }
7651
8115
  function registrationSubjectsOf(sourceFile, importModule, importName, resolution) {
7652
- const importedLocalName = resolveImportedLocalName(
8116
+ const spellings = importedReferenceSpellings(
7653
8117
  sourceFile,
7654
8118
  importModule,
7655
8119
  importName
7656
8120
  );
7657
8121
  const subjects = /* @__PURE__ */ new Map();
7658
- if (importedLocalName === null) {
8122
+ if (spellings.length === 0) {
7659
8123
  return subjects;
7660
8124
  }
7661
8125
  sourceFile.forEachDescendant((node) => {
@@ -7665,7 +8129,7 @@ function registrationSubjectsOf(sourceFile, importModule, importName, resolution
7665
8129
  return;
7666
8130
  }
7667
8131
  const calleeText = Node32.isCallExpression(init) || Node32.isNewExpression(init) ? init.getExpression().getText() : null;
7668
- if (calleeText === importedLocalName) {
8132
+ if (calleeText !== null && spellings.includes(calleeText)) {
7669
8133
  subjects.set(node.getName(), init);
7670
8134
  }
7671
8135
  return;
@@ -7678,7 +8142,9 @@ function registrationSubjectsOf(sourceFile, importModule, importName, resolution
7678
8142
  return;
7679
8143
  }
7680
8144
  const typeText = typeNode.getText();
7681
- if (typeText === importedLocalName || typeText.startsWith(`${importedLocalName}<`)) {
8145
+ if (spellings.some(
8146
+ (spelling) => typeText === spelling || typeText.startsWith(`${spelling}<`)
8147
+ )) {
7682
8148
  subjects.set(node.getName(), creationSiteBehind(node, resolution));
7683
8149
  }
7684
8150
  });
@@ -7722,17 +8188,17 @@ function registrationSubjectIdsOf(sourceFile, matches, resolution) {
7722
8188
  return ids;
7723
8189
  }
7724
8190
  function unboundConstructionsOf(sourceFile, importModule, importName) {
7725
- const importedLocalName = resolveImportedLocalName(
8191
+ const spellings = importedReferenceSpellings(
7726
8192
  sourceFile,
7727
8193
  importModule,
7728
8194
  importName
7729
8195
  );
7730
- if (importedLocalName === null) {
8196
+ if (spellings.length === 0) {
7731
8197
  return [];
7732
8198
  }
7733
8199
  const constructions = [];
7734
8200
  sourceFile.forEachDescendant((node) => {
7735
- if ((Node32.isCallExpression(node) || Node32.isNewExpression(node)) && node.getExpression().getText() === importedLocalName && !Node32.isVariableDeclaration(node.getParent())) {
8201
+ if ((Node32.isCallExpression(node) || Node32.isNewExpression(node)) && spellings.includes(node.getExpression().getText()) && !Node32.isVariableDeclaration(node.getParent())) {
7736
8202
  constructions.push(node);
7737
8203
  }
7738
8204
  });
@@ -7801,32 +8267,14 @@ function mountTargetsAmong(args, targetPosition, knownSubjectIds, resolution) {
7801
8267
  }
7802
8268
  return targets;
7803
8269
  }
7804
- function stringProperty(obj, name) {
7805
- if (!Node32.isObjectLiteralExpression(obj)) {
7806
- return null;
7807
- }
7808
- const property = obj.getProperty(name);
7809
- if (property === void 0 || !Node32.isPropertyAssignment(property)) {
7810
- return null;
7811
- }
7812
- const value = property.getInitializer();
7813
- if (value !== void 0 && (Node32.isStringLiteral(value) || Node32.isNoSubstitutionTemplateLiteral(value))) {
7814
- return value.getLiteralValue();
7815
- }
7816
- return null;
7817
- }
7818
8270
  function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
7819
8271
  if (binding.method.type === "fromArgumentProperty" && binding.path.type === "fromArgumentProperty" && binding.method.position === binding.path.position) {
7820
8272
  const arg = call.getArguments()[binding.method.position];
7821
8273
  if (arg === void 0) {
7822
8274
  return null;
7823
8275
  }
7824
- const routeObject = objectLiteralOf(arg, resolution);
7825
- if (routeObject === null) {
7826
- return null;
7827
- }
7828
- const method2 = stringProperty(routeObject, binding.method.property);
7829
- const path15 = stringProperty(routeObject, binding.path.property);
8276
+ const method2 = stringPropertyOf(arg, binding.method.property, resolution);
8277
+ const path15 = stringPropertyOf(arg, binding.path.property, resolution);
7830
8278
  if (method2 === null || path15 === null) {
7831
8279
  return null;
7832
8280
  }
@@ -8027,7 +8475,7 @@ import { joinMountedPath as joinMountedPath2 } from "@suss/resolution";
8027
8475
  // src/resolve/unfollowedCall.ts
8028
8476
  import {
8029
8477
  Node as Node34,
8030
- SyntaxKind as SyntaxKind7
8478
+ SyntaxKind as SyntaxKind8
8031
8479
  } from "ts-morph";
8032
8480
  import {
8033
8481
  unfollowedCallGap,
@@ -8053,14 +8501,14 @@ function isExternalDeclaration(declaration) {
8053
8501
  return true;
8054
8502
  }
8055
8503
  if (Node34.isImportSpecifier(declaration) || Node34.isImportClause(declaration) || Node34.isNamespaceImport(declaration)) {
8056
- const target = declaration.getFirstAncestorByKind(SyntaxKind7.ImportDeclaration)?.getModuleSpecifierSourceFile();
8504
+ const target = declaration.getFirstAncestorByKind(SyntaxKind8.ImportDeclaration)?.getModuleSpecifierSourceFile();
8057
8505
  return target === void 0 || isInExternalCode(target);
8058
8506
  }
8059
8507
  return declaresAnotherModule(declaration);
8060
8508
  }
8061
8509
  function declaresAnotherModule(declaration) {
8062
8510
  const module = declaration.getFirstAncestorByKind(
8063
- SyntaxKind7.ModuleDeclaration
8511
+ SyntaxKind8.ModuleDeclaration
8064
8512
  );
8065
8513
  return module !== void 0 && Node34.isStringLiteral(module.getNameNode());
8066
8514
  }
@@ -8686,8 +9134,8 @@ function parameterReads(func, parameterNames2, barriers = NO_BARRIERS) {
8686
9134
  }
8687
9135
 
8688
9136
  // src/resolve/readName.ts
8689
- import { Node as Node39, SyntaxKind as SyntaxKind8 } from "ts-morph";
8690
- import { patternHole as patternHole2, referenceName } from "@suss/behavioral-ir";
9137
+ import { Node as Node39, SyntaxKind as SyntaxKind9 } from "ts-morph";
9138
+ import { patternHole, referenceName } from "@suss/behavioral-ir";
8691
9139
  var MAX_HELPER_HOPS = 2;
8692
9140
  var UNNAMED_HOLE = "param";
8693
9141
  function readName(expr, options = {}) {
@@ -8787,7 +9235,7 @@ function isFallbackBranch(node) {
8787
9235
  return false;
8788
9236
  }
8789
9237
  const operator = step.getOperatorToken().getKind();
8790
- return operator === SyntaxKind8.BarBarToken || operator === SyntaxKind8.QuestionQuestionToken;
9238
+ return operator === SyntaxKind9.BarBarToken || operator === SyntaxKind9.QuestionQuestionToken;
8791
9239
  }
8792
9240
  function fromTemplate(expr, ctx) {
8793
9241
  if (!Node39.isTemplateExpression(expr)) {
@@ -8805,10 +9253,10 @@ function fromBinary(expr, ctx) {
8805
9253
  return null;
8806
9254
  }
8807
9255
  const operator = expr.getOperatorToken().getKind();
8808
- if (operator === SyntaxKind8.BarBarToken || operator === SyntaxKind8.QuestionQuestionToken) {
9256
+ if (operator === SyntaxKind9.BarBarToken || operator === SyntaxKind9.QuestionQuestionToken) {
8809
9257
  return ctx.insideHole ? null : read(expr.getRight(), ctx);
8810
9258
  }
8811
- if (operator !== SyntaxKind8.PlusToken) {
9259
+ if (operator !== SyntaxKind9.PlusToken) {
8812
9260
  return null;
8813
9261
  }
8814
9262
  const parts = { ...ctx, insideHole: true };
@@ -8951,7 +9399,7 @@ function boundOnce(expr, ctx) {
8951
9399
  }
8952
9400
  function readOrHole(expr, ctx) {
8953
9401
  const name = read(expr, ctx);
8954
- return name ?? patternHole2(holeName(expr, ctx));
9402
+ return name ?? patternHole(holeName(expr, ctx));
8955
9403
  }
8956
9404
  function holeName(expr, ctx) {
8957
9405
  const bound = boundOnce(expr, ctx);
@@ -9018,7 +9466,7 @@ function madeExpression(receiver) {
9018
9466
  }
9019
9467
  function callOpsFor(call, resolveWrittenValue, originatesFrom, anchorCallsOf) {
9020
9468
  const resolve2 = resolveWrittenValue ?? (() => null);
9021
- const expression = calleeOf2(call);
9469
+ const expression = calleeOf3(call);
9022
9470
  const callee = Node40.isPropertyAccessExpression(expression) ? expression : null;
9023
9471
  let args = null;
9024
9472
  const argumentsOf = () => {
@@ -9070,7 +9518,7 @@ function anchorCallBehind(subject, origin, resolve2, originatesFrom, anchorCalls
9070
9518
  if (!Node40.isCallExpression(candidate) && !Node40.isNewExpression(candidate)) {
9071
9519
  return false;
9072
9520
  }
9073
- const candidateCallee = calleeOf2(candidate);
9521
+ const candidateCallee = calleeOf3(candidate);
9074
9522
  if (origin.named !== void 0 && !origin.named.includes(constructorName(candidate))) {
9075
9523
  return false;
9076
9524
  }
@@ -9204,7 +9652,7 @@ function opsOverCall(value, resolve2) {
9204
9652
  function isCalled(value) {
9205
9653
  return Node40.isCallExpression(value) || Node40.isNewExpression(value) || Node40.isTaggedTemplateExpression(value);
9206
9654
  }
9207
- function calleeOf2(call) {
9655
+ function calleeOf3(call) {
9208
9656
  return Node40.isTaggedTemplateExpression(call) ? call.getTag() : call.getExpression();
9209
9657
  }
9210
9658
  function argumentsIn(call) {
@@ -9755,235 +10203,48 @@ function returnPositionOf(value) {
9755
10203
  current2 = parent;
9756
10204
  continue;
9757
10205
  }
9758
- if (Node42.isConditionalExpression(parent) && (parent.getWhenTrue() === current2 || parent.getWhenFalse() === current2)) {
9759
- current2 = parent;
9760
- continue;
9761
- }
9762
- return null;
9763
- }
9764
- }
9765
-
9766
- // src/terminals/continuation.ts
9767
- function tryMatchParameterCall(node, func, pattern, match) {
9768
- if (!Node43.isCallExpression(node)) {
9769
- return null;
9770
- }
9771
- const callee = node.getExpression();
9772
- if (parameterPositionOf(callee, func) !== match.parameterPosition) {
9773
- return null;
9774
- }
9775
- const terminal = {
9776
- kind: pattern.kind,
9777
- statusCode: null,
9778
- body: null,
9779
- exceptionType: null,
9780
- message: null,
9781
- component: null,
9782
- delegateTarget: callee.getText(),
9783
- emitEvent: null,
9784
- renderTree: null,
9785
- location: { start: startLineOf(node), end: endLineOf(node) }
9786
- };
9787
- return { node, terminal };
9788
- }
9789
-
9790
- // src/terminals/jsx.ts
9791
- import { Node as Node44 } from "ts-morph";
9792
- function tryMatchJsxReturn(node, pattern) {
9793
- let expr;
9794
- let source;
9795
- if (Node44.isReturnStatement(node)) {
9796
- expr = node.getExpression();
9797
- source = node;
9798
- } else if (Node44.isArrowFunction(node)) {
9799
- const body = node.getBody();
9800
- if (body !== void 0 && !Node44.isBlock(body)) {
9801
- expr = body;
9802
- source = body;
9803
- }
9804
- }
9805
- if (expr === void 0 || source === void 0) {
9806
- return null;
9807
- }
9808
- const tree = jsxToRenderNode(expr);
9809
- if (tree === null) {
9810
- return null;
9811
- }
9812
- const component = tree.type === "element" ? tree.tag : "Fragment";
9813
- const terminal = {
9814
- kind: pattern.kind,
9815
- statusCode: null,
9816
- body: null,
9817
- exceptionType: null,
9818
- message: null,
9819
- component,
9820
- delegateTarget: null,
9821
- emitEvent: null,
9822
- renderTree: tree,
9823
- location: {
9824
- start: startLineOf(node),
9825
- end: endLineOf(node)
9826
- }
9827
- };
9828
- return { node, source, terminal };
9829
- }
9830
- function componentTargetOf(tagNode) {
9831
- if (!Node44.isIdentifier(tagNode) || !/^[A-Z]/.test(tagNode.getText())) {
9832
- return null;
9833
- }
9834
- const target = functionTargetOf(tagNode);
9835
- return target === null ? null : { file: target.file, name: target.name };
9836
- }
9837
- function jsxToRenderNode(node) {
9838
- if (Node44.isJsxElement(node)) {
9839
- const opening = node.getOpeningElement();
9840
- const tag = opening.getTagNameNode().getText();
9841
- const attrs = collectJsxAttributes(opening);
9842
- const target = componentTargetOf(opening.getTagNameNode());
9843
- const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
9844
- return {
9845
- type: "element",
9846
- tag,
9847
- children,
9848
- ...attrs !== null ? { attrs } : {},
9849
- ...target !== null ? { target } : {}
9850
- };
9851
- }
9852
- if (Node44.isJsxSelfClosingElement(node)) {
9853
- const tag = node.getTagNameNode().getText();
9854
- const attrs = collectJsxAttributes(node);
9855
- const target = componentTargetOf(node.getTagNameNode());
9856
- return {
9857
- type: "element",
9858
- tag,
9859
- children: [],
9860
- ...attrs !== null ? { attrs } : {},
9861
- ...target !== null ? { target } : {}
9862
- };
9863
- }
9864
- if (Node44.isJsxFragment(node)) {
9865
- const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
9866
- return { type: "element", tag: "Fragment", children };
9867
- }
9868
- if (Node44.isParenthesizedExpression(node)) {
9869
- return jsxToRenderNode(node.getExpression());
9870
- }
9871
- return null;
9872
- }
9873
- function collectJsxAttributes(opening) {
9874
- const entries = {};
9875
- for (const attr of opening.getAttributes()) {
9876
- if (Node44.isJsxSpreadAttribute(attr)) {
9877
- const exprText = attr.getExpression().getText();
9878
- entries[`...${exprText}`] = exprText;
9879
- continue;
9880
- }
9881
- if (!Node44.isJsxAttribute(attr)) {
9882
- continue;
9883
- }
9884
- const name = attr.getNameNode().getText();
9885
- const initializer = attr.getInitializer();
9886
- if (initializer === void 0) {
9887
- entries[name] = "";
9888
- continue;
9889
- }
9890
- if (Node44.isJsxExpression(initializer)) {
9891
- const inner = initializer.getExpression();
9892
- entries[name] = inner !== void 0 ? inner.getText() : "";
9893
- continue;
9894
- }
9895
- entries[name] = initializer.getText();
9896
- }
9897
- return Object.keys(entries).length > 0 ? entries : null;
9898
- }
9899
- function jsxChildToRenderNode(child) {
9900
- if (Node44.isJsxText(child)) {
9901
- const text = child.getLiteralText().trim();
9902
- if (text.length === 0) {
9903
- return null;
9904
- }
9905
- return { type: "text", value: text };
9906
- }
9907
- if (Node44.isJsxExpression(child)) {
9908
- const inner = child.getExpression();
9909
- if (inner === void 0) {
9910
- return null;
9911
- }
9912
- return jsxExpressionToRenderNode(inner);
9913
- }
9914
- if (Node44.isJsxElement(child) || Node44.isJsxSelfClosingElement(child) || Node44.isJsxFragment(child)) {
9915
- return jsxToRenderNode(child);
9916
- }
9917
- return null;
9918
- }
9919
- function jsxExpressionToRenderNode(expr) {
9920
- if (Node44.isParenthesizedExpression(expr)) {
9921
- return jsxExpressionToRenderNode(expr.getExpression());
9922
- }
9923
- if (Node44.isBinaryExpression(expr)) {
9924
- const op = expr.getOperatorToken().getText();
9925
- if (op === "&&") {
9926
- const right = renderAlternative(peelParens(expr.getRight()));
9927
- if (right.kind === "jsx") {
9928
- return {
9929
- type: "conditional",
9930
- condition: expr.getLeft().getText(),
9931
- whenTrue: right.node,
9932
- whenFalse: null
9933
- };
9934
- }
9935
- }
9936
- }
9937
- if (Node44.isConditionalExpression(expr)) {
9938
- const truthy = renderAlternative(peelParens(expr.getWhenTrue()));
9939
- const falsy = renderAlternative(peelParens(expr.getWhenFalse()));
9940
- if (truthy.kind === "jsx") {
9941
- return {
9942
- type: "conditional",
9943
- condition: expr.getCondition().getText(),
9944
- whenTrue: truthy.node,
9945
- whenFalse: falsy.kind === "jsx" ? falsy.node : null
9946
- };
9947
- }
9948
- if (falsy.kind === "jsx") {
9949
- return {
9950
- type: "conditional",
9951
- condition: `!(${expr.getCondition().getText()})`,
9952
- whenTrue: falsy.node,
9953
- whenFalse: null
9954
- };
10206
+ if (Node42.isConditionalExpression(parent) && (parent.getWhenTrue() === current2 || parent.getWhenFalse() === current2)) {
10207
+ current2 = parent;
10208
+ continue;
9955
10209
  }
10210
+ return null;
9956
10211
  }
9957
- return { type: "expression", sourceText: expr.getText() };
9958
10212
  }
9959
- function renderAlternative(node) {
9960
- if (Node44.isNullLiteral(node)) {
9961
- return { kind: "noRender" };
9962
- }
9963
- if (Node44.isFalseLiteral(node)) {
9964
- return { kind: "noRender" };
9965
- }
9966
- if (Node44.isIdentifier(node) && node.getText() === "undefined") {
9967
- return { kind: "noRender" };
10213
+
10214
+ // src/terminals/continuation.ts
10215
+ function tryMatchParameterCall(node, func, pattern, match) {
10216
+ if (!Node43.isCallExpression(node)) {
10217
+ return null;
9968
10218
  }
9969
- if (Node44.isJsxElement(node) || Node44.isJsxSelfClosingElement(node) || Node44.isJsxFragment(node)) {
9970
- const tree = jsxToRenderNode(node);
9971
- if (tree !== null) {
9972
- return { kind: "jsx", node: tree };
9973
- }
10219
+ const callee = node.getExpression();
10220
+ if (parameterPositionOf(callee, func) !== match.parameterPosition) {
10221
+ return null;
9974
10222
  }
9975
- return { kind: "notStatic" };
10223
+ const terminal = {
10224
+ kind: pattern.kind,
10225
+ statusCode: null,
10226
+ body: null,
10227
+ exceptionType: null,
10228
+ message: null,
10229
+ component: null,
10230
+ delegateTarget: callee.getText(),
10231
+ emitEvent: null,
10232
+ renderTree: null,
10233
+ location: { start: startLineOf(node), end: endLineOf(node) }
10234
+ };
10235
+ return { node, terminal };
9976
10236
  }
9977
10237
 
9978
- // src/terminals/returns.ts
10238
+ // src/terminals/extract.ts
9979
10239
  import {
9980
- Node as Node49
10240
+ Node as Node45
9981
10241
  } from "ts-morph";
10242
+ import { constantOf } from "@suss/values";
9982
10243
 
9983
10244
  // src/shapes/shapes.ts
9984
10245
  import {
9985
- Node as Node45,
9986
- SyntaxKind as SyntaxKind9
10246
+ Node as Node44,
10247
+ SyntaxKind as SyntaxKind10
9987
10248
  } from "ts-morph";
9988
10249
 
9989
10250
  // src/shapes/typeShapes.ts
@@ -10443,60 +10704,60 @@ function extractShapeWithArguments(node, substitutions) {
10443
10704
  }
10444
10705
  function extractShapeInner(node) {
10445
10706
  const unwrapped2 = peelSyntax(node);
10446
- if (boundArguments !== null && Node45.isIdentifier(unwrapped2)) {
10707
+ if (boundArguments !== null && Node44.isIdentifier(unwrapped2)) {
10447
10708
  const argument = boundArguments.get(unwrapped2.getText());
10448
10709
  if (argument !== void 0 && argument !== unwrapped2) {
10449
10710
  return extractShape(argument);
10450
10711
  }
10451
10712
  }
10452
- if (Node45.isObjectLiteralExpression(unwrapped2)) {
10713
+ if (Node44.isObjectLiteralExpression(unwrapped2)) {
10453
10714
  return shapeFromObjectLiteral(unwrapped2);
10454
10715
  }
10455
- if (Node45.isArrayLiteralExpression(unwrapped2)) {
10716
+ if (Node44.isArrayLiteralExpression(unwrapped2)) {
10456
10717
  return shapeFromArrayLiteral(unwrapped2);
10457
10718
  }
10458
- if (Node45.isStringLiteral(unwrapped2) || Node45.isNoSubstitutionTemplateLiteral(unwrapped2)) {
10719
+ if (Node44.isStringLiteral(unwrapped2) || Node44.isNoSubstitutionTemplateLiteral(unwrapped2)) {
10459
10720
  return { type: "literal", value: unwrapped2.getLiteralValue() };
10460
10721
  }
10461
- if (Node45.isTemplateExpression(unwrapped2)) {
10722
+ if (Node44.isTemplateExpression(unwrapped2)) {
10462
10723
  return { type: "text" };
10463
10724
  }
10464
- if (Node45.isNumericLiteral(unwrapped2)) {
10725
+ if (Node44.isNumericLiteral(unwrapped2)) {
10465
10726
  return numericLiteralShape(
10466
10727
  unwrapped2.getLiteralValue(),
10467
10728
  unwrapped2.getText()
10468
10729
  );
10469
10730
  }
10470
- if (Node45.isPrefixUnaryExpression(unwrapped2)) {
10731
+ if (Node44.isPrefixUnaryExpression(unwrapped2)) {
10471
10732
  const op = unwrapped2.getOperatorToken();
10472
- if (op === SyntaxKind9.MinusToken || op === SyntaxKind9.PlusToken) {
10733
+ if (op === SyntaxKind10.MinusToken || op === SyntaxKind10.PlusToken) {
10473
10734
  const inner = unwrapped2.getOperand();
10474
- if (Node45.isNumericLiteral(inner)) {
10735
+ if (Node44.isNumericLiteral(inner)) {
10475
10736
  const v3 = inner.getLiteralValue();
10476
- const signed = op === SyntaxKind9.MinusToken ? -v3 : v3;
10737
+ const signed = op === SyntaxKind10.MinusToken ? -v3 : v3;
10477
10738
  const rawBody = inner.getText();
10478
- const raw = op === SyntaxKind9.MinusToken ? `-${rawBody}` : rawBody;
10739
+ const raw = op === SyntaxKind10.MinusToken ? `-${rawBody}` : rawBody;
10479
10740
  return numericLiteralShape(signed, raw);
10480
10741
  }
10481
10742
  }
10482
10743
  }
10483
- if (Node45.isBigIntLiteral(unwrapped2)) {
10744
+ if (Node44.isBigIntLiteral(unwrapped2)) {
10484
10745
  return { type: "ref", name: "bigint" };
10485
10746
  }
10486
10747
  const kind = unwrapped2.getKind();
10487
- if (kind === SyntaxKind9.TrueKeyword) {
10748
+ if (kind === SyntaxKind10.TrueKeyword) {
10488
10749
  return { type: "literal", value: true };
10489
10750
  }
10490
- if (kind === SyntaxKind9.FalseKeyword) {
10751
+ if (kind === SyntaxKind10.FalseKeyword) {
10491
10752
  return { type: "literal", value: false };
10492
10753
  }
10493
- if (kind === SyntaxKind9.NullKeyword) {
10754
+ if (kind === SyntaxKind10.NullKeyword) {
10494
10755
  return { type: "null" };
10495
10756
  }
10496
- if (Node45.isIdentifier(unwrapped2) && unwrapped2.getText() === "undefined") {
10757
+ if (Node44.isIdentifier(unwrapped2) && unwrapped2.getText() === "undefined") {
10497
10758
  return { type: "undefined" };
10498
10759
  }
10499
- if (Node45.isConditionalExpression(unwrapped2)) {
10760
+ if (Node44.isConditionalExpression(unwrapped2)) {
10500
10761
  const whenTrue = extractShape(unwrapped2.getWhenTrue());
10501
10762
  const whenFalse = extractShape(unwrapped2.getWhenFalse());
10502
10763
  const variants = [];
@@ -10527,7 +10788,7 @@ function shapeFromArrayLiteral(arr) {
10527
10788
  }
10528
10789
  const shapes = [];
10529
10790
  for (const el of elements) {
10530
- if (Node45.isSpreadElement(el)) {
10791
+ if (Node44.isSpreadElement(el)) {
10531
10792
  const inner = el.getExpression();
10532
10793
  const innerShape = extractShape(inner);
10533
10794
  if (innerShape?.type === "array") {
@@ -10546,7 +10807,7 @@ function shapeFromObjectLiteral(obj) {
10546
10807
  const properties = {};
10547
10808
  const unresolvedSpreads = [];
10548
10809
  for (const prop of obj.getProperties()) {
10549
- if (Node45.isPropertyAssignment(prop)) {
10810
+ if (Node44.isPropertyAssignment(prop)) {
10550
10811
  const name = propertyName2(prop);
10551
10812
  if (name === null) {
10552
10813
  continue;
@@ -10562,7 +10823,7 @@ function shapeFromObjectLiteral(obj) {
10562
10823
  };
10563
10824
  continue;
10564
10825
  }
10565
- if (Node45.isShorthandPropertyAssignment(prop)) {
10826
+ if (Node44.isShorthandPropertyAssignment(prop)) {
10566
10827
  const name = prop.getName();
10567
10828
  const valueExpr = prop.getNameNode();
10568
10829
  properties[name] = extractShape(valueExpr) ?? {
@@ -10571,7 +10832,7 @@ function shapeFromObjectLiteral(obj) {
10571
10832
  };
10572
10833
  continue;
10573
10834
  }
10574
- if (Node45.isSpreadAssignment(prop)) {
10835
+ if (Node44.isSpreadAssignment(prop)) {
10575
10836
  const expr = prop.getExpression();
10576
10837
  const spreadShape = extractShape(expr);
10577
10838
  if (spreadShape?.type === "record") {
@@ -10590,7 +10851,7 @@ function shapeFromObjectLiteral(obj) {
10590
10851
  }
10591
10852
  function propertyName2(prop) {
10592
10853
  const nameNode = prop.getNameNode();
10593
- if (Node45.isIdentifier(nameNode) || Node45.isStringLiteral(nameNode) || Node45.isNoSubstitutionTemplateLiteral(nameNode) || Node45.isNumericLiteral(nameNode)) {
10854
+ if (Node44.isIdentifier(nameNode) || Node44.isStringLiteral(nameNode) || Node44.isNoSubstitutionTemplateLiteral(nameNode) || Node44.isNumericLiteral(nameNode)) {
10594
10855
  return nameNode.getText().replace(/^["']|["']$/g, "");
10595
10856
  }
10596
10857
  return null;
@@ -10616,23 +10877,20 @@ function collapseVariants2(shapes) {
10616
10877
  }
10617
10878
 
10618
10879
  // src/terminals/extract.ts
10619
- import {
10620
- Node as Node46
10621
- } from "ts-morph";
10622
10880
  function unwrapAs(node) {
10623
10881
  return peelSyntax(node);
10624
10882
  }
10625
10883
  function unwrapJsonStringify(node) {
10626
10884
  const outer = unwrapAs(node);
10627
- if (!Node46.isCallExpression(outer)) {
10885
+ if (!Node45.isCallExpression(outer)) {
10628
10886
  return node;
10629
10887
  }
10630
10888
  const callee = outer.getExpression();
10631
- if (!Node46.isPropertyAccessExpression(callee) || callee.getName() !== "stringify") {
10889
+ if (!Node45.isPropertyAccessExpression(callee) || callee.getName() !== "stringify") {
10632
10890
  return node;
10633
10891
  }
10634
10892
  const receiver = callee.getExpression();
10635
- if (!Node46.isIdentifier(receiver) || receiver.getText() !== "JSON") {
10893
+ if (!Node45.isIdentifier(receiver) || receiver.getText() !== "JSON") {
10636
10894
  return node;
10637
10895
  }
10638
10896
  const args = outer.getArguments();
@@ -10642,7 +10900,7 @@ function unwrapJsonStringify(node) {
10642
10900
  return unwrapAs(args[0]);
10643
10901
  }
10644
10902
  function substituted(value, ctx) {
10645
- if (ctx.substitutions === void 0 || !Node46.isIdentifier(value)) {
10903
+ if (ctx.substitutions === void 0 || !Node45.isIdentifier(value)) {
10646
10904
  return value;
10647
10905
  }
10648
10906
  return ctx.substitutions.get(value.getText()) ?? value;
@@ -10655,10 +10913,10 @@ function extractStatusCode(ctx) {
10655
10913
  if (result !== null) {
10656
10914
  return result;
10657
10915
  }
10658
- if (ctx.extraction.defaultStatusCode !== void 0) {
10659
- return { type: "literal", value: ctx.extraction.defaultStatusCode };
10660
- }
10661
- return null;
10916
+ return declaredStatusCode(ctx.extraction);
10917
+ }
10918
+ function declaredStatusCode(extraction) {
10919
+ return extraction.defaultStatusCode !== void 0 ? { type: "literal", value: extraction.defaultStatusCode } : null;
10662
10920
  }
10663
10921
  function matchConstructorCode(ctorText, codes) {
10664
10922
  const fullMatch = codes[ctorText];
@@ -10675,25 +10933,21 @@ function matchConstructorCode(ctorText, codes) {
10675
10933
  return null;
10676
10934
  }
10677
10935
  function statusOf(value, ctx) {
10678
- const unwrapped2 = unwrapAs(value);
10679
- if (Node46.isNumericLiteral(unwrapped2)) {
10680
- return { type: "literal", value: Number(unwrapped2.getText()) };
10681
- }
10682
- const resolved = ctx.resolveWrittenValue?.(unwrapped2) ?? null;
10683
- if (resolved !== null && Node46.isNumericLiteral(resolved)) {
10684
- return { type: "literal", value: Number(resolved.getText()) };
10936
+ const status = constantOf(evaluatedValue(value, ctx.resolution));
10937
+ if (typeof status === "number") {
10938
+ return { type: "literal", value: status };
10685
10939
  }
10686
- return { type: "dynamic", sourceText: unwrapped2.getText() };
10940
+ return { type: "dynamic", sourceText: unwrapAs(value).getText() };
10687
10941
  }
10688
10942
  function statusFromProperty(obj, name, ctx) {
10689
10943
  const prop = obj.getProperty(name);
10690
10944
  if (prop === void 0) {
10691
10945
  return null;
10692
10946
  }
10693
- if (Node46.isShorthandPropertyAssignment(prop)) {
10947
+ if (Node45.isShorthandPropertyAssignment(prop)) {
10694
10948
  return { type: "dynamic", sourceText: prop.getName() };
10695
10949
  }
10696
- if (!Node46.isPropertyAssignment(prop)) {
10950
+ if (!Node45.isPropertyAssignment(prop)) {
10697
10951
  return null;
10698
10952
  }
10699
10953
  const value = prop.getInitializer();
@@ -10716,7 +10970,7 @@ function extractStatusCodeFromRule(ctx) {
10716
10970
  return null;
10717
10971
  }
10718
10972
  const first = ctx.throwCallArgs?.[0];
10719
- if (first !== void 0 && Node46.isNumericLiteral(first)) {
10973
+ if (first !== void 0 && Node45.isNumericLiteral(first)) {
10720
10974
  const value = first.getLiteralValue();
10721
10975
  if (value >= 100 && value <= 599) {
10722
10976
  return { type: "literal", value };
@@ -10729,7 +10983,7 @@ function extractStatusCodeFromRule(ctx) {
10729
10983
  return null;
10730
10984
  }
10731
10985
  const arg = ctx.throwCallArgs[sc.position];
10732
- if (arg === void 0 || !Node46.isNewExpression(arg)) {
10986
+ if (arg === void 0 || !Node45.isNewExpression(arg)) {
10733
10987
  return null;
10734
10988
  }
10735
10989
  const ctorText = arg.getExpression().getText();
@@ -10738,7 +10992,7 @@ function extractStatusCodeFromRule(ctx) {
10738
10992
  if (sc.from === "argumentProperty") {
10739
10993
  const args = ctx.throwCallArgs ?? ctx.calls?.[0]?.getArguments();
10740
10994
  const arg = args?.[sc.position];
10741
- if (arg === void 0 || !Node46.isObjectLiteralExpression(arg)) {
10995
+ if (arg === void 0 || !Node45.isObjectLiteralExpression(arg)) {
10742
10996
  return null;
10743
10997
  }
10744
10998
  return statusFromProperty(arg, sc.name, ctx);
@@ -10748,8 +11002,8 @@ function extractStatusCodeFromRule(ctx) {
10748
11002
  return null;
10749
11003
  }
10750
11004
  for (const prop of ctx.returnedObj.getProperties()) {
10751
- if (!Node46.isPropertyAssignment(prop)) {
10752
- if (Node46.isShorthandPropertyAssignment(prop)) {
11005
+ if (!Node45.isPropertyAssignment(prop)) {
11006
+ if (Node45.isShorthandPropertyAssignment(prop)) {
10753
11007
  if (prop.getName() === sc.name) {
10754
11008
  const resolved = ctx.substitutions?.get(prop.getName());
10755
11009
  if (resolved !== void 0) {
@@ -10807,8 +11061,8 @@ function extractBody(ctx) {
10807
11061
  return null;
10808
11062
  }
10809
11063
  for (const prop of ctx.returnedObj.getProperties()) {
10810
- if (!Node46.isPropertyAssignment(prop)) {
10811
- if (Node46.isShorthandPropertyAssignment(prop)) {
11064
+ if (!Node45.isPropertyAssignment(prop)) {
11065
+ if (Node45.isShorthandPropertyAssignment(prop)) {
10812
11066
  if (prop.getName() === b.name) {
10813
11067
  const resolved = ctx.substitutions?.get(prop.getName());
10814
11068
  if (resolved !== void 0) {
@@ -10862,8 +11116,201 @@ function extractBody(ctx) {
10862
11116
  return null;
10863
11117
  }
10864
11118
 
11119
+ // src/terminals/jsx.ts
11120
+ import { Node as Node46 } from "ts-morph";
11121
+ function tryMatchJsxReturn(node, pattern) {
11122
+ let expr;
11123
+ let source;
11124
+ if (Node46.isReturnStatement(node)) {
11125
+ expr = node.getExpression();
11126
+ source = node;
11127
+ } else if (Node46.isArrowFunction(node)) {
11128
+ const body = node.getBody();
11129
+ if (body !== void 0 && !Node46.isBlock(body)) {
11130
+ expr = body;
11131
+ source = body;
11132
+ }
11133
+ }
11134
+ if (expr === void 0 || source === void 0) {
11135
+ return null;
11136
+ }
11137
+ const tree = jsxToRenderNode(expr);
11138
+ if (tree === null) {
11139
+ return null;
11140
+ }
11141
+ const component = tree.type === "element" ? tree.tag : "Fragment";
11142
+ const terminal = {
11143
+ kind: pattern.kind,
11144
+ statusCode: null,
11145
+ body: null,
11146
+ exceptionType: null,
11147
+ message: null,
11148
+ component,
11149
+ delegateTarget: null,
11150
+ emitEvent: null,
11151
+ renderTree: tree,
11152
+ location: {
11153
+ start: startLineOf(node),
11154
+ end: endLineOf(node)
11155
+ }
11156
+ };
11157
+ return { node, source, terminal };
11158
+ }
11159
+ function componentTargetOf(tagNode) {
11160
+ if (!Node46.isIdentifier(tagNode) || !/^[A-Z]/.test(tagNode.getText())) {
11161
+ return null;
11162
+ }
11163
+ const target = functionTargetOf(tagNode);
11164
+ return target === null ? null : { file: target.file, name: target.name };
11165
+ }
11166
+ function jsxToRenderNode(node) {
11167
+ if (Node46.isJsxElement(node)) {
11168
+ const opening = node.getOpeningElement();
11169
+ const tag = opening.getTagNameNode().getText();
11170
+ const attrs = collectJsxAttributes(opening);
11171
+ const target = componentTargetOf(opening.getTagNameNode());
11172
+ const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
11173
+ return {
11174
+ type: "element",
11175
+ tag,
11176
+ children,
11177
+ ...attrs !== null ? { attrs } : {},
11178
+ ...target !== null ? { target } : {}
11179
+ };
11180
+ }
11181
+ if (Node46.isJsxSelfClosingElement(node)) {
11182
+ const tag = node.getTagNameNode().getText();
11183
+ const attrs = collectJsxAttributes(node);
11184
+ const target = componentTargetOf(node.getTagNameNode());
11185
+ return {
11186
+ type: "element",
11187
+ tag,
11188
+ children: [],
11189
+ ...attrs !== null ? { attrs } : {},
11190
+ ...target !== null ? { target } : {}
11191
+ };
11192
+ }
11193
+ if (Node46.isJsxFragment(node)) {
11194
+ const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
11195
+ return { type: "element", tag: "Fragment", children };
11196
+ }
11197
+ if (Node46.isParenthesizedExpression(node)) {
11198
+ return jsxToRenderNode(node.getExpression());
11199
+ }
11200
+ return null;
11201
+ }
11202
+ function collectJsxAttributes(opening) {
11203
+ const entries = {};
11204
+ for (const attr of opening.getAttributes()) {
11205
+ if (Node46.isJsxSpreadAttribute(attr)) {
11206
+ const exprText = attr.getExpression().getText();
11207
+ entries[`...${exprText}`] = exprText;
11208
+ continue;
11209
+ }
11210
+ if (!Node46.isJsxAttribute(attr)) {
11211
+ continue;
11212
+ }
11213
+ const name = attr.getNameNode().getText();
11214
+ const initializer = attr.getInitializer();
11215
+ if (initializer === void 0) {
11216
+ entries[name] = "";
11217
+ continue;
11218
+ }
11219
+ if (Node46.isJsxExpression(initializer)) {
11220
+ const inner = initializer.getExpression();
11221
+ entries[name] = inner !== void 0 ? inner.getText() : "";
11222
+ continue;
11223
+ }
11224
+ entries[name] = initializer.getText();
11225
+ }
11226
+ return Object.keys(entries).length > 0 ? entries : null;
11227
+ }
11228
+ function jsxChildToRenderNode(child) {
11229
+ if (Node46.isJsxText(child)) {
11230
+ const text = child.getLiteralText().trim();
11231
+ if (text.length === 0) {
11232
+ return null;
11233
+ }
11234
+ return { type: "text", value: text };
11235
+ }
11236
+ if (Node46.isJsxExpression(child)) {
11237
+ const inner = child.getExpression();
11238
+ if (inner === void 0) {
11239
+ return null;
11240
+ }
11241
+ return jsxExpressionToRenderNode(inner);
11242
+ }
11243
+ if (Node46.isJsxElement(child) || Node46.isJsxSelfClosingElement(child) || Node46.isJsxFragment(child)) {
11244
+ return jsxToRenderNode(child);
11245
+ }
11246
+ return null;
11247
+ }
11248
+ function jsxExpressionToRenderNode(expr) {
11249
+ if (Node46.isParenthesizedExpression(expr)) {
11250
+ return jsxExpressionToRenderNode(expr.getExpression());
11251
+ }
11252
+ if (Node46.isBinaryExpression(expr)) {
11253
+ const op = expr.getOperatorToken().getText();
11254
+ if (op === "&&") {
11255
+ const right = renderAlternative(peelParens(expr.getRight()));
11256
+ if (right.kind === "jsx") {
11257
+ return {
11258
+ type: "conditional",
11259
+ condition: expr.getLeft().getText(),
11260
+ whenTrue: right.node,
11261
+ whenFalse: null
11262
+ };
11263
+ }
11264
+ }
11265
+ }
11266
+ if (Node46.isConditionalExpression(expr)) {
11267
+ const truthy = renderAlternative(peelParens(expr.getWhenTrue()));
11268
+ const falsy = renderAlternative(peelParens(expr.getWhenFalse()));
11269
+ if (truthy.kind === "jsx") {
11270
+ return {
11271
+ type: "conditional",
11272
+ condition: expr.getCondition().getText(),
11273
+ whenTrue: truthy.node,
11274
+ whenFalse: falsy.kind === "jsx" ? falsy.node : null
11275
+ };
11276
+ }
11277
+ if (falsy.kind === "jsx") {
11278
+ return {
11279
+ type: "conditional",
11280
+ condition: `!(${expr.getCondition().getText()})`,
11281
+ whenTrue: falsy.node,
11282
+ whenFalse: null
11283
+ };
11284
+ }
11285
+ }
11286
+ return { type: "expression", sourceText: expr.getText() };
11287
+ }
11288
+ function renderAlternative(node) {
11289
+ if (Node46.isNullLiteral(node)) {
11290
+ return { kind: "noRender" };
11291
+ }
11292
+ if (Node46.isFalseLiteral(node)) {
11293
+ return { kind: "noRender" };
11294
+ }
11295
+ if (Node46.isIdentifier(node) && node.getText() === "undefined") {
11296
+ return { kind: "noRender" };
11297
+ }
11298
+ if (Node46.isJsxElement(node) || Node46.isJsxSelfClosingElement(node) || Node46.isJsxFragment(node)) {
11299
+ const tree = jsxToRenderNode(node);
11300
+ if (tree !== null) {
11301
+ return { kind: "jsx", node: tree };
11302
+ }
11303
+ }
11304
+ return { kind: "notStatic" };
11305
+ }
11306
+
11307
+ // src/terminals/returns.ts
11308
+ import {
11309
+ Node as Node49
11310
+ } from "ts-morph";
11311
+
10865
11312
  // src/terminals/helperResolution.ts
10866
- import { Node as Node47, SyntaxKind as SyntaxKind10 } from "ts-morph";
11313
+ import { Node as Node47, SyntaxKind as SyntaxKind11 } from "ts-morph";
10867
11314
  function resolveHelperReturn(call, resolveCallee2) {
10868
11315
  const callee = call.getExpression();
10869
11316
  if (!Node47.isIdentifier(callee)) {
@@ -11075,7 +11522,7 @@ function returnedObjects(fn) {
11075
11522
  }
11076
11523
  const found = [];
11077
11524
  for (const statement of body.getDescendantsOfKind(
11078
- SyntaxKind10.ReturnStatement
11525
+ SyntaxKind11.ReturnStatement
11079
11526
  )) {
11080
11527
  if (enclosingFunctionOf(statement) !== body) {
11081
11528
  continue;
@@ -11114,13 +11561,14 @@ function bindArguments(callArgs, params) {
11114
11561
 
11115
11562
  // src/terminals/statusBranches.ts
11116
11563
  import { Node as Node48 } from "ts-morph";
11117
- function statusChoicesOf(argument) {
11564
+ import { constantOf as constantOf2 } from "@suss/values";
11565
+ function statusChoicesOf(argument, resolution) {
11118
11566
  const chosen = asConditional(argument);
11119
11567
  if (chosen === null) {
11120
11568
  return null;
11121
11569
  }
11122
- const whenTrue = numberOf(chosen.getWhenTrue());
11123
- const whenFalse = numberOf(chosen.getWhenFalse());
11570
+ const whenTrue = numberOf(chosen.getWhenTrue(), resolution);
11571
+ const whenFalse = numberOf(chosen.getWhenFalse(), resolution);
11124
11572
  if (whenTrue === null || whenFalse === null) {
11125
11573
  return null;
11126
11574
  }
@@ -11151,20 +11599,14 @@ function asConditional(node) {
11151
11599
  return only === void 0 ? null : toConditional(only);
11152
11600
  }
11153
11601
  var toConditional = (node) => Node48.isConditionalExpression(node) ? node : null;
11154
- function numberOf(node) {
11155
- const inner = unwrap(node);
11156
- if (!Node48.isNumericLiteral(inner)) {
11157
- return null;
11158
- }
11159
- const value = Number(inner.getText());
11160
- return Number.isFinite(value) ? value : null;
11161
- }
11162
- function unwrap(node) {
11163
- return peelSyntax(node);
11602
+ function numberOf(node, resolution) {
11603
+ const value = constantOf2(evaluatedValue(node, resolution));
11604
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
11164
11605
  }
11165
11606
 
11166
11607
  // src/terminals/returns.ts
11167
- function unwrapMethodChain(call, methodChain, func, paramPos) {
11608
+ function unwrapMethodChain(call, match, func) {
11609
+ const { methodChain, parameterPosition: paramPos } = match;
11168
11610
  if (methodChain.length === 0) {
11169
11611
  return null;
11170
11612
  }
@@ -11180,7 +11622,10 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
11180
11622
  return null;
11181
11623
  }
11182
11624
  collected.unshift(current2);
11183
- const subject = callee.getExpression();
11625
+ const subject = withoutPassThroughCalls(
11626
+ callee.getExpression(),
11627
+ match.passThroughMethods ?? []
11628
+ );
11184
11629
  if (i === 0) {
11185
11630
  if (parameterPositionOf(subject, func) !== paramPos) {
11186
11631
  return null;
@@ -11194,11 +11639,22 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
11194
11639
  }
11195
11640
  return { calls: collected };
11196
11641
  }
11642
+ function withoutPassThroughCalls(subject, passThrough) {
11643
+ let current2 = subject;
11644
+ while (Node49.isCallExpression(current2)) {
11645
+ const callee = current2.getExpression();
11646
+ if (!Node49.isPropertyAccessExpression(callee) || !passThrough.includes(callee.getName())) {
11647
+ break;
11648
+ }
11649
+ current2 = callee.getExpression();
11650
+ }
11651
+ return current2;
11652
+ }
11197
11653
  function returnedValueOf(returnStatement) {
11198
11654
  const written = returnStatement.getExpression();
11199
11655
  return written === void 0 ? null : unwrapValue(written);
11200
11656
  }
11201
- function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveCallee2) {
11657
+ function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
11202
11658
  if (Node49.isObjectLiteralExpression(node)) {
11203
11659
  const source = returnPositionOf(node);
11204
11660
  if (source === null) {
@@ -11213,7 +11669,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
11213
11669
  pattern,
11214
11670
  match,
11215
11671
  void 0,
11216
- resolveWrittenValue
11672
+ resolution
11217
11673
  );
11218
11674
  return terminal === null ? [] : [{ ...terminal, source }];
11219
11675
  }
@@ -11231,7 +11687,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
11231
11687
  pattern,
11232
11688
  match,
11233
11689
  void 0,
11234
- resolveWrittenValue
11690
+ resolution
11235
11691
  );
11236
11692
  return terminal === null ? [] : [terminal];
11237
11693
  }
@@ -11259,7 +11715,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
11259
11715
  pattern,
11260
11716
  match,
11261
11717
  resolved.substitutions,
11262
- resolveWrittenValue
11718
+ resolution
11263
11719
  );
11264
11720
  if (terminal !== null) {
11265
11721
  terminals.push(terminal);
@@ -11267,7 +11723,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue, resolveC
11267
11723
  }
11268
11724
  return terminals;
11269
11725
  }
11270
- function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions, resolveWrittenValue) {
11726
+ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions, resolution) {
11271
11727
  const required = match.requiredProperties;
11272
11728
  if (required !== void 0 && required.length > 0) {
11273
11729
  const presentNames = /* @__PURE__ */ new Set();
@@ -11286,7 +11742,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
11286
11742
  extraction: pattern.extraction,
11287
11743
  returnedObj: obj,
11288
11744
  ...substitutions !== void 0 ? { substitutions } : {},
11289
- ...resolveWrittenValue !== void 0 ? { resolveWrittenValue } : {}
11745
+ ...resolution !== void 0 ? { resolution } : {}
11290
11746
  };
11291
11747
  const statusCode = extractStatusCode(ctx);
11292
11748
  let body = extractBody(ctx);
@@ -11316,16 +11772,11 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
11316
11772
  }
11317
11773
  };
11318
11774
  }
11319
- function tryMatchParameterMethodCall(node, func, pattern, match, resolveWrittenValue) {
11775
+ function tryMatchParameterMethodCall(node, func, pattern, match, resolution) {
11320
11776
  if (!Node49.isCallExpression(node)) {
11321
11777
  return [];
11322
11778
  }
11323
- const result = unwrapMethodChain(
11324
- node,
11325
- match.methodChain,
11326
- func,
11327
- match.parameterPosition
11328
- );
11779
+ const result = unwrapMethodChain(node, match, func);
11329
11780
  if (result === null) {
11330
11781
  return [];
11331
11782
  }
@@ -11334,7 +11785,7 @@ function tryMatchParameterMethodCall(node, func, pattern, match, resolveWrittenV
11334
11785
  const ctx = {
11335
11786
  extraction: pattern.extraction,
11336
11787
  calls,
11337
- ...resolveWrittenValue !== void 0 ? { resolveWrittenValue } : {}
11788
+ ...resolution !== void 0 ? { resolution } : {}
11338
11789
  };
11339
11790
  const statusCode = extractStatusCode(ctx);
11340
11791
  const body = extractBody(ctx);
@@ -11355,7 +11806,7 @@ function tryMatchParameterMethodCall(node, func, pattern, match, resolveWrittenV
11355
11806
  };
11356
11807
  const base = { node, ...source !== null ? { source } : {} };
11357
11808
  const argument = statusArgument(calls, pattern.extraction);
11358
- const choices = argument === null ? null : statusChoicesOf(argument);
11809
+ const choices = argument === null ? null : statusChoicesOf(argument, resolution);
11359
11810
  if (choices === null) {
11360
11811
  return [{ ...base, terminal }];
11361
11812
  }
@@ -11389,12 +11840,7 @@ function returnCoveredByParameterMethodCall(expr, func, patterns) {
11389
11840
  if (pattern.match.type !== "parameterMethodCall") {
11390
11841
  continue;
11391
11842
  }
11392
- const result = unwrapMethodChain(
11393
- current2,
11394
- pattern.match.methodChain,
11395
- func,
11396
- pattern.match.parameterPosition
11397
- );
11843
+ const result = unwrapMethodChain(current2, pattern.match, func);
11398
11844
  if (result !== null) {
11399
11845
  return true;
11400
11846
  }
@@ -11434,10 +11880,9 @@ function tryMatchReturnStatement(node, pattern, func, allPatterns) {
11434
11880
  return null;
11435
11881
  }
11436
11882
  function buildReturnTerminal(locationNode, pattern, body) {
11437
- const statusCode = pattern.extraction.defaultStatusCode !== void 0 ? { type: "literal", value: pattern.extraction.defaultStatusCode } : null;
11438
11883
  const terminal = {
11439
11884
  kind: pattern.kind,
11440
- statusCode,
11885
+ statusCode: declaredStatusCode(pattern.extraction),
11441
11886
  body,
11442
11887
  exceptionType: null,
11443
11888
  message: null,
@@ -11492,7 +11937,7 @@ function calleeSubject(callee) {
11492
11937
  }
11493
11938
  return null;
11494
11939
  }
11495
- function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue, originatesFrom) {
11940
+ function tryMatchFunctionCall(node, pattern, match, resolution, originatesFrom) {
11496
11941
  if (!Node49.isCallExpression(node) && !Node49.isNewExpression(node)) {
11497
11942
  return null;
11498
11943
  }
@@ -11511,7 +11956,7 @@ function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue, origina
11511
11956
  const ctx = {
11512
11957
  extraction: pattern.extraction,
11513
11958
  throwCallArgs: callArgs,
11514
- ...resolveWrittenValue !== void 0 ? { resolveWrittenValue } : {}
11959
+ ...resolution !== void 0 ? { resolution } : {}
11515
11960
  };
11516
11961
  const statusCode = extractStatusCode(ctx);
11517
11962
  const body = extractBody(ctx);
@@ -11536,7 +11981,7 @@ function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue, origina
11536
11981
 
11537
11982
  // src/terminals/throws.ts
11538
11983
  import { Node as Node50 } from "ts-morph";
11539
- function tryMatchThrowExpression(node, pattern, match, resolveWrittenValue) {
11984
+ function tryMatchThrowExpression(node, pattern, match, resolution) {
11540
11985
  if (!Node50.isThrowStatement(node)) {
11541
11986
  return null;
11542
11987
  }
@@ -11551,7 +11996,7 @@ function tryMatchThrowExpression(node, pattern, match, resolveWrittenValue) {
11551
11996
  extraction: pattern.extraction,
11552
11997
  ...callArgs !== null ? { throwCallArgs: callArgs } : {},
11553
11998
  ...exceptionType !== null ? { exceptionType } : {},
11554
- ...resolveWrittenValue !== void 0 ? { resolveWrittenValue } : {}
11999
+ ...resolution !== void 0 ? { resolution } : {}
11555
12000
  };
11556
12001
  const statusCode = extractStatusCode(ctx);
11557
12002
  const body = extractBody(ctx);
@@ -11607,7 +12052,7 @@ function classifyThrownExpression(thrown, constructorPattern) {
11607
12052
 
11608
12053
  // src/terminals/index.ts
11609
12054
  var NESTED_ESCAPING_MATCH_TYPES = /* @__PURE__ */ new Set(["parameterMethodCall"]);
11610
- function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenValue, originatesFrom, resolveCallee2) {
12055
+ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolution, originatesFrom, resolveCallee2) {
11611
12056
  const results = [];
11612
12057
  func.forEachDescendant((node, traversal) => {
11613
12058
  if (isDescentStop(node, func, barriers)) {
@@ -11625,7 +12070,7 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
11625
12070
  node,
11626
12071
  pattern,
11627
12072
  pattern.match,
11628
- resolveWrittenValue,
12073
+ resolution,
11629
12074
  resolveCallee2
11630
12075
  );
11631
12076
  if (matches.length > 0) {
@@ -11640,7 +12085,7 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
11640
12085
  func,
11641
12086
  pattern,
11642
12087
  pattern.match,
11643
- resolveWrittenValue
12088
+ resolution
11644
12089
  );
11645
12090
  if (matches.length > 0) {
11646
12091
  results.push(...matches);
@@ -11657,14 +12102,14 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
11657
12102
  node,
11658
12103
  pattern,
11659
12104
  pattern.match,
11660
- resolveWrittenValue
12105
+ resolution
11661
12106
  );
11662
12107
  } else if (pattern.match.type === "functionCall") {
11663
12108
  found = tryMatchFunctionCall(
11664
12109
  node,
11665
12110
  pattern,
11666
12111
  pattern.match,
11667
- resolveWrittenValue,
12112
+ resolution,
11668
12113
  originatesFrom
11669
12114
  );
11670
12115
  } else if (pattern.match.type === "parameterCall") {
@@ -11726,15 +12171,15 @@ function functionMayFallThrough(func) {
11726
12171
  }
11727
12172
  return true;
11728
12173
  }
11729
- function makeFallthroughTerminal(func) {
12174
+ function makeFallthroughTerminal(func, pattern) {
11730
12175
  const body = func.getBody();
11731
12176
  const anchor = body ?? func;
11732
12177
  const line = endLineOf(anchor);
11733
12178
  return {
11734
12179
  node: anchor,
11735
12180
  terminal: {
11736
- kind: "return",
11737
- statusCode: null,
12181
+ kind: pattern.kind,
12182
+ statusCode: declaredStatusCode(pattern.extraction),
11738
12183
  body: null,
11739
12184
  exceptionType: null,
11740
12185
  message: null,
@@ -11820,15 +12265,16 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
11820
12265
  });
11821
12266
  return unmatched;
11822
12267
  }
11823
- function extractRawBranches(func, terminalPatterns, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolveWrittenValue, originatesFrom, anchorCallsOf, resolveCallee2) {
12268
+ function extractRawBranches(func, terminalPatterns, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolution, originatesFrom, anchorCallsOf, resolveCallee2) {
11824
12269
  const terminals = findTerminals(
11825
12270
  func,
11826
12271
  terminalPatterns,
11827
12272
  barriers,
11828
- resolveWrittenValue,
12273
+ resolution,
11829
12274
  originatesFrom,
11830
12275
  resolveCallee2
11831
12276
  );
12277
+ const resolveWrittenValue = resolution === void 0 ? void 0 : (value) => resolution.resolveWrittenValue(value);
11832
12278
  const invocations = extractInvocationEffects(func, barriers);
11833
12279
  const recognized = [
11834
12280
  ...runInvocationRecognizers(
@@ -11853,15 +12299,15 @@ function extractRawBranches(func, terminalPatterns, invocationRecognizers = [],
11853
12299
  terminals.map(({ node }) => node),
11854
12300
  barriers
11855
12301
  );
11856
- const wantsFallthrough = terminalPatterns.some(
12302
+ const fallthroughPattern = terminalPatterns.find(
11857
12303
  (p) => p.match.type === "functionFallthrough"
11858
12304
  );
11859
- if (wantsFallthrough && functionMayFallThrough(func)) {
12305
+ if (fallthroughPattern !== void 0 && functionMayFallThrough(func)) {
11860
12306
  const hasDefaultTerminal = terminals.some(
11861
12307
  ({ node }) => (byTerminal.get(node) ?? []).some(isDefaultConditionList)
11862
12308
  );
11863
12309
  if (!hasDefaultTerminal) {
11864
- const synthetic = makeFallthroughTerminal(func);
12310
+ const synthetic = makeFallthroughTerminal(func, fallthroughPattern);
11865
12311
  terminals.push(synthetic);
11866
12312
  const pathResult = computePathConditions(
11867
12313
  func,
@@ -13793,7 +14239,7 @@ function extractReachableSummary(candidate, options, recognizers) {
13793
14239
  recognizers.invocation,
13794
14240
  recognizers.access,
13795
14241
  void 0,
13796
- recognizers.resolveWrittenValue
14242
+ recognizers.resolution
13797
14243
  );
13798
14244
  raw.boundaryBinding = functionCallBinding({
13799
14245
  transport: "in-process",
@@ -14398,7 +14844,7 @@ function prefixOfExpr(expr, responseCall, depth) {
14398
14844
  if (depth >= MAX_PREFIX_DEPTH) {
14399
14845
  return null;
14400
14846
  }
14401
- const node = unwrap2(expr);
14847
+ const node = unwrap(expr);
14402
14848
  if (node === responseCall) {
14403
14849
  return [];
14404
14850
  }
@@ -14451,7 +14897,7 @@ function firstCallbackParamName(callback) {
14451
14897
  const nameNode = param.getNameNode();
14452
14898
  return Node62.isIdentifier(nameNode) ? nameNode.getText() : null;
14453
14899
  }
14454
- function unwrap2(expr) {
14900
+ function unwrap(expr) {
14455
14901
  let node = expr;
14456
14902
  while (Node62.isAwaitExpression(node) || Node62.isParenthesizedExpression(node) || Node62.isAsExpression(node)) {
14457
14903
  node = node.getExpression();
@@ -14466,7 +14912,7 @@ function chainRootedAt(expr, rootName) {
14466
14912
  return Node62.isIdentifier(chain.root) && chain.root.getText() === rootName ? chain.segments : null;
14467
14913
  }
14468
14914
  function memberChain(expr) {
14469
- let node = Node62.isExpression(expr) ? unwrap2(expr) : expr;
14915
+ let node = Node62.isExpression(expr) ? unwrap(expr) : expr;
14470
14916
  if (Node62.isCallExpression(node)) {
14471
14917
  node = node.getExpression();
14472
14918
  }
@@ -15369,7 +15815,7 @@ function announcedBoundaryStructure(unit) {
15369
15815
  declaredContract: null
15370
15816
  };
15371
15817
  }
15372
- function extractCodeStructure(unit, pack, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolveWrittenValue, originatesFrom, anchorCallsOf, resolveCallee2) {
15818
+ function extractCodeStructure(unit, pack, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS, resolution, originatesFrom, anchorCallsOf, resolveCallee2) {
15373
15819
  const read2 = withDefinitions(
15374
15820
  () => readCodeStructure(
15375
15821
  unit,
@@ -15377,7 +15823,7 @@ function extractCodeStructure(unit, pack, invocationRecognizers = [], accessReco
15377
15823
  invocationRecognizers,
15378
15824
  accessRecognizers,
15379
15825
  barriers,
15380
- resolveWrittenValue,
15826
+ resolution,
15381
15827
  originatesFrom,
15382
15828
  anchorCallsOf,
15383
15829
  resolveCallee2
@@ -15462,7 +15908,7 @@ function terminalsFor(unit, pack) {
15462
15908
  }
15463
15909
  return [...declared, FUNCTION_FALLTHROUGH_TERMINAL];
15464
15910
  }
15465
- function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers, barriers, resolveWrittenValue, originatesFrom, anchorCallsOf, resolveCallee2) {
15911
+ function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers, barriers, resolution, originatesFrom, anchorCallsOf, resolveCallee2) {
15466
15912
  const { func, kind, name } = unit;
15467
15913
  if (func === null) {
15468
15914
  return announcedBoundaryStructure(unit);
@@ -15477,7 +15923,7 @@ function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers,
15477
15923
  invocationRecognizers,
15478
15924
  accessRecognizers,
15479
15925
  barriers,
15480
- resolveWrittenValue,
15926
+ resolution,
15481
15927
  originatesFrom,
15482
15928
  anchorCallsOf,
15483
15929
  resolveCallee2
@@ -15599,21 +16045,9 @@ function extractBindingMethod(binding, callSite, pack, resolution) {
15599
16045
  return resolveContractField(callSite, pack, "method", resolution);
15600
16046
  }
15601
16047
  if (m.type === "fromArgumentProperty") {
15602
- const args = callSite.callExpression.getArguments();
15603
- const arg = args[m.position];
15604
- if (arg !== void 0 && Node64.isObjectLiteralExpression(arg)) {
15605
- const prop = arg.getProperty(m.property);
15606
- if (prop !== void 0 && Node64.isPropertyAssignment(prop)) {
15607
- const init = prop.getInitializer();
15608
- if (init !== void 0) {
15609
- const value = stringValueOf(init, resolution);
15610
- if (value !== null) {
15611
- return value;
15612
- }
15613
- }
15614
- }
15615
- }
15616
- return m.default;
16048
+ const arg = callSite.callExpression.getArguments()[m.position];
16049
+ const value = arg === void 0 ? null : stringPropertyOf(arg, m.property, resolution);
16050
+ return value ?? m.default;
15617
16051
  }
15618
16052
  if (m.type === "literal") {
15619
16053
  return m.value;
@@ -15816,7 +16250,7 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
15816
16250
  allInvocationRecognizers,
15817
16251
  allAccessRecognizers,
15818
16252
  barriers,
15819
- resolution === void 0 ? void 0 : (value) => resolution.resolveWrittenValue(value),
16253
+ resolution,
15820
16254
  resolution === void 0 ? void 0 : (value, module) => resolution.importOriginsOf(value, [module]).length > 0,
15821
16255
  resolution === void 0 ? void 0 : (value, matches) => resolution.anchorCallsOf(value, matches),
15822
16256
  resolution === void 0 ? void 0 : (value) => resolution.resolveCallable(value)
@@ -16178,7 +16612,7 @@ function findWrapperPathParam(summary, lookup) {
16178
16612
  if (names.length === 0) {
16179
16613
  return null;
16180
16614
  }
16181
- for (const call of func.getDescendantsOfKind(SyntaxKind11.CallExpression)) {
16615
+ for (const call of func.getDescendantsOfKind(SyntaxKind12.CallExpression)) {
16182
16616
  const first = call.getArguments()[0];
16183
16617
  if (first === void 0 || !Node64.isIdentifier(first)) {
16184
16618
  continue;
@@ -16650,7 +17084,7 @@ function createTypeScriptAdapter(suppliedConfig) {
16650
17084
  ...projectHelpers.contributedRecognizers()
16651
17085
  ],
16652
17086
  access: collectAccessRecognizers(config.frameworks, tallies),
16653
- resolveWrittenValue: (value) => resolution.resolveWrittenValue(value),
17087
+ resolution,
16654
17088
  resolveCallableSources: (value, alsoFrom) => resolution.resolveCallableSources(value, alsoFrom),
16655
17089
  sourceDeclarationsBehind: (declaration) => sourceDeclarationsBehind(declaration, resolution)
16656
17090
  },
@@ -17189,7 +17623,7 @@ function findNearestTsconfig(startDir) {
17189
17623
 
17190
17624
  // src/facts/why.ts
17191
17625
  import path12 from "path";
17192
- import { Node as Node65, Project as Project3, SyntaxKind as SyntaxKind12 } from "ts-morph";
17626
+ import { Node as Node65, Project as Project3, SyntaxKind as SyntaxKind13 } from "ts-morph";
17193
17627
  import { explainResolutionProof, renderExplanation } from "@suss/resolution";
17194
17628
  var JS_PHRASES = {
17195
17629
  bind: ({ tuple, describe }) => ({
@@ -17236,7 +17670,7 @@ var TypeScriptWhySession = class {
17236
17670
  return null;
17237
17671
  }
17238
17672
  for (const call of sourceFile.getDescendantsOfKind(
17239
- SyntaxKind12.CallExpression
17673
+ SyntaxKind13.CallExpression
17240
17674
  )) {
17241
17675
  const line = call.getStartLineNumber();
17242
17676
  if (line < startLine || line > endLine) {