@suss/adapter-typescript 0.1.1 → 0.2.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.
Files changed (3) hide show
  1. package/dist/index.cjs +280 -191
  2. package/dist/index.js +280 -191
  3. package/package.json +5 -5
package/dist/index.cjs CHANGED
@@ -78,25 +78,25 @@ var import_ts_morph2 = require("ts-morph");
78
78
  var import_ts_morph = require("ts-morph");
79
79
  var MAX_LAYERS = 16;
80
80
  function peelSyntax(node) {
81
- let current = node;
81
+ let current2 = node;
82
82
  for (let i = 0; i < MAX_LAYERS; i++) {
83
- if (import_ts_morph.Node.isAsExpression(current) || import_ts_morph.Node.isTypeAssertion(current) || import_ts_morph.Node.isParenthesizedExpression(current) || import_ts_morph.Node.isNonNullExpression(current) || import_ts_morph.Node.isSatisfiesExpression(current)) {
84
- current = current.getExpression();
83
+ if (import_ts_morph.Node.isAsExpression(current2) || import_ts_morph.Node.isTypeAssertion(current2) || import_ts_morph.Node.isParenthesizedExpression(current2) || import_ts_morph.Node.isNonNullExpression(current2) || import_ts_morph.Node.isSatisfiesExpression(current2)) {
84
+ current2 = current2.getExpression();
85
85
  continue;
86
86
  }
87
87
  break;
88
88
  }
89
- return current;
89
+ return current2;
90
90
  }
91
91
  function peelParens(node) {
92
- let current = node;
92
+ let current2 = node;
93
93
  for (let i = 0; i < MAX_LAYERS; i++) {
94
- if (!import_ts_morph.Node.isParenthesizedExpression(current)) {
94
+ if (!import_ts_morph.Node.isParenthesizedExpression(current2)) {
95
95
  break;
96
96
  }
97
- current = current.getExpression();
97
+ current2 = current2.getExpression();
98
98
  }
99
- return current;
99
+ return current2;
100
100
  }
101
101
 
102
102
  // src/resolve/astResolve.ts
@@ -965,15 +965,15 @@ function collectAncestorConditionInfos(terminalNode, functionRoot) {
965
965
  }
966
966
  function collectAncestorConditionInfosBelow(terminalNode, stopNode) {
967
967
  const result = [];
968
- let current = terminalNode;
969
- while (current !== void 0 && current !== stopNode) {
970
- const parent = current.getParent();
968
+ let current2 = terminalNode;
969
+ while (current2 !== void 0 && current2 !== stopNode) {
970
+ const parent = current2.getParent();
971
971
  if (parent !== void 0 && import_ts_morph6.Node.isIfStatement(parent)) {
972
972
  const thenBranch = parent.getThenStatement();
973
973
  const elseBranch = parent.getElseStatement();
974
974
  const expr = parent.getExpression();
975
- const inThen = isAncestorOrSelf(thenBranch, current);
976
- const inElse = elseBranch !== void 0 && isAncestorOrSelf(elseBranch, current);
975
+ const inThen = isAncestorOrSelf(thenBranch, current2);
976
+ const inElse = elseBranch !== void 0 && isAncestorOrSelf(elseBranch, current2);
977
977
  if (inThen) {
978
978
  result.unshift(
979
979
  makeConditionInfo(expr.getText(), "positive", "explicit", expr)
@@ -983,24 +983,24 @@ function collectAncestorConditionInfosBelow(terminalNode, stopNode) {
983
983
  makeConditionInfo(expr.getText(), "negative", "explicit", expr)
984
984
  );
985
985
  }
986
- } else if (import_ts_morph6.Node.isCaseClause(current)) {
987
- const switchStmt = current.getParent()?.getParent();
986
+ } else if (import_ts_morph6.Node.isCaseClause(current2)) {
987
+ const switchStmt = current2.getParent()?.getParent();
988
988
  if (switchStmt !== void 0 && import_ts_morph6.Node.isSwitchStatement(switchStmt)) {
989
989
  const switchExpr = switchStmt.getExpression().getText();
990
- const labels = collectFallthroughCaseLabels(current);
990
+ const labels = collectFallthroughCaseLabels(current2);
991
991
  const condText = labels.length === 1 ? `${switchExpr} === ${labels[0]}` : labels.map((l) => `${switchExpr} === ${l}`).join(" || ");
992
992
  result.unshift(
993
993
  makeConditionInfo(condText, "positive", "explicit", null)
994
994
  );
995
995
  }
996
- } else if (import_ts_morph6.Node.isCatchClause(current)) {
996
+ } else if (import_ts_morph6.Node.isCatchClause(current2)) {
997
997
  result.unshift(
998
998
  makeConditionInfo("catch", "positive", "catchBlock", null)
999
999
  );
1000
1000
  } else if (parent !== void 0 && import_ts_morph6.Node.isConditionalExpression(parent)) {
1001
1001
  const expr = parent.getCondition();
1002
- const inTrue = isAncestorOrSelf(parent.getWhenTrue(), current);
1003
- const inFalse = isAncestorOrSelf(parent.getWhenFalse(), current);
1002
+ const inTrue = isAncestorOrSelf(parent.getWhenTrue(), current2);
1003
+ const inFalse = isAncestorOrSelf(parent.getWhenFalse(), current2);
1004
1004
  if (inTrue) {
1005
1005
  result.unshift(
1006
1006
  makeConditionInfo(expr.getText(), "positive", "explicit", expr)
@@ -1013,7 +1013,7 @@ function collectAncestorConditionInfosBelow(terminalNode, stopNode) {
1013
1013
  } else if (parent !== void 0 && import_ts_morph6.Node.isBinaryExpression(parent)) {
1014
1014
  const op = parent.getOperatorToken().getText();
1015
1015
  const left = parent.getLeft();
1016
- if (current === parent.getRight() || isAncestorOrSelf(parent.getRight(), current)) {
1016
+ if (current2 === parent.getRight() || isAncestorOrSelf(parent.getRight(), current2)) {
1017
1017
  if (op === "&&") {
1018
1018
  result.unshift(
1019
1019
  makeConditionInfo(left.getText(), "positive", "explicit", left)
@@ -1025,7 +1025,7 @@ function collectAncestorConditionInfosBelow(terminalNode, stopNode) {
1025
1025
  }
1026
1026
  }
1027
1027
  }
1028
- current = parent;
1028
+ current2 = parent;
1029
1029
  }
1030
1030
  return result;
1031
1031
  }
@@ -1035,12 +1035,12 @@ function collectAncestorBranches(terminalNode, functionRoot) {
1035
1035
  );
1036
1036
  }
1037
1037
  function isAncestorOrSelf(maybeAncestor, node) {
1038
- let current = node;
1039
- while (current !== void 0) {
1040
- if (current === maybeAncestor) {
1038
+ let current2 = node;
1039
+ while (current2 !== void 0) {
1040
+ if (current2 === maybeAncestor) {
1041
1041
  return true;
1042
1042
  }
1043
- current = current.getParent();
1043
+ current2 = current2.getParent();
1044
1044
  }
1045
1045
  return false;
1046
1046
  }
@@ -1560,12 +1560,12 @@ function degradedResult(func, terminalNodes, reason) {
1560
1560
  return { byTerminal, fallthrough: [[marker]] };
1561
1561
  }
1562
1562
  function enclosingVisitedStatement(terminal, body, visited) {
1563
- let current = terminal;
1564
- while (current !== void 0 && current !== body) {
1565
- if (import_ts_morph7.Node.isStatement(current) && visited.has(current)) {
1566
- return current;
1563
+ let current2 = terminal;
1564
+ while (current2 !== void 0 && current2 !== body) {
1565
+ if (import_ts_morph7.Node.isStatement(current2) && visited.has(current2)) {
1566
+ return current2;
1567
1567
  }
1568
- current = current.getParent();
1568
+ current2 = current2.getParent();
1569
1569
  }
1570
1570
  return null;
1571
1571
  }
@@ -1603,12 +1603,12 @@ function isModuleScopeStop(node) {
1603
1603
  return import_ts_morph8.Node.isFunctionDeclaration(node) || import_ts_morph8.Node.isMethodDeclaration(node) || import_ts_morph8.Node.isArrowFunction(node) || import_ts_morph8.Node.isFunctionExpression(node) || import_ts_morph8.Node.isClassDeclaration(node) || import_ts_morph8.Node.isClassExpression(node);
1604
1604
  }
1605
1605
  function crossesNestedFunctionScope(node, func) {
1606
- let current = node;
1607
- while (current !== void 0 && current !== func) {
1608
- if (startsItsOwnScope(current)) {
1606
+ let current2 = node;
1607
+ while (current2 !== void 0 && current2 !== func) {
1608
+ if (startsItsOwnScope(current2)) {
1609
1609
  return true;
1610
1610
  }
1611
- current = current.getParent();
1611
+ current2 = current2.getParent();
1612
1612
  }
1613
1613
  return false;
1614
1614
  }
@@ -1931,13 +1931,13 @@ function inlineModuleBinding(ident, depth) {
1931
1931
  return null;
1932
1932
  }
1933
1933
  function isModuleScoped(decl) {
1934
- let current = decl.getParent();
1935
- while (current !== void 0) {
1936
- if (import_ts_morph9.Node.isSourceFile(current)) {
1934
+ let current2 = decl.getParent();
1935
+ while (current2 !== void 0) {
1936
+ if (import_ts_morph9.Node.isSourceFile(current2)) {
1937
1937
  return true;
1938
1938
  }
1939
- if (import_ts_morph9.Node.isVariableDeclarationList(current) || import_ts_morph9.Node.isVariableStatement(current)) {
1940
- current = current.getParent();
1939
+ if (import_ts_morph9.Node.isVariableDeclarationList(current2) || import_ts_morph9.Node.isVariableStatement(current2)) {
1940
+ current2 = current2.getParent();
1941
1941
  continue;
1942
1942
  }
1943
1943
  return false;
@@ -1960,12 +1960,12 @@ function unwrapCasts(node) {
1960
1960
  return node;
1961
1961
  }
1962
1962
  function enclosingStatementLine(node) {
1963
- let current = node;
1964
- while (current !== void 0) {
1965
- if (import_ts_morph9.Node.isStatement(current)) {
1966
- return startLineOf(current);
1963
+ let current2 = node;
1964
+ while (current2 !== void 0) {
1965
+ if (import_ts_morph9.Node.isStatement(current2)) {
1966
+ return startLineOf(current2);
1967
1967
  }
1968
- current = current.getParent();
1968
+ current2 = current2.getParent();
1969
1969
  }
1970
1970
  return startLineOf(node);
1971
1971
  }
@@ -2172,6 +2172,46 @@ var import_ts_morph17 = require("ts-morph");
2172
2172
  // src/shapes/shapes.ts
2173
2173
  var import_ts_morph11 = require("ts-morph");
2174
2174
 
2175
+ // src/shapes/typeShapes.ts
2176
+ var import_node_crypto = require("crypto");
2177
+
2178
+ // src/shapes/definitions.ts
2179
+ var current = null;
2180
+ var definitionsInProgress = () => current;
2181
+ function createDefinitionTable() {
2182
+ const shapes = /* @__PURE__ */ new Map();
2183
+ return {
2184
+ has: (key) => shapes.has(key),
2185
+ reserve: (key) => {
2186
+ shapes.set(key, null);
2187
+ },
2188
+ define: (key, shape) => {
2189
+ shapes.set(key, shape);
2190
+ },
2191
+ collected: () => {
2192
+ const out = {};
2193
+ let any = false;
2194
+ for (const [key, shape] of shapes) {
2195
+ if (shape !== null) {
2196
+ out[key] = shape;
2197
+ any = true;
2198
+ }
2199
+ }
2200
+ return any ? out : null;
2201
+ }
2202
+ };
2203
+ }
2204
+ function withDefinitions(read) {
2205
+ const table = createDefinitionTable();
2206
+ const outer = current;
2207
+ current = table;
2208
+ try {
2209
+ return { value: read(), definitions: table.collected() };
2210
+ } finally {
2211
+ current = outer;
2212
+ }
2213
+ }
2214
+
2175
2215
  // src/shapes/typeShapes.ts
2176
2216
  var MAX_DEPTH = 6;
2177
2217
  var OPAQUE_NAMED_TYPES = /* @__PURE__ */ new Set([
@@ -2290,7 +2330,7 @@ function typeToShape(type, ctx) {
2290
2330
  return outsideRef;
2291
2331
  }
2292
2332
  if (type.isObject() || type.isClassOrInterface()) {
2293
- return objectToShape(type, ctx);
2333
+ return namedOnce(type, ctx) ?? objectToShape(type, ctx);
2294
2334
  }
2295
2335
  if (type.isEnum() || type.isEnumLiteral()) {
2296
2336
  return enumToShape(type, ctx);
@@ -2437,6 +2477,43 @@ function isOutsideProject(file) {
2437
2477
  outsideProjectByFile.set(key, outside);
2438
2478
  return outside;
2439
2479
  }
2480
+ function namedOnce(type, ctx) {
2481
+ const table = definitionsInProgress();
2482
+ if (table === null) {
2483
+ return null;
2484
+ }
2485
+ const named = refFromType(type, ctx);
2486
+ if (named.type !== "ref") {
2487
+ return null;
2488
+ }
2489
+ const symbol = type.getAliasSymbol() ?? type.getSymbol();
2490
+ const name = symbol?.getName();
2491
+ if (name === void 0 || name === "__type" || name === "__object") {
2492
+ return null;
2493
+ }
2494
+ const key = definitionKeyFor(type, named.name);
2495
+ const filed = { ...named, def: key };
2496
+ if (!table.has(key)) {
2497
+ table.reserve(key);
2498
+ const expanded = objectToShape(type, {
2499
+ enclosing: ctx.enclosing,
2500
+ depth: 0,
2501
+ seen: /* @__PURE__ */ new Set()
2502
+ });
2503
+ if (expanded === null) {
2504
+ return null;
2505
+ }
2506
+ table.define(key, expanded);
2507
+ }
2508
+ return filed;
2509
+ }
2510
+ function definitionKeyFor(type, name) {
2511
+ const written = withoutImportQualifiers(type.getText());
2512
+ return `${name}@${shortHash(written)}`;
2513
+ }
2514
+ function shortHash(text) {
2515
+ return (0, import_node_crypto.createHash)("sha1").update(text).digest("hex").slice(0, 12);
2516
+ }
2440
2517
  function refFromType(type, ctx) {
2441
2518
  const symbol = type.getAliasSymbol() ?? type.getSymbol();
2442
2519
  if (symbol) {
@@ -2993,22 +3070,22 @@ function branchCanRun(returnValue, substitutions) {
2993
3070
  function guardsAbove(returnValue) {
2994
3071
  const guards = [];
2995
3072
  let child = returnValue;
2996
- let current = returnValue.getParent();
2997
- while (current !== void 0) {
2998
- if (import_ts_morph13.Node.isIfStatement(current)) {
3073
+ let current2 = returnValue.getParent();
3074
+ while (current2 !== void 0) {
3075
+ if (import_ts_morph13.Node.isIfStatement(current2)) {
2999
3076
  guards.push({
3000
- condition: current.getExpression(),
3001
- whenTrue: current.getThenStatement() === child
3077
+ condition: current2.getExpression(),
3078
+ whenTrue: current2.getThenStatement() === child
3002
3079
  });
3003
3080
  }
3004
- if (import_ts_morph13.Node.isBlock(current)) {
3005
- guards.push(...earlyReturnGuardsBefore(current, child));
3081
+ if (import_ts_morph13.Node.isBlock(current2)) {
3082
+ guards.push(...earlyReturnGuardsBefore(current2, child));
3006
3083
  }
3007
- if (import_ts_morph13.Node.isFunctionDeclaration(current) || import_ts_morph13.Node.isArrowFunction(current) || import_ts_morph13.Node.isFunctionExpression(current)) {
3084
+ if (import_ts_morph13.Node.isFunctionDeclaration(current2) || import_ts_morph13.Node.isArrowFunction(current2) || import_ts_morph13.Node.isFunctionExpression(current2)) {
3008
3085
  break;
3009
3086
  }
3010
- child = current;
3011
- current = current.getParent();
3087
+ child = current2;
3088
+ current2 = current2.getParent();
3012
3089
  }
3013
3090
  return guards;
3014
3091
  }
@@ -3173,12 +3250,12 @@ function returnedObjects(fn) {
3173
3250
  return found;
3174
3251
  }
3175
3252
  function enclosingFunctionOf(node) {
3176
- let current = node.getParent();
3177
- while (current !== void 0) {
3178
- if (import_ts_morph13.Node.isFunctionDeclaration(current) || import_ts_morph13.Node.isArrowFunction(current) || import_ts_morph13.Node.isFunctionExpression(current) || import_ts_morph13.Node.isMethodDeclaration(current)) {
3179
- return current.getBody();
3253
+ let current2 = node.getParent();
3254
+ while (current2 !== void 0) {
3255
+ if (import_ts_morph13.Node.isFunctionDeclaration(current2) || import_ts_morph13.Node.isArrowFunction(current2) || import_ts_morph13.Node.isFunctionExpression(current2) || import_ts_morph13.Node.isMethodDeclaration(current2)) {
3256
+ return current2.getBody();
3180
3257
  }
3181
- current = current.getParent();
3258
+ current2 = current2.getParent();
3182
3259
  }
3183
3260
  return void 0;
3184
3261
  }
@@ -3196,16 +3273,16 @@ function bindArguments(callArgs, params) {
3196
3273
  // src/terminals/shared.ts
3197
3274
  var import_ts_morph14 = require("ts-morph");
3198
3275
  function unwrapValue(node) {
3199
- let current = node;
3200
- while (import_ts_morph14.Node.isParenthesizedExpression(current) || import_ts_morph14.Node.isAwaitExpression(current) || import_ts_morph14.Node.isAsExpression(current) || import_ts_morph14.Node.isNonNullExpression(current) || import_ts_morph14.Node.isSatisfiesExpression(current)) {
3201
- current = current.getExpression();
3276
+ let current2 = node;
3277
+ while (import_ts_morph14.Node.isParenthesizedExpression(current2) || import_ts_morph14.Node.isAwaitExpression(current2) || import_ts_morph14.Node.isAsExpression(current2) || import_ts_morph14.Node.isNonNullExpression(current2) || import_ts_morph14.Node.isSatisfiesExpression(current2)) {
3278
+ current2 = current2.getExpression();
3202
3279
  }
3203
- return current;
3280
+ return current2;
3204
3281
  }
3205
3282
  function returnPositionOf(value) {
3206
- let current = value;
3283
+ let current2 = value;
3207
3284
  while (true) {
3208
- const parent = current.getParent();
3285
+ const parent = current2.getParent();
3209
3286
  if (parent === void 0) {
3210
3287
  return null;
3211
3288
  }
@@ -3213,14 +3290,14 @@ function returnPositionOf(value) {
3213
3290
  return parent;
3214
3291
  }
3215
3292
  if (import_ts_morph14.Node.isArrowFunction(parent)) {
3216
- return parent.getBody() === current ? current : null;
3293
+ return parent.getBody() === current2 ? current2 : null;
3217
3294
  }
3218
3295
  if (import_ts_morph14.Node.isParenthesizedExpression(parent) || import_ts_morph14.Node.isAwaitExpression(parent) || import_ts_morph14.Node.isAsExpression(parent) || import_ts_morph14.Node.isNonNullExpression(parent) || import_ts_morph14.Node.isSatisfiesExpression(parent)) {
3219
- current = parent;
3296
+ current2 = parent;
3220
3297
  continue;
3221
3298
  }
3222
- if (import_ts_morph14.Node.isConditionalExpression(parent) && (parent.getWhenTrue() === current || parent.getWhenFalse() === current)) {
3223
- current = parent;
3299
+ if (import_ts_morph14.Node.isConditionalExpression(parent) && (parent.getWhenTrue() === current2 || parent.getWhenFalse() === current2)) {
3300
+ current2 = parent;
3224
3301
  continue;
3225
3302
  }
3226
3303
  return null;
@@ -3364,12 +3441,12 @@ function writesRunInOrder(declaration, writes) {
3364
3441
  return last !== void 0 && !isReadBefore(declaration, last.node.getStart());
3365
3442
  }
3366
3443
  function statementOf(node) {
3367
- let current = node;
3368
- while (current !== void 0) {
3369
- if (import_ts_morph15.Node.isStatement(current)) {
3370
- return current;
3444
+ let current2 = node;
3445
+ while (current2 !== void 0) {
3446
+ if (import_ts_morph15.Node.isStatement(current2)) {
3447
+ return current2;
3371
3448
  }
3372
- current = current.getParent();
3449
+ current2 = current2.getParent();
3373
3450
  }
3374
3451
  return null;
3375
3452
  }
@@ -3463,11 +3540,11 @@ function numberOf(node) {
3463
3540
  return Number.isFinite(value) ? value : null;
3464
3541
  }
3465
3542
  function unwrap(node) {
3466
- let current = node;
3467
- while (import_ts_morph16.Node.isParenthesizedExpression(current) || import_ts_morph16.Node.isAsExpression(current) || import_ts_morph16.Node.isNonNullExpression(current)) {
3468
- current = current.getExpression();
3543
+ let current2 = node;
3544
+ while (import_ts_morph16.Node.isParenthesizedExpression(current2) || import_ts_morph16.Node.isAsExpression(current2) || import_ts_morph16.Node.isNonNullExpression(current2)) {
3545
+ current2 = current2.getExpression();
3469
3546
  }
3470
- return current;
3547
+ return current2;
3471
3548
  }
3472
3549
 
3473
3550
  // src/terminals/returns.ts
@@ -3476,17 +3553,17 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
3476
3553
  return null;
3477
3554
  }
3478
3555
  const collected = [];
3479
- let current = call;
3556
+ let current2 = call;
3480
3557
  for (let i = methodChain.length - 1; i >= 0; i--) {
3481
3558
  const expectedMethod = methodChain[i];
3482
- const callee = current.getExpression();
3559
+ const callee = current2.getExpression();
3483
3560
  if (!import_ts_morph17.Node.isPropertyAccessExpression(callee)) {
3484
3561
  return null;
3485
3562
  }
3486
3563
  if (callee.getName() !== expectedMethod) {
3487
3564
  return null;
3488
3565
  }
3489
- collected.unshift(current);
3566
+ collected.unshift(current2);
3490
3567
  const subject = callee.getExpression();
3491
3568
  if (i === 0) {
3492
3569
  if (!import_ts_morph17.Node.isIdentifier(subject)) {
@@ -3513,7 +3590,7 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
3513
3590
  if (!import_ts_morph17.Node.isCallExpression(subject)) {
3514
3591
  return null;
3515
3592
  }
3516
- current = subject;
3593
+ current2 = subject;
3517
3594
  }
3518
3595
  }
3519
3596
  return { calls: collected };
@@ -3688,8 +3765,8 @@ function statusArgument(calls, extraction) {
3688
3765
  return calls[0]?.getArguments()[from.position] ?? null;
3689
3766
  }
3690
3767
  function returnCoveredByParameterMethodCall(expr, func, patterns) {
3691
- const current = unwrapValue(expr);
3692
- if (!import_ts_morph17.Node.isCallExpression(current)) {
3768
+ const current2 = unwrapValue(expr);
3769
+ if (!import_ts_morph17.Node.isCallExpression(current2)) {
3693
3770
  return false;
3694
3771
  }
3695
3772
  for (const pattern of patterns) {
@@ -3697,7 +3774,7 @@ function returnCoveredByParameterMethodCall(expr, func, patterns) {
3697
3774
  continue;
3698
3775
  }
3699
3776
  const result = unwrapMethodChain(
3700
- current,
3777
+ current2,
3701
3778
  pattern.match.methodChain,
3702
3779
  func,
3703
3780
  pattern.match.parameterPosition
@@ -4277,17 +4354,17 @@ var ModuleGraph = class {
4277
4354
  const walked = /* @__PURE__ */ new Set();
4278
4355
  const stack = [root];
4279
4356
  while (stack.length > 0) {
4280
- const current = stack.pop();
4281
- const currentPath = current.getFilePath();
4357
+ const current2 = stack.pop();
4358
+ const currentPath = current2.getFilePath();
4282
4359
  if (walked.has(currentPath) || settled.has(currentPath)) {
4283
4360
  continue;
4284
4361
  }
4285
4362
  walked.add(currentPath);
4286
- if (namesPackage(this.specifiersOf(current), name)) {
4363
+ if (namesPackage(this.specifiersOf(current2), name)) {
4287
4364
  this.assert("importsPackage", [currentPath, name]);
4288
4365
  continue;
4289
4366
  }
4290
- stack.push(...this.importedFilesOf(current));
4367
+ stack.push(...this.importedFilesOf(current2));
4291
4368
  }
4292
4369
  for (const filePath of walked) {
4293
4370
  settled.add(filePath);
@@ -4610,7 +4687,7 @@ function indexFunctions(sf) {
4610
4687
  }
4611
4688
 
4612
4689
  // src/cache.ts
4613
- var import_node_crypto = require("crypto");
4690
+ var import_node_crypto2 = require("crypto");
4614
4691
  var import_promises2 = __toESM(require("fs/promises"), 1);
4615
4692
  var import_node_path2 = __toESM(require("path"), 1);
4616
4693
  var SCHEMA_VERSION = "3";
@@ -4689,7 +4766,7 @@ function entryDirFor(cacheDir, input) {
4689
4766
  input.adapterPacksDigest,
4690
4767
  input.tsconfigPath ?? ""
4691
4768
  ].join("\0");
4692
- const name = (0, import_node_crypto.createHash)("sha256").update(key).digest("hex").slice(0, 16);
4769
+ const name = (0, import_node_crypto2.createHash)("sha256").update(key).digest("hex").slice(0, 16);
4693
4770
  return import_node_path2.default.join(cacheDir, `${ENTRY_PREFIX}${name}`);
4694
4771
  }
4695
4772
  function isEntryDir(name) {
@@ -5387,12 +5464,12 @@ function toFunctionRoot(node) {
5387
5464
  return isFunctionRoot(node) ? declarationCarryingTheBody(node) : null;
5388
5465
  }
5389
5466
  function findEnclosingFunction(node) {
5390
- let current = node.getParent();
5391
- while (current !== void 0) {
5392
- if (import_ts_morph25.Node.isFunctionDeclaration(current) || import_ts_morph25.Node.isFunctionExpression(current) || import_ts_morph25.Node.isArrowFunction(current) || import_ts_morph25.Node.isMethodDeclaration(current)) {
5393
- return current;
5467
+ let current2 = node.getParent();
5468
+ while (current2 !== void 0) {
5469
+ if (import_ts_morph25.Node.isFunctionDeclaration(current2) || import_ts_morph25.Node.isFunctionExpression(current2) || import_ts_morph25.Node.isArrowFunction(current2) || import_ts_morph25.Node.isMethodDeclaration(current2)) {
5470
+ return current2;
5394
5471
  }
5395
- current = current.getParent();
5472
+ current2 = current2.getParent();
5396
5473
  }
5397
5474
  return null;
5398
5475
  }
@@ -6250,10 +6327,10 @@ function resolveTypedDocumentHeader(arg) {
6250
6327
  return null;
6251
6328
  }
6252
6329
  function documentNodeCastTypeArgs(node) {
6253
- let current = node;
6254
- while (import_ts_morph32.Node.isAsExpression(current) || import_ts_morph32.Node.isParenthesizedExpression(current)) {
6255
- if (import_ts_morph32.Node.isAsExpression(current)) {
6256
- const typeNode = current.getTypeNode();
6330
+ let current2 = node;
6331
+ while (import_ts_morph32.Node.isAsExpression(current2) || import_ts_morph32.Node.isParenthesizedExpression(current2)) {
6332
+ if (import_ts_morph32.Node.isAsExpression(current2)) {
6333
+ const typeNode = current2.getTypeNode();
6257
6334
  if (typeNode !== void 0 && import_ts_morph32.Node.isTypeReference(typeNode)) {
6258
6335
  const name = typeNode.getTypeName().getText();
6259
6336
  const simpleName = name.includes(".") ? name.split(".").pop() ?? name : name;
@@ -6262,7 +6339,7 @@ function documentNodeCastTypeArgs(node) {
6262
6339
  }
6263
6340
  }
6264
6341
  }
6265
- current = current.getExpression();
6342
+ current2 = current2.getExpression();
6266
6343
  }
6267
6344
  return null;
6268
6345
  }
@@ -6287,11 +6364,11 @@ function operationHeaderFromResultType(typeNode) {
6287
6364
  return null;
6288
6365
  }
6289
6366
  function stripDocumentNodeCasts(node) {
6290
- let current = node;
6291
- while (import_ts_morph32.Node.isAsExpression(current) || import_ts_morph32.Node.isParenthesizedExpression(current)) {
6292
- current = current.getExpression();
6367
+ let current2 = node;
6368
+ while (import_ts_morph32.Node.isAsExpression(current2) || import_ts_morph32.Node.isParenthesizedExpression(current2)) {
6369
+ current2 = current2.getExpression();
6293
6370
  }
6294
- return current;
6371
+ return current2;
6295
6372
  }
6296
6373
  function evaluateObjectLiteralAsJson(node) {
6297
6374
  if (import_ts_morph32.Node.isStringLiteral(node) || import_ts_morph32.Node.isNoSubstitutionTemplateLiteral(node)) {
@@ -6369,12 +6446,12 @@ function resolveGraphqlFileImport(decl) {
6369
6446
  }
6370
6447
  }
6371
6448
  function enclosingFunctionRoot(node) {
6372
- let current = node.getParent();
6373
- while (current !== void 0) {
6374
- if (import_ts_morph32.Node.isFunctionDeclaration(current) || import_ts_morph32.Node.isFunctionExpression(current) || import_ts_morph32.Node.isArrowFunction(current) || import_ts_morph32.Node.isMethodDeclaration(current)) {
6375
- return current;
6449
+ let current2 = node.getParent();
6450
+ while (current2 !== void 0) {
6451
+ if (import_ts_morph32.Node.isFunctionDeclaration(current2) || import_ts_morph32.Node.isFunctionExpression(current2) || import_ts_morph32.Node.isArrowFunction(current2) || import_ts_morph32.Node.isMethodDeclaration(current2)) {
6452
+ return current2;
6376
6453
  }
6377
- current = current.getParent();
6454
+ current2 = current2.getParent();
6378
6455
  }
6379
6456
  return null;
6380
6457
  }
@@ -6895,12 +6972,12 @@ function isScopeNode(node) {
6895
6972
  function trackFactoryBindings(sourceFile, recognize) {
6896
6973
  const scopes = /* @__PURE__ */ new Map();
6897
6974
  function scopeOf(node) {
6898
- let current = node.getParent();
6899
- while (current !== void 0) {
6900
- if (isScopeNode(current)) {
6901
- return current;
6975
+ let current2 = node.getParent();
6976
+ while (current2 !== void 0) {
6977
+ if (isScopeNode(current2)) {
6978
+ return current2;
6902
6979
  }
6903
- current = current.getParent();
6980
+ current2 = current2.getParent();
6904
6981
  }
6905
6982
  return sourceFile;
6906
6983
  }
@@ -6962,16 +7039,16 @@ function trackFactoryBindings(sourceFile, recognize) {
6962
7039
  }
6963
7040
  return {
6964
7041
  resolve(name, fromNode) {
6965
- let current = fromNode;
6966
- while (current !== void 0) {
6967
- const map = scopes.get(current);
7042
+ let current2 = fromNode;
7043
+ while (current2 !== void 0) {
7044
+ const map = scopes.get(current2);
6968
7045
  if (map !== void 0) {
6969
7046
  const found = map.get(name);
6970
7047
  if (found !== void 0) {
6971
7048
  return found;
6972
7049
  }
6973
7050
  }
6974
- current = current.getParent();
7051
+ current2 = current2.getParent();
6975
7052
  }
6976
7053
  return null;
6977
7054
  }
@@ -7258,21 +7335,21 @@ function literalIndexOf(index) {
7258
7335
  return null;
7259
7336
  }
7260
7337
  function unwrapExpression(expression) {
7261
- let current = expression;
7338
+ let current2 = expression;
7262
7339
  for (; ; ) {
7263
- if (import_ts_morph39.Node.isAwaitExpression(current)) {
7264
- current = current.getExpression();
7340
+ if (import_ts_morph39.Node.isAwaitExpression(current2)) {
7341
+ current2 = current2.getExpression();
7265
7342
  continue;
7266
7343
  }
7267
- if (import_ts_morph39.Node.isParenthesizedExpression(current)) {
7268
- current = current.getExpression();
7344
+ if (import_ts_morph39.Node.isParenthesizedExpression(current2)) {
7345
+ current2 = current2.getExpression();
7269
7346
  continue;
7270
7347
  }
7271
- if (import_ts_morph39.Node.isAsExpression(current) || import_ts_morph39.Node.isSatisfiesExpression(current)) {
7272
- current = current.getExpression();
7348
+ if (import_ts_morph39.Node.isAsExpression(current2) || import_ts_morph39.Node.isSatisfiesExpression(current2)) {
7349
+ current2 = current2.getExpression();
7273
7350
  continue;
7274
7351
  }
7275
- return current;
7352
+ return current2;
7276
7353
  }
7277
7354
  }
7278
7355
  function emitValue(db, table, value) {
@@ -7570,13 +7647,13 @@ function recordBodyNode(db, table, fnId, node) {
7570
7647
  return false;
7571
7648
  }
7572
7649
  function descendantIsReturned(fn) {
7573
- let current = fn.getParent();
7574
- while (current !== void 0) {
7575
- if (import_ts_morph39.Node.isReturnStatement(current)) {
7650
+ let current2 = fn.getParent();
7651
+ while (current2 !== void 0) {
7652
+ if (import_ts_morph39.Node.isReturnStatement(current2)) {
7576
7653
  return true;
7577
7654
  }
7578
- if (import_ts_morph39.Node.isParenthesizedExpression(current) || import_ts_morph39.Node.isAsExpression(current) || import_ts_morph39.Node.isSatisfiesExpression(current)) {
7579
- current = current.getParent();
7655
+ if (import_ts_morph39.Node.isParenthesizedExpression(current2) || import_ts_morph39.Node.isAsExpression(current2) || import_ts_morph39.Node.isSatisfiesExpression(current2)) {
7656
+ current2 = current2.getParent();
7580
7657
  continue;
7581
7658
  }
7582
7659
  return false;
@@ -8531,11 +8608,11 @@ function configString(arg, property, resolution) {
8531
8608
  return null;
8532
8609
  }
8533
8610
  function peelExpression(node) {
8534
- let current = node;
8535
- while (current !== void 0 && (import_ts_morph45.Node.isAsExpression(current) || import_ts_morph45.Node.isSatisfiesExpression(current) || import_ts_morph45.Node.isParenthesizedExpression(current) || import_ts_morph45.Node.isNonNullExpression(current))) {
8536
- current = current.getExpression();
8611
+ let current2 = node;
8612
+ while (current2 !== void 0 && (import_ts_morph45.Node.isAsExpression(current2) || import_ts_morph45.Node.isSatisfiesExpression(current2) || import_ts_morph45.Node.isParenthesizedExpression(current2) || import_ts_morph45.Node.isNonNullExpression(current2))) {
8613
+ current2 = current2.getExpression();
8537
8614
  }
8538
- return current;
8615
+ return current2;
8539
8616
  }
8540
8617
  function toObjectLiteral(node, resolution) {
8541
8618
  const peeled = peelExpression(node);
@@ -8598,11 +8675,11 @@ function hasJsxReturn(func) {
8598
8675
  return found;
8599
8676
  }
8600
8677
  function isJsxOrFragment(node) {
8601
- let current = node;
8602
- while (import_ts_morph45.Node.isParenthesizedExpression(current)) {
8603
- current = current.getExpression();
8678
+ let current2 = node;
8679
+ while (import_ts_morph45.Node.isParenthesizedExpression(current2)) {
8680
+ current2 = current2.getExpression();
8604
8681
  }
8605
- return import_ts_morph45.Node.isJsxElement(current) || import_ts_morph45.Node.isJsxSelfClosingElement(current) || import_ts_morph45.Node.isJsxFragment(current);
8682
+ return import_ts_morph45.Node.isJsxElement(current2) || import_ts_morph45.Node.isJsxSelfClosingElement(current2) || import_ts_morph45.Node.isJsxFragment(current2);
8606
8683
  }
8607
8684
 
8608
8685
  // src/facts/store.ts
@@ -9588,19 +9665,19 @@ function findBareRethrow(func, location) {
9588
9665
  return found;
9589
9666
  }
9590
9667
  function enclosingTry(throwStmt) {
9591
- let current = throwStmt.getParent();
9668
+ let current2 = throwStmt.getParent();
9592
9669
  let sawCatchClause = false;
9593
- while (current !== void 0) {
9594
- if (import_ts_morph48.Node.isCatchClause(current)) {
9670
+ while (current2 !== void 0) {
9671
+ if (import_ts_morph48.Node.isCatchClause(current2)) {
9595
9672
  sawCatchClause = true;
9596
9673
  }
9597
- if (import_ts_morph48.Node.isTryStatement(current)) {
9598
- return sawCatchClause ? current : null;
9674
+ if (import_ts_morph48.Node.isTryStatement(current2)) {
9675
+ return sawCatchClause ? current2 : null;
9599
9676
  }
9600
- if (import_ts_morph48.Node.isFunctionDeclaration(current) || import_ts_morph48.Node.isFunctionExpression(current) || import_ts_morph48.Node.isArrowFunction(current) || import_ts_morph48.Node.isMethodDeclaration(current)) {
9677
+ if (import_ts_morph48.Node.isFunctionDeclaration(current2) || import_ts_morph48.Node.isFunctionExpression(current2) || import_ts_morph48.Node.isArrowFunction(current2) || import_ts_morph48.Node.isMethodDeclaration(current2)) {
9601
9678
  return null;
9602
9679
  }
9603
- current = current.getParent();
9680
+ current2 = current2.getParent();
9604
9681
  }
9605
9682
  return null;
9606
9683
  }
@@ -9670,12 +9747,12 @@ function functionFromDecl(decl) {
9670
9747
  // src/shapes/fieldAccesses.ts
9671
9748
  var import_ts_morph49 = require("ts-morph");
9672
9749
  function findResponseAccessor(callExpr) {
9673
- let current = callExpr;
9674
- const parent1 = current.getParent();
9750
+ let current2 = callExpr;
9751
+ const parent1 = current2.getParent();
9675
9752
  if (parent1 !== void 0 && import_ts_morph49.Node.isAwaitExpression(parent1)) {
9676
- current = parent1;
9753
+ current2 = parent1;
9677
9754
  }
9678
- const parent2 = current.getParent();
9755
+ const parent2 = current2.getParent();
9679
9756
  if (parent2 === void 0 || !import_ts_morph49.Node.isVariableDeclaration(parent2)) {
9680
9757
  return null;
9681
9758
  }
@@ -9832,12 +9909,12 @@ function collectPropertyAccesses(subtree, accessor) {
9832
9909
  return;
9833
9910
  }
9834
9911
  const chain = [];
9835
- let current = node;
9836
- while (import_ts_morph49.Node.isPropertyAccessExpression(current)) {
9837
- chain.unshift(current.getName());
9838
- current = current.getExpression();
9912
+ let current2 = node;
9913
+ while (import_ts_morph49.Node.isPropertyAccessExpression(current2)) {
9914
+ chain.unshift(current2.getName());
9915
+ current2 = current2.getExpression();
9839
9916
  }
9840
- if (import_ts_morph49.Node.isIdentifier(current) && current.getText() === varName) {
9917
+ if (import_ts_morph49.Node.isIdentifier(current2) && current2.getText() === varName) {
9841
9918
  pushChain(chain);
9842
9919
  }
9843
9920
  });
@@ -9865,10 +9942,10 @@ function collectPropertyAccesses(subtree, accessor) {
9865
9942
  parent = chainTop.getParent();
9866
9943
  }
9867
9944
  const segments = [];
9868
- let current = chainTop;
9869
- while (import_ts_morph49.Node.isPropertyAccessExpression(current)) {
9870
- segments.push(current.getName());
9871
- current = current.getExpression();
9945
+ let current2 = chainTop;
9946
+ while (import_ts_morph49.Node.isPropertyAccessExpression(current2)) {
9947
+ segments.push(current2.getName());
9948
+ current2 = current2.getExpression();
9872
9949
  }
9873
9950
  segments.reverse();
9874
9951
  pushChain([...prefix, ...segments]);
@@ -9883,15 +9960,15 @@ function isBindingDeclarationSite(node) {
9883
9960
  return parent !== void 0 && import_ts_morph49.Node.isParameterDeclaration(parent) && parent.getNameNode() === node;
9884
9961
  }
9885
9962
  function isInsideObjectBindingPattern(node) {
9886
- let current = node.getParent();
9887
- while (current !== void 0) {
9888
- if (import_ts_morph49.Node.isObjectBindingPattern(current)) {
9963
+ let current2 = node.getParent();
9964
+ while (current2 !== void 0) {
9965
+ if (import_ts_morph49.Node.isObjectBindingPattern(current2)) {
9889
9966
  return true;
9890
9967
  }
9891
- if (import_ts_morph49.Node.isFunctionLikeDeclaration(current) || import_ts_morph49.Node.isVariableStatement(current)) {
9968
+ if (import_ts_morph49.Node.isFunctionLikeDeclaration(current2) || import_ts_morph49.Node.isVariableStatement(current2)) {
9892
9969
  break;
9893
9970
  }
9894
- current = current.getParent();
9971
+ current2 = current2.getParent();
9895
9972
  }
9896
9973
  return false;
9897
9974
  }
@@ -9945,9 +10022,9 @@ function findBranchSubtree(func, byLineRange, terminalStartLine, terminalEndLine
9945
10022
  if (terminalNode === null) {
9946
10023
  return func;
9947
10024
  }
9948
- let current = terminalNode;
9949
- while (current !== func) {
9950
- const parent = current.getParent();
10025
+ let current2 = terminalNode;
10026
+ while (current2 !== func) {
10027
+ const parent = current2.getParent();
9951
10028
  if (parent === void 0) {
9952
10029
  break;
9953
10030
  }
@@ -9962,17 +10039,17 @@ function findBranchSubtree(func, byLineRange, terminalStartLine, terminalEndLine
9962
10039
  return elseBlock;
9963
10040
  }
9964
10041
  }
9965
- current = parent;
10042
+ current2 = parent;
9966
10043
  }
9967
10044
  return func;
9968
10045
  }
9969
10046
  function isDescendantOf(node, ancestor) {
9970
- let current = node;
9971
- while (current !== void 0) {
9972
- if (current === ancestor) {
10047
+ let current2 = node;
10048
+ while (current2 !== void 0) {
10049
+ if (current2 === ancestor) {
9973
10050
  return true;
9974
10051
  }
9975
- current = current.getParent();
10052
+ current2 = current2.getParent();
9976
10053
  }
9977
10054
  return false;
9978
10055
  }
@@ -10126,12 +10203,12 @@ function tryExtractFunction(decl) {
10126
10203
  return null;
10127
10204
  }
10128
10205
  function isWithinFunction(node, func) {
10129
- let current = node.getParent();
10130
- while (current !== void 0) {
10131
- if (current === func) {
10206
+ let current2 = node.getParent();
10207
+ while (current2 !== void 0) {
10208
+ if (current2 === func) {
10132
10209
  return true;
10133
10210
  }
10134
- current = current.getParent();
10211
+ current2 = current2.getParent();
10135
10212
  }
10136
10213
  return false;
10137
10214
  }
@@ -10201,7 +10278,7 @@ function createTimer() {
10201
10278
  }
10202
10279
 
10203
10280
  // src/version.ts
10204
- var import_node_crypto2 = require("crypto");
10281
+ var import_node_crypto3 = require("crypto");
10205
10282
  var import_node_fs4 = __toESM(require("fs"), 1);
10206
10283
  var import_node_module = require("module");
10207
10284
  var import_node_path6 = __toESM(require("path"), 1);
@@ -10241,7 +10318,7 @@ function computeContentHash(paths) {
10241
10318
  if (paths.length === 0) {
10242
10319
  return "";
10243
10320
  }
10244
- const hash = (0, import_node_crypto2.createHash)("sha256");
10321
+ const hash = (0, import_node_crypto3.createHash)("sha256");
10245
10322
  for (const file of paths) {
10246
10323
  try {
10247
10324
  hash.update(import_node_fs4.default.readFileSync(file));
@@ -10548,6 +10625,18 @@ function announcedBoundaryStructure(unit) {
10548
10625
  };
10549
10626
  }
10550
10627
  function extractCodeStructure(unit, pack, invocationRecognizers = [], accessRecognizers = [], barriers = NO_BARRIERS) {
10628
+ const read = withDefinitions(
10629
+ () => readCodeStructure(
10630
+ unit,
10631
+ pack,
10632
+ invocationRecognizers,
10633
+ accessRecognizers,
10634
+ barriers
10635
+ )
10636
+ );
10637
+ return read.definitions === null ? read.value : { ...read.value, definitions: read.definitions };
10638
+ }
10639
+ function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers, barriers) {
10551
10640
  const { func, kind, name } = unit;
10552
10641
  if (func === null) {
10553
10642
  return announcedBoundaryStructure(unit);
@@ -11145,13 +11234,13 @@ function wrapperNameNode(func) {
11145
11234
  return null;
11146
11235
  }
11147
11236
  function enclosingCall(node) {
11148
- let current = node.getParent();
11149
- while (current !== void 0) {
11150
- if (import_ts_morph51.Node.isCallExpression(current)) {
11151
- return current;
11237
+ let current2 = node.getParent();
11238
+ while (current2 !== void 0) {
11239
+ if (import_ts_morph51.Node.isCallExpression(current2)) {
11240
+ return current2;
11152
11241
  }
11153
- if (import_ts_morph51.Node.isPropertyAccessExpression(current)) {
11154
- current = current.getParent();
11242
+ if (import_ts_morph51.Node.isPropertyAccessExpression(current2)) {
11243
+ current2 = current2.getParent();
11155
11244
  continue;
11156
11245
  }
11157
11246
  return null;
@@ -11159,12 +11248,12 @@ function enclosingCall(node) {
11159
11248
  return null;
11160
11249
  }
11161
11250
  function enclosingFunction(node) {
11162
- let current = node.getParent();
11163
- while (current !== void 0) {
11164
- if (import_ts_morph51.Node.isFunctionDeclaration(current) || import_ts_morph51.Node.isFunctionExpression(current) || import_ts_morph51.Node.isArrowFunction(current) || import_ts_morph51.Node.isMethodDeclaration(current)) {
11165
- return current;
11251
+ let current2 = node.getParent();
11252
+ while (current2 !== void 0) {
11253
+ if (import_ts_morph51.Node.isFunctionDeclaration(current2) || import_ts_morph51.Node.isFunctionExpression(current2) || import_ts_morph51.Node.isArrowFunction(current2) || import_ts_morph51.Node.isMethodDeclaration(current2)) {
11254
+ return current2;
11166
11255
  }
11167
- current = current.getParent();
11256
+ current2 = current2.getParent();
11168
11257
  }
11169
11258
  return null;
11170
11259
  }