@suss/adapter-typescript 0.22.4 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.cjs +326 -320
- package/dist/index.js +10 -4
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -78,13 +78,13 @@ module.exports = __toCommonJS(index_exports);
|
|
|
78
78
|
|
|
79
79
|
// src/adapter.ts
|
|
80
80
|
var import_node_path10 = __toESM(require("path"), 1);
|
|
81
|
-
var
|
|
81
|
+
var import_ts_morph67 = require("ts-morph");
|
|
82
82
|
var import_behavioral_ir8 = require("@suss/behavioral-ir");
|
|
83
83
|
var import_datalog6 = require("@suss/datalog");
|
|
84
84
|
var import_extractor11 = require("@suss/extractor");
|
|
85
85
|
|
|
86
86
|
// src/assembly.ts
|
|
87
|
-
var
|
|
87
|
+
var import_ts_morph55 = require("ts-morph");
|
|
88
88
|
var import_extractor5 = require("@suss/extractor");
|
|
89
89
|
|
|
90
90
|
// src/conditions.ts
|
|
@@ -10181,7 +10181,7 @@ function enclosingStatementLine(node) {
|
|
|
10181
10181
|
}
|
|
10182
10182
|
|
|
10183
10183
|
// src/terminals/index.ts
|
|
10184
|
-
var
|
|
10184
|
+
var import_ts_morph54 = require("ts-morph");
|
|
10185
10185
|
|
|
10186
10186
|
// src/terminals/continuation.ts
|
|
10187
10187
|
var import_ts_morph45 = require("ts-morph");
|
|
@@ -10253,14 +10253,15 @@ function tryMatchParameterCall(node, func, pattern, match) {
|
|
|
10253
10253
|
}
|
|
10254
10254
|
|
|
10255
10255
|
// src/terminals/extract.ts
|
|
10256
|
-
var
|
|
10256
|
+
var import_ts_morph48 = require("ts-morph");
|
|
10257
10257
|
var import_values5 = require("@suss/values");
|
|
10258
10258
|
|
|
10259
10259
|
// src/shapes/shapes.ts
|
|
10260
|
-
var
|
|
10260
|
+
var import_ts_morph47 = require("ts-morph");
|
|
10261
10261
|
|
|
10262
10262
|
// src/shapes/typeShapes.ts
|
|
10263
10263
|
var import_node_crypto = require("crypto");
|
|
10264
|
+
var import_ts_morph46 = require("ts-morph");
|
|
10264
10265
|
|
|
10265
10266
|
// src/shapes/definitions.ts
|
|
10266
10267
|
var current = null;
|
|
@@ -10422,7 +10423,7 @@ function typeToShape(type, ctx) {
|
|
|
10422
10423
|
if (type.isEnum() || type.isEnumLiteral()) {
|
|
10423
10424
|
return enumToShape(type, ctx);
|
|
10424
10425
|
}
|
|
10425
|
-
const text = type
|
|
10426
|
+
const text = printedTypeName(type, ctx);
|
|
10426
10427
|
if (text && text.length > 0 && text !== "__type") {
|
|
10427
10428
|
return { type: "ref", name: text };
|
|
10428
10429
|
}
|
|
@@ -10470,8 +10471,7 @@ function intersectionToShape(type, ctx) {
|
|
|
10470
10471
|
if (nonRecords.length === 1 && records.length === 0) {
|
|
10471
10472
|
return nonRecords[0];
|
|
10472
10473
|
}
|
|
10473
|
-
|
|
10474
|
-
return { type: "ref", name: text };
|
|
10474
|
+
return { type: "ref", name: printedTypeName(type, ctx) };
|
|
10475
10475
|
}
|
|
10476
10476
|
function objectToShape(type, ctx) {
|
|
10477
10477
|
const key = typeKey(type, ctx.enclosing);
|
|
@@ -10531,7 +10531,7 @@ function opaqueNamedRef(type, ctx) {
|
|
|
10531
10531
|
if (!OPAQUE_NAMED_TYPES.has(name)) {
|
|
10532
10532
|
return null;
|
|
10533
10533
|
}
|
|
10534
|
-
const text = type
|
|
10534
|
+
const text = printedTypeName(type, ctx);
|
|
10535
10535
|
return { type: "ref", name: text && text.length > 0 ? text : name };
|
|
10536
10536
|
}
|
|
10537
10537
|
function outsideProjectRef(type, ctx) {
|
|
@@ -10612,6 +10612,12 @@ function refFromType(type, ctx) {
|
|
|
10612
10612
|
}
|
|
10613
10613
|
return { type: "ref", name: withoutImportQualifiers(type.getText()) };
|
|
10614
10614
|
}
|
|
10615
|
+
var PRINTED_NAME_FLAGS = import_ts_morph46.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | import_ts_morph46.TypeFormatFlags.UseTypeOfFunction | import_ts_morph46.TypeFormatFlags.NoTruncation | import_ts_morph46.TypeFormatFlags.WriteTypeArgumentsOfSignature;
|
|
10616
|
+
function printedTypeName(type, ctx) {
|
|
10617
|
+
return withoutImportQualifiers(
|
|
10618
|
+
type.getText(ctx.enclosing, PRINTED_NAME_FLAGS)
|
|
10619
|
+
);
|
|
10620
|
+
}
|
|
10615
10621
|
var IMPORT_QUALIFIER = /import\("[^"]*"\)\./g;
|
|
10616
10622
|
var withoutImportQualifiers = (text) => text.replace(IMPORT_QUALIFIER, "");
|
|
10617
10623
|
function declaringFileOf(symbol) {
|
|
@@ -10716,60 +10722,60 @@ function extractShapeWithArguments(node, substitutions) {
|
|
|
10716
10722
|
}
|
|
10717
10723
|
function extractShapeInner(node) {
|
|
10718
10724
|
const unwrapped2 = peelSyntax(node);
|
|
10719
|
-
if (boundArguments !== null &&
|
|
10725
|
+
if (boundArguments !== null && import_ts_morph47.Node.isIdentifier(unwrapped2)) {
|
|
10720
10726
|
const argument = boundArguments.get(unwrapped2.getText());
|
|
10721
10727
|
if (argument !== void 0 && argument !== unwrapped2) {
|
|
10722
10728
|
return extractShape(argument);
|
|
10723
10729
|
}
|
|
10724
10730
|
}
|
|
10725
|
-
if (
|
|
10731
|
+
if (import_ts_morph47.Node.isObjectLiteralExpression(unwrapped2)) {
|
|
10726
10732
|
return shapeFromObjectLiteral(unwrapped2);
|
|
10727
10733
|
}
|
|
10728
|
-
if (
|
|
10734
|
+
if (import_ts_morph47.Node.isArrayLiteralExpression(unwrapped2)) {
|
|
10729
10735
|
return shapeFromArrayLiteral(unwrapped2);
|
|
10730
10736
|
}
|
|
10731
|
-
if (
|
|
10737
|
+
if (import_ts_morph47.Node.isStringLiteral(unwrapped2) || import_ts_morph47.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
|
|
10732
10738
|
return { type: "literal", value: unwrapped2.getLiteralValue() };
|
|
10733
10739
|
}
|
|
10734
|
-
if (
|
|
10740
|
+
if (import_ts_morph47.Node.isTemplateExpression(unwrapped2)) {
|
|
10735
10741
|
return { type: "text" };
|
|
10736
10742
|
}
|
|
10737
|
-
if (
|
|
10743
|
+
if (import_ts_morph47.Node.isNumericLiteral(unwrapped2)) {
|
|
10738
10744
|
return numericLiteralShape(
|
|
10739
10745
|
unwrapped2.getLiteralValue(),
|
|
10740
10746
|
unwrapped2.getText()
|
|
10741
10747
|
);
|
|
10742
10748
|
}
|
|
10743
|
-
if (
|
|
10749
|
+
if (import_ts_morph47.Node.isPrefixUnaryExpression(unwrapped2)) {
|
|
10744
10750
|
const op = unwrapped2.getOperatorToken();
|
|
10745
|
-
if (op ===
|
|
10751
|
+
if (op === import_ts_morph47.SyntaxKind.MinusToken || op === import_ts_morph47.SyntaxKind.PlusToken) {
|
|
10746
10752
|
const inner = unwrapped2.getOperand();
|
|
10747
|
-
if (
|
|
10753
|
+
if (import_ts_morph47.Node.isNumericLiteral(inner)) {
|
|
10748
10754
|
const v3 = inner.getLiteralValue();
|
|
10749
|
-
const signed = op ===
|
|
10755
|
+
const signed = op === import_ts_morph47.SyntaxKind.MinusToken ? -v3 : v3;
|
|
10750
10756
|
const rawBody = inner.getText();
|
|
10751
|
-
const raw = op ===
|
|
10757
|
+
const raw = op === import_ts_morph47.SyntaxKind.MinusToken ? `-${rawBody}` : rawBody;
|
|
10752
10758
|
return numericLiteralShape(signed, raw);
|
|
10753
10759
|
}
|
|
10754
10760
|
}
|
|
10755
10761
|
}
|
|
10756
|
-
if (
|
|
10762
|
+
if (import_ts_morph47.Node.isBigIntLiteral(unwrapped2)) {
|
|
10757
10763
|
return { type: "ref", name: "bigint" };
|
|
10758
10764
|
}
|
|
10759
10765
|
const kind = unwrapped2.getKind();
|
|
10760
|
-
if (kind ===
|
|
10766
|
+
if (kind === import_ts_morph47.SyntaxKind.TrueKeyword) {
|
|
10761
10767
|
return { type: "literal", value: true };
|
|
10762
10768
|
}
|
|
10763
|
-
if (kind ===
|
|
10769
|
+
if (kind === import_ts_morph47.SyntaxKind.FalseKeyword) {
|
|
10764
10770
|
return { type: "literal", value: false };
|
|
10765
10771
|
}
|
|
10766
|
-
if (kind ===
|
|
10772
|
+
if (kind === import_ts_morph47.SyntaxKind.NullKeyword) {
|
|
10767
10773
|
return { type: "null" };
|
|
10768
10774
|
}
|
|
10769
|
-
if (
|
|
10775
|
+
if (import_ts_morph47.Node.isIdentifier(unwrapped2) && unwrapped2.getText() === "undefined") {
|
|
10770
10776
|
return { type: "undefined" };
|
|
10771
10777
|
}
|
|
10772
|
-
if (
|
|
10778
|
+
if (import_ts_morph47.Node.isConditionalExpression(unwrapped2)) {
|
|
10773
10779
|
const whenTrue = extractShape(unwrapped2.getWhenTrue());
|
|
10774
10780
|
const whenFalse = extractShape(unwrapped2.getWhenFalse());
|
|
10775
10781
|
const variants = [];
|
|
@@ -10800,7 +10806,7 @@ function shapeFromArrayLiteral(arr) {
|
|
|
10800
10806
|
}
|
|
10801
10807
|
const shapes = [];
|
|
10802
10808
|
for (const el of elements) {
|
|
10803
|
-
if (
|
|
10809
|
+
if (import_ts_morph47.Node.isSpreadElement(el)) {
|
|
10804
10810
|
const inner = el.getExpression();
|
|
10805
10811
|
const innerShape = extractShape(inner);
|
|
10806
10812
|
if (innerShape?.type === "array") {
|
|
@@ -10819,7 +10825,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10819
10825
|
const properties = {};
|
|
10820
10826
|
const unresolvedSpreads = [];
|
|
10821
10827
|
for (const prop of obj.getProperties()) {
|
|
10822
|
-
if (
|
|
10828
|
+
if (import_ts_morph47.Node.isPropertyAssignment(prop)) {
|
|
10823
10829
|
const name = propertyName2(prop);
|
|
10824
10830
|
if (name === null) {
|
|
10825
10831
|
continue;
|
|
@@ -10835,7 +10841,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10835
10841
|
};
|
|
10836
10842
|
continue;
|
|
10837
10843
|
}
|
|
10838
|
-
if (
|
|
10844
|
+
if (import_ts_morph47.Node.isShorthandPropertyAssignment(prop)) {
|
|
10839
10845
|
const name = prop.getName();
|
|
10840
10846
|
const valueExpr = prop.getNameNode();
|
|
10841
10847
|
properties[name] = extractShape(valueExpr) ?? {
|
|
@@ -10844,7 +10850,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10844
10850
|
};
|
|
10845
10851
|
continue;
|
|
10846
10852
|
}
|
|
10847
|
-
if (
|
|
10853
|
+
if (import_ts_morph47.Node.isSpreadAssignment(prop)) {
|
|
10848
10854
|
const expr = prop.getExpression();
|
|
10849
10855
|
const spreadShape = extractShape(expr);
|
|
10850
10856
|
if (spreadShape?.type === "record") {
|
|
@@ -10863,7 +10869,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10863
10869
|
}
|
|
10864
10870
|
function propertyName2(prop) {
|
|
10865
10871
|
const nameNode = prop.getNameNode();
|
|
10866
|
-
if (
|
|
10872
|
+
if (import_ts_morph47.Node.isIdentifier(nameNode) || import_ts_morph47.Node.isStringLiteral(nameNode) || import_ts_morph47.Node.isNoSubstitutionTemplateLiteral(nameNode) || import_ts_morph47.Node.isNumericLiteral(nameNode)) {
|
|
10867
10873
|
return nameNode.getText().replace(/^["']|["']$/g, "");
|
|
10868
10874
|
}
|
|
10869
10875
|
return null;
|
|
@@ -10894,15 +10900,15 @@ function unwrapAs(node) {
|
|
|
10894
10900
|
}
|
|
10895
10901
|
function unwrapJsonStringify(node) {
|
|
10896
10902
|
const outer = unwrapAs(node);
|
|
10897
|
-
if (!
|
|
10903
|
+
if (!import_ts_morph48.Node.isCallExpression(outer)) {
|
|
10898
10904
|
return node;
|
|
10899
10905
|
}
|
|
10900
10906
|
const callee = outer.getExpression();
|
|
10901
|
-
if (!
|
|
10907
|
+
if (!import_ts_morph48.Node.isPropertyAccessExpression(callee) || callee.getName() !== "stringify") {
|
|
10902
10908
|
return node;
|
|
10903
10909
|
}
|
|
10904
10910
|
const receiver = callee.getExpression();
|
|
10905
|
-
if (!
|
|
10911
|
+
if (!import_ts_morph48.Node.isIdentifier(receiver) || receiver.getText() !== "JSON") {
|
|
10906
10912
|
return node;
|
|
10907
10913
|
}
|
|
10908
10914
|
const args = outer.getArguments();
|
|
@@ -10912,7 +10918,7 @@ function unwrapJsonStringify(node) {
|
|
|
10912
10918
|
return unwrapAs(args[0]);
|
|
10913
10919
|
}
|
|
10914
10920
|
function substituted(value, ctx) {
|
|
10915
|
-
if (ctx.substitutions === void 0 || !
|
|
10921
|
+
if (ctx.substitutions === void 0 || !import_ts_morph48.Node.isIdentifier(value)) {
|
|
10916
10922
|
return value;
|
|
10917
10923
|
}
|
|
10918
10924
|
return ctx.substitutions.get(value.getText()) ?? value;
|
|
@@ -10956,10 +10962,10 @@ function statusFromProperty(obj, name, ctx) {
|
|
|
10956
10962
|
if (prop === void 0) {
|
|
10957
10963
|
return null;
|
|
10958
10964
|
}
|
|
10959
|
-
if (
|
|
10965
|
+
if (import_ts_morph48.Node.isShorthandPropertyAssignment(prop)) {
|
|
10960
10966
|
return { type: "dynamic", sourceText: prop.getName() };
|
|
10961
10967
|
}
|
|
10962
|
-
if (!
|
|
10968
|
+
if (!import_ts_morph48.Node.isPropertyAssignment(prop)) {
|
|
10963
10969
|
return null;
|
|
10964
10970
|
}
|
|
10965
10971
|
const value = prop.getInitializer();
|
|
@@ -10982,7 +10988,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
10982
10988
|
return null;
|
|
10983
10989
|
}
|
|
10984
10990
|
const first = ctx.throwCallArgs?.[0];
|
|
10985
|
-
if (first !== void 0 &&
|
|
10991
|
+
if (first !== void 0 && import_ts_morph48.Node.isNumericLiteral(first)) {
|
|
10986
10992
|
const value = first.getLiteralValue();
|
|
10987
10993
|
if (value >= 100 && value <= 599) {
|
|
10988
10994
|
return { type: "literal", value };
|
|
@@ -10995,7 +11001,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
10995
11001
|
return null;
|
|
10996
11002
|
}
|
|
10997
11003
|
const arg = ctx.throwCallArgs[sc.position];
|
|
10998
|
-
if (arg === void 0 || !
|
|
11004
|
+
if (arg === void 0 || !import_ts_morph48.Node.isNewExpression(arg)) {
|
|
10999
11005
|
return null;
|
|
11000
11006
|
}
|
|
11001
11007
|
const ctorText = arg.getExpression().getText();
|
|
@@ -11004,7 +11010,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
11004
11010
|
if (sc.from === "argumentProperty") {
|
|
11005
11011
|
const args = ctx.throwCallArgs ?? ctx.calls?.[0]?.getArguments();
|
|
11006
11012
|
const arg = args?.[sc.position];
|
|
11007
|
-
if (arg === void 0 || !
|
|
11013
|
+
if (arg === void 0 || !import_ts_morph48.Node.isObjectLiteralExpression(arg)) {
|
|
11008
11014
|
return null;
|
|
11009
11015
|
}
|
|
11010
11016
|
return statusFromProperty(arg, sc.name, ctx);
|
|
@@ -11014,8 +11020,8 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
11014
11020
|
return null;
|
|
11015
11021
|
}
|
|
11016
11022
|
for (const prop of ctx.returnedObj.getProperties()) {
|
|
11017
|
-
if (!
|
|
11018
|
-
if (
|
|
11023
|
+
if (!import_ts_morph48.Node.isPropertyAssignment(prop)) {
|
|
11024
|
+
if (import_ts_morph48.Node.isShorthandPropertyAssignment(prop)) {
|
|
11019
11025
|
if (prop.getName() === sc.name) {
|
|
11020
11026
|
const resolved = ctx.substitutions?.get(prop.getName());
|
|
11021
11027
|
if (resolved !== void 0) {
|
|
@@ -11073,8 +11079,8 @@ function extractBody(ctx) {
|
|
|
11073
11079
|
return null;
|
|
11074
11080
|
}
|
|
11075
11081
|
for (const prop of ctx.returnedObj.getProperties()) {
|
|
11076
|
-
if (!
|
|
11077
|
-
if (
|
|
11082
|
+
if (!import_ts_morph48.Node.isPropertyAssignment(prop)) {
|
|
11083
|
+
if (import_ts_morph48.Node.isShorthandPropertyAssignment(prop)) {
|
|
11078
11084
|
if (prop.getName() === b.name) {
|
|
11079
11085
|
const resolved = ctx.substitutions?.get(prop.getName());
|
|
11080
11086
|
if (resolved !== void 0) {
|
|
@@ -11129,16 +11135,16 @@ function extractBody(ctx) {
|
|
|
11129
11135
|
}
|
|
11130
11136
|
|
|
11131
11137
|
// src/terminals/jsx.ts
|
|
11132
|
-
var
|
|
11138
|
+
var import_ts_morph49 = require("ts-morph");
|
|
11133
11139
|
function tryMatchJsxReturn(node, pattern) {
|
|
11134
11140
|
let expr;
|
|
11135
11141
|
let source;
|
|
11136
|
-
if (
|
|
11142
|
+
if (import_ts_morph49.Node.isReturnStatement(node)) {
|
|
11137
11143
|
expr = node.getExpression();
|
|
11138
11144
|
source = node;
|
|
11139
|
-
} else if (
|
|
11145
|
+
} else if (import_ts_morph49.Node.isArrowFunction(node)) {
|
|
11140
11146
|
const body = node.getBody();
|
|
11141
|
-
if (body !== void 0 && !
|
|
11147
|
+
if (body !== void 0 && !import_ts_morph49.Node.isBlock(body)) {
|
|
11142
11148
|
expr = body;
|
|
11143
11149
|
source = body;
|
|
11144
11150
|
}
|
|
@@ -11169,14 +11175,14 @@ function tryMatchJsxReturn(node, pattern) {
|
|
|
11169
11175
|
return { node, source, terminal };
|
|
11170
11176
|
}
|
|
11171
11177
|
function componentTargetOf(tagNode) {
|
|
11172
|
-
if (!
|
|
11178
|
+
if (!import_ts_morph49.Node.isIdentifier(tagNode) || !/^[A-Z]/.test(tagNode.getText())) {
|
|
11173
11179
|
return null;
|
|
11174
11180
|
}
|
|
11175
11181
|
const target = functionTargetOf(tagNode);
|
|
11176
11182
|
return target === null ? null : { file: target.file, name: target.name };
|
|
11177
11183
|
}
|
|
11178
11184
|
function jsxToRenderNode(node) {
|
|
11179
|
-
if (
|
|
11185
|
+
if (import_ts_morph49.Node.isJsxElement(node)) {
|
|
11180
11186
|
const opening = node.getOpeningElement();
|
|
11181
11187
|
const tag = opening.getTagNameNode().getText();
|
|
11182
11188
|
const attrs = collectJsxAttributes(opening);
|
|
@@ -11190,7 +11196,7 @@ function jsxToRenderNode(node) {
|
|
|
11190
11196
|
...target !== null ? { target } : {}
|
|
11191
11197
|
};
|
|
11192
11198
|
}
|
|
11193
|
-
if (
|
|
11199
|
+
if (import_ts_morph49.Node.isJsxSelfClosingElement(node)) {
|
|
11194
11200
|
const tag = node.getTagNameNode().getText();
|
|
11195
11201
|
const attrs = collectJsxAttributes(node);
|
|
11196
11202
|
const target = componentTargetOf(node.getTagNameNode());
|
|
@@ -11202,11 +11208,11 @@ function jsxToRenderNode(node) {
|
|
|
11202
11208
|
...target !== null ? { target } : {}
|
|
11203
11209
|
};
|
|
11204
11210
|
}
|
|
11205
|
-
if (
|
|
11211
|
+
if (import_ts_morph49.Node.isJsxFragment(node)) {
|
|
11206
11212
|
const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
|
|
11207
11213
|
return { type: "element", tag: "Fragment", children };
|
|
11208
11214
|
}
|
|
11209
|
-
if (
|
|
11215
|
+
if (import_ts_morph49.Node.isParenthesizedExpression(node)) {
|
|
11210
11216
|
return jsxToRenderNode(node.getExpression());
|
|
11211
11217
|
}
|
|
11212
11218
|
return null;
|
|
@@ -11214,12 +11220,12 @@ function jsxToRenderNode(node) {
|
|
|
11214
11220
|
function collectJsxAttributes(opening) {
|
|
11215
11221
|
const entries = {};
|
|
11216
11222
|
for (const attr of opening.getAttributes()) {
|
|
11217
|
-
if (
|
|
11223
|
+
if (import_ts_morph49.Node.isJsxSpreadAttribute(attr)) {
|
|
11218
11224
|
const exprText = attr.getExpression().getText();
|
|
11219
11225
|
entries[`...${exprText}`] = exprText;
|
|
11220
11226
|
continue;
|
|
11221
11227
|
}
|
|
11222
|
-
if (!
|
|
11228
|
+
if (!import_ts_morph49.Node.isJsxAttribute(attr)) {
|
|
11223
11229
|
continue;
|
|
11224
11230
|
}
|
|
11225
11231
|
const name = attr.getNameNode().getText();
|
|
@@ -11228,7 +11234,7 @@ function collectJsxAttributes(opening) {
|
|
|
11228
11234
|
entries[name] = "";
|
|
11229
11235
|
continue;
|
|
11230
11236
|
}
|
|
11231
|
-
if (
|
|
11237
|
+
if (import_ts_morph49.Node.isJsxExpression(initializer)) {
|
|
11232
11238
|
const inner = initializer.getExpression();
|
|
11233
11239
|
entries[name] = inner !== void 0 ? inner.getText() : "";
|
|
11234
11240
|
continue;
|
|
@@ -11238,30 +11244,30 @@ function collectJsxAttributes(opening) {
|
|
|
11238
11244
|
return Object.keys(entries).length > 0 ? entries : null;
|
|
11239
11245
|
}
|
|
11240
11246
|
function jsxChildToRenderNode(child) {
|
|
11241
|
-
if (
|
|
11247
|
+
if (import_ts_morph49.Node.isJsxText(child)) {
|
|
11242
11248
|
const text = child.getLiteralText().trim();
|
|
11243
11249
|
if (text.length === 0) {
|
|
11244
11250
|
return null;
|
|
11245
11251
|
}
|
|
11246
11252
|
return { type: "text", value: text };
|
|
11247
11253
|
}
|
|
11248
|
-
if (
|
|
11254
|
+
if (import_ts_morph49.Node.isJsxExpression(child)) {
|
|
11249
11255
|
const inner = child.getExpression();
|
|
11250
11256
|
if (inner === void 0) {
|
|
11251
11257
|
return null;
|
|
11252
11258
|
}
|
|
11253
11259
|
return jsxExpressionToRenderNode(inner);
|
|
11254
11260
|
}
|
|
11255
|
-
if (
|
|
11261
|
+
if (import_ts_morph49.Node.isJsxElement(child) || import_ts_morph49.Node.isJsxSelfClosingElement(child) || import_ts_morph49.Node.isJsxFragment(child)) {
|
|
11256
11262
|
return jsxToRenderNode(child);
|
|
11257
11263
|
}
|
|
11258
11264
|
return null;
|
|
11259
11265
|
}
|
|
11260
11266
|
function jsxExpressionToRenderNode(expr) {
|
|
11261
|
-
if (
|
|
11267
|
+
if (import_ts_morph49.Node.isParenthesizedExpression(expr)) {
|
|
11262
11268
|
return jsxExpressionToRenderNode(expr.getExpression());
|
|
11263
11269
|
}
|
|
11264
|
-
if (
|
|
11270
|
+
if (import_ts_morph49.Node.isBinaryExpression(expr)) {
|
|
11265
11271
|
const op = expr.getOperatorToken().getText();
|
|
11266
11272
|
if (op === "&&") {
|
|
11267
11273
|
const right = renderAlternative(peelParens(expr.getRight()));
|
|
@@ -11275,7 +11281,7 @@ function jsxExpressionToRenderNode(expr) {
|
|
|
11275
11281
|
}
|
|
11276
11282
|
}
|
|
11277
11283
|
}
|
|
11278
|
-
if (
|
|
11284
|
+
if (import_ts_morph49.Node.isConditionalExpression(expr)) {
|
|
11279
11285
|
const truthy = renderAlternative(peelParens(expr.getWhenTrue()));
|
|
11280
11286
|
const falsy = renderAlternative(peelParens(expr.getWhenFalse()));
|
|
11281
11287
|
if (truthy.kind === "jsx") {
|
|
@@ -11298,16 +11304,16 @@ function jsxExpressionToRenderNode(expr) {
|
|
|
11298
11304
|
return { type: "expression", sourceText: expr.getText() };
|
|
11299
11305
|
}
|
|
11300
11306
|
function renderAlternative(node) {
|
|
11301
|
-
if (
|
|
11307
|
+
if (import_ts_morph49.Node.isNullLiteral(node)) {
|
|
11302
11308
|
return { kind: "noRender" };
|
|
11303
11309
|
}
|
|
11304
|
-
if (
|
|
11310
|
+
if (import_ts_morph49.Node.isFalseLiteral(node)) {
|
|
11305
11311
|
return { kind: "noRender" };
|
|
11306
11312
|
}
|
|
11307
|
-
if (
|
|
11313
|
+
if (import_ts_morph49.Node.isIdentifier(node) && node.getText() === "undefined") {
|
|
11308
11314
|
return { kind: "noRender" };
|
|
11309
11315
|
}
|
|
11310
|
-
if (
|
|
11316
|
+
if (import_ts_morph49.Node.isJsxElement(node) || import_ts_morph49.Node.isJsxSelfClosingElement(node) || import_ts_morph49.Node.isJsxFragment(node)) {
|
|
11311
11317
|
const tree = jsxToRenderNode(node);
|
|
11312
11318
|
if (tree !== null) {
|
|
11313
11319
|
return { kind: "jsx", node: tree };
|
|
@@ -11317,13 +11323,13 @@ function renderAlternative(node) {
|
|
|
11317
11323
|
}
|
|
11318
11324
|
|
|
11319
11325
|
// src/terminals/returns.ts
|
|
11320
|
-
var
|
|
11326
|
+
var import_ts_morph52 = require("ts-morph");
|
|
11321
11327
|
|
|
11322
11328
|
// src/terminals/helperResolution.ts
|
|
11323
|
-
var
|
|
11329
|
+
var import_ts_morph50 = require("ts-morph");
|
|
11324
11330
|
function resolveHelperReturn(call, resolveCallee2) {
|
|
11325
11331
|
const callee = call.getExpression();
|
|
11326
|
-
if (!
|
|
11332
|
+
if (!import_ts_morph50.Node.isIdentifier(callee)) {
|
|
11327
11333
|
return { kind: "notLocal" };
|
|
11328
11334
|
}
|
|
11329
11335
|
const helper = memoizedLocalHelper(callee, resolveCallee2);
|
|
@@ -11353,16 +11359,16 @@ function guardsAbove(returnValue) {
|
|
|
11353
11359
|
let child = returnValue;
|
|
11354
11360
|
let current2 = returnValue.getParent();
|
|
11355
11361
|
while (current2 !== void 0) {
|
|
11356
|
-
if (
|
|
11362
|
+
if (import_ts_morph50.Node.isIfStatement(current2)) {
|
|
11357
11363
|
guards.push({
|
|
11358
11364
|
condition: current2.getExpression(),
|
|
11359
11365
|
whenTrue: current2.getThenStatement() === child
|
|
11360
11366
|
});
|
|
11361
11367
|
}
|
|
11362
|
-
if (
|
|
11368
|
+
if (import_ts_morph50.Node.isBlock(current2)) {
|
|
11363
11369
|
guards.push(...earlyReturnGuardsBefore(current2, child));
|
|
11364
11370
|
}
|
|
11365
|
-
if (
|
|
11371
|
+
if (import_ts_morph50.Node.isFunctionDeclaration(current2) || import_ts_morph50.Node.isArrowFunction(current2) || import_ts_morph50.Node.isFunctionExpression(current2)) {
|
|
11366
11372
|
break;
|
|
11367
11373
|
}
|
|
11368
11374
|
child = current2;
|
|
@@ -11371,7 +11377,7 @@ function guardsAbove(returnValue) {
|
|
|
11371
11377
|
return guards;
|
|
11372
11378
|
}
|
|
11373
11379
|
function earlyReturnGuardsBefore(block, child) {
|
|
11374
|
-
if (!
|
|
11380
|
+
if (!import_ts_morph50.Node.isBlock(block)) {
|
|
11375
11381
|
return [];
|
|
11376
11382
|
}
|
|
11377
11383
|
const guards = [];
|
|
@@ -11379,7 +11385,7 @@ function earlyReturnGuardsBefore(block, child) {
|
|
|
11379
11385
|
if (statement === child) {
|
|
11380
11386
|
break;
|
|
11381
11387
|
}
|
|
11382
|
-
if (!
|
|
11388
|
+
if (!import_ts_morph50.Node.isIfStatement(statement) || statement.getElseStatement()) {
|
|
11383
11389
|
continue;
|
|
11384
11390
|
}
|
|
11385
11391
|
if (alwaysReturns(statement.getThenStatement())) {
|
|
@@ -11389,10 +11395,10 @@ function earlyReturnGuardsBefore(block, child) {
|
|
|
11389
11395
|
return guards;
|
|
11390
11396
|
}
|
|
11391
11397
|
function alwaysReturns(statement) {
|
|
11392
|
-
if (
|
|
11398
|
+
if (import_ts_morph50.Node.isReturnStatement(statement) || import_ts_morph50.Node.isThrowStatement(statement)) {
|
|
11393
11399
|
return true;
|
|
11394
11400
|
}
|
|
11395
|
-
if (!
|
|
11401
|
+
if (!import_ts_morph50.Node.isBlock(statement)) {
|
|
11396
11402
|
return false;
|
|
11397
11403
|
}
|
|
11398
11404
|
const statements = statement.getStatements();
|
|
@@ -11410,7 +11416,7 @@ var COMPARISONS = {
|
|
|
11410
11416
|
"!=": (a, b) => a !== b
|
|
11411
11417
|
};
|
|
11412
11418
|
function evaluateComparison(condition, substitutions) {
|
|
11413
|
-
if (!
|
|
11419
|
+
if (!import_ts_morph50.Node.isBinaryExpression(condition)) {
|
|
11414
11420
|
return null;
|
|
11415
11421
|
}
|
|
11416
11422
|
const left = numberFor(condition.getLeft(), substitutions);
|
|
@@ -11422,8 +11428,8 @@ function evaluateComparison(condition, substitutions) {
|
|
|
11422
11428
|
return compare === void 0 ? null : compare(left, right);
|
|
11423
11429
|
}
|
|
11424
11430
|
function numberFor(node, substitutions) {
|
|
11425
|
-
const resolved =
|
|
11426
|
-
return
|
|
11431
|
+
const resolved = import_ts_morph50.Node.isIdentifier(node) && substitutions.has(node.getText()) ? substitutions.get(node.getText()) : node;
|
|
11432
|
+
return import_ts_morph50.Node.isNumericLiteral(resolved) ? Number(resolved.getText()) : null;
|
|
11427
11433
|
}
|
|
11428
11434
|
var helperBySymbol = /* @__PURE__ */ new WeakMap();
|
|
11429
11435
|
function memoizedLocalHelper(callee, resolveCallee2) {
|
|
@@ -11510,12 +11516,12 @@ function declarationsFor(callee, resolveCallee2) {
|
|
|
11510
11516
|
return (aliased ?? symbol).getDeclarations();
|
|
11511
11517
|
}
|
|
11512
11518
|
function asFunctionLike(declaration) {
|
|
11513
|
-
if (
|
|
11519
|
+
if (import_ts_morph50.Node.isFunctionDeclaration(declaration) || import_ts_morph50.Node.isArrowFunction(declaration) || import_ts_morph50.Node.isFunctionExpression(declaration)) {
|
|
11514
11520
|
return declaration;
|
|
11515
11521
|
}
|
|
11516
|
-
if (
|
|
11522
|
+
if (import_ts_morph50.Node.isVariableDeclaration(declaration)) {
|
|
11517
11523
|
const initializer = declaration.getInitializer();
|
|
11518
|
-
if (initializer !== void 0 && (
|
|
11524
|
+
if (initializer !== void 0 && (import_ts_morph50.Node.isArrowFunction(initializer) || import_ts_morph50.Node.isFunctionExpression(initializer))) {
|
|
11519
11525
|
return initializer;
|
|
11520
11526
|
}
|
|
11521
11527
|
}
|
|
@@ -11526,13 +11532,13 @@ function returnedObjects(fn) {
|
|
|
11526
11532
|
if (body === void 0) {
|
|
11527
11533
|
return [];
|
|
11528
11534
|
}
|
|
11529
|
-
if (!
|
|
11535
|
+
if (!import_ts_morph50.Node.isBlock(body)) {
|
|
11530
11536
|
const expression = peelParens(body);
|
|
11531
|
-
return
|
|
11537
|
+
return import_ts_morph50.Node.isObjectLiteralExpression(expression) ? [expression] : [];
|
|
11532
11538
|
}
|
|
11533
11539
|
const found = [];
|
|
11534
11540
|
for (const statement of body.getDescendantsOfKind(
|
|
11535
|
-
|
|
11541
|
+
import_ts_morph50.SyntaxKind.ReturnStatement
|
|
11536
11542
|
)) {
|
|
11537
11543
|
if (enclosingFunctionOf(statement) !== body) {
|
|
11538
11544
|
continue;
|
|
@@ -11542,7 +11548,7 @@ function returnedObjects(fn) {
|
|
|
11542
11548
|
continue;
|
|
11543
11549
|
}
|
|
11544
11550
|
const unwrapped2 = peelParens(expression);
|
|
11545
|
-
if (
|
|
11551
|
+
if (import_ts_morph50.Node.isObjectLiteralExpression(unwrapped2)) {
|
|
11546
11552
|
found.push(unwrapped2);
|
|
11547
11553
|
}
|
|
11548
11554
|
}
|
|
@@ -11551,7 +11557,7 @@ function returnedObjects(fn) {
|
|
|
11551
11557
|
function enclosingFunctionOf(node) {
|
|
11552
11558
|
let current2 = node.getParent();
|
|
11553
11559
|
while (current2 !== void 0) {
|
|
11554
|
-
if (
|
|
11560
|
+
if (import_ts_morph50.Node.isFunctionDeclaration(current2) || import_ts_morph50.Node.isArrowFunction(current2) || import_ts_morph50.Node.isFunctionExpression(current2) || import_ts_morph50.Node.isMethodDeclaration(current2)) {
|
|
11555
11561
|
return current2.getBody();
|
|
11556
11562
|
}
|
|
11557
11563
|
current2 = current2.getParent();
|
|
@@ -11570,7 +11576,7 @@ function bindArguments(callArgs, params) {
|
|
|
11570
11576
|
}
|
|
11571
11577
|
|
|
11572
11578
|
// src/terminals/statusBranches.ts
|
|
11573
|
-
var
|
|
11579
|
+
var import_ts_morph51 = require("ts-morph");
|
|
11574
11580
|
var import_values6 = require("@suss/values");
|
|
11575
11581
|
function statusChoicesOf(argument, resolution) {
|
|
11576
11582
|
const chosen = asConditional(argument);
|
|
@@ -11594,10 +11600,10 @@ function asConditional(node) {
|
|
|
11594
11600
|
if (direct !== null) {
|
|
11595
11601
|
return direct;
|
|
11596
11602
|
}
|
|
11597
|
-
if (!
|
|
11603
|
+
if (!import_ts_morph51.Node.isIdentifier(node)) {
|
|
11598
11604
|
return null;
|
|
11599
11605
|
}
|
|
11600
|
-
const declaration = node.getSymbol()?.getDeclarations().find(
|
|
11606
|
+
const declaration = node.getSymbol()?.getDeclarations().find(import_ts_morph51.Node.isVariableDeclaration);
|
|
11601
11607
|
if (declaration === void 0) {
|
|
11602
11608
|
return null;
|
|
11603
11609
|
}
|
|
@@ -11608,7 +11614,7 @@ function asConditional(node) {
|
|
|
11608
11614
|
const only = written.values[0];
|
|
11609
11615
|
return only === void 0 ? null : toConditional(only);
|
|
11610
11616
|
}
|
|
11611
|
-
var toConditional = (node) =>
|
|
11617
|
+
var toConditional = (node) => import_ts_morph51.Node.isConditionalExpression(node) ? node : null;
|
|
11612
11618
|
function numberOf(node, resolution) {
|
|
11613
11619
|
const value = (0, import_values6.constantOf)(evaluatedValue(node, resolution));
|
|
11614
11620
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
@@ -11625,7 +11631,7 @@ function unwrapMethodChain(call, match, func) {
|
|
|
11625
11631
|
for (let i = methodChain.length - 1; i >= 0; i--) {
|
|
11626
11632
|
const expectedMethod = methodChain[i];
|
|
11627
11633
|
const callee = current2.getExpression();
|
|
11628
|
-
if (!
|
|
11634
|
+
if (!import_ts_morph52.Node.isPropertyAccessExpression(callee)) {
|
|
11629
11635
|
return null;
|
|
11630
11636
|
}
|
|
11631
11637
|
if (callee.getName() !== expectedMethod) {
|
|
@@ -11641,7 +11647,7 @@ function unwrapMethodChain(call, match, func) {
|
|
|
11641
11647
|
return null;
|
|
11642
11648
|
}
|
|
11643
11649
|
} else {
|
|
11644
|
-
if (!
|
|
11650
|
+
if (!import_ts_morph52.Node.isCallExpression(subject)) {
|
|
11645
11651
|
return null;
|
|
11646
11652
|
}
|
|
11647
11653
|
current2 = subject;
|
|
@@ -11651,9 +11657,9 @@ function unwrapMethodChain(call, match, func) {
|
|
|
11651
11657
|
}
|
|
11652
11658
|
function withoutPassThroughCalls(subject, passThrough) {
|
|
11653
11659
|
let current2 = subject;
|
|
11654
|
-
while (
|
|
11660
|
+
while (import_ts_morph52.Node.isCallExpression(current2)) {
|
|
11655
11661
|
const callee = current2.getExpression();
|
|
11656
|
-
if (!
|
|
11662
|
+
if (!import_ts_morph52.Node.isPropertyAccessExpression(callee) || !passThrough.includes(callee.getName())) {
|
|
11657
11663
|
break;
|
|
11658
11664
|
}
|
|
11659
11665
|
current2 = callee.getExpression();
|
|
@@ -11665,12 +11671,12 @@ function returnedValueOf(returnStatement) {
|
|
|
11665
11671
|
return written === void 0 ? null : unwrapValue(written);
|
|
11666
11672
|
}
|
|
11667
11673
|
function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
11668
|
-
if (
|
|
11674
|
+
if (import_ts_morph52.Node.isObjectLiteralExpression(node)) {
|
|
11669
11675
|
const source = returnPositionOf(node);
|
|
11670
11676
|
if (source === null) {
|
|
11671
11677
|
return [];
|
|
11672
11678
|
}
|
|
11673
|
-
if (
|
|
11679
|
+
if (import_ts_morph52.Node.isReturnStatement(source) && returnedValueOf(source) === node) {
|
|
11674
11680
|
return [];
|
|
11675
11681
|
}
|
|
11676
11682
|
const terminal = terminalFromReturnedObject(
|
|
@@ -11683,14 +11689,14 @@ function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
|
11683
11689
|
);
|
|
11684
11690
|
return terminal === null ? [] : [{ ...terminal, source }];
|
|
11685
11691
|
}
|
|
11686
|
-
if (!
|
|
11692
|
+
if (!import_ts_morph52.Node.isReturnStatement(node)) {
|
|
11687
11693
|
return [];
|
|
11688
11694
|
}
|
|
11689
11695
|
const returned = returnedValueOf(node);
|
|
11690
11696
|
if (returned === null) {
|
|
11691
11697
|
return [];
|
|
11692
11698
|
}
|
|
11693
|
-
if (
|
|
11699
|
+
if (import_ts_morph52.Node.isObjectLiteralExpression(returned)) {
|
|
11694
11700
|
const terminal = terminalFromReturnedObject(
|
|
11695
11701
|
returned,
|
|
11696
11702
|
node,
|
|
@@ -11701,7 +11707,7 @@ function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
|
11701
11707
|
);
|
|
11702
11708
|
return terminal === null ? [] : [terminal];
|
|
11703
11709
|
}
|
|
11704
|
-
if (!
|
|
11710
|
+
if (!import_ts_morph52.Node.isCallExpression(returned)) {
|
|
11705
11711
|
return [];
|
|
11706
11712
|
}
|
|
11707
11713
|
const resolved = resolveHelperReturn(returned, resolveCallee2);
|
|
@@ -11738,7 +11744,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11738
11744
|
if (required !== void 0 && required.length > 0) {
|
|
11739
11745
|
const presentNames = /* @__PURE__ */ new Set();
|
|
11740
11746
|
for (const prop of obj.getProperties()) {
|
|
11741
|
-
if (
|
|
11747
|
+
if (import_ts_morph52.Node.isPropertyAssignment(prop) || import_ts_morph52.Node.isShorthandPropertyAssignment(prop)) {
|
|
11742
11748
|
presentNames.add(prop.getName());
|
|
11743
11749
|
}
|
|
11744
11750
|
}
|
|
@@ -11764,7 +11770,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11764
11770
|
// When a helper built the value, the anchor is the caller's own
|
|
11765
11771
|
// return, so it doubles as the provenance. A value reached any other
|
|
11766
11772
|
// way leaves this unset and its caller fills it in.
|
|
11767
|
-
...
|
|
11773
|
+
...import_ts_morph52.Node.isReturnStatement(anchor) ? { source: anchor } : {},
|
|
11768
11774
|
terminal: {
|
|
11769
11775
|
kind: pattern.kind,
|
|
11770
11776
|
statusCode,
|
|
@@ -11783,7 +11789,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11783
11789
|
};
|
|
11784
11790
|
}
|
|
11785
11791
|
function tryMatchParameterMethodCall(node, func, pattern, match, resolution) {
|
|
11786
|
-
if (!
|
|
11792
|
+
if (!import_ts_morph52.Node.isCallExpression(node)) {
|
|
11787
11793
|
return [];
|
|
11788
11794
|
}
|
|
11789
11795
|
const result = unwrapMethodChain(node, match, func);
|
|
@@ -11843,7 +11849,7 @@ function statusArgument(calls, extraction) {
|
|
|
11843
11849
|
}
|
|
11844
11850
|
function returnCoveredByParameterMethodCall(expr, func, patterns) {
|
|
11845
11851
|
const current2 = unwrapValue(expr);
|
|
11846
|
-
if (!
|
|
11852
|
+
if (!import_ts_morph52.Node.isCallExpression(current2)) {
|
|
11847
11853
|
return false;
|
|
11848
11854
|
}
|
|
11849
11855
|
for (const pattern of patterns) {
|
|
@@ -11859,7 +11865,7 @@ function returnCoveredByParameterMethodCall(expr, func, patterns) {
|
|
|
11859
11865
|
}
|
|
11860
11866
|
function tryMatchReturnStatement(node, pattern, func, allPatterns) {
|
|
11861
11867
|
const match = pattern.match.type === "returnStatement" ? pattern.match : null;
|
|
11862
|
-
if (
|
|
11868
|
+
if (import_ts_morph52.Node.isReturnStatement(node)) {
|
|
11863
11869
|
const expr = node.getExpression();
|
|
11864
11870
|
if (match?.excludeCallReturns === true) {
|
|
11865
11871
|
if (expr === void 0) {
|
|
@@ -11878,9 +11884,9 @@ function tryMatchReturnStatement(node, pattern, func, allPatterns) {
|
|
|
11878
11884
|
}
|
|
11879
11885
|
return buildReturnTerminal(node, pattern, body);
|
|
11880
11886
|
}
|
|
11881
|
-
if (
|
|
11887
|
+
if (import_ts_morph52.Node.isArrowFunction(node)) {
|
|
11882
11888
|
const body = node.getBody();
|
|
11883
|
-
if (body === void 0 ||
|
|
11889
|
+
if (body === void 0 || import_ts_morph52.Node.isBlock(body)) {
|
|
11884
11890
|
return null;
|
|
11885
11891
|
}
|
|
11886
11892
|
const shape = extractShape(body);
|
|
@@ -11938,20 +11944,20 @@ function unresolvedTerminal(kind, node) {
|
|
|
11938
11944
|
};
|
|
11939
11945
|
}
|
|
11940
11946
|
function calleeSubject(callee) {
|
|
11941
|
-
if (
|
|
11947
|
+
if (import_ts_morph52.Node.isIdentifier(callee)) {
|
|
11942
11948
|
return callee;
|
|
11943
11949
|
}
|
|
11944
|
-
if (
|
|
11950
|
+
if (import_ts_morph52.Node.isPropertyAccessExpression(callee)) {
|
|
11945
11951
|
const subject = callee.getExpression();
|
|
11946
|
-
return
|
|
11952
|
+
return import_ts_morph52.Node.isIdentifier(subject) ? subject : null;
|
|
11947
11953
|
}
|
|
11948
11954
|
return null;
|
|
11949
11955
|
}
|
|
11950
11956
|
function tryMatchFunctionCall(node, pattern, match, resolution, originatesFrom) {
|
|
11951
|
-
if (!
|
|
11957
|
+
if (!import_ts_morph52.Node.isCallExpression(node) && !import_ts_morph52.Node.isNewExpression(node)) {
|
|
11952
11958
|
return null;
|
|
11953
11959
|
}
|
|
11954
|
-
if (
|
|
11960
|
+
if (import_ts_morph52.Node.isNewExpression(node) && returnPositionOf(node) === null) {
|
|
11955
11961
|
return null;
|
|
11956
11962
|
}
|
|
11957
11963
|
const callee = node.getExpression();
|
|
@@ -11990,9 +11996,9 @@ function tryMatchFunctionCall(node, pattern, match, resolution, originatesFrom)
|
|
|
11990
11996
|
}
|
|
11991
11997
|
|
|
11992
11998
|
// src/terminals/throws.ts
|
|
11993
|
-
var
|
|
11999
|
+
var import_ts_morph53 = require("ts-morph");
|
|
11994
12000
|
function tryMatchThrowExpression(node, pattern, match, resolution) {
|
|
11995
|
-
if (!
|
|
12001
|
+
if (!import_ts_morph53.Node.isThrowStatement(node)) {
|
|
11996
12002
|
return null;
|
|
11997
12003
|
}
|
|
11998
12004
|
const thrownExpr = node.getExpression();
|
|
@@ -12034,17 +12040,17 @@ function extractThrowMessage(callArgs) {
|
|
|
12034
12040
|
return null;
|
|
12035
12041
|
}
|
|
12036
12042
|
for (const arg of callArgs) {
|
|
12037
|
-
if (
|
|
12043
|
+
if (import_ts_morph53.Node.isStringLiteral(arg) || import_ts_morph53.Node.isNoSubstitutionTemplateLiteral(arg)) {
|
|
12038
12044
|
return arg.getLiteralValue();
|
|
12039
12045
|
}
|
|
12040
|
-
if (
|
|
12046
|
+
if (import_ts_morph53.Node.isTemplateExpression(arg)) {
|
|
12041
12047
|
return arg.getText();
|
|
12042
12048
|
}
|
|
12043
12049
|
}
|
|
12044
12050
|
return null;
|
|
12045
12051
|
}
|
|
12046
12052
|
function classifyThrownExpression(thrown, constructorPattern) {
|
|
12047
|
-
if (
|
|
12053
|
+
if (import_ts_morph53.Node.isCallExpression(thrown) || import_ts_morph53.Node.isNewExpression(thrown)) {
|
|
12048
12054
|
const calleeText = thrown.getExpression().getText();
|
|
12049
12055
|
if (constructorPattern !== void 0 && !calleeText.startsWith(constructorPattern)) {
|
|
12050
12056
|
return null;
|
|
@@ -12131,9 +12137,9 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolution, origi
|
|
|
12131
12137
|
}
|
|
12132
12138
|
}
|
|
12133
12139
|
});
|
|
12134
|
-
if (results.length === 0 &&
|
|
12140
|
+
if (results.length === 0 && import_ts_morph54.Node.isArrowFunction(func)) {
|
|
12135
12141
|
const body = func.getBody();
|
|
12136
|
-
if (body !== void 0 && !
|
|
12142
|
+
if (body !== void 0 && !import_ts_morph54.Node.isBlock(body)) {
|
|
12137
12143
|
for (const pattern of patterns) {
|
|
12138
12144
|
let found = null;
|
|
12139
12145
|
if (pattern.match.type === "parameterMethodCall") {
|
|
@@ -12168,7 +12174,7 @@ function functionMayFallThrough(func) {
|
|
|
12168
12174
|
if (body === void 0) {
|
|
12169
12175
|
return false;
|
|
12170
12176
|
}
|
|
12171
|
-
if (!
|
|
12177
|
+
if (!import_ts_morph54.Node.isBlock(body)) {
|
|
12172
12178
|
return false;
|
|
12173
12179
|
}
|
|
12174
12180
|
const statements = body.getStatements();
|
|
@@ -12176,7 +12182,7 @@ function functionMayFallThrough(func) {
|
|
|
12176
12182
|
return true;
|
|
12177
12183
|
}
|
|
12178
12184
|
const last = statements[statements.length - 1];
|
|
12179
|
-
if (
|
|
12185
|
+
if (import_ts_morph54.Node.isReturnStatement(last) || import_ts_morph54.Node.isThrowStatement(last)) {
|
|
12180
12186
|
return false;
|
|
12181
12187
|
}
|
|
12182
12188
|
return true;
|
|
@@ -12224,7 +12230,7 @@ function writesTerminal(call, terminalNodes) {
|
|
|
12224
12230
|
}
|
|
12225
12231
|
}
|
|
12226
12232
|
function isReceiverOf(node, parent) {
|
|
12227
|
-
return (
|
|
12233
|
+
return (import_ts_morph55.Node.isPropertyAccessExpression(parent) || import_ts_morph55.Node.isElementAccessExpression(parent) || import_ts_morph55.Node.isCallExpression(parent)) && parent.getExpression() === node;
|
|
12228
12234
|
}
|
|
12229
12235
|
var isDefaultConditionList = (conditions) => conditions.length === 0 || conditions.every(
|
|
12230
12236
|
(c) => c.source === "earlyReturn" || c.source === "earlyThrow"
|
|
@@ -12234,7 +12240,7 @@ function bodyContentOf(func) {
|
|
|
12234
12240
|
if (body === void 0) {
|
|
12235
12241
|
return "absent";
|
|
12236
12242
|
}
|
|
12237
|
-
if (!
|
|
12243
|
+
if (!import_ts_morph55.Node.isBlock(body)) {
|
|
12238
12244
|
return "statements";
|
|
12239
12245
|
}
|
|
12240
12246
|
return body.getStatements().length === 0 ? "empty" : "statements";
|
|
@@ -12250,7 +12256,7 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
|
|
|
12250
12256
|
claimed.add(source);
|
|
12251
12257
|
}
|
|
12252
12258
|
}
|
|
12253
|
-
if (
|
|
12259
|
+
if (import_ts_morph55.Node.isArrowFunction(func) && import_ts_morph55.Node.isExpression(body)) {
|
|
12254
12260
|
return claimed.has(body) ? 0 : 1;
|
|
12255
12261
|
}
|
|
12256
12262
|
let unmatched = 0;
|
|
@@ -12263,7 +12269,7 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
|
|
|
12263
12269
|
traversal.skip();
|
|
12264
12270
|
return;
|
|
12265
12271
|
}
|
|
12266
|
-
if (!
|
|
12272
|
+
if (!import_ts_morph55.Node.isReturnStatement(node)) {
|
|
12267
12273
|
return;
|
|
12268
12274
|
}
|
|
12269
12275
|
if (node.getExpression() === void 0) {
|
|
@@ -12416,7 +12422,7 @@ function accountFor(site, terminalNodes, branches) {
|
|
|
12416
12422
|
}
|
|
12417
12423
|
|
|
12418
12424
|
// src/bootstrap/sourceFileLookup.ts
|
|
12419
|
-
var
|
|
12425
|
+
var import_ts_morph56 = require("ts-morph");
|
|
12420
12426
|
function createSourceFileLookup(project) {
|
|
12421
12427
|
const all = project.getSourceFiles();
|
|
12422
12428
|
const byAbs = /* @__PURE__ */ new Map();
|
|
@@ -12478,7 +12484,7 @@ function spanKey(span) {
|
|
|
12478
12484
|
function indexFunctions(sf) {
|
|
12479
12485
|
const index = /* @__PURE__ */ new Map();
|
|
12480
12486
|
sf.forEachDescendant((node) => {
|
|
12481
|
-
if (!
|
|
12487
|
+
if (!import_ts_morph56.Node.isFunctionDeclaration(node) && !import_ts_morph56.Node.isFunctionExpression(node) && !import_ts_morph56.Node.isArrowFunction(node) && !import_ts_morph56.Node.isMethodDeclaration(node)) {
|
|
12482
12488
|
return;
|
|
12483
12489
|
}
|
|
12484
12490
|
const bySpan = spanKey({ start: node.getStart(), end: node.getEnd() });
|
|
@@ -12492,13 +12498,13 @@ function indexFunctions(sf) {
|
|
|
12492
12498
|
}
|
|
12493
12499
|
|
|
12494
12500
|
// src/contract.ts
|
|
12495
|
-
var
|
|
12501
|
+
var import_ts_morph57 = require("ts-morph");
|
|
12496
12502
|
var import_behavioral_ir4 = require("@suss/behavioral-ir");
|
|
12497
12503
|
function extractDeclaredBody(node) {
|
|
12498
12504
|
if (node === void 0) {
|
|
12499
12505
|
return null;
|
|
12500
12506
|
}
|
|
12501
|
-
if (!
|
|
12507
|
+
if (!import_ts_morph57.Node.isCallExpression(node)) {
|
|
12502
12508
|
return null;
|
|
12503
12509
|
}
|
|
12504
12510
|
const typeArgs = node.getTypeArguments();
|
|
@@ -12512,10 +12518,10 @@ function resolveHandlerPropNode(func) {
|
|
|
12512
12518
|
if (parent === void 0) {
|
|
12513
12519
|
return null;
|
|
12514
12520
|
}
|
|
12515
|
-
if (
|
|
12521
|
+
if (import_ts_morph57.Node.isPropertyAssignment(parent)) {
|
|
12516
12522
|
return parent;
|
|
12517
12523
|
}
|
|
12518
|
-
if (
|
|
12524
|
+
if (import_ts_morph57.Node.isMethodDeclaration(func)) {
|
|
12519
12525
|
return func;
|
|
12520
12526
|
}
|
|
12521
12527
|
return null;
|
|
@@ -12527,11 +12533,11 @@ function findRouterCall(unit) {
|
|
|
12527
12533
|
return null;
|
|
12528
12534
|
}
|
|
12529
12535
|
const handlersObj = propNode.getParent();
|
|
12530
|
-
if (handlersObj === void 0 || !
|
|
12536
|
+
if (handlersObj === void 0 || !import_ts_morph57.Node.isObjectLiteralExpression(handlersObj)) {
|
|
12531
12537
|
return null;
|
|
12532
12538
|
}
|
|
12533
12539
|
const routerCall = handlersObj.getParent();
|
|
12534
|
-
if (routerCall === void 0 || !
|
|
12540
|
+
if (routerCall === void 0 || !import_ts_morph57.Node.isCallExpression(routerCall)) {
|
|
12535
12541
|
return null;
|
|
12536
12542
|
}
|
|
12537
12543
|
const args = routerCall.getArguments();
|
|
@@ -12544,17 +12550,17 @@ function findRouterCall(unit) {
|
|
|
12544
12550
|
};
|
|
12545
12551
|
}
|
|
12546
12552
|
function resolveContractObject(contractArg, resolution) {
|
|
12547
|
-
if (
|
|
12553
|
+
if (import_ts_morph57.Node.isObjectLiteralExpression(contractArg)) {
|
|
12548
12554
|
return contractArg;
|
|
12549
12555
|
}
|
|
12550
|
-
if (
|
|
12556
|
+
if (import_ts_morph57.Node.isPropertyAccessExpression(contractArg)) {
|
|
12551
12557
|
const base = resolveContractObject(contractArg.getExpression(), resolution);
|
|
12552
|
-
if (base === null || !
|
|
12558
|
+
if (base === null || !import_ts_morph57.Node.isObjectLiteralExpression(base)) {
|
|
12553
12559
|
return null;
|
|
12554
12560
|
}
|
|
12555
12561
|
const propName = contractArg.getName();
|
|
12556
12562
|
for (const prop of base.getProperties()) {
|
|
12557
|
-
if (!
|
|
12563
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(prop)) {
|
|
12558
12564
|
continue;
|
|
12559
12565
|
}
|
|
12560
12566
|
if (prop.getName() !== propName) {
|
|
@@ -12564,20 +12570,20 @@ function resolveContractObject(contractArg, resolution) {
|
|
|
12564
12570
|
if (value === void 0) {
|
|
12565
12571
|
return null;
|
|
12566
12572
|
}
|
|
12567
|
-
if (
|
|
12573
|
+
if (import_ts_morph57.Node.isObjectLiteralExpression(value)) {
|
|
12568
12574
|
return value;
|
|
12569
12575
|
}
|
|
12570
|
-
if (
|
|
12576
|
+
if (import_ts_morph57.Node.isIdentifier(value) || import_ts_morph57.Node.isPropertyAccessExpression(value)) {
|
|
12571
12577
|
return resolveContractObject(value, resolution);
|
|
12572
12578
|
}
|
|
12573
|
-
if (
|
|
12579
|
+
if (import_ts_morph57.Node.isCallExpression(value)) {
|
|
12574
12580
|
return unwrapContractInit(value);
|
|
12575
12581
|
}
|
|
12576
12582
|
return null;
|
|
12577
12583
|
}
|
|
12578
12584
|
return null;
|
|
12579
12585
|
}
|
|
12580
|
-
if (!
|
|
12586
|
+
if (!import_ts_morph57.Node.isIdentifier(contractArg)) {
|
|
12581
12587
|
return null;
|
|
12582
12588
|
}
|
|
12583
12589
|
const symbol = contractArg.getSymbol();
|
|
@@ -12589,7 +12595,7 @@ function resolveContractObject(contractArg, resolution) {
|
|
|
12589
12595
|
return null;
|
|
12590
12596
|
}
|
|
12591
12597
|
const decl = decls[0];
|
|
12592
|
-
if (
|
|
12598
|
+
if (import_ts_morph57.Node.isImportSpecifier(decl)) {
|
|
12593
12599
|
const importDecl = decl.getImportDeclaration();
|
|
12594
12600
|
const sourceFile = importDecl.getModuleSpecifierSourceFile();
|
|
12595
12601
|
if (sourceFile !== void 0 && resolution !== void 0) {
|
|
@@ -12598,14 +12604,14 @@ function resolveContractObject(contractArg, resolution) {
|
|
|
12598
12604
|
);
|
|
12599
12605
|
if (exported !== void 0 && exported.length > 0) {
|
|
12600
12606
|
const exportedDecl = exported[0];
|
|
12601
|
-
if (
|
|
12607
|
+
if (import_ts_morph57.Node.isVariableDeclaration(exportedDecl)) {
|
|
12602
12608
|
return unwrapContractInit(exportedDecl.getInitializer());
|
|
12603
12609
|
}
|
|
12604
12610
|
}
|
|
12605
12611
|
}
|
|
12606
12612
|
return null;
|
|
12607
12613
|
}
|
|
12608
|
-
if (
|
|
12614
|
+
if (import_ts_morph57.Node.isVariableDeclaration(decl)) {
|
|
12609
12615
|
return unwrapContractInit(decl.getInitializer());
|
|
12610
12616
|
}
|
|
12611
12617
|
return null;
|
|
@@ -12615,39 +12621,39 @@ function unwrapContractInit(init) {
|
|
|
12615
12621
|
return null;
|
|
12616
12622
|
}
|
|
12617
12623
|
const node = peelSyntax(init);
|
|
12618
|
-
if (
|
|
12624
|
+
if (import_ts_morph57.Node.isCallExpression(node)) {
|
|
12619
12625
|
const args = node.getArguments();
|
|
12620
|
-
if (args.length > 0 &&
|
|
12626
|
+
if (args.length > 0 && import_ts_morph57.Node.isObjectLiteralExpression(args[0])) {
|
|
12621
12627
|
return args[0];
|
|
12622
12628
|
}
|
|
12623
12629
|
return null;
|
|
12624
12630
|
}
|
|
12625
|
-
if (
|
|
12631
|
+
if (import_ts_morph57.Node.isObjectLiteralExpression(node)) {
|
|
12626
12632
|
return node;
|
|
12627
12633
|
}
|
|
12628
12634
|
return null;
|
|
12629
12635
|
}
|
|
12630
12636
|
function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
12631
|
-
if (!
|
|
12637
|
+
if (!import_ts_morph57.Node.isObjectLiteralExpression(endpointNode)) {
|
|
12632
12638
|
return null;
|
|
12633
12639
|
}
|
|
12634
12640
|
const responses = [];
|
|
12635
12641
|
let method;
|
|
12636
12642
|
let path14;
|
|
12637
12643
|
for (const prop of endpointNode.getProperties()) {
|
|
12638
|
-
if (!
|
|
12644
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(prop)) {
|
|
12639
12645
|
continue;
|
|
12640
12646
|
}
|
|
12641
12647
|
const propName = prop.getName();
|
|
12642
12648
|
if (propName === pattern.methodProperty) {
|
|
12643
12649
|
const val = prop.getInitializer();
|
|
12644
|
-
if (val !== void 0 &&
|
|
12650
|
+
if (val !== void 0 && import_ts_morph57.Node.isStringLiteral(val)) {
|
|
12645
12651
|
method = val.getLiteralValue();
|
|
12646
12652
|
}
|
|
12647
12653
|
}
|
|
12648
12654
|
if (propName === pattern.pathProperty) {
|
|
12649
12655
|
const val = prop.getInitializer();
|
|
12650
|
-
if (val !== void 0 &&
|
|
12656
|
+
if (val !== void 0 && import_ts_morph57.Node.isStringLiteral(val)) {
|
|
12651
12657
|
path14 = val.getLiteralValue();
|
|
12652
12658
|
}
|
|
12653
12659
|
}
|
|
@@ -12656,7 +12662,7 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12656
12662
|
const val = written === void 0 ? null : objectLiteralOf(written, resolution);
|
|
12657
12663
|
if (val !== null) {
|
|
12658
12664
|
for (const respProp of propertiesOf(val, resolution)) {
|
|
12659
|
-
if (!
|
|
12665
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(respProp)) {
|
|
12660
12666
|
continue;
|
|
12661
12667
|
}
|
|
12662
12668
|
const statusStr = respProp.getName();
|
|
@@ -12706,11 +12712,11 @@ function readContract(unit, pattern, framework, resolution) {
|
|
|
12706
12712
|
return null;
|
|
12707
12713
|
}
|
|
12708
12714
|
const contractObj = resolveContractObject(routerInfo.contractArg, resolution);
|
|
12709
|
-
if (contractObj === null || !
|
|
12715
|
+
if (contractObj === null || !import_ts_morph57.Node.isObjectLiteralExpression(contractObj)) {
|
|
12710
12716
|
return null;
|
|
12711
12717
|
}
|
|
12712
12718
|
for (const prop of contractObj.getProperties()) {
|
|
12713
|
-
if (!
|
|
12719
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(prop)) {
|
|
12714
12720
|
continue;
|
|
12715
12721
|
}
|
|
12716
12722
|
if (prop.getName() !== routerInfo.handlerName) {
|
|
@@ -12735,7 +12741,7 @@ function endpointFromRegistrationArgument(unit, position, resolution) {
|
|
|
12735
12741
|
return null;
|
|
12736
12742
|
}
|
|
12737
12743
|
const call = func.getParent();
|
|
12738
|
-
if (call === void 0 || !
|
|
12744
|
+
if (call === void 0 || !import_ts_morph57.Node.isCallExpression(call)) {
|
|
12739
12745
|
return null;
|
|
12740
12746
|
}
|
|
12741
12747
|
const args = call.getArguments();
|
|
@@ -12747,24 +12753,24 @@ function endpointFromRegistrationArgument(unit, position, resolution) {
|
|
|
12747
12753
|
return null;
|
|
12748
12754
|
}
|
|
12749
12755
|
let node = arg;
|
|
12750
|
-
while (
|
|
12756
|
+
while (import_ts_morph57.Node.isAsExpression(node)) {
|
|
12751
12757
|
node = node.getExpression();
|
|
12752
12758
|
}
|
|
12753
|
-
if (
|
|
12759
|
+
if (import_ts_morph57.Node.isObjectLiteralExpression(node)) {
|
|
12754
12760
|
return node;
|
|
12755
12761
|
}
|
|
12756
|
-
if (
|
|
12762
|
+
if (import_ts_morph57.Node.isCallExpression(node)) {
|
|
12757
12763
|
return unwrapContractInit(node);
|
|
12758
12764
|
}
|
|
12759
12765
|
return resolveContractObject(node, resolution);
|
|
12760
12766
|
}
|
|
12761
12767
|
function readContractForClientCall(callExpression, methodName, pattern, framework, resolution) {
|
|
12762
|
-
const callee =
|
|
12763
|
-
if (callee === null || !
|
|
12768
|
+
const callee = import_ts_morph57.Node.isCallExpression(callExpression) ? callExpression.getExpression() : null;
|
|
12769
|
+
if (callee === null || !import_ts_morph57.Node.isPropertyAccessExpression(callee)) {
|
|
12764
12770
|
return null;
|
|
12765
12771
|
}
|
|
12766
12772
|
const clientIdentifier = callee.getExpression();
|
|
12767
|
-
if (!
|
|
12773
|
+
if (!import_ts_morph57.Node.isIdentifier(clientIdentifier)) {
|
|
12768
12774
|
return null;
|
|
12769
12775
|
}
|
|
12770
12776
|
const symbol = clientIdentifier.getSymbol();
|
|
@@ -12776,11 +12782,11 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12776
12782
|
return null;
|
|
12777
12783
|
}
|
|
12778
12784
|
const decl = decls[0];
|
|
12779
|
-
if (!
|
|
12785
|
+
if (!import_ts_morph57.Node.isVariableDeclaration(decl)) {
|
|
12780
12786
|
return null;
|
|
12781
12787
|
}
|
|
12782
12788
|
const init = decl.getInitializer();
|
|
12783
|
-
if (init === void 0 || !
|
|
12789
|
+
if (init === void 0 || !import_ts_morph57.Node.isCallExpression(init)) {
|
|
12784
12790
|
return null;
|
|
12785
12791
|
}
|
|
12786
12792
|
const args = init.getArguments();
|
|
@@ -12788,11 +12794,11 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12788
12794
|
return null;
|
|
12789
12795
|
}
|
|
12790
12796
|
const contractObj = resolveContractObject(args[0], resolution);
|
|
12791
|
-
if (contractObj === null || !
|
|
12797
|
+
if (contractObj === null || !import_ts_morph57.Node.isObjectLiteralExpression(contractObj)) {
|
|
12792
12798
|
return null;
|
|
12793
12799
|
}
|
|
12794
12800
|
for (const prop of contractObj.getProperties()) {
|
|
12795
|
-
if (!
|
|
12801
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(prop)) {
|
|
12796
12802
|
continue;
|
|
12797
12803
|
}
|
|
12798
12804
|
if (prop.getName() !== methodName) {
|
|
@@ -12888,7 +12894,7 @@ function parameterName(segment, convention) {
|
|
|
12888
12894
|
|
|
12889
12895
|
// src/discovery/graphqlClientConstruction.ts
|
|
12890
12896
|
var import_picomatch2 = __toESM(require("picomatch"), 1);
|
|
12891
|
-
var
|
|
12897
|
+
var import_ts_morph58 = require("ts-morph");
|
|
12892
12898
|
var import_behavioral_ir5 = require("@suss/behavioral-ir");
|
|
12893
12899
|
function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
|
|
12894
12900
|
const scopes = compileOperationScopes(packs);
|
|
@@ -13036,7 +13042,7 @@ function constructionRegistryStatus(construction, spec) {
|
|
|
13036
13042
|
if (cacheConstruction === null) {
|
|
13037
13043
|
return "unknown";
|
|
13038
13044
|
}
|
|
13039
|
-
if (!
|
|
13045
|
+
if (!import_ts_morph58.Node.isNewExpression(cacheConstruction) && !import_ts_morph58.Node.isCallExpression(cacheConstruction)) {
|
|
13040
13046
|
return "unknown";
|
|
13041
13047
|
}
|
|
13042
13048
|
const args = cacheConstruction.getArguments();
|
|
@@ -13050,15 +13056,15 @@ function constructionRegistryStatus(construction, spec) {
|
|
|
13050
13056
|
if (cacheOptions.getProperty(spec.registryProperty) !== void 0) {
|
|
13051
13057
|
return "configured";
|
|
13052
13058
|
}
|
|
13053
|
-
const hasSpread = cacheOptions.getProperties().some((property) =>
|
|
13059
|
+
const hasSpread = cacheOptions.getProperties().some((property) => import_ts_morph58.Node.isSpreadAssignment(property));
|
|
13054
13060
|
return hasSpread ? "unknown" : "absent";
|
|
13055
13061
|
}
|
|
13056
13062
|
function firstArgumentObjectLiteral(construction) {
|
|
13057
|
-
if (!
|
|
13063
|
+
if (!import_ts_morph58.Node.isNewExpression(construction) && !import_ts_morph58.Node.isCallExpression(construction)) {
|
|
13058
13064
|
return null;
|
|
13059
13065
|
}
|
|
13060
13066
|
const arg = construction.getArguments()[0];
|
|
13061
|
-
if (arg === void 0 || !
|
|
13067
|
+
if (arg === void 0 || !import_ts_morph58.Node.isObjectLiteralExpression(arg)) {
|
|
13062
13068
|
return null;
|
|
13063
13069
|
}
|
|
13064
13070
|
return arg;
|
|
@@ -13068,10 +13074,10 @@ function propertyValueOf2(options, name) {
|
|
|
13068
13074
|
if (property === void 0) {
|
|
13069
13075
|
return null;
|
|
13070
13076
|
}
|
|
13071
|
-
if (
|
|
13077
|
+
if (import_ts_morph58.Node.isPropertyAssignment(property)) {
|
|
13072
13078
|
return property.getInitializer() ?? null;
|
|
13073
13079
|
}
|
|
13074
|
-
if (
|
|
13080
|
+
if (import_ts_morph58.Node.isShorthandPropertyAssignment(property)) {
|
|
13075
13081
|
const symbol = property.getProject().getTypeChecker().getShorthandAssignmentValueSymbol(property);
|
|
13076
13082
|
return symbol?.getValueDeclaration() ?? null;
|
|
13077
13083
|
}
|
|
@@ -13081,13 +13087,13 @@ function resolveToConstructionOf(expression, cacheClass) {
|
|
|
13081
13087
|
let current2 = expression;
|
|
13082
13088
|
for (let hop = 0; hop < 4 && current2 !== void 0; hop += 1) {
|
|
13083
13089
|
current2 = unwrapExpression2(current2);
|
|
13084
|
-
if (
|
|
13090
|
+
if (import_ts_morph58.Node.isVariableDeclaration(current2)) {
|
|
13085
13091
|
current2 = current2.getInitializer();
|
|
13086
13092
|
continue;
|
|
13087
13093
|
}
|
|
13088
|
-
if (
|
|
13094
|
+
if (import_ts_morph58.Node.isNewExpression(current2) || import_ts_morph58.Node.isCallExpression(current2)) {
|
|
13089
13095
|
const callee = current2.getExpression();
|
|
13090
|
-
if (callee === void 0 || !
|
|
13096
|
+
if (callee === void 0 || !import_ts_morph58.Node.isIdentifier(callee)) {
|
|
13091
13097
|
return null;
|
|
13092
13098
|
}
|
|
13093
13099
|
const local = localImportName(
|
|
@@ -13097,11 +13103,11 @@ function resolveToConstructionOf(expression, cacheClass) {
|
|
|
13097
13103
|
);
|
|
13098
13104
|
return local !== null && callee.getText() === local ? current2 : null;
|
|
13099
13105
|
}
|
|
13100
|
-
if (!
|
|
13106
|
+
if (!import_ts_morph58.Node.isIdentifier(current2)) {
|
|
13101
13107
|
return null;
|
|
13102
13108
|
}
|
|
13103
13109
|
const declaration = current2.getSymbol()?.getValueDeclaration();
|
|
13104
|
-
if (declaration === void 0 || !
|
|
13110
|
+
if (declaration === void 0 || !import_ts_morph58.Node.isVariableDeclaration(declaration)) {
|
|
13105
13111
|
return null;
|
|
13106
13112
|
}
|
|
13107
13113
|
current2 = declaration.getInitializer();
|
|
@@ -13112,11 +13118,11 @@ function unwrapExpression2(node) {
|
|
|
13112
13118
|
return peelSyntax(node);
|
|
13113
13119
|
}
|
|
13114
13120
|
function isConstructionNamed(node, localName) {
|
|
13115
|
-
if (!
|
|
13121
|
+
if (!import_ts_morph58.Node.isNewExpression(node) && !import_ts_morph58.Node.isCallExpression(node)) {
|
|
13116
13122
|
return false;
|
|
13117
13123
|
}
|
|
13118
13124
|
const callee = node.getExpression();
|
|
13119
|
-
return callee !== void 0 &&
|
|
13125
|
+
return callee !== void 0 && import_ts_morph58.Node.isIdentifier(callee) && callee.getText() === localName;
|
|
13120
13126
|
}
|
|
13121
13127
|
function localImportName(sourceFile, importModule, importName) {
|
|
13122
13128
|
for (const one of namedImportsOf(sourceFile, [importModule], {
|
|
@@ -13130,11 +13136,11 @@ function localImportName(sourceFile, importModule, importName) {
|
|
|
13130
13136
|
}
|
|
13131
13137
|
function constructionRef(node, uriProperty, resolution) {
|
|
13132
13138
|
const optionsArg = node.getArguments()[0];
|
|
13133
|
-
if (optionsArg === void 0 || !
|
|
13139
|
+
if (optionsArg === void 0 || !import_ts_morph58.Node.isObjectLiteralExpression(optionsArg)) {
|
|
13134
13140
|
return null;
|
|
13135
13141
|
}
|
|
13136
13142
|
const property = optionsArg.getProperty(uriProperty);
|
|
13137
|
-
if (property === void 0 || !
|
|
13143
|
+
if (property === void 0 || !import_ts_morph58.Node.isPropertyAssignment(property)) {
|
|
13138
13144
|
return null;
|
|
13139
13145
|
}
|
|
13140
13146
|
const value = property.getInitializer();
|
|
@@ -13149,10 +13155,10 @@ function constructionRef(node, uriProperty, resolution) {
|
|
|
13149
13155
|
}
|
|
13150
13156
|
|
|
13151
13157
|
// src/discovery/helperIndex.ts
|
|
13152
|
-
var
|
|
13158
|
+
var import_ts_morph60 = require("ts-morph");
|
|
13153
13159
|
|
|
13154
13160
|
// src/discovery/helperReading.ts
|
|
13155
|
-
var
|
|
13161
|
+
var import_ts_morph59 = require("ts-morph");
|
|
13156
13162
|
var UNREAD = { as: "unread" };
|
|
13157
13163
|
function readHelperSinks(helper) {
|
|
13158
13164
|
const positions = parameterPositions(helper);
|
|
@@ -13162,11 +13168,11 @@ function readHelperSinks(helper) {
|
|
|
13162
13168
|
return sinks;
|
|
13163
13169
|
}
|
|
13164
13170
|
body.forEachDescendant((node) => {
|
|
13165
|
-
if (!
|
|
13171
|
+
if (!import_ts_morph59.Node.isCallExpression(node)) {
|
|
13166
13172
|
return;
|
|
13167
13173
|
}
|
|
13168
13174
|
const callee = node.getExpression();
|
|
13169
|
-
const [method, receiver] =
|
|
13175
|
+
const [method, receiver] = import_ts_morph59.Node.isPropertyAccessExpression(callee) ? [callee.getName(), readValue(callee.getExpression(), positions)] : [null, UNREAD];
|
|
13170
13176
|
sinks.push({
|
|
13171
13177
|
method,
|
|
13172
13178
|
receiver,
|
|
@@ -13186,25 +13192,25 @@ function parameterPositions(helper) {
|
|
|
13186
13192
|
return positions;
|
|
13187
13193
|
}
|
|
13188
13194
|
function readValue(node, positions) {
|
|
13189
|
-
if (
|
|
13195
|
+
if (import_ts_morph59.Node.isStringLiteral(node) || import_ts_morph59.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
13190
13196
|
return { as: "text", text: node.getLiteralValue() };
|
|
13191
13197
|
}
|
|
13192
|
-
if (
|
|
13198
|
+
if (import_ts_morph59.Node.isTemplateExpression(node)) {
|
|
13193
13199
|
return templateText(node, positions);
|
|
13194
13200
|
}
|
|
13195
|
-
if (
|
|
13201
|
+
if (import_ts_morph59.Node.isIdentifier(node)) {
|
|
13196
13202
|
const position = positions.get(node.getText());
|
|
13197
13203
|
return position === void 0 ? UNREAD : { as: "parameter", position };
|
|
13198
13204
|
}
|
|
13199
|
-
if (
|
|
13205
|
+
if (import_ts_morph59.Node.isPropertyAccessExpression(node)) {
|
|
13200
13206
|
const target = node.getExpression();
|
|
13201
|
-
const position =
|
|
13207
|
+
const position = import_ts_morph59.Node.isIdentifier(target) ? positions.get(target.getText()) : void 0;
|
|
13202
13208
|
return position === void 0 ? UNREAD : { as: "parameter", position, property: node.getName() };
|
|
13203
13209
|
}
|
|
13204
|
-
if (
|
|
13210
|
+
if (import_ts_morph59.Node.isObjectLiteralExpression(node)) {
|
|
13205
13211
|
return objectValue(node, positions);
|
|
13206
13212
|
}
|
|
13207
|
-
if (
|
|
13213
|
+
if (import_ts_morph59.Node.isCallExpression(node)) {
|
|
13208
13214
|
return {
|
|
13209
13215
|
as: "call",
|
|
13210
13216
|
callee: node.getExpression().getText(),
|
|
@@ -13214,13 +13220,13 @@ function readValue(node, positions) {
|
|
|
13214
13220
|
return UNREAD;
|
|
13215
13221
|
}
|
|
13216
13222
|
function templateText(node, positions) {
|
|
13217
|
-
if (!
|
|
13223
|
+
if (!import_ts_morph59.Node.isTemplateExpression(node)) {
|
|
13218
13224
|
return UNREAD;
|
|
13219
13225
|
}
|
|
13220
13226
|
let text = node.getHead().getLiteralText();
|
|
13221
13227
|
for (const span of node.getTemplateSpans()) {
|
|
13222
13228
|
const expression = span.getExpression();
|
|
13223
|
-
const position =
|
|
13229
|
+
const position = import_ts_morph59.Node.isIdentifier(expression) ? positions.get(expression.getText()) : void 0;
|
|
13224
13230
|
if (position === void 0) {
|
|
13225
13231
|
return UNREAD;
|
|
13226
13232
|
}
|
|
@@ -13229,12 +13235,12 @@ function templateText(node, positions) {
|
|
|
13229
13235
|
return { as: "text", text };
|
|
13230
13236
|
}
|
|
13231
13237
|
function objectValue(node, positions) {
|
|
13232
|
-
if (!
|
|
13238
|
+
if (!import_ts_morph59.Node.isObjectLiteralExpression(node)) {
|
|
13233
13239
|
return UNREAD;
|
|
13234
13240
|
}
|
|
13235
13241
|
const properties = {};
|
|
13236
13242
|
for (const property of node.getProperties()) {
|
|
13237
|
-
if (!
|
|
13243
|
+
if (!import_ts_morph59.Node.isPropertyAssignment(property)) {
|
|
13238
13244
|
continue;
|
|
13239
13245
|
}
|
|
13240
13246
|
const initializer = property.getInitializer();
|
|
@@ -13249,7 +13255,7 @@ function objectValue(node, positions) {
|
|
|
13249
13255
|
return { as: "object", properties };
|
|
13250
13256
|
}
|
|
13251
13257
|
function propertyKey(name) {
|
|
13252
|
-
return
|
|
13258
|
+
return import_ts_morph59.Node.isStringLiteral(name) ? name.getLiteralValue() : name.getText();
|
|
13253
13259
|
}
|
|
13254
13260
|
|
|
13255
13261
|
// src/discovery/helperIndex.ts
|
|
@@ -13379,11 +13385,11 @@ function registrationMatchesOf(pack) {
|
|
|
13379
13385
|
}
|
|
13380
13386
|
function collectHandOffs(sourceFile, subjects, match, resolution, found) {
|
|
13381
13387
|
sourceFile.forEachDescendant((node) => {
|
|
13382
|
-
if (!
|
|
13388
|
+
if (!import_ts_morph60.Node.isCallExpression(node)) {
|
|
13383
13389
|
return;
|
|
13384
13390
|
}
|
|
13385
13391
|
const callee = node.getExpression();
|
|
13386
|
-
if (!
|
|
13392
|
+
if (!import_ts_morph60.Node.isIdentifier(callee)) {
|
|
13387
13393
|
return;
|
|
13388
13394
|
}
|
|
13389
13395
|
const handedOver = subjectArgument(node, subjects, match, resolution);
|
|
@@ -13398,12 +13404,12 @@ function collectHandOffs(sourceFile, subjects, match, resolution, found) {
|
|
|
13398
13404
|
});
|
|
13399
13405
|
}
|
|
13400
13406
|
function subjectArgument(call, subjects, match, resolution) {
|
|
13401
|
-
if (!
|
|
13407
|
+
if (!import_ts_morph60.Node.isCallExpression(call)) {
|
|
13402
13408
|
return -1;
|
|
13403
13409
|
}
|
|
13404
13410
|
const args = call.getArguments();
|
|
13405
13411
|
for (const [position, argument] of args.entries()) {
|
|
13406
|
-
if (!
|
|
13412
|
+
if (!import_ts_morph60.Node.isIdentifier(argument) && !import_ts_morph60.Node.isPropertyAccessExpression(argument)) {
|
|
13407
13413
|
continue;
|
|
13408
13414
|
}
|
|
13409
13415
|
if (subjectNodeFor(argument, subjects, match, resolution) !== void 0) {
|
|
@@ -13464,7 +13470,7 @@ function declaredFunctions(sourceFile) {
|
|
|
13464
13470
|
}
|
|
13465
13471
|
for (const variable4 of sourceFile.getVariableDeclarations()) {
|
|
13466
13472
|
const initializer = variable4.getInitializer();
|
|
13467
|
-
if (initializer !== void 0 && (
|
|
13473
|
+
if (initializer !== void 0 && (import_ts_morph60.Node.isArrowFunction(initializer) || import_ts_morph60.Node.isFunctionExpression(initializer))) {
|
|
13468
13474
|
found.push([variable4.getName(), initializer]);
|
|
13469
13475
|
}
|
|
13470
13476
|
}
|
|
@@ -13557,7 +13563,7 @@ function recordEdge(edgesByChild, candidate) {
|
|
|
13557
13563
|
}
|
|
13558
13564
|
|
|
13559
13565
|
// src/discovery/wrapperIndex.ts
|
|
13560
|
-
var
|
|
13566
|
+
var import_ts_morph61 = require("ts-morph");
|
|
13561
13567
|
var import_resolution6 = require("@suss/resolution");
|
|
13562
13568
|
var NO_WRAPPERS = {
|
|
13563
13569
|
wrappersFor: () => [],
|
|
@@ -13681,11 +13687,11 @@ function discoverWrapperRegistrations(sourceFile, pattern, match, wraps, resolut
|
|
|
13681
13687
|
const candidates = [];
|
|
13682
13688
|
const unresolved = [];
|
|
13683
13689
|
sourceFile.forEachDescendant((node) => {
|
|
13684
|
-
if (!
|
|
13690
|
+
if (!import_ts_morph61.Node.isCallExpression(node)) {
|
|
13685
13691
|
return;
|
|
13686
13692
|
}
|
|
13687
13693
|
const callee = node.getExpression();
|
|
13688
|
-
if (!
|
|
13694
|
+
if (!import_ts_morph61.Node.isPropertyAccessExpression(callee) || callee.getName() !== wraps.method) {
|
|
13689
13695
|
return;
|
|
13690
13696
|
}
|
|
13691
13697
|
const subjectNode = subjectNodeFor(
|
|
@@ -13780,7 +13786,7 @@ function discoverConstructorOptions(sourceFile, pattern, wraps, subjects, resolu
|
|
|
13780
13786
|
return { candidates, unresolved };
|
|
13781
13787
|
}
|
|
13782
13788
|
function constructorOptionOf(construction, wraps, resolution) {
|
|
13783
|
-
if (!(
|
|
13789
|
+
if (!(import_ts_morph61.Node.isNewExpression(construction) || import_ts_morph61.Node.isCallExpression(construction))) {
|
|
13784
13790
|
return void 0;
|
|
13785
13791
|
}
|
|
13786
13792
|
const optionsArg = construction.getArguments()[wraps.targetPosition];
|
|
@@ -13820,21 +13826,21 @@ function labelFor(targetArg, wraps) {
|
|
|
13820
13826
|
}
|
|
13821
13827
|
function factoryNameOf(targetArg) {
|
|
13822
13828
|
const written = factKeyOf(targetArg);
|
|
13823
|
-
if (!
|
|
13829
|
+
if (!import_ts_morph61.Node.isCallExpression(written)) {
|
|
13824
13830
|
return void 0;
|
|
13825
13831
|
}
|
|
13826
13832
|
const callee = written.getExpression();
|
|
13827
|
-
if (
|
|
13833
|
+
if (import_ts_morph61.Node.isIdentifier(callee)) {
|
|
13828
13834
|
return callee.getText();
|
|
13829
13835
|
}
|
|
13830
|
-
if (
|
|
13836
|
+
if (import_ts_morph61.Node.isPropertyAccessExpression(callee)) {
|
|
13831
13837
|
return callee.getName();
|
|
13832
13838
|
}
|
|
13833
13839
|
return void 0;
|
|
13834
13840
|
}
|
|
13835
13841
|
function factoryStopOf(targetArg) {
|
|
13836
13842
|
const written = factKeyOf(targetArg);
|
|
13837
|
-
if (!
|
|
13843
|
+
if (!import_ts_morph61.Node.isCallExpression(written)) {
|
|
13838
13844
|
return null;
|
|
13839
13845
|
}
|
|
13840
13846
|
const callee = factoryNameOf(targetArg);
|
|
@@ -13865,7 +13871,7 @@ function scopeOf(args, wraps, resolution) {
|
|
|
13865
13871
|
}
|
|
13866
13872
|
|
|
13867
13873
|
// src/discoveryContext.ts
|
|
13868
|
-
var
|
|
13874
|
+
var import_ts_morph62 = require("ts-morph");
|
|
13869
13875
|
function createTsDiscoveryContext(resolution) {
|
|
13870
13876
|
const store = resolution ?? new ResolutionStore();
|
|
13871
13877
|
return {
|
|
@@ -13900,7 +13906,7 @@ function exportedFunctions(sourceFile, resolution) {
|
|
|
13900
13906
|
return out;
|
|
13901
13907
|
}
|
|
13902
13908
|
function exportedFunction(decl, resolution) {
|
|
13903
|
-
const writtenAgain =
|
|
13909
|
+
const writtenAgain = import_ts_morph62.Node.isVariableDeclaration(decl) && isWrittenAgain(decl);
|
|
13904
13910
|
if (!writtenAgain) {
|
|
13905
13911
|
const declared = resolveDeclarationToFunction(decl);
|
|
13906
13912
|
if (declared !== null) {
|
|
@@ -13921,7 +13927,7 @@ function valueToAskAbout(decl, writtenAgain) {
|
|
|
13921
13927
|
if (writtenAgain) {
|
|
13922
13928
|
return decl;
|
|
13923
13929
|
}
|
|
13924
|
-
const value =
|
|
13930
|
+
const value = import_ts_morph62.Node.isVariableDeclaration(decl) ? decl.getInitializer() ?? decl : decl;
|
|
13925
13931
|
return couldStillNameAFunction(value) ? value : null;
|
|
13926
13932
|
}
|
|
13927
13933
|
function resolveDeclarationToFunction(decl) {
|
|
@@ -13929,18 +13935,18 @@ function resolveDeclarationToFunction(decl) {
|
|
|
13929
13935
|
if (fn !== null) {
|
|
13930
13936
|
return fn;
|
|
13931
13937
|
}
|
|
13932
|
-
if (
|
|
13938
|
+
if (import_ts_morph62.Node.isVariableDeclaration(decl)) {
|
|
13933
13939
|
const init = decl.getInitializer();
|
|
13934
|
-
if (init !== void 0 && (
|
|
13940
|
+
if (init !== void 0 && (import_ts_morph62.Node.isArrowFunction(init) || import_ts_morph62.Node.isFunctionExpression(init))) {
|
|
13935
13941
|
return init;
|
|
13936
13942
|
}
|
|
13937
13943
|
}
|
|
13938
13944
|
return null;
|
|
13939
13945
|
}
|
|
13940
13946
|
function hasJsxReturn(func) {
|
|
13941
|
-
if (
|
|
13947
|
+
if (import_ts_morph62.Node.isArrowFunction(func)) {
|
|
13942
13948
|
const body2 = func.getBody();
|
|
13943
|
-
if (
|
|
13949
|
+
if (import_ts_morph62.Node.isExpression(body2) && isJsxOrFragment(body2)) {
|
|
13944
13950
|
return true;
|
|
13945
13951
|
}
|
|
13946
13952
|
}
|
|
@@ -13954,11 +13960,11 @@ function hasJsxReturn(func) {
|
|
|
13954
13960
|
traversal.stop();
|
|
13955
13961
|
return;
|
|
13956
13962
|
}
|
|
13957
|
-
if (node !== func && (
|
|
13963
|
+
if (node !== func && (import_ts_morph62.Node.isFunctionDeclaration(node) || import_ts_morph62.Node.isFunctionExpression(node) || import_ts_morph62.Node.isArrowFunction(node) || import_ts_morph62.Node.isMethodDeclaration(node))) {
|
|
13958
13964
|
traversal.skip();
|
|
13959
13965
|
return;
|
|
13960
13966
|
}
|
|
13961
|
-
if (
|
|
13967
|
+
if (import_ts_morph62.Node.isReturnStatement(node)) {
|
|
13962
13968
|
const expr = node.getExpression();
|
|
13963
13969
|
if (expr !== void 0 && isJsxOrFragment(expr)) {
|
|
13964
13970
|
found = true;
|
|
@@ -13969,7 +13975,7 @@ function hasJsxReturn(func) {
|
|
|
13969
13975
|
}
|
|
13970
13976
|
function isJsxOrFragment(node) {
|
|
13971
13977
|
const current2 = peelParens(node);
|
|
13972
|
-
return
|
|
13978
|
+
return import_ts_morph62.Node.isJsxElement(current2) || import_ts_morph62.Node.isJsxSelfClosingElement(current2) || import_ts_morph62.Node.isJsxFragment(current2);
|
|
13973
13979
|
}
|
|
13974
13980
|
|
|
13975
13981
|
// src/graphqlContract.ts
|
|
@@ -14215,7 +14221,7 @@ function deriveBoundaryEffects(summaries, facts) {
|
|
|
14215
14221
|
}
|
|
14216
14222
|
|
|
14217
14223
|
// src/resolve/reachableClosure.ts
|
|
14218
|
-
var
|
|
14224
|
+
var import_ts_morph63 = require("ts-morph");
|
|
14219
14225
|
var import_behavioral_ir6 = require("@suss/behavioral-ir");
|
|
14220
14226
|
var import_datalog4 = require("@suss/datalog");
|
|
14221
14227
|
var import_extractor7 = require("@suss/extractor");
|
|
@@ -14248,7 +14254,7 @@ function targetOf(node) {
|
|
|
14248
14254
|
};
|
|
14249
14255
|
}
|
|
14250
14256
|
function resolveCallee(call, calleeName, scan) {
|
|
14251
|
-
if (!
|
|
14257
|
+
if (!import_ts_morph63.Node.isCallExpression(call)) {
|
|
14252
14258
|
return null;
|
|
14253
14259
|
}
|
|
14254
14260
|
const callee = call.getExpression();
|
|
@@ -14261,7 +14267,7 @@ function resolveCallee(call, calleeName, scan) {
|
|
|
14261
14267
|
}
|
|
14262
14268
|
}
|
|
14263
14269
|
const resolveSources = scan.resolveCallableSources;
|
|
14264
|
-
if (resolveSources !== void 0 &&
|
|
14270
|
+
if (resolveSources !== void 0 && import_ts_morph63.Node.isPropertyAccessExpression(callee) && declarations.some(isDeclaredShape)) {
|
|
14265
14271
|
const sources = resolveSources(callee, scan.reachedFrom);
|
|
14266
14272
|
const only = sources.length === 1 ? sources[0] : void 0;
|
|
14267
14273
|
const resolved = only === void 0 ? null : resolveDecl(only, calleeName);
|
|
@@ -14307,11 +14313,11 @@ function passedPositionKey(target, position) {
|
|
|
14307
14313
|
return `${offsetKeyFor(target.file, target.span)}#${position}`;
|
|
14308
14314
|
}
|
|
14309
14315
|
function resolveJsxReference(node, scan) {
|
|
14310
|
-
if (!
|
|
14316
|
+
if (!import_ts_morph63.Node.isJsxOpeningElement(node) && !import_ts_morph63.Node.isJsxSelfClosingElement(node)) {
|
|
14311
14317
|
return null;
|
|
14312
14318
|
}
|
|
14313
14319
|
const tag = node.getTagNameNode();
|
|
14314
|
-
if (!
|
|
14320
|
+
if (!import_ts_morph63.Node.isIdentifier(tag) || !/^[A-Z]/.test(tag.getText())) {
|
|
14315
14321
|
return null;
|
|
14316
14322
|
}
|
|
14317
14323
|
const name = tag.getText();
|
|
@@ -14357,12 +14363,12 @@ function collectReachable(func, scan) {
|
|
|
14357
14363
|
candidates.push(outcome.candidate);
|
|
14358
14364
|
};
|
|
14359
14365
|
const recordPassedArgs = (call, calleeText, calleeOutcome) => {
|
|
14360
|
-
if (!
|
|
14366
|
+
if (!import_ts_morph63.Node.isCallExpression(call)) {
|
|
14361
14367
|
return;
|
|
14362
14368
|
}
|
|
14363
14369
|
const calleeTarget = declaredAtOf(calleeOutcome);
|
|
14364
14370
|
call.getArguments().forEach((arg, position) => {
|
|
14365
|
-
if (!
|
|
14371
|
+
if (!import_ts_morph63.Node.isIdentifier(arg)) {
|
|
14366
14372
|
return;
|
|
14367
14373
|
}
|
|
14368
14374
|
const resolved = functionTargetOf(arg);
|
|
@@ -14382,7 +14388,7 @@ function collectReachable(func, scan) {
|
|
|
14382
14388
|
record2(jsx.outcome);
|
|
14383
14389
|
return;
|
|
14384
14390
|
}
|
|
14385
|
-
if (!
|
|
14391
|
+
if (!import_ts_morph63.Node.isCallExpression(node)) {
|
|
14386
14392
|
return;
|
|
14387
14393
|
}
|
|
14388
14394
|
const calleeText = normalizeCallee(node.getExpression().getText());
|
|
@@ -14468,7 +14474,7 @@ function recognizerOnlyRoots(packsByFile) {
|
|
|
14468
14474
|
}
|
|
14469
14475
|
for (const declaration of variableStatement.getDeclarations()) {
|
|
14470
14476
|
const init = declaration.getInitializer();
|
|
14471
|
-
if (init !== void 0 && (
|
|
14477
|
+
if (init !== void 0 && (import_ts_morph63.Node.isArrowFunction(init) || import_ts_morph63.Node.isFunctionExpression(init)) && hasBody(init)) {
|
|
14472
14478
|
roots.push({ func: init, name: declaration.getName() });
|
|
14473
14479
|
}
|
|
14474
14480
|
}
|
|
@@ -14722,7 +14728,7 @@ function recordParameterGaps(parameterCallsByKey, summariesByKey, passedPosition
|
|
|
14722
14728
|
}
|
|
14723
14729
|
|
|
14724
14730
|
// src/resolve/rethrowEnrichment.ts
|
|
14725
|
-
var
|
|
14731
|
+
var import_ts_morph64 = require("ts-morph");
|
|
14726
14732
|
var import_datalog5 = require("@suss/datalog");
|
|
14727
14733
|
var RETHROW_RULES = [
|
|
14728
14734
|
(0, import_datalog5.rule)(
|
|
@@ -14859,7 +14865,7 @@ function findBareRethrow(func, location) {
|
|
|
14859
14865
|
traversal.stop();
|
|
14860
14866
|
return;
|
|
14861
14867
|
}
|
|
14862
|
-
if (!
|
|
14868
|
+
if (!import_ts_morph64.Node.isThrowStatement(node)) {
|
|
14863
14869
|
return;
|
|
14864
14870
|
}
|
|
14865
14871
|
if (startLineOf(node) !== location.start) {
|
|
@@ -14869,7 +14875,7 @@ function findBareRethrow(func, location) {
|
|
|
14869
14875
|
return;
|
|
14870
14876
|
}
|
|
14871
14877
|
const thrown = node.getExpression();
|
|
14872
|
-
if (thrown !== void 0 &&
|
|
14878
|
+
if (thrown !== void 0 && import_ts_morph64.Node.isIdentifier(thrown)) {
|
|
14873
14879
|
found = node;
|
|
14874
14880
|
}
|
|
14875
14881
|
});
|
|
@@ -14879,13 +14885,13 @@ function enclosingTry(throwStmt) {
|
|
|
14879
14885
|
let current2 = throwStmt.getParent();
|
|
14880
14886
|
let sawCatchClause = false;
|
|
14881
14887
|
while (current2 !== void 0) {
|
|
14882
|
-
if (
|
|
14888
|
+
if (import_ts_morph64.Node.isCatchClause(current2)) {
|
|
14883
14889
|
sawCatchClause = true;
|
|
14884
14890
|
}
|
|
14885
|
-
if (
|
|
14891
|
+
if (import_ts_morph64.Node.isTryStatement(current2)) {
|
|
14886
14892
|
return sawCatchClause ? current2 : null;
|
|
14887
14893
|
}
|
|
14888
|
-
if (
|
|
14894
|
+
if (import_ts_morph64.Node.isFunctionDeclaration(current2) || import_ts_morph64.Node.isFunctionExpression(current2) || import_ts_morph64.Node.isArrowFunction(current2) || import_ts_morph64.Node.isMethodDeclaration(current2)) {
|
|
14889
14895
|
return null;
|
|
14890
14896
|
}
|
|
14891
14897
|
current2 = current2.getParent();
|
|
@@ -14893,14 +14899,14 @@ function enclosingTry(throwStmt) {
|
|
|
14893
14899
|
return null;
|
|
14894
14900
|
}
|
|
14895
14901
|
function collectTryBodyCallees(tryStmt, index, keyFor) {
|
|
14896
|
-
if (!
|
|
14902
|
+
if (!import_ts_morph64.Node.isTryStatement(tryStmt)) {
|
|
14897
14903
|
return [];
|
|
14898
14904
|
}
|
|
14899
14905
|
const tryBlock = tryStmt.getTryBlock();
|
|
14900
14906
|
const callees = [];
|
|
14901
14907
|
const seen = /* @__PURE__ */ new Set();
|
|
14902
14908
|
tryBlock.forEachDescendant((node) => {
|
|
14903
|
-
if (!
|
|
14909
|
+
if (!import_ts_morph64.Node.isCallExpression(node)) {
|
|
14904
14910
|
return;
|
|
14905
14911
|
}
|
|
14906
14912
|
const calleeSummary = resolveCalleeSummary(node, index);
|
|
@@ -14917,7 +14923,7 @@ function collectTryBodyCallees(tryStmt, index, keyFor) {
|
|
|
14917
14923
|
return callees;
|
|
14918
14924
|
}
|
|
14919
14925
|
function resolveCalleeSummary(call, index) {
|
|
14920
|
-
if (!
|
|
14926
|
+
if (!import_ts_morph64.Node.isCallExpression(call)) {
|
|
14921
14927
|
return null;
|
|
14922
14928
|
}
|
|
14923
14929
|
const callee = call.getExpression();
|
|
@@ -14947,12 +14953,12 @@ function resolveCalleeSummary(call, index) {
|
|
|
14947
14953
|
return null;
|
|
14948
14954
|
}
|
|
14949
14955
|
function functionFromDecl(decl) {
|
|
14950
|
-
if (
|
|
14956
|
+
if (import_ts_morph64.Node.isFunctionDeclaration(decl) || import_ts_morph64.Node.isFunctionExpression(decl) || import_ts_morph64.Node.isArrowFunction(decl) || import_ts_morph64.Node.isMethodDeclaration(decl)) {
|
|
14951
14957
|
return decl;
|
|
14952
14958
|
}
|
|
14953
|
-
if (
|
|
14959
|
+
if (import_ts_morph64.Node.isVariableDeclaration(decl)) {
|
|
14954
14960
|
const init = decl.getInitializer();
|
|
14955
|
-
if (init !== void 0 && (
|
|
14961
|
+
if (init !== void 0 && (import_ts_morph64.Node.isArrowFunction(init) || import_ts_morph64.Node.isFunctionExpression(init))) {
|
|
14956
14962
|
return init;
|
|
14957
14963
|
}
|
|
14958
14964
|
}
|
|
@@ -14960,22 +14966,22 @@ function functionFromDecl(decl) {
|
|
|
14960
14966
|
}
|
|
14961
14967
|
|
|
14962
14968
|
// src/shapes/fieldAccesses.ts
|
|
14963
|
-
var
|
|
14969
|
+
var import_ts_morph65 = require("ts-morph");
|
|
14964
14970
|
function findResponseAccessor(callExpr) {
|
|
14965
14971
|
let current2 = callExpr;
|
|
14966
14972
|
const parent1 = current2.getParent();
|
|
14967
|
-
if (parent1 !== void 0 &&
|
|
14973
|
+
if (parent1 !== void 0 && import_ts_morph65.Node.isAwaitExpression(parent1)) {
|
|
14968
14974
|
current2 = parent1;
|
|
14969
14975
|
}
|
|
14970
14976
|
const parent2 = current2.getParent();
|
|
14971
|
-
if (parent2 === void 0 || !
|
|
14977
|
+
if (parent2 === void 0 || !import_ts_morph65.Node.isVariableDeclaration(parent2)) {
|
|
14972
14978
|
return null;
|
|
14973
14979
|
}
|
|
14974
14980
|
const nameNode = parent2.getNameNode();
|
|
14975
|
-
if (
|
|
14981
|
+
if (import_ts_morph65.Node.isIdentifier(nameNode)) {
|
|
14976
14982
|
return { kind: "identifier", name: nameNode.getText() };
|
|
14977
14983
|
}
|
|
14978
|
-
if (
|
|
14984
|
+
if (import_ts_morph65.Node.isObjectBindingPattern(nameNode)) {
|
|
14979
14985
|
const bindings = /* @__PURE__ */ new Map();
|
|
14980
14986
|
for (const element of nameNode.getElements()) {
|
|
14981
14987
|
if (element.getDotDotDotToken() !== void 0) {
|
|
@@ -14996,11 +15002,11 @@ function findResponseAccessor(callExpr) {
|
|
|
14996
15002
|
function buildThenChainAccessor(callExpr, func) {
|
|
14997
15003
|
const bindings = /* @__PURE__ */ new Map();
|
|
14998
15004
|
func.forEachDescendant((node) => {
|
|
14999
|
-
if (!
|
|
15005
|
+
if (!import_ts_morph65.Node.isParameterDeclaration(node)) {
|
|
15000
15006
|
return;
|
|
15001
15007
|
}
|
|
15002
15008
|
const nameNode = node.getNameNode();
|
|
15003
|
-
if (!
|
|
15009
|
+
if (!import_ts_morph65.Node.isIdentifier(nameNode)) {
|
|
15004
15010
|
return;
|
|
15005
15011
|
}
|
|
15006
15012
|
const prefix = prefixOfThenParam(node, callExpr, 0);
|
|
@@ -15032,7 +15038,7 @@ function prefixOfExpr(expr, responseCall, depth) {
|
|
|
15032
15038
|
if (node === responseCall) {
|
|
15033
15039
|
return [];
|
|
15034
15040
|
}
|
|
15035
|
-
if (
|
|
15041
|
+
if (import_ts_morph65.Node.isCallExpression(node)) {
|
|
15036
15042
|
const hop = thenLikeCall(node);
|
|
15037
15043
|
if (hop !== null) {
|
|
15038
15044
|
if (hop.method === "catch") {
|
|
@@ -15064,14 +15070,14 @@ function prefixOfMemberExpr(expr, responseCall, depth) {
|
|
|
15064
15070
|
return null;
|
|
15065
15071
|
}
|
|
15066
15072
|
const decl = chain.root.getSymbol()?.getDeclarations()?.[0];
|
|
15067
|
-
if (decl === void 0 || !
|
|
15073
|
+
if (decl === void 0 || !import_ts_morph65.Node.isParameterDeclaration(decl)) {
|
|
15068
15074
|
return null;
|
|
15069
15075
|
}
|
|
15070
15076
|
const base = prefixOfThenParam(decl, responseCall, depth + 1);
|
|
15071
15077
|
return base === null ? null : [...base, ...chain.segments];
|
|
15072
15078
|
}
|
|
15073
15079
|
function firstCallbackParamName(callback) {
|
|
15074
|
-
if (callback === void 0 || !(
|
|
15080
|
+
if (callback === void 0 || !(import_ts_morph65.Node.isArrowFunction(callback) || import_ts_morph65.Node.isFunctionExpression(callback))) {
|
|
15075
15081
|
return null;
|
|
15076
15082
|
}
|
|
15077
15083
|
const param = callback.getParameters()[0];
|
|
@@ -15079,11 +15085,11 @@ function firstCallbackParamName(callback) {
|
|
|
15079
15085
|
return null;
|
|
15080
15086
|
}
|
|
15081
15087
|
const nameNode = param.getNameNode();
|
|
15082
|
-
return
|
|
15088
|
+
return import_ts_morph65.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
|
|
15083
15089
|
}
|
|
15084
15090
|
function unwrap(expr) {
|
|
15085
15091
|
let node = expr;
|
|
15086
|
-
while (
|
|
15092
|
+
while (import_ts_morph65.Node.isAwaitExpression(node) || import_ts_morph65.Node.isParenthesizedExpression(node) || import_ts_morph65.Node.isAsExpression(node)) {
|
|
15087
15093
|
node = node.getExpression();
|
|
15088
15094
|
}
|
|
15089
15095
|
return node;
|
|
@@ -15093,15 +15099,15 @@ function chainRootedAt(expr, rootName) {
|
|
|
15093
15099
|
if (chain === null) {
|
|
15094
15100
|
return null;
|
|
15095
15101
|
}
|
|
15096
|
-
return
|
|
15102
|
+
return import_ts_morph65.Node.isIdentifier(chain.root) && chain.root.getText() === rootName ? chain.segments : null;
|
|
15097
15103
|
}
|
|
15098
15104
|
function memberChain(expr) {
|
|
15099
|
-
let node =
|
|
15100
|
-
if (
|
|
15105
|
+
let node = import_ts_morph65.Node.isExpression(expr) ? unwrap(expr) : expr;
|
|
15106
|
+
if (import_ts_morph65.Node.isCallExpression(node)) {
|
|
15101
15107
|
node = node.getExpression();
|
|
15102
15108
|
}
|
|
15103
15109
|
const segments = [];
|
|
15104
|
-
while (
|
|
15110
|
+
while (import_ts_morph65.Node.isPropertyAccessExpression(node)) {
|
|
15105
15111
|
segments.unshift(node.getName());
|
|
15106
15112
|
node = node.getExpression();
|
|
15107
15113
|
}
|
|
@@ -15120,16 +15126,16 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
15120
15126
|
if (accessor.kind === "identifier") {
|
|
15121
15127
|
const varName = accessor.name;
|
|
15122
15128
|
subtree.forEachDescendant((node) => {
|
|
15123
|
-
if (!
|
|
15129
|
+
if (!import_ts_morph65.Node.isPropertyAccessExpression(node)) {
|
|
15124
15130
|
return;
|
|
15125
15131
|
}
|
|
15126
15132
|
const chain = [];
|
|
15127
15133
|
let current2 = node;
|
|
15128
|
-
while (
|
|
15134
|
+
while (import_ts_morph65.Node.isPropertyAccessExpression(current2)) {
|
|
15129
15135
|
chain.unshift(current2.getName());
|
|
15130
15136
|
current2 = current2.getExpression();
|
|
15131
15137
|
}
|
|
15132
|
-
if (
|
|
15138
|
+
if (import_ts_morph65.Node.isIdentifier(current2) && current2.getText() === varName) {
|
|
15133
15139
|
pushChain(chain);
|
|
15134
15140
|
}
|
|
15135
15141
|
});
|
|
@@ -15140,7 +15146,7 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
15140
15146
|
return source === void 0 ? void 0 : [source];
|
|
15141
15147
|
} : (name) => accessor.bindings.get(name);
|
|
15142
15148
|
subtree.forEachDescendant((node) => {
|
|
15143
|
-
if (!
|
|
15149
|
+
if (!import_ts_morph65.Node.isIdentifier(node)) {
|
|
15144
15150
|
return;
|
|
15145
15151
|
}
|
|
15146
15152
|
const prefix = prefixOf(node.getText());
|
|
@@ -15152,13 +15158,13 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
15152
15158
|
}
|
|
15153
15159
|
let chainTop = node;
|
|
15154
15160
|
let parent = chainTop.getParent();
|
|
15155
|
-
while (parent !== void 0 &&
|
|
15161
|
+
while (parent !== void 0 && import_ts_morph65.Node.isPropertyAccessExpression(parent) && parent.getExpression() === chainTop) {
|
|
15156
15162
|
chainTop = parent;
|
|
15157
15163
|
parent = chainTop.getParent();
|
|
15158
15164
|
}
|
|
15159
15165
|
const segments = [];
|
|
15160
15166
|
let current2 = chainTop;
|
|
15161
|
-
while (
|
|
15167
|
+
while (import_ts_morph65.Node.isPropertyAccessExpression(current2)) {
|
|
15162
15168
|
segments.push(current2.getName());
|
|
15163
15169
|
current2 = current2.getExpression();
|
|
15164
15170
|
}
|
|
@@ -15172,15 +15178,15 @@ function isBindingDeclarationSite(node) {
|
|
|
15172
15178
|
return true;
|
|
15173
15179
|
}
|
|
15174
15180
|
const parent = node.getParent();
|
|
15175
|
-
return parent !== void 0 &&
|
|
15181
|
+
return parent !== void 0 && import_ts_morph65.Node.isParameterDeclaration(parent) && parent.getNameNode() === node;
|
|
15176
15182
|
}
|
|
15177
15183
|
function isInsideObjectBindingPattern(node) {
|
|
15178
15184
|
let current2 = node.getParent();
|
|
15179
15185
|
while (current2 !== void 0) {
|
|
15180
|
-
if (
|
|
15186
|
+
if (import_ts_morph65.Node.isObjectBindingPattern(current2)) {
|
|
15181
15187
|
return true;
|
|
15182
15188
|
}
|
|
15183
|
-
if (
|
|
15189
|
+
if (import_ts_morph65.Node.isFunctionLikeDeclaration(current2) || import_ts_morph65.Node.isVariableStatement(current2)) {
|
|
15184
15190
|
break;
|
|
15185
15191
|
}
|
|
15186
15192
|
current2 = current2.getParent();
|
|
@@ -15243,7 +15249,7 @@ function findBranchSubtree(func, byLineRange, terminalStartLine, terminalEndLine
|
|
|
15243
15249
|
if (parent === void 0) {
|
|
15244
15250
|
break;
|
|
15245
15251
|
}
|
|
15246
|
-
if (
|
|
15252
|
+
if (import_ts_morph65.Node.isIfStatement(parent)) {
|
|
15247
15253
|
const ifStmt = parent;
|
|
15248
15254
|
const thenBlock = ifStmt.getThenStatement();
|
|
15249
15255
|
const elseBlock = ifStmt.getElseStatement();
|
|
@@ -15305,7 +15311,7 @@ function buildNonBodyPropertySet(semantics) {
|
|
|
15305
15311
|
}
|
|
15306
15312
|
|
|
15307
15313
|
// src/subUnitContext.ts
|
|
15308
|
-
var
|
|
15314
|
+
var import_ts_morph66 = require("ts-morph");
|
|
15309
15315
|
function createTsSubUnitContext() {
|
|
15310
15316
|
return {
|
|
15311
15317
|
findJsxAttributes,
|
|
@@ -15332,18 +15338,18 @@ function findJsxAttributes(parent) {
|
|
|
15332
15338
|
if (skip(node, traversal)) {
|
|
15333
15339
|
return;
|
|
15334
15340
|
}
|
|
15335
|
-
if (!
|
|
15341
|
+
if (!import_ts_morph66.Node.isJsxOpeningElement(node) && !import_ts_morph66.Node.isJsxSelfClosingElement(node)) {
|
|
15336
15342
|
return;
|
|
15337
15343
|
}
|
|
15338
15344
|
const tag = node.getTagNameNode().getText();
|
|
15339
15345
|
for (const attr of node.getAttributes()) {
|
|
15340
|
-
if (!
|
|
15346
|
+
if (!import_ts_morph66.Node.isJsxAttribute(attr)) {
|
|
15341
15347
|
continue;
|
|
15342
15348
|
}
|
|
15343
15349
|
const initializer = attr.getInitializer();
|
|
15344
15350
|
let valueExpression = null;
|
|
15345
15351
|
if (initializer !== void 0) {
|
|
15346
|
-
if (
|
|
15352
|
+
if (import_ts_morph66.Node.isJsxExpression(initializer)) {
|
|
15347
15353
|
const inner = initializer.getExpression();
|
|
15348
15354
|
valueExpression = inner ?? null;
|
|
15349
15355
|
} else {
|
|
@@ -15366,11 +15372,11 @@ function findCallExpressionsByName(parent, name) {
|
|
|
15366
15372
|
if (skip(node, traversal)) {
|
|
15367
15373
|
return;
|
|
15368
15374
|
}
|
|
15369
|
-
if (!
|
|
15375
|
+
if (!import_ts_morph66.Node.isCallExpression(node)) {
|
|
15370
15376
|
return;
|
|
15371
15377
|
}
|
|
15372
15378
|
const callee = node.getExpression();
|
|
15373
|
-
if (
|
|
15379
|
+
if (import_ts_morph66.Node.isIdentifier(callee) && callee.getText() === name) {
|
|
15374
15380
|
out.push(node);
|
|
15375
15381
|
}
|
|
15376
15382
|
});
|
|
@@ -15381,10 +15387,10 @@ function resolveAttributeValueFunction(attr, parent) {
|
|
|
15381
15387
|
if (expr === null) {
|
|
15382
15388
|
return null;
|
|
15383
15389
|
}
|
|
15384
|
-
if (
|
|
15390
|
+
if (import_ts_morph66.Node.isArrowFunction(expr) || import_ts_morph66.Node.isFunctionExpression(expr)) {
|
|
15385
15391
|
return { func: expr, localName: null };
|
|
15386
15392
|
}
|
|
15387
|
-
if (
|
|
15393
|
+
if (import_ts_morph66.Node.isIdentifier(expr)) {
|
|
15388
15394
|
const symbol = expr.getSymbol();
|
|
15389
15395
|
if (symbol === void 0) {
|
|
15390
15396
|
return null;
|
|
@@ -15403,15 +15409,15 @@ function resolveAttributeValueFunction(attr, parent) {
|
|
|
15403
15409
|
return null;
|
|
15404
15410
|
}
|
|
15405
15411
|
function tryExtractFunction(decl) {
|
|
15406
|
-
if (
|
|
15412
|
+
if (import_ts_morph66.Node.isFunctionDeclaration(decl)) {
|
|
15407
15413
|
return decl;
|
|
15408
15414
|
}
|
|
15409
|
-
if (
|
|
15415
|
+
if (import_ts_morph66.Node.isVariableDeclaration(decl)) {
|
|
15410
15416
|
const init = decl.getInitializer();
|
|
15411
15417
|
if (init === void 0) {
|
|
15412
15418
|
return null;
|
|
15413
15419
|
}
|
|
15414
|
-
if (
|
|
15420
|
+
if (import_ts_morph66.Node.isArrowFunction(init) || import_ts_morph66.Node.isFunctionExpression(init)) {
|
|
15415
15421
|
return init;
|
|
15416
15422
|
}
|
|
15417
15423
|
}
|
|
@@ -15432,7 +15438,7 @@ function getCallArgumentFunction(call, position) {
|
|
|
15432
15438
|
if (arg === void 0) {
|
|
15433
15439
|
return null;
|
|
15434
15440
|
}
|
|
15435
|
-
if (
|
|
15441
|
+
if (import_ts_morph66.Node.isArrowFunction(arg) || import_ts_morph66.Node.isFunctionExpression(arg)) {
|
|
15436
15442
|
return arg;
|
|
15437
15443
|
}
|
|
15438
15444
|
return null;
|
|
@@ -15444,7 +15450,7 @@ function readArrayLiteralText(node) {
|
|
|
15444
15450
|
if (node === null) {
|
|
15445
15451
|
return null;
|
|
15446
15452
|
}
|
|
15447
|
-
if (
|
|
15453
|
+
if (import_ts_morph66.Node.isArrayLiteralExpression(node)) {
|
|
15448
15454
|
return node.getElements().map((e) => e.getText());
|
|
15449
15455
|
}
|
|
15450
15456
|
return [node.getText()];
|
|
@@ -15693,13 +15699,13 @@ var raise = (msg) => {
|
|
|
15693
15699
|
throw new Error(msg);
|
|
15694
15700
|
};
|
|
15695
15701
|
function bindingPatternNames(nameNode) {
|
|
15696
|
-
if (
|
|
15702
|
+
if (import_ts_morph67.Node.isObjectBindingPattern(nameNode)) {
|
|
15697
15703
|
return nameNode.getElements().map((e) => e.getName());
|
|
15698
15704
|
}
|
|
15699
|
-
if (
|
|
15705
|
+
if (import_ts_morph67.Node.isArrayBindingPattern(nameNode)) {
|
|
15700
15706
|
const names = [];
|
|
15701
15707
|
for (const element of nameNode.getElements()) {
|
|
15702
|
-
if (
|
|
15708
|
+
if (import_ts_morph67.Node.isOmittedExpression(element)) {
|
|
15703
15709
|
continue;
|
|
15704
15710
|
}
|
|
15705
15711
|
names.push(element.getName());
|
|
@@ -15729,7 +15735,7 @@ function objectParamInputs(param, position, mapping) {
|
|
|
15729
15735
|
}
|
|
15730
15736
|
function componentPropsParameters(param, mapping) {
|
|
15731
15737
|
const nameNode = param.getNameNode();
|
|
15732
|
-
if (!
|
|
15738
|
+
if (!import_ts_morph67.Node.isObjectBindingPattern(nameNode)) {
|
|
15733
15739
|
const type = param.getType();
|
|
15734
15740
|
return [
|
|
15735
15741
|
{
|
|
@@ -15759,7 +15765,7 @@ function bindingRole(element, name) {
|
|
|
15759
15765
|
if (property === void 0) {
|
|
15760
15766
|
return name;
|
|
15761
15767
|
}
|
|
15762
|
-
if (
|
|
15768
|
+
if (import_ts_morph67.Node.isStringLiteral(property)) {
|
|
15763
15769
|
return property.getLiteralValue();
|
|
15764
15770
|
}
|
|
15765
15771
|
return property.getText();
|
|
@@ -15791,7 +15797,7 @@ function extractParameters(func, inputMapping) {
|
|
|
15791
15797
|
const param = params[i];
|
|
15792
15798
|
const nameNode = param.getNameNode();
|
|
15793
15799
|
const boundNames = bindingPatternNames(nameNode);
|
|
15794
|
-
if (
|
|
15800
|
+
if (import_ts_morph67.Node.isObjectBindingPattern(nameNode)) {
|
|
15795
15801
|
for (const element of nameNode.getElements()) {
|
|
15796
15802
|
result.push({
|
|
15797
15803
|
name: element.getName(),
|
|
@@ -15858,7 +15864,7 @@ function extractDependencyCalls(func, barriers = NO_BARRIERS) {
|
|
|
15858
15864
|
traversal.skip();
|
|
15859
15865
|
return;
|
|
15860
15866
|
}
|
|
15861
|
-
if (!
|
|
15867
|
+
if (!import_ts_morph67.Node.isVariableDeclaration(node)) {
|
|
15862
15868
|
return;
|
|
15863
15869
|
}
|
|
15864
15870
|
const init = node.getInitializer();
|
|
@@ -15867,19 +15873,19 @@ function extractDependencyCalls(func, barriers = NO_BARRIERS) {
|
|
|
15867
15873
|
}
|
|
15868
15874
|
let isAsync = false;
|
|
15869
15875
|
let callExpr = init;
|
|
15870
|
-
if (
|
|
15876
|
+
if (import_ts_morph67.Node.isAwaitExpression(init)) {
|
|
15871
15877
|
isAsync = true;
|
|
15872
15878
|
callExpr = init.getExpression();
|
|
15873
15879
|
}
|
|
15874
|
-
if (!
|
|
15880
|
+
if (!import_ts_morph67.Node.isCallExpression(callExpr)) {
|
|
15875
15881
|
return;
|
|
15876
15882
|
}
|
|
15877
15883
|
const calleeName = callExpr.getExpression().getText();
|
|
15878
15884
|
const nameNode = node.getNameNode();
|
|
15879
|
-
const assignedTo =
|
|
15885
|
+
const assignedTo = import_ts_morph67.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
|
|
15880
15886
|
const declList = node.getParent();
|
|
15881
15887
|
const varStmt = declList?.getParent();
|
|
15882
|
-
const locationNode = varStmt !== void 0 &&
|
|
15888
|
+
const locationNode = varStmt !== void 0 && import_ts_morph67.Node.isVariableStatement(varStmt) ? varStmt : node;
|
|
15883
15889
|
results.push({
|
|
15884
15890
|
name: calleeName,
|
|
15885
15891
|
assignedTo,
|
|
@@ -16796,9 +16802,9 @@ function findWrapperPathParam(summary, lookup) {
|
|
|
16796
16802
|
if (names.length === 0) {
|
|
16797
16803
|
return null;
|
|
16798
16804
|
}
|
|
16799
|
-
for (const call of func.getDescendantsOfKind(
|
|
16805
|
+
for (const call of func.getDescendantsOfKind(import_ts_morph67.SyntaxKind.CallExpression)) {
|
|
16800
16806
|
const first = call.getArguments()[0];
|
|
16801
|
-
if (first === void 0 || !
|
|
16807
|
+
if (first === void 0 || !import_ts_morph67.Node.isIdentifier(first)) {
|
|
16802
16808
|
continue;
|
|
16803
16809
|
}
|
|
16804
16810
|
const at = names.indexOf(first.getText());
|
|
@@ -16847,16 +16853,16 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
16847
16853
|
return out;
|
|
16848
16854
|
}
|
|
16849
16855
|
function wrapperNameNode(func) {
|
|
16850
|
-
if (
|
|
16856
|
+
if (import_ts_morph67.Node.isFunctionDeclaration(func) || import_ts_morph67.Node.isMethodDeclaration(func)) {
|
|
16851
16857
|
const name = func.getNameNode();
|
|
16852
|
-
if (name !== void 0 &&
|
|
16858
|
+
if (name !== void 0 && import_ts_morph67.Node.isIdentifier(name)) {
|
|
16853
16859
|
return name;
|
|
16854
16860
|
}
|
|
16855
16861
|
}
|
|
16856
16862
|
const parent = func.getParent();
|
|
16857
|
-
if (parent !== void 0 &&
|
|
16863
|
+
if (parent !== void 0 && import_ts_morph67.Node.isVariableDeclaration(parent)) {
|
|
16858
16864
|
const nameNode = parent.getNameNode();
|
|
16859
|
-
if (
|
|
16865
|
+
if (import_ts_morph67.Node.isIdentifier(nameNode)) {
|
|
16860
16866
|
return nameNode;
|
|
16861
16867
|
}
|
|
16862
16868
|
}
|
|
@@ -16865,10 +16871,10 @@ function wrapperNameNode(func) {
|
|
|
16865
16871
|
function enclosingCall(node) {
|
|
16866
16872
|
let current2 = node.getParent();
|
|
16867
16873
|
while (current2 !== void 0) {
|
|
16868
|
-
if (
|
|
16874
|
+
if (import_ts_morph67.Node.isCallExpression(current2)) {
|
|
16869
16875
|
return current2;
|
|
16870
16876
|
}
|
|
16871
|
-
if (
|
|
16877
|
+
if (import_ts_morph67.Node.isPropertyAccessExpression(current2)) {
|
|
16872
16878
|
current2 = current2.getParent();
|
|
16873
16879
|
continue;
|
|
16874
16880
|
}
|
|
@@ -16879,7 +16885,7 @@ function enclosingCall(node) {
|
|
|
16879
16885
|
function enclosingFunction(node) {
|
|
16880
16886
|
let current2 = node.getParent();
|
|
16881
16887
|
while (current2 !== void 0) {
|
|
16882
|
-
if (
|
|
16888
|
+
if (import_ts_morph67.Node.isFunctionDeclaration(current2) || import_ts_morph67.Node.isFunctionExpression(current2) || import_ts_morph67.Node.isArrowFunction(current2) || import_ts_morph67.Node.isMethodDeclaration(current2)) {
|
|
16883
16889
|
return current2;
|
|
16884
16890
|
}
|
|
16885
16891
|
current2 = current2.getParent();
|
|
@@ -16887,13 +16893,13 @@ function enclosingFunction(node) {
|
|
|
16887
16893
|
return null;
|
|
16888
16894
|
}
|
|
16889
16895
|
function callerName(func) {
|
|
16890
|
-
if (
|
|
16896
|
+
if (import_ts_morph67.Node.isFunctionDeclaration(func) || import_ts_morph67.Node.isMethodDeclaration(func)) {
|
|
16891
16897
|
return func.getName() ?? "anonymous";
|
|
16892
16898
|
}
|
|
16893
16899
|
const parent = func.getParent();
|
|
16894
|
-
if (parent !== void 0 &&
|
|
16900
|
+
if (parent !== void 0 && import_ts_morph67.Node.isVariableDeclaration(parent)) {
|
|
16895
16901
|
const nameNode = parent.getNameNode();
|
|
16896
|
-
if (
|
|
16902
|
+
if (import_ts_morph67.Node.isIdentifier(nameNode)) {
|
|
16897
16903
|
return nameNode.getText();
|
|
16898
16904
|
}
|
|
16899
16905
|
}
|
|
@@ -16992,7 +16998,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
16992
16998
|
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ? import_node_path10.default.dirname(suppliedConfig.tsConfigFilePath) : void 0)
|
|
16993
16999
|
)
|
|
16994
17000
|
};
|
|
16995
|
-
const project = config.project ?? new
|
|
17001
|
+
const project = config.project ?? new import_ts_morph67.Project(
|
|
16996
17002
|
config.tsConfigFilePath !== void 0 ? {
|
|
16997
17003
|
tsConfigFilePath: config.tsConfigFilePath,
|
|
16998
17004
|
skipAddingFilesFromTsConfig: true
|
|
@@ -17708,7 +17714,7 @@ function buildSubUnitSummary(subUnit, parent, invocationRecognizers, accessRecog
|
|
|
17708
17714
|
// src/bootstrap/noTsconfigProject.ts
|
|
17709
17715
|
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
17710
17716
|
var import_node_path11 = __toESM(require("path"), 1);
|
|
17711
|
-
var
|
|
17717
|
+
var import_ts_morph68 = require("ts-morph");
|
|
17712
17718
|
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
17713
17719
|
".ts",
|
|
17714
17720
|
".tsx",
|
|
@@ -17756,12 +17762,12 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
17756
17762
|
return found;
|
|
17757
17763
|
}
|
|
17758
17764
|
function createProjectWithoutTsconfig(rootDir) {
|
|
17759
|
-
const project = new
|
|
17765
|
+
const project = new import_ts_morph68.Project({
|
|
17760
17766
|
skipAddingFilesFromTsConfig: true,
|
|
17761
17767
|
compilerOptions: {
|
|
17762
|
-
target:
|
|
17763
|
-
module:
|
|
17764
|
-
moduleResolution:
|
|
17768
|
+
target: import_ts_morph68.ScriptTarget.ES2022,
|
|
17769
|
+
module: import_ts_morph68.ModuleKind.ESNext,
|
|
17770
|
+
moduleResolution: import_ts_morph68.ModuleResolutionKind.Bundler,
|
|
17765
17771
|
allowJs: true,
|
|
17766
17772
|
checkJs: false,
|
|
17767
17773
|
noEmit: true,
|
|
@@ -17802,7 +17808,7 @@ function findNearestTsconfig(startDir) {
|
|
|
17802
17808
|
|
|
17803
17809
|
// src/facts/why.ts
|
|
17804
17810
|
var import_node_path12 = __toESM(require("path"), 1);
|
|
17805
|
-
var
|
|
17811
|
+
var import_ts_morph69 = require("ts-morph");
|
|
17806
17812
|
var import_resolution7 = require("@suss/resolution");
|
|
17807
17813
|
var JS_PHRASES = {
|
|
17808
17814
|
bind: ({ tuple, describe }) => ({
|
|
@@ -17816,7 +17822,7 @@ var TypeScriptWhySession = class {
|
|
|
17816
17822
|
constructor(options) {
|
|
17817
17823
|
this.root = import_node_path12.default.resolve(options.dir);
|
|
17818
17824
|
const tsconfig = findNearestTsconfig(this.root);
|
|
17819
|
-
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new
|
|
17825
|
+
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new import_ts_morph69.Project({ tsConfigFilePath: tsconfig });
|
|
17820
17826
|
this.store = new ResolutionStore();
|
|
17821
17827
|
}
|
|
17822
17828
|
/**
|
|
@@ -17831,7 +17837,7 @@ var TypeScriptWhySession = class {
|
|
|
17831
17837
|
}
|
|
17832
17838
|
let found = null;
|
|
17833
17839
|
sourceFile.forEachDescendant((node) => {
|
|
17834
|
-
if (
|
|
17840
|
+
if (import_ts_morph69.Node.isExpression(node) && node.getStartLineNumber() === line && node.getText() === text && (found === null || node.getWidth() <= found.getWidth())) {
|
|
17835
17841
|
found = node;
|
|
17836
17842
|
}
|
|
17837
17843
|
});
|
|
@@ -17849,7 +17855,7 @@ var TypeScriptWhySession = class {
|
|
|
17849
17855
|
return null;
|
|
17850
17856
|
}
|
|
17851
17857
|
for (const call of sourceFile.getDescendantsOfKind(
|
|
17852
|
-
|
|
17858
|
+
import_ts_morph69.SyntaxKind.CallExpression
|
|
17853
17859
|
)) {
|
|
17854
17860
|
const line = call.getStartLineNumber();
|
|
17855
17861
|
if (line < startLine || line > endLine) {
|
|
@@ -17923,21 +17929,21 @@ var TypeScriptWhySession = class {
|
|
|
17923
17929
|
}
|
|
17924
17930
|
};
|
|
17925
17931
|
function displayNameOf(node) {
|
|
17926
|
-
if (
|
|
17932
|
+
if (import_ts_morph69.Node.isIdentifier(node) || import_ts_morph69.Node.isPropertyAccessExpression(node)) {
|
|
17927
17933
|
return node.getText();
|
|
17928
17934
|
}
|
|
17929
|
-
if (
|
|
17935
|
+
if (import_ts_morph69.Node.isCallExpression(node) || import_ts_morph69.Node.isNewExpression(node)) {
|
|
17930
17936
|
return `${node.getExpression()?.getText() ?? "call"}(...)`;
|
|
17931
17937
|
}
|
|
17932
|
-
if (
|
|
17938
|
+
if (import_ts_morph69.Node.isFunctionDeclaration(node) || import_ts_morph69.Node.isClassDeclaration(node) || import_ts_morph69.Node.isMethodDeclaration(node) || import_ts_morph69.Node.isVariableDeclaration(node)) {
|
|
17933
17939
|
const name = node.getName();
|
|
17934
17940
|
if (name !== void 0) {
|
|
17935
17941
|
return name;
|
|
17936
17942
|
}
|
|
17937
17943
|
}
|
|
17938
|
-
if (
|
|
17944
|
+
if (import_ts_morph69.Node.isArrowFunction(node) || import_ts_morph69.Node.isFunctionExpression(node)) {
|
|
17939
17945
|
const parent = node.getParent();
|
|
17940
|
-
if (parent !== void 0 &&
|
|
17946
|
+
if (parent !== void 0 && import_ts_morph69.Node.isVariableDeclaration(parent)) {
|
|
17941
17947
|
return parent.getName();
|
|
17942
17948
|
}
|
|
17943
17949
|
}
|
|
@@ -17947,7 +17953,7 @@ function displayNameOf(node) {
|
|
|
17947
17953
|
|
|
17948
17954
|
// src/stubEvidence.ts
|
|
17949
17955
|
var import_node_path13 = __toESM(require("path"), 1);
|
|
17950
|
-
var
|
|
17956
|
+
var import_ts_morph70 = require("ts-morph");
|
|
17951
17957
|
function stubEvidenceIn(project, packageName, root) {
|
|
17952
17958
|
const resolution = new ResolutionStore();
|
|
17953
17959
|
const byExport = /* @__PURE__ */ new Map();
|
|
@@ -17974,7 +17980,7 @@ function stubEvidenceIn(project, packageName, root) {
|
|
|
17974
17980
|
);
|
|
17975
17981
|
}
|
|
17976
17982
|
function stubEvidence(options) {
|
|
17977
|
-
const project = new
|
|
17983
|
+
const project = new import_ts_morph70.Project(
|
|
17978
17984
|
options.tsConfigFilePath !== void 0 ? { tsConfigFilePath: options.tsConfigFilePath } : { compilerOptions: { allowJs: true } }
|
|
17979
17985
|
);
|
|
17980
17986
|
const root = options.tsConfigFilePath !== void 0 ? import_node_path13.default.dirname(options.tsConfigFilePath) : import_node_path13.default.resolve(options.directory ?? process.cwd());
|