@akanjs/cli 3.2.0-rc.3 → 3.2.0-rc.30

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 (144) hide show
  1. package/.build-stamp +2 -1
  2. package/CodeAgent-c17abdbf.js +11 -0
  3. package/{CodeTui-wv9yf7eq.js → CodeTui-jed1nj82.js} +822 -666
  4. package/README.ko.md +26 -1
  5. package/README.md +26 -1
  6. package/TunnelShare-mbfcaqg0.js +18 -0
  7. package/agent.command-9whnc6vb.js +56 -0
  8. package/akanCode.js +12 -12
  9. package/appExecutor-020cyesq.js +11 -0
  10. package/{application.command-6515t682.js → application.command-4eqvyxkw.js} +77 -36
  11. package/{applicationBuildRunner-bqbyeg84.js → applicationBuildRunner-frtcrqfd.js} +18 -13
  12. package/buildBatch.proc.js +26 -11
  13. package/{cloud.command-32esk0v1.js → cloud.command-hbvmeezn.js} +31 -28
  14. package/cloud.script-9kmbr3d6.js +35 -0
  15. package/{code.command-xk7rwq2x.js → code.command-0ayrenk4.js} +14 -9
  16. package/{context.command-jwenkkf0.js → context.command-php852kf.js} +28 -23
  17. package/context.runner-nngmn7c0.js +34 -0
  18. package/{dependencyScanner-78sq8m4q.js → dependencyScanner-ge10gb52.js} +2 -2
  19. package/{devTui-cd03z4mx.js → devTui-rf374y2w.js} +1 -1
  20. package/{fileSys-zpvt5gtf.js → fileSys-q22646yc.js} +1 -1
  21. package/{guideline.command-w6yqpdec.js → guideline.command-w1grfwh7.js} +9 -4
  22. package/guidelines/agentRule/agentRule.instruction.md +29 -12
  23. package/guidelines/akanApi/akanApi.instruction.md +5 -3
  24. package/guidelines/conventions/core.md +23 -5
  25. package/guidelines/conventions/rules/app.md +4 -1
  26. package/guidelines/conventions/rules/page.md +5 -0
  27. package/guidelines/conventions/rules/ts.md +3 -3
  28. package/guidelines/errorCodes/errorCodes.instruction.md +158 -0
  29. package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
  30. package/guidelines/mcpRule/mcpRule.instruction.md +96 -2
  31. package/guidelines/pageRule/pageRule.instruction.md +15 -1
  32. package/guidelines/runtimeRule/runtimeRule.instruction.md +12 -6
  33. package/guidelines/transportRule/transportRule.instruction.md +8 -1
  34. package/incrementalBuilder.proc.js +574 -410
  35. package/{index-w15mg3km.js → index-0dm25wvf.js} +1 -1
  36. package/{index-xrmrvafh.js → index-0gaj78wn.js} +808 -694
  37. package/{index-j1hjb477.js → index-11d7nh8a.js} +1 -1
  38. package/{index-hj6w4ka1.js → index-1p81ecbz.js} +1 -1
  39. package/{index-ygrdw6jw.js → index-1pjwsh2g.js} +65 -8
  40. package/{index-43acpsc7.js → index-28nk8w3j.js} +12 -12
  41. package/{index-qd7xn2bk.js → index-2ny1e95c.js} +2 -2
  42. package/{index-8gm4yag8.js → index-42jhx2ya.js} +6 -6
  43. package/{index-2rqyrvcy.js → index-4st0hq72.js} +62 -33
  44. package/{index-bak9f2br.js → index-5d57kx0s.js} +15 -11
  45. package/{index-bdmgqzb5.js → index-6469101k.js} +58 -29
  46. package/{index-7kmbqp0b.js → index-6pxmcaq8.js} +1 -1
  47. package/{index-54s6knqe.js → index-6zb17wcm.js} +12 -10
  48. package/{index-0ba8nj4d.js → index-7bs463x7.js} +50 -38
  49. package/{index-y725zb1a.js → index-7v7tvgt7.js} +196 -168
  50. package/{index-r0a604h4.js → index-99kjwyma.js} +1 -1
  51. package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
  52. package/{index-386canwe.js → index-9rv2zt48.js} +186 -121
  53. package/{index-20wvskt8.js → index-9wab2ngg.js} +1 -1
  54. package/{index-2eym1yjb.js → index-9wjrwjgz.js} +288 -209
  55. package/{index-kcpk2d20.js → index-at6haq2x.js} +1474 -1139
  56. package/{index-6h775rv3.js → index-ba2xd32s.js} +53 -12
  57. package/{index-yf9wc28h.js → index-bejy9zyc.js} +1 -1
  58. package/{index-ngpt3zz3.js → index-bj8s07s7.js} +525 -440
  59. package/{index-bns3wcpc.js → index-by2tvsq6.js} +1 -1
  60. package/{index-vbhx60x5.js → index-cb91b6d8.js} +2140 -2165
  61. package/index-dss3ds74.js +127 -0
  62. package/{index-e22zedc2.js → index-f16kr6vj.js} +3 -3
  63. package/{index-ny2k80mv.js → index-ffa52fwf.js} +1 -1
  64. package/{index-djc5nxpy.js → index-fp5xf6ef.js} +6 -6
  65. package/{index-qrk06tfp.js → index-g45y5f3e.js} +2 -2
  66. package/{index-8jpc5fqv.js → index-g7jgd4xs.js} +2 -2
  67. package/index-j4yvgfhr.js +70 -0
  68. package/{index-ytpmk3pb.js → index-jgj31xvw.js} +18 -11
  69. package/{index-j6eeh5d7.js → index-knpm8sdm.js} +5 -5
  70. package/{index-s34v3y28.js → index-m3t28rt3.js} +11 -11
  71. package/{index-dpgywgeq.js → index-m5gg0wzv.js} +27 -16
  72. package/index-na8r4a27.js +30 -0
  73. package/{index-h0p6n4k1.js → index-nm7nt9vm.js} +3 -3
  74. package/{index-j4hkbzj6.js → index-p06kfhdf.js} +6 -6
  75. package/{index-35j83zkd.js → index-p5zh7pmc.js} +2 -2
  76. package/{index-cmg5ngqa.js → index-p7beqww9.js} +2 -2
  77. package/{index-zhkcab5a.js → index-prgvqqxe.js} +580 -364
  78. package/{index-wfmpxke3.js → index-qssq2d41.js} +2775 -3677
  79. package/{index-sc0g6zbm.js → index-rwgqba9p.js} +24 -11
  80. package/{index-zcdmnfrf.js → index-s3m89wt2.js} +9 -9
  81. package/{index-v50xjbbe.js → index-t4d0ckde.js} +1 -1
  82. package/{index-9p260r4e.js → index-trffs83s.js} +538 -250
  83. package/{index-ddk49ypz.js → index-v929w7j7.js} +133 -49
  84. package/index-va90m8nd.js +25 -0
  85. package/index-vjbne22r.js +80 -0
  86. package/{index-h7hehkw6.js → index-xczjdng6.js} +3 -1
  87. package/{index-39jz41jb.js → index-xs9a3ddt.js} +3 -3
  88. package/{index-84c2pgak.js → index-yvzm8mby.js} +94 -82
  89. package/{index-wr9magsr.js → index-yxkjsyx8.js} +3 -3
  90. package/index-ze48c0vd.js +788 -0
  91. package/{index-ygdbn9jn.js → index-zyb0ebm4.js} +1 -1
  92. package/index.js +29 -24
  93. package/libExecutor-tq994592.js +10 -0
  94. package/{library.command-qs8beggh.js → library.command-x219mhcx.js} +9 -4
  95. package/{localRegistry.command-hz4ged9n.js → localRegistry.command-zvdcejhn.js} +30 -24
  96. package/{module.command-z9js77m2.js → module.command-k6cwcm7g.js} +17 -8
  97. package/{package.command-zqenq8c0.js → package.command-vw7x09f8.js} +13 -8
  98. package/package.json +2 -2
  99. package/{page.command-t0nx1jat.js → page.command-gf06paq2.js} +9 -4
  100. package/{pipeline.command-2yjeas7m.js → pipeline.command-y07dgj9b.js} +14 -8
  101. package/pkgExecutor-stde3yc3.js +10 -0
  102. package/{primitive.command-v5kypwy4.js → primitive.command-edydvh07.js} +13 -8
  103. package/{projectTypecheck-s9hhe5sa.js → projectTypecheck-mk8wefvd.js} +2 -1
  104. package/{prompter-qrwx1p17.js → prompter-qyggfhqd.js} +2 -2
  105. package/{quality.command-q55j2htd.js → quality.command-mdb45vyr.js} +23 -16
  106. package/{recipeScanner-4b69ybe0.js → recipeScanner-rrx69awy.js} +1 -1
  107. package/{repair.command-7ssbbdq2.js → repair.command-kvtaeecy.js} +13 -8
  108. package/{routeSourceValidator-4h947v7c.js → routeSourceValidator-8n6j1vn7.js} +4 -2
  109. package/{scalar.command-p5jb7z57.js → scalar.command-sjt9p5e1.js} +11 -6
  110. package/skills/akan-debug/SKILL.md +10 -3
  111. package/skills/akan-err/SKILL.md +7 -0
  112. package/skills/akan-mcp/SKILL.md +14 -2
  113. package/skills/akan-scaffold/SKILL.md +2 -2
  114. package/skills/akan-transport/SKILL.md +2 -0
  115. package/skills/akan-validate/SKILL.md +1 -0
  116. package/{subspace.command-7wxy6ptj.js → subspace.command-mkkqync4.js} +29 -23
  117. package/templates/app/page/_layout.tsx +13 -0
  118. package/templates/app/page/styles.css.template +40 -0
  119. package/templates/appSample/page/_index.tsx +9 -9
  120. package/templates/appSample/page/_layout.tsx +1 -0
  121. package/templates/appSample/page/styles.css.template +40 -5
  122. package/templates/appSample/ui/Recipe/jellyButton.ts +1 -1
  123. package/templates/biomeForm.ts +1 -1
  124. package/templates/env/_env.server.type.ts +1 -1
  125. package/templates/facetIndex/index.ts +2 -37
  126. package/templates/lib/sig.ts +0 -4
  127. package/templates/lib/useClient.ts +1 -1
  128. package/templates/workspaceRoot/AGENTS.md.template +2 -1
  129. package/{tunnel.command-22g11n0x.js → tunnel.command-tr5b3030.js} +17 -12
  130. package/{typeChecker-s640r6c0.js → typeChecker-bfrd1n9n.js} +1 -1
  131. package/typecheck.proc.js +6 -3
  132. package/{verify.command-m0wnndd7.js → verify.command-0p9h8tpp.js} +26 -20
  133. package/{workflow.command-jx8dqs9n.js → workflow.command-9mfcwqzj.js} +37 -19
  134. package/{workspace.command-ca9kfyt3.js → workspace.command-5hjtmcfs.js} +61 -54
  135. package/CodeAgent-e9c712an.js +0 -11
  136. package/TunnelShare-zkfkrw8w.js +0 -14
  137. package/agent.command-9erafkcb.js +0 -51
  138. package/cloud.script-arsagnq6.js +0 -30
  139. package/context.runner-mqpp67br.js +0 -29
  140. package/index-x3x31df8.js +0 -14
  141. /package/templates/{appSample → app}/public/fonts/Pretendard-Bold.woff2 +0 -0
  142. /package/templates/{appSample → app}/public/fonts/Pretendard-Medium.woff2 +0 -0
  143. /package/templates/{appSample → app}/public/fonts/Pretendard-Regular.woff2 +0 -0
  144. /package/templates/{appSample → app}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
@@ -110,6 +110,13 @@ ${at.file}` : null;
110
110
  return node.fields ? { ...node, fields: node.fields.map(({ digest: _field, ...field }) => field) } : node;
111
111
  }
112
112
  }
113
+ // pkgs/@akanjs/language/guardResolver.ts
114
+ import { barrelFacetDirs, facetBarrelNamesOf } from "akanjs/common/facetBarrel.ts";
115
+
116
+ // pkgs/@akanjs/language/escapeRegExp.ts
117
+ var regExpSpecials = /[\\^$.*+?()[\]{}|]/g;
118
+ var escapeRegExp = (text) => text.replace(regExpSpecials, (special) => `\\${special}`);
119
+
113
120
  // pkgs/@akanjs/language/guardFacts.ts
114
121
  var guardLabelOf = (guard, labels) => {
115
122
  const [, role = null, local = guard] = guard.match(/^([\w$]+) (.+)$/) ?? [];
@@ -117,6 +124,7 @@ var guardLabelOf = (guard, labels) => {
117
124
  return label === undefined ? guard : role ? `${role} ${label}` : label;
118
125
  };
119
126
  var maxLabelArgs = 32;
127
+ var maxLayers = 4;
120
128
  var guardRefReaderOf = (ts, ast, unwrap) => {
121
129
  const pathOf = (expression) => {
122
130
  if (ts.isIdentifier(expression))
@@ -126,10 +134,19 @@ var guardRefReaderOf = (ts, ast, unwrap) => {
126
134
  const head = pathOf(expression.expression);
127
135
  return head && `${head}.${expression.name.text}`;
128
136
  };
129
- const calleeOf = (call) => pathOf(unwrap(call.expression)) ?? "?";
137
+ const layersOf = (call) => {
138
+ const inner = unwrap(call.expression);
139
+ if (!ts.isCallExpression(inner))
140
+ return { root: call, layers: 0 };
141
+ const { root, layers } = layersOf(inner);
142
+ return { root, layers: layers + 1 };
143
+ };
144
+ const calleeOf = (call) => pathOf(unwrap(layersOf(call).root.expression)) ?? "?";
130
145
  const labelOf = (source, call) => {
131
146
  const args = call.arguments.map((arg) => arg.getText(source)).join(", ");
132
- return `${calleeOf(call)}(${args.length <= maxLabelArgs && !args.includes(`
147
+ const inner = unwrap(call.expression);
148
+ const head = ts.isCallExpression(inner) ? labelOf(source, inner) : pathOf(inner) ?? "?";
149
+ return `${head}(${args.length <= maxLabelArgs && !args.includes(`
133
150
  `) ? args : "\u2026"})`;
134
151
  };
135
152
  const guardRefOf = (expression, made, member) => {
@@ -157,9 +174,9 @@ var guardRefReaderOf = (ts, ast, unwrap) => {
157
174
  const single = refOf(guards);
158
175
  return single ? [single] : [];
159
176
  };
160
- return { pathOf, labelOf, guardsIn };
177
+ return { pathOf, layersOf, labelOf, guardsIn };
161
178
  };
162
- var guardFactoryReaderOf = (ts, ast, { spanOf, extentOf, unwrap, docOf }, pathOf) => {
179
+ var guardFactoryReaderOf = (ts, ast, { spanOf, extentOf, unwrap, docOf }, pathOf, layersOf) => {
163
180
  const implementsGuard = (node, guardNames) => !!node.heritageClauses?.some((clause) => clause.token === ts.SyntaxKind.ImplementsKeyword && clause.types.some(({ expression }) => guardNames.has(ast.expressionName(expression) ?? "")));
164
181
  const scopeOf = (node) => {
165
182
  const scope = node.members.find((member) => ts.isPropertyDeclaration(member) && ast.nodeName(member.name) === "scope" && !!ts.getModifiers(member)?.some(({ kind }) => kind === ts.SyntaxKind.StaticKeyword))?.initializer;
@@ -181,7 +198,7 @@ var guardFactoryReaderOf = (ts, ast, { spanOf, extentOf, unwrap, docOf }, pathOf
181
198
  }
182
199
  return functions;
183
200
  };
184
- const returnedOf = (body, guardNames) => {
201
+ const returnedOf = (body, guardNames, depth = 0) => {
185
202
  const locals = new Map;
186
203
  const pending = [];
187
204
  const visit = (node) => {
@@ -202,6 +219,7 @@ var guardFactoryReaderOf = (ts, ast, { spanOf, extentOf, unwrap, docOf }, pathOf
202
219
  const calls = [];
203
220
  const seen = new Set;
204
221
  const passed = new Set;
222
+ const returned = [];
205
223
  for (let node = pending.pop();node; node = pending.pop()) {
206
224
  if (seen.has(node))
207
225
  continue;
@@ -209,6 +227,8 @@ var guardFactoryReaderOf = (ts, ast, { spanOf, extentOf, unwrap, docOf }, pathOf
209
227
  const value = ts.isExpression(node) ? unwrap(node) : node;
210
228
  if ((ts.isClassExpression(value) || ts.isClassDeclaration(value)) && implementsGuard(value, guardNames))
211
229
  guard ??= value;
230
+ else if ((ts.isArrowFunction(value) || ts.isFunctionExpression(value)) && !passed.has(node) && depth < maxLayers)
231
+ returned.push(value.body);
212
232
  else if (ts.isConditionalExpression(value))
213
233
  pending.push(value.whenTrue, value.whenFalse);
214
234
  else if (ts.isBinaryExpression(value))
@@ -218,15 +238,22 @@ var guardFactoryReaderOf = (ts, ast, { spanOf, extentOf, unwrap, docOf }, pathOf
218
238
  if (local)
219
239
  pending.push(local);
220
240
  } else if (ts.isCallExpression(value)) {
221
- const callee = pathOf(unwrap(value.expression));
222
- if (callee && !passed.has(node) && !calls.includes(callee))
223
- calls.push(callee);
224
- for (const arg of value.arguments)
225
- passed.add(arg);
226
- pending.push(...value.arguments);
241
+ const { root, layers } = layersOf(value);
242
+ const callee = pathOf(unwrap(root.expression));
243
+ if (callee && !passed.has(node) && !calls.some((call) => call.callee === callee))
244
+ calls.push({ callee, layers });
245
+ for (let call = value;ts.isCallExpression(call); call = unwrap(call.expression)) {
246
+ for (const arg of call.arguments)
247
+ passed.add(arg);
248
+ pending.push(...call.arguments);
249
+ }
227
250
  }
228
251
  }
229
- return { guard, calls };
252
+ const [inner] = returned;
253
+ if (guard || calls.length || !inner)
254
+ return { guard, calls, layers: 0 };
255
+ const nested = returnedOf(inner, guardNames, depth + 1);
256
+ return { ...nested, layers: nested.layers + 1 };
230
257
  };
231
258
  const guardFactoriesOf = (source, guardNames, isImported) => {
232
259
  const functions = functionsOf(source);
@@ -236,7 +263,7 @@ var guardFactoryReaderOf = (ts, ast, { spanOf, extentOf, unwrap, docOf }, pathOf
236
263
  for (let isGrowing = true;isGrowing; ) {
237
264
  isGrowing = false;
238
265
  for (const [name, { guard, calls }] of returned) {
239
- if (members.has(name) || !guard && !calls.some(isFactoryCall))
266
+ if (members.has(name) || !guard && !calls.some(({ callee }) => isFactoryCall(callee)))
240
267
  continue;
241
268
  members.add(name);
242
269
  isGrowing = true;
@@ -255,7 +282,8 @@ var guardFactoryReaderOf = (ts, ast, { spanOf, extentOf, unwrap, docOf }, pathOf
255
282
  scope: made.guard ? scopeOf(made.guard) : null,
256
283
  doc: docOf(source, found.statement),
257
284
  direct: !!made.guard,
258
- via: made.calls.filter(isFactoryCall)
285
+ via: made.calls.filter(({ callee }) => isFactoryCall(callee)),
286
+ layers: made.layers
259
287
  });
260
288
  }
261
289
  return factories;
@@ -264,8 +292,8 @@ var guardFactoryReaderOf = (ts, ast, { spanOf, extentOf, unwrap, docOf }, pathOf
264
292
  };
265
293
  var createGuardFactReader = (ts, ast, base) => {
266
294
  const { spanOf, extentOf, unwrap, docOf } = base;
267
- const { pathOf, labelOf, guardsIn } = guardRefReaderOf(ts, ast, unwrap);
268
- const { implementsGuard, scopeOf, guardFactoriesOf } = guardFactoryReaderOf(ts, ast, base, pathOf);
295
+ const { pathOf, layersOf, labelOf, guardsIn } = guardRefReaderOf(ts, ast, unwrap);
296
+ const { implementsGuard, scopeOf, guardFactoriesOf } = guardFactoryReaderOf(ts, ast, base, pathOf, layersOf);
269
297
  const guardsOf = (source, imports, madeInPlace) => {
270
298
  const guardNames = new Set([
271
299
  "Guard",
@@ -278,15 +306,16 @@ var createGuardFactReader = (ts, ast, base) => {
278
306
  const calls = [];
279
307
  const makeOf = (made, value, isInPlace = false) => {
280
308
  if (ts.isClassExpression(value) && implementsGuard(value, guardNames)) {
281
- guards.push({ ...made, scope: scopeOf(value), factory: null });
309
+ guards.push({ ...made, scope: scopeOf(value), factory: null, layers: 0 });
282
310
  return;
283
311
  }
284
- const callee = ts.isCallExpression(value) ? pathOf(unwrap(value.expression)) : null;
312
+ const { root, layers } = ts.isCallExpression(value) ? layersOf(value) : { root: null, layers: 0 };
313
+ const callee = root && pathOf(unwrap(root.expression));
285
314
  const factory = callee && factories.get(callee);
286
315
  if (factory)
287
- guards.push({ ...made, scope: factory.scope, factory: factory.name });
316
+ guards.push({ ...made, scope: factory.scope, factory: factory.name, layers });
288
317
  else if (callee && (isImported(callee) || isInPlace))
289
- calls.push({ ...made, callee, kind: "call", scope: null });
318
+ calls.push({ ...made, callee, kind: "call", scope: null, layers });
290
319
  };
291
320
  for (const statement of source.statements) {
292
321
  if (ts.isClassDeclaration(statement) && statement.name) {
@@ -300,9 +329,9 @@ var createGuardFactReader = (ts, ast, base) => {
300
329
  const base = statement.heritageClauses?.find(({ token }) => token === ts.SyntaxKind.ExtendsKeyword)?.types[0];
301
330
  const callee = base && pathOf(base.expression);
302
331
  if (implementsGuard(statement, guardNames))
303
- guards.push({ ...declared, factory: null });
332
+ guards.push({ ...declared, factory: null, layers: 0 });
304
333
  else if (callee)
305
- calls.push({ ...declared, callee, kind: "extends" });
334
+ calls.push({ ...declared, callee, kind: "extends", layers: 0 });
306
335
  }
307
336
  if (!ts.isVariableStatement(statement))
308
337
  continue;
@@ -339,10 +368,6 @@ var createGuardFactReader = (ts, ast, base) => {
339
368
  return { guardsIn, guardsOf };
340
369
  };
341
370
 
342
- // pkgs/@akanjs/language/escapeRegExp.ts
343
- var regExpSpecials = /[\\^$.*+?()[\]{}|]/g;
344
- var escapeRegExp = (text) => text.replace(regExpSpecials, (special) => `\\${special}`);
345
-
346
371
  // pkgs/@akanjs/language/moduleFacts.ts
347
372
  var testFilePattern = /\.(?:test|spec)\.tsx?$/;
348
373
  var moduleCallees = new Set([
@@ -369,7 +394,7 @@ var ownerOf = (relativePath) => {
369
394
  const [root, name] = relativePath.split("/");
370
395
  return (root === "apps" || root === "libs") && name ? `${root}/${name}` : null;
371
396
  };
372
- var createFactReader = (ts, ast) => {
397
+ var syntaxReaderOf = (ts, ast) => {
373
398
  const spanOf = (source, node) => {
374
399
  const start = node.getStart(source);
375
400
  const end = node.getEnd();
@@ -427,6 +452,74 @@ var createFactReader = (ts, ast) => {
427
452
  const node = keyName(property);
428
453
  return name && node ? [{ name, span: spanOf(source, node), extent: extentOf(source, property) }] : [];
429
454
  });
455
+ const verbReaderOf = (parameter) => {
456
+ const verbs = new Map;
457
+ if (parameter && ts.isObjectBindingPattern(parameter.name))
458
+ for (const element of parameter.name.elements) {
459
+ const verb = element.propertyName ?? element.name;
460
+ if (ts.isIdentifier(verb) && ts.isIdentifier(element.name))
461
+ verbs.set(element.name.text, verb.text);
462
+ }
463
+ const holder = parameter && ts.isIdentifier(parameter.name) ? parameter.name.text : null;
464
+ return (callee) => {
465
+ if (callee && ts.isIdentifier(callee))
466
+ return verbs.get(callee.text) ?? null;
467
+ if (callee && ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === holder)
468
+ return callee.name.text;
469
+ return null;
470
+ };
471
+ };
472
+ return {
473
+ spanOf,
474
+ extentOf,
475
+ unwrap,
476
+ moduleRefOf,
477
+ returnedObject,
478
+ builderOf,
479
+ guardNameOf,
480
+ optionObjectOf,
481
+ chainOf,
482
+ keyName,
483
+ objectKeys,
484
+ verbReaderOf
485
+ };
486
+ };
487
+ var sourceReaderOf = (ts) => {
488
+ const importsOf = (statement) => {
489
+ const { importClause, moduleSpecifier } = statement;
490
+ if (!importClause || !ts.isStringLiteral(moduleSpecifier))
491
+ return [];
492
+ const from = moduleSpecifier.text;
493
+ const bindings = importClause.namedBindings;
494
+ return [
495
+ ...importClause.name ? [{ name: importClause.name.text, imported: "default", from }] : [],
496
+ ...bindings && ts.isNamespaceImport(bindings) ? [{ name: bindings.name.text, imported: "*", from }] : [],
497
+ ...bindings && ts.isNamedImports(bindings) ? bindings.elements.map((element) => ({
498
+ name: element.name.text,
499
+ imported: (element.propertyName ?? element.name).text,
500
+ from
501
+ })) : []
502
+ ];
503
+ };
504
+ const docOf = (source, node) => {
505
+ const { text } = source;
506
+ const ranges = ts.getLeadingCommentRanges(text, node.getFullStart()) ?? [];
507
+ const comments = [];
508
+ let end = node.getStart(source);
509
+ for (const range of [...ranges].reverse()) {
510
+ if ((text.slice(range.end, end).match(/\n/g)?.length ?? 0) > 1)
511
+ break;
512
+ comments.unshift(text.slice(range.pos, range.end));
513
+ end = range.pos;
514
+ }
515
+ const lines = comments.flatMap((comment) => comment.split(`
516
+ `)).map((line) => line.trim().replace(/^\/\*\*?|\*\/$/g, "").replace(/^(?:\/\/[?*!]?|\*)/, "").replace(/\{@link\s+([^}\s|]+)[^}]*\}/g, "$1").trim()).filter((line) => line && !/^(?:biome-ignore|eslint-|@ts-)/.test(line));
517
+ return lines.length ? lines.join(" ") : null;
518
+ };
519
+ const importsIn = (source) => source.statements.filter(ts.isImportDeclaration).flatMap(importsOf);
520
+ return { docOf, importsIn };
521
+ };
522
+ var signalKeyReaderOf = (ts, ast, { spanOf, extentOf, returnedObject, optionObjectOf, chainOf, verbReaderOf }, guardsIn) => {
430
523
  const sliceKeysOf = (source, builder, made, model) => (returnedObject(builder)?.properties ?? []).flatMap((property) => {
431
524
  if (!ts.isPropertyAssignment(property))
432
525
  return [];
@@ -445,23 +538,30 @@ var createFactReader = (ts, ast) => {
445
538
  }
446
539
  ];
447
540
  });
448
- const verbReaderOf = (parameter) => {
449
- const verbs = new Map;
450
- if (parameter && ts.isObjectBindingPattern(parameter.name))
451
- for (const element of parameter.name.elements) {
452
- const verb = element.propertyName ?? element.name;
453
- if (ts.isIdentifier(verb) && ts.isIdentifier(element.name))
454
- verbs.set(element.name.text, verb.text);
455
- }
456
- const holder = parameter && ts.isIdentifier(parameter.name) ? parameter.name.text : null;
457
- return (callee) => {
458
- if (callee && ts.isIdentifier(callee))
459
- return verbs.get(callee.text) ?? null;
460
- if (callee && ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === holder)
461
- return callee.name.text;
462
- return null;
463
- };
541
+ const endpointKeysOf = (source, builder, made, model) => {
542
+ const verbOf = verbReaderOf(builder?.parameters[0]);
543
+ return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
544
+ if (!ts.isPropertyAssignment(property))
545
+ return [];
546
+ const name = ast.nodeName(property.name);
547
+ if (!name)
548
+ return [];
549
+ const { root, methods } = chainOf(property.initializer);
550
+ return [
551
+ {
552
+ name,
553
+ span: spanOf(source, property.name),
554
+ extent: extentOf(source, property),
555
+ verb: root ? verbOf(root.expression) : null,
556
+ guards: root ? guardsIn(source, optionObjectOf(root), made, `${model}.${name}`) : [],
557
+ argCount: methods.filter((method) => argMethods.has(method)).length
558
+ }
559
+ ];
560
+ });
464
561
  };
562
+ return { sliceKeysOf, endpointKeysOf };
563
+ };
564
+ var jobKeyReaderOf = (ts, ast, { spanOf, extentOf, unwrap, returnedObject, chainOf, verbReaderOf }) => {
465
565
  const numberOf = (expression) => {
466
566
  const value = unwrap(expression);
467
567
  if (ts.isNumericLiteral(value))
@@ -534,6 +634,9 @@ var createFactReader = (ts, ast) => {
534
634
  ];
535
635
  });
536
636
  };
637
+ return { internalKeysOf };
638
+ };
639
+ var serviceReaderOf = (ts, ast, { spanOf, extentOf, returnedObject, guardNameOf, chainOf, verbReaderOf }) => {
537
640
  const plugsOf = (source, builder) => {
538
641
  const verbOf = verbReaderOf(builder?.parameters[0]);
539
642
  return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
@@ -559,27 +662,17 @@ var createFactReader = (ts, ast) => {
559
662
  visit(source);
560
663
  return bindings;
561
664
  };
562
- const endpointKeysOf = (source, builder, made, model) => {
563
- const verbOf = verbReaderOf(builder?.parameters[0]);
564
- return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
565
- if (!ts.isPropertyAssignment(property))
566
- return [];
567
- const name = ast.nodeName(property.name);
568
- if (!name)
569
- return [];
570
- const { root, methods } = chainOf(property.initializer);
571
- return [
572
- {
573
- name,
574
- span: spanOf(source, property.name),
575
- extent: extentOf(source, property),
576
- verb: root ? verbOf(root.expression) : null,
577
- guards: root ? guardsIn(source, optionObjectOf(root), made, `${model}.${name}`) : [],
578
- argCount: methods.filter((method) => argMethods.has(method)).length
579
- }
580
- ];
581
- });
582
- };
665
+ const methodsOf = (source, statement) => statement.members.flatMap((member) => {
666
+ if (!ts.isMethodDeclaration(member) || !member.body)
667
+ return [];
668
+ const name = ast.nodeName(member.name);
669
+ if (!name || ts.getModifiers(member)?.some(({ kind }) => kind === ts.SyntaxKind.StaticKeyword))
670
+ return [];
671
+ return [{ name, span: spanOf(source, member.name), extent: extentOf(source, member) }];
672
+ });
673
+ return { plugsOf, adaptorBindingsIn, methodsOf };
674
+ };
675
+ var constantReaderOf = (ts, ast, { spanOf, extentOf, unwrap, returnedObject, chainOf, keyName, objectKeys }) => {
583
676
  const filterQueriesOf = (source, builder) => {
584
677
  const query = returnedObject(builder)?.properties.find((property) => ts.isPropertyAssignment(property) && ast.nodeName(property.name) === "query")?.initializer;
585
678
  return query && ts.isObjectLiteralExpression(query) ? objectKeys(source, query) : [];
@@ -617,48 +710,18 @@ var createFactReader = (ts, ast) => {
617
710
  return [];
618
711
  return list.elements.flatMap((element) => ts.isStringLiteralLike(element) ? [element.text] : []);
619
712
  };
620
- const methodsOf = (source, statement) => statement.members.flatMap((member) => {
621
- if (!ts.isMethodDeclaration(member) || !member.body)
622
- return [];
623
- const name = ast.nodeName(member.name);
624
- if (!name || ts.getModifiers(member)?.some(({ kind }) => kind === ts.SyntaxKind.StaticKeyword))
625
- return [];
626
- return [{ name, span: spanOf(source, member.name), extent: extentOf(source, member) }];
627
- });
628
- const importsOf = (statement) => {
629
- const { importClause, moduleSpecifier } = statement;
630
- if (!importClause || !ts.isStringLiteral(moduleSpecifier))
631
- return [];
632
- const from = moduleSpecifier.text;
633
- const bindings = importClause.namedBindings;
634
- return [
635
- ...importClause.name ? [{ name: importClause.name.text, imported: "default", from }] : [],
636
- ...bindings && ts.isNamespaceImport(bindings) ? [{ name: bindings.name.text, imported: "*", from }] : [],
637
- ...bindings && ts.isNamedImports(bindings) ? bindings.elements.map((element) => ({
638
- name: element.name.text,
639
- imported: (element.propertyName ?? element.name).text,
640
- from
641
- })) : []
642
- ];
643
- };
644
- const docOf = (source, node) => {
645
- const { text } = source;
646
- const ranges = ts.getLeadingCommentRanges(text, node.getFullStart()) ?? [];
647
- const comments = [];
648
- let end = node.getStart(source);
649
- for (const range of [...ranges].reverse()) {
650
- if ((text.slice(range.end, end).match(/\n/g)?.length ?? 0) > 1)
651
- break;
652
- comments.unshift(text.slice(range.pos, range.end));
653
- end = range.pos;
654
- }
655
- const lines = comments.flatMap((comment) => comment.split(`
656
- `)).map((line) => line.trim().replace(/^\/\*\*?|\*\/$/g, "").replace(/^(?:\/\/[?*!]?|\*)/, "").replace(/\{@link\s+([^}\s|]+)[^}]*\}/g, "$1").trim()).filter((line) => line && !/^(?:biome-ignore|eslint-|@ts-)/.test(line));
657
- return lines.length ? lines.join(" ") : null;
658
- };
713
+ return { constantOf, enumValuesOf, filterQueriesOf };
714
+ };
715
+ var createFactReader = (ts, ast) => {
716
+ const syntax = syntaxReaderOf(ts, ast);
717
+ const { spanOf, extentOf, unwrap, moduleRefOf, returnedObject, builderOf, chainOf, objectKeys } = syntax;
718
+ const { docOf, importsIn } = sourceReaderOf(ts);
659
719
  const { guardsIn, guardsOf } = createGuardFactReader(ts, ast, { spanOf, extentOf, unwrap, docOf });
720
+ const { sliceKeysOf, endpointKeysOf } = signalKeyReaderOf(ts, ast, syntax, guardsIn);
721
+ const { internalKeysOf } = jobKeyReaderOf(ts, ast, syntax);
722
+ const { plugsOf, adaptorBindingsIn, methodsOf } = serviceReaderOf(ts, ast, syntax);
723
+ const { constantOf, enumValuesOf, filterQueriesOf } = constantReaderOf(ts, ast, syntax);
660
724
  const lowerFirst = (text) => text.charAt(0).toLowerCase() + text.slice(1);
661
- const importsIn = (source) => source.statements.filter(ts.isImportDeclaration).flatMap(importsOf);
662
725
  const read = (source, owner) => {
663
726
  const imports = importsIn(source);
664
727
  const madeInPlace = [];
@@ -756,7 +819,11 @@ var frameworkOwner = "akanjs";
756
819
  var frameworkPattern = /^akanjs(?:\/|$)/;
757
820
  var aliasPattern = /^@(apps|libs)\/([^/]+)/;
758
821
  var maxMapDepth = 4;
822
+ var identifierPattern = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200c\u200d]*$/u;
759
823
  var starExportPattern = /export\s*\*\s*from\s*["']([^"']+)["']/g;
824
+ var facetEntryPattern = new RegExp(`^((?:apps|libs)/[^/]+/(${barrelFacetDirs.map(escapeRegExp).join("|")}))/([^/]+)(/)?`);
825
+ var exportingPatternOf = (name) => new RegExp(`export\\s*\\{(?:[^}]*?[\\s,])?${escapeRegExp(name)}(?![\\w$])`);
826
+ var exportMentioningPatternOf = (name) => new RegExp(`export(?![\\w$])[^;]*?(?<![\\w$])${escapeRegExp(name)}(?![\\w$])`);
760
827
  var declaringPatternOf = (name, isAnyBinding) => {
761
828
  const escaped = escapeRegExp(name);
762
829
  const braced = "\\{(?:[^}]*?[\\s,])?";
@@ -778,8 +845,12 @@ class GuardResolver {
778
845
  #reexports = new Map;
779
846
  #declarations = new Map;
780
847
  #starExports = new Map;
848
+ #moduleExports = new Map;
849
+ #fileStars = new Map;
850
+ #starReach = new Map;
781
851
  #ownerFiles = null;
782
852
  #modules = null;
853
+ #barrels = null;
783
854
  constructor(source, routes) {
784
855
  this.#source = source;
785
856
  this.#routes = routes;
@@ -803,21 +874,26 @@ ${name}`);
803
874
  made: [],
804
875
  isReal: fact.direct,
805
876
  scope: fact.scope,
877
+ layers: fact.layers,
806
878
  targets: []
807
879
  };
808
880
  factories.set(fact.name, [...factories.get(fact.name) ?? [], factory]);
809
881
  declaredFactories.push(factory);
810
882
  }
811
883
  for (const factory of declaredFactories)
812
- factory.targets = factory.fact.via.map((callee) => this.#factoryAt(factories, callee, factory.site)).filter((target) => target !== undefined);
884
+ factory.targets = factory.fact.via.flatMap(({ callee, layers }) => {
885
+ const target = this.#factoryAt(factories, callee, factory.site);
886
+ return target ? [{ target, layers }] : [];
887
+ });
813
888
  for (let isGrowing = true;isGrowing; ) {
814
889
  isGrowing = false;
815
890
  for (const factory of declaredFactories) {
816
- const target = factory.targets.find((other) => other.isReal);
817
- if (factory.isReal || !target)
891
+ const via = factory.targets.find(({ target, layers }) => target.isReal && target.layers >= layers);
892
+ if (factory.isReal || !via)
818
893
  continue;
819
894
  factory.isReal = true;
820
- factory.scope ??= target.scope;
895
+ factory.layers = factory.fact.layers + via.target.layers - via.layers;
896
+ factory.scope ??= via.target.scope;
821
897
  isGrowing = true;
822
898
  }
823
899
  }
@@ -827,7 +903,7 @@ ${name}`);
827
903
  seen.add(factory);
828
904
  return [
829
905
  { fileName: factory.site.fileName, extent: factory.fact.extent },
830
- ...factory.targets.filter((target) => target.isReal).flatMap((target) => partsOf(target, seen))
906
+ ...factory.targets.filter(({ target }) => target.isReal).flatMap(({ target }) => partsOf(target, seen))
831
907
  ];
832
908
  };
833
909
  const declare = (file, made, scope, parts) => {
@@ -848,7 +924,7 @@ ${name}`, guard);
848
924
  const factory = made.factory ? factories.get(made.factory)?.find((other) => other.site.fileName === file.fileName) : undefined;
849
925
  if (!made.factory)
850
926
  declare(file, made, made.scope, []);
851
- else if (factory?.isReal)
927
+ else if (factory?.isReal && factory.layers === made.layers)
852
928
  factory.made.push(declare(file, made, factory.scope, partsOf(factory)));
853
929
  }
854
930
  for (const made of file.guardCalls) {
@@ -857,7 +933,7 @@ ${name}`, guard);
857
933
  continue;
858
934
  }
859
935
  const factory = this.#factoryAt(factories, made.callee, file);
860
- if (factory?.isReal)
936
+ if (factory?.isReal && factory.layers === made.layers)
861
937
  factory.made.push(declare(file, made, factory.scope, partsOf(factory)));
862
938
  }
863
939
  }
@@ -902,7 +978,7 @@ ${name}`, guard);
902
978
  const own = this.#nearest(candidates.filter((other) => other.owner === from), ({ site }) => site.fileName, near);
903
979
  if (own)
904
980
  return own;
905
- const reexport = from && depth < maxMapDepth ? this.reexportOf(from, name, near) : null;
981
+ const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
906
982
  if (reexport)
907
983
  return this.#factoryAt(factories, reexport.local, reexport.site, depth + 1);
908
984
  return from && near ? this.#throughStar(candidates, from, name, near) : undefined;
@@ -940,13 +1016,13 @@ ${name}`, guard);
940
1016
  const visible = isBase ? undefined : declared.find((other) => this.visible(other.owner, site.owner));
941
1017
  return visible ? { guard: visible } : { name, from };
942
1018
  }
943
- const reexport = from && depth < maxMapDepth ? this.reexportOf(from, name, near) : null;
1019
+ const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
944
1020
  if (reexport)
945
1021
  return this.#findGuard(reexport.local, reexport.site, depth + 1, isBase);
946
1022
  const reached = from && near ? this.#throughStar(declared, from, name, near) : undefined;
947
1023
  return reached ? { guard: reached } : { name, from };
948
1024
  }
949
- reexportOf(owner, name, near) {
1025
+ #reexportOf(owner, name, near) {
950
1026
  const key = `${owner}
951
1027
  ${name}
952
1028
  ${near ?? ""}`;
@@ -954,7 +1030,7 @@ ${near ?? ""}`;
954
1030
  if (cached !== undefined)
955
1031
  return cached;
956
1032
  let found = null;
957
- const exporting = new RegExp(`export\\s*\\{(?:[^}]*?[\\s,])?${escapeRegExp(name)}(?![\\w$])`);
1033
+ const exporting = exportingPatternOf(name);
958
1034
  for (const fileName of this.#filesOf(owner, name, near)) {
959
1035
  const text = this.#source.readText(fileName);
960
1036
  if (text === undefined || !exporting.test(text))
@@ -972,7 +1048,7 @@ ${near ?? ""}`;
972
1048
  this.#reexports.set(key, found);
973
1049
  return found;
974
1050
  }
975
- #reexportIn(source, name) {
1051
+ #reexportIn(source, name, takesPackageDefault = false) {
976
1052
  const { ts, reader } = this.#source;
977
1053
  for (const statement of source.statements) {
978
1054
  if (!ts.isExportDeclaration(statement) || statement.isTypeOnly)
@@ -989,7 +1065,9 @@ ${near ?? ""}`;
989
1065
  const imported = reader.importsIn(source).find((item) => item.name === original);
990
1066
  if (!imported)
991
1067
  return { name: original, from: null };
992
- return imported.imported === "default" || imported.imported === "*" ? null : { name: imported.imported, from: imported.from };
1068
+ if (imported.imported === "default")
1069
+ return takesPackageDefault && this.pathOfSpecifier(source.fileName, imported.from) === null ? { name: "default", from: imported.from } : null;
1070
+ return imported.imported === "*" ? null : { name: imported.imported, from: imported.from };
993
1071
  }
994
1072
  return null;
995
1073
  }
@@ -998,7 +1076,9 @@ ${near ?? ""}`;
998
1076
  const relative = this.#source.relative(fileName);
999
1077
  return !!near && (relative.startsWith(`${near}/`) || relative.replace(/\.tsx?$/, "") === near);
1000
1078
  };
1001
- const candidates = this.filesIn(owner).filter(([, words]) => words.includes(`
1079
+ if (!identifierPattern.test(name))
1080
+ return [];
1081
+ const candidates = this.#filesIn(owner).filter(([, words]) => words.includes(`
1002
1082
  ${name}
1003
1083
  `)).map(([fileName]) => fileName);
1004
1084
  return [...candidates.filter(isNear), ...candidates.filter((other) => !isNear(other))];
@@ -1015,7 +1095,7 @@ ${owner ?? ""}`;
1015
1095
  const entries = [];
1016
1096
  const fileNames = [
1017
1097
  ...fileName ? [fileName] : [],
1018
- ...(owner === null ? [] : this.filesIn(owner)).filter(([other, words]) => other !== fileName && words.includes(`
1098
+ ...(owner === null ? [] : this.#filesIn(owner)).filter(([other, words]) => other !== fileName && words.includes(`
1019
1099
  ${objectName}
1020
1100
  `) && words.includes(`
1021
1101
  ${member}
@@ -1089,30 +1169,120 @@ ${near ?? ""}`;
1089
1169
  #throughStar(declared, owner, name, near) {
1090
1170
  if (!declared.length)
1091
1171
  return;
1092
- const { owners, isOpaque } = this.#starExportsOf(owner, near);
1172
+ const { owners, isOpaque } = this.starExportsOf(owner, near);
1093
1173
  const reached = declared.filter((other) => other.owner !== null && owners.includes(other.owner));
1094
1174
  return reached.length === 1 && !isOpaque && !this.declares(owner, name) ? reached[0] : undefined;
1095
1175
  }
1096
- #starExportsOf(owner, near) {
1097
- const cached = this.#starExports.get(near);
1176
+ starExportsOf(owner, near) {
1177
+ const key = `${owner}
1178
+ ${near}`;
1179
+ const cached = this.#starExports.get(key);
1098
1180
  if (cached)
1099
1181
  return cached;
1100
- const found = { owners: [], isOpaque: false };
1101
- this.#starExports.set(near, found);
1102
- const paths = [near];
1103
- for (let idx = 0;idx < paths.length && !found.isOpaque; idx++)
1104
- for (const fileName of this.#modulesAt(paths[idx] ?? "")) {
1105
- for (const [, specifier = ""] of this.#source.readText(fileName)?.matchAll(starExportPattern) ?? []) {
1106
- const target = this.ownerOfSpecifier(fileName, specifier);
1107
- const path = this.pathOfSpecifier(fileName, specifier);
1108
- if (target === undefined || target === frameworkOwner || path === null)
1109
- found.isOpaque = true;
1110
- else if (!paths.includes(path))
1111
- paths.push(path);
1112
- if (target && target !== frameworkOwner && target !== owner && !found.owners.includes(target))
1113
- found.owners.push(target);
1114
- }
1182
+ const found = { owners: [], packages: [], paths: [near], isOpaque: false };
1183
+ this.#starExports.set(key, found);
1184
+ const reach = (specifier, path, target) => {
1185
+ if (path === null && !found.packages.includes(specifier))
1186
+ found.packages.push(specifier);
1187
+ if (target === undefined || target === frameworkOwner || path === null)
1188
+ found.isOpaque = true;
1189
+ else if (!found.paths.includes(path))
1190
+ found.paths.push(path);
1191
+ if (target && target !== frameworkOwner && target !== owner && !found.owners.includes(target))
1192
+ found.owners.push(target);
1193
+ };
1194
+ for (let idx = 0;idx < found.paths.length; idx++) {
1195
+ const path = found.paths[idx] ?? "";
1196
+ for (const module of this.#barrelAt(path) ?? [])
1197
+ reach(module, module, ownerOf(module) ?? undefined);
1198
+ for (const fileName of this.#modulesAt(path))
1199
+ for (const [, specifier = ""] of this.#source.readText(fileName)?.matchAll(starExportPattern) ?? [])
1200
+ reach(specifier, this.pathOfSpecifier(fileName, specifier), this.ownerOfSpecifier(fileName, specifier));
1201
+ }
1202
+ return found;
1203
+ }
1204
+ exportsAt(path, name) {
1205
+ const key = `${path}
1206
+ ${name}`;
1207
+ const cached = this.#moduleExports.get(key);
1208
+ if (cached)
1209
+ return cached;
1210
+ const found = { named: null, stars: [], isLocal: false };
1211
+ const stars = new Set(this.#barrelAt(path));
1212
+ for (const fileName of this.#modulesAt(path)) {
1213
+ const text = this.#source.readText(fileName);
1214
+ if (text === undefined)
1215
+ continue;
1216
+ const named = text.includes(name) && identifierPattern.test(name) && exportingPatternOf(name).test(text) ? this.#reexportIn(this.#source.parse(fileName, text), name, true) : null;
1217
+ if (named) {
1218
+ found.named = { ...named, fileName };
1219
+ break;
1220
+ }
1221
+ if (text.includes(name) && exportMentioningPatternOf(name).test(text) && this.#exportsLocally(this.#source.parse(fileName, text), name)) {
1222
+ found.isLocal = true;
1223
+ break;
1224
+ }
1225
+ for (const target of this.#starsIn(fileName, text))
1226
+ stars.add(target);
1227
+ }
1228
+ if (!found.named && !found.isLocal)
1229
+ found.stars = [...stars];
1230
+ this.#moduleExports.set(key, found);
1231
+ return found;
1232
+ }
1233
+ #exportsLocally(source, name) {
1234
+ const { ts } = this.#source;
1235
+ const binds = (node) => ts.isIdentifier(node) ? node.text === name : node.elements.some((element) => !ts.isOmittedExpression(element) && binds(element.name));
1236
+ return source.statements.some((statement) => {
1237
+ if (ts.isExportDeclaration(statement)) {
1238
+ const { exportClause, isTypeOnly, moduleSpecifier } = statement;
1239
+ if (isTypeOnly || !exportClause)
1240
+ return false;
1241
+ if (ts.isNamespaceExport(exportClause))
1242
+ return exportClause.name.text === name;
1243
+ return !moduleSpecifier && ts.isNamedExports(exportClause) && exportClause.elements.some((element) => !element.isTypeOnly && element.name.text === name);
1115
1244
  }
1245
+ const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) ?? [] : [];
1246
+ if (!modifiers.some(({ kind }) => kind === ts.SyntaxKind.ExportKeyword) || modifiers.some(({ kind }) => kind === ts.SyntaxKind.DefaultKeyword))
1247
+ return false;
1248
+ if (ts.isVariableStatement(statement))
1249
+ return statement.declarationList.declarations.some((declaration) => binds(declaration.name));
1250
+ return (ts.isClassDeclaration(statement) || ts.isFunctionDeclaration(statement) || ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement) || ts.isImportEqualsDeclaration(statement)) && !!statement.name && ts.isIdentifier(statement.name) && statement.name.text === name;
1251
+ });
1252
+ }
1253
+ mentionsAlong(path, name) {
1254
+ return this.#starReachOf(path).some((text) => text.includes(name));
1255
+ }
1256
+ #starReachOf(path) {
1257
+ const cached = this.#starReach.get(path);
1258
+ if (cached)
1259
+ return cached;
1260
+ const paths = new Set([path]);
1261
+ const texts = [];
1262
+ for (const at of paths) {
1263
+ for (const next of this.#barrelAt(at) ?? [])
1264
+ paths.add(next);
1265
+ for (const fileName of this.#modulesAt(at)) {
1266
+ const text = this.#source.readText(fileName) ?? "";
1267
+ texts.push(text);
1268
+ for (const next of this.#starsIn(fileName, text))
1269
+ paths.add(next);
1270
+ }
1271
+ }
1272
+ this.#starReach.set(path, texts);
1273
+ return texts;
1274
+ }
1275
+ #starsIn(fileName, text) {
1276
+ const cached = this.#fileStars.get(fileName);
1277
+ if (cached)
1278
+ return cached;
1279
+ const found = [];
1280
+ for (const [, specifier = ""] of text.matchAll(starExportPattern)) {
1281
+ const target = this.pathOfSpecifier(fileName, specifier);
1282
+ if (target !== null)
1283
+ found.push(target);
1284
+ }
1285
+ this.#fileStars.set(fileName, found);
1116
1286
  return found;
1117
1287
  }
1118
1288
  #modulesAt(path) {
@@ -1126,11 +1296,33 @@ ${near ?? ""}`;
1126
1296
  }
1127
1297
  return this.#modules.get(path) ?? [];
1128
1298
  }
1299
+ #barrelAt(path) {
1300
+ if (!this.#barrels) {
1301
+ const entries = new Map;
1302
+ for (const [fileName] of this.#source.files) {
1303
+ const [, folder, facet, entry, nested] = this.#source.relative(fileName).match(facetEntryPattern) ?? [];
1304
+ if (!folder || !facet || !entry)
1305
+ continue;
1306
+ const found = entries.get(folder) ?? { facet, files: new Set, dirs: new Set };
1307
+ (nested ? found.dirs : found.files).add(entry);
1308
+ entries.set(folder, found);
1309
+ }
1310
+ this.#barrels = new Map([...entries].map(([folder, { facet, files, dirs }]) => [
1311
+ folder,
1312
+ facetBarrelNamesOf(facet, [...files], [...dirs]).map((name) => `${folder}/${name}`)
1313
+ ]));
1314
+ }
1315
+ return this.#modulesAt(path).length ? undefined : this.#barrels.get(path);
1316
+ }
1129
1317
  declares(owner, name) {
1130
1318
  const declaring = declaringPatternOf(name, true);
1131
1319
  return this.#filesOf(owner, name, null).some((fileName) => declaring.test(this.#source.readText(fileName) ?? ""));
1132
1320
  }
1133
- filesIn(owner) {
1321
+ declaresAt(path, name) {
1322
+ const declaring = declaringPatternOf(name, true);
1323
+ return this.#modulesAt(path).some((fileName) => declaring.test(this.#source.readText(fileName) ?? ""));
1324
+ }
1325
+ #filesIn(owner) {
1134
1326
  if (!this.#ownerFiles) {
1135
1327
  this.#ownerFiles = new Map;
1136
1328
  for (const entry of this.#source.files) {
@@ -1180,6 +1372,196 @@ ${near ?? ""}`;
1180
1372
  }
1181
1373
  }
1182
1374
 
1375
+ // pkgs/@akanjs/language/adaptorResolver.ts
1376
+ var packageOf = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
1377
+ var packageKeyOf = ({ name, from }) => `${packageOf(from)}
1378
+ ${name}`;
1379
+ var exportedKeyOf = (item) => ("fact" in item) ? item.id : ("local" in item) ? `${item.local}
1380
+ ` : packageKeyOf(item);
1381
+ var isPackageExport = (item) => ("from" in item);
1382
+
1383
+ class AdaptorResolver {
1384
+ #source;
1385
+ #resolver;
1386
+ #sink;
1387
+ #adaptors = new Map;
1388
+ #plugs = new Map;
1389
+ #serviceFields = new Set;
1390
+ #exported = new Map;
1391
+ constructor(source, resolver, sink) {
1392
+ this.#source = source;
1393
+ this.#resolver = resolver;
1394
+ this.#sink = sink;
1395
+ }
1396
+ declare(facts) {
1397
+ const counts = new Map;
1398
+ for (const file of facts)
1399
+ for (const fact of file.adaptors) {
1400
+ const key = this.#sink.key("adaptor", file.owner, fact.name);
1401
+ counts.set(key, (counts.get(key) ?? 0) + 1);
1402
+ }
1403
+ const declared = facts.flatMap((file) => file.adaptors.map((fact) => {
1404
+ const key = this.#sink.key("adaptor", file.owner, fact.name);
1405
+ const id = (counts.get(key) ?? 0) > 1 ? this.#sink.key("adaptor", file.owner, `${this.#resolver.inOwner(file.fileName, file.owner)}#${fact.name}`) : key;
1406
+ const adaptor = { fact, owner: file.owner, fileName: file.fileName, id };
1407
+ this.#adaptors.set(fact.name, [...this.#adaptors.get(fact.name) ?? [], adaptor]);
1408
+ this.#nodeOf(adaptor);
1409
+ return { adaptor, file };
1410
+ }));
1411
+ for (const { adaptor, file } of declared)
1412
+ for (const plug of adaptor.fact.plugs)
1413
+ this.#sink.addEdge(adaptor.id, this.#idOf(plug.target, file), "plugs", plug.name, this.#sink.location(plug.span));
1414
+ for (const file of facts)
1415
+ for (const binding of file.adaptorBindings)
1416
+ this.#sink.addEdge(this.#idOf(binding.role, file), this.#idOf(binding.adaptor, file), "binds", file.owner, this.#sink.location(binding.span));
1417
+ }
1418
+ addService(refName, service, file) {
1419
+ for (const plug of service.plugs) {
1420
+ const key = `${refName}
1421
+ ${plug.name}`;
1422
+ this.#plugs.set(key, [
1423
+ ...this.#plugs.get(key) ?? [],
1424
+ { owner: file.owner, target: this.#idOf(plug.target, file) }
1425
+ ]);
1426
+ }
1427
+ for (const field of service.fields)
1428
+ this.#serviceFields.add(`${file.owner ?? ""}
1429
+ ${refName}
1430
+ ${field}`);
1431
+ }
1432
+ pluggedOf(owner, module, field) {
1433
+ const plugs = this.#plugs.get(`${module}
1434
+ ${field}`) ?? [];
1435
+ const own = plugs.filter((plug) => plug.owner === owner);
1436
+ if (!own.length && this.#serviceFields.has(`${owner ?? ""}
1437
+ ${module}
1438
+ ${field}`))
1439
+ return [];
1440
+ const inherited = own.length ? own : plugs.filter((plug) => this.#resolver.visible(plug.owner, owner));
1441
+ return [...new Set(inherited.map(({ target }) => target))];
1442
+ }
1443
+ #idOf(local, file) {
1444
+ const [head, member] = local.split(".");
1445
+ const imported = file.imports.find((item) => item.name === head);
1446
+ const name = member ?? (imported && imported.imported !== "default" && imported.imported !== "*" ? imported.imported : head);
1447
+ const path = imported ? this.#resolver.pathOfSpecifier(file.fileName, imported.from) : null;
1448
+ if (imported && path === null && !frameworkPattern.test(imported.from))
1449
+ return this.#packageAdaptorOf(name, imported.from);
1450
+ const from = imported ? this.#resolver.ownerOfSpecifier(file.fileName, imported.from) : undefined;
1451
+ const declared = this.#adaptors.get(name) ?? [];
1452
+ const holder = from === undefined ? file.owner : from;
1453
+ const own = this.#adaptorIn(name, declared, holder, path, file.fileName);
1454
+ if (own && "from" in own)
1455
+ return this.#packageAdaptorOf(own.name, own.from);
1456
+ const shims = own === undefined && from && from !== frameworkOwner && path ? this.#exportedAt(name, path).filter(isPackageExport) : [];
1457
+ const [shim] = shims;
1458
+ if (shim && shims.length === 1)
1459
+ return this.#packageAdaptorOf(shim.name, shim.from);
1460
+ const found = own === undefined && !shim && from !== frameworkOwner ? declared.find((adaptor) => this.#resolver.visible(adaptor.owner, holder)) : own;
1461
+ if (found)
1462
+ return found.id;
1463
+ const starred = own === undefined && !shim && from && from !== frameworkOwner ? this.#starredPackageOf(from, name, path) : null;
1464
+ if (starred)
1465
+ return this.#packageAdaptorOf(starred.name, starred.from);
1466
+ const owner = from === frameworkOwner ? null : imported ? from ?? null : file.owner;
1467
+ const detail = from === frameworkOwner ? [frameworkOwner] : [];
1468
+ return this.#sink.addNode(this.#sink.key("adaptor", owner, name), "adaptor", owner, name, null, detail).id;
1469
+ }
1470
+ #adaptorIn(name, declared, owner, path, fileName) {
1471
+ const own = declared.filter((adaptor) => adaptor.owner === owner);
1472
+ const [first] = own;
1473
+ if (path === null)
1474
+ return own.find((adaptor) => adaptor.fileName === fileName) ?? first;
1475
+ if (own.length === 1)
1476
+ return first;
1477
+ const exported = this.#exportedAt(name, path).filter((item) => first || !isPackageExport(item));
1478
+ const [only] = exported;
1479
+ if (only)
1480
+ return exported.length === 1 && !("local" in only) ? only : null;
1481
+ return first ? null : undefined;
1482
+ }
1483
+ #exportedAt(name, path) {
1484
+ const key = `${path}
1485
+ ${name}`;
1486
+ const cached = this.#exported.get(key);
1487
+ if (cached)
1488
+ return cached;
1489
+ if (!this.#resolver.mentionsAlong(path, name)) {
1490
+ this.#exported.set(key, []);
1491
+ return [];
1492
+ }
1493
+ const reached = new Map;
1494
+ const seen = new Set;
1495
+ const pending = [[name, path]];
1496
+ for (let next = pending.pop();next; next = pending.pop()) {
1497
+ const [wanted, at] = next;
1498
+ if (seen.has(`${at}
1499
+ ${wanted}`))
1500
+ continue;
1501
+ seen.add(`${at}
1502
+ ${wanted}`);
1503
+ for (const item of this.#bindingAt(wanted, at, pending, name))
1504
+ reached.set(exportedKeyOf(item), item);
1505
+ }
1506
+ const found = [...reached.values()];
1507
+ this.#exported.set(key, found);
1508
+ return found;
1509
+ }
1510
+ #bindingAt(name, path, pending, plugged) {
1511
+ const here = this.#declaredAt(name, path);
1512
+ if (here.length)
1513
+ return here;
1514
+ const { named, stars, isLocal } = this.#resolver.exportsAt(path, name);
1515
+ if (isLocal)
1516
+ return [{ local: path }];
1517
+ if (named?.from === null) {
1518
+ const local = this.#declaredAt(named.name, path);
1519
+ return local.length ? local : [{ local: path }];
1520
+ }
1521
+ if (named) {
1522
+ const target = this.#resolver.pathOfSpecifier(named.fileName, named.from);
1523
+ if (target === null) {
1524
+ const exposed = named.name !== "default" ? named.name : name !== "default" ? name : plugged;
1525
+ return [{ name: exposed, from: named.from }];
1526
+ }
1527
+ pending.push([named.name, target]);
1528
+ return [];
1529
+ }
1530
+ for (const star of stars)
1531
+ pending.push([name, star]);
1532
+ return [];
1533
+ }
1534
+ #declaredAt(name, path) {
1535
+ return (this.#adaptors.get(name) ?? []).filter((adaptor) => {
1536
+ const module = this.#source.relative(adaptor.fileName).replace(/\.tsx?$/, "");
1537
+ return module === path || module === `${path}/index`;
1538
+ });
1539
+ }
1540
+ #packageAdaptorOf(name, specifier) {
1541
+ if (frameworkPattern.test(specifier))
1542
+ return this.#sink.addNode(this.#sink.key("adaptor", null, name), "adaptor", null, name, null, [frameworkOwner]).id;
1543
+ const pkg = packageOf(specifier);
1544
+ return this.#sink.addNode(this.#sink.key("adaptor", pkg, name), "adaptor", null, name, null, [pkg]).id;
1545
+ }
1546
+ #starredPackageOf(owner, name, near) {
1547
+ if (!near)
1548
+ return null;
1549
+ const { packages, paths } = this.#resolver.starExportsOf(owner, near);
1550
+ const [only] = packages;
1551
+ if (!only || new Set(packages.map(packageOf)).size !== 1)
1552
+ return null;
1553
+ return paths.some((path) => this.#resolver.declaresAt(path, name)) ? null : { name, from: only };
1554
+ }
1555
+ #nodeOf({ fact, owner, fileName, id }) {
1556
+ const detail = fact.refName ? [fact.refName] : [];
1557
+ const node = this.#sink.addNode(id, "adaptor", owner, fact.name, fact.span, detail);
1558
+ if (fact.doc && !node.doc)
1559
+ node.doc = fact.doc;
1560
+ this.#sink.digest(node, this.#source.readText(fileName), fact.extent);
1561
+ return node.id;
1562
+ }
1563
+ }
1564
+
1183
1565
  // pkgs/@akanjs/language/routeFacts.ts
1184
1566
  import { normalizeRoutePattern, tryParseRouteModuleKey } from "akanjs/common/routeConvention.ts";
1185
1567
 
@@ -1375,13 +1757,18 @@ class GraphBuilder {
1375
1757
  #routeFiles = new Map;
1376
1758
  #routes;
1377
1759
  #resolver;
1378
- #adaptors = new Map;
1379
- #plugs = new Map;
1380
- #serviceFields = new Set;
1760
+ #adaptors;
1381
1761
  constructor(source) {
1382
1762
  this.#source = source;
1383
1763
  this.#routes = new RouteFactReader(source.ts, source.reader, source.parse);
1384
1764
  this.#resolver = new GuardResolver(source, this.#routes);
1765
+ this.#adaptors = new AdaptorResolver(source, this.#resolver, {
1766
+ key: (kind, owner, scope) => this.#key(kind, owner, scope),
1767
+ addNode: (id, kind, owner, name, span, detail) => this.#addNode(id, kind, owner, null, name, span, detail),
1768
+ addEdge: (from, to, kind, label, at) => this.#addEdge(from, to, kind, label, at),
1769
+ digest: (node, text, extent) => this.#digest(node, text, extent),
1770
+ location: (span) => this.#location(span)
1771
+ });
1385
1772
  }
1386
1773
  build() {
1387
1774
  const { facts } = this.#source;
@@ -1393,26 +1780,7 @@ class GraphBuilder {
1393
1780
  ...[...constantsByOwner].filter(([key]) => key !== owner && key?.startsWith("libs/")).flatMap(([, list]) => list)
1394
1781
  ];
1395
1782
  const typed = [];
1396
- const adaptorCounts = new Map;
1397
- for (const file of facts)
1398
- for (const fact of file.adaptors) {
1399
- const key = this.#key("adaptor", file.owner, fact.name);
1400
- adaptorCounts.set(key, (adaptorCounts.get(key) ?? 0) + 1);
1401
- }
1402
- const declaredAdaptors = facts.flatMap((file) => file.adaptors.map((fact) => {
1403
- const key = this.#key("adaptor", file.owner, fact.name);
1404
- const id = (adaptorCounts.get(key) ?? 0) > 1 ? this.#key("adaptor", file.owner, `${this.#resolver.inOwner(file.fileName, file.owner)}#${fact.name}`) : key;
1405
- const declared = { fact, owner: file.owner, fileName: file.fileName, id };
1406
- this.#adaptors.set(fact.name, [...this.#adaptors.get(fact.name) ?? [], declared]);
1407
- this.#adaptorNodeOf(declared);
1408
- return { declared, file };
1409
- }));
1410
- for (const { declared, file } of declaredAdaptors)
1411
- for (const plug of declared.fact.plugs)
1412
- this.#addEdge(declared.id, this.#adaptorIdOf(plug.target, file), "plugs", plug.name, this.#location(plug.span));
1413
- for (const file of facts)
1414
- for (const binding of file.adaptorBindings)
1415
- this.#addEdge(this.#adaptorIdOf(binding.role, file), this.#adaptorIdOf(binding.adaptor, file), "binds", file.owner, this.#location(binding.span));
1783
+ this.#adaptors.declare(facts);
1416
1784
  for (const guard of this.#resolver.declare(facts))
1417
1785
  this.#guardNodeOf(guard);
1418
1786
  for (const file of facts) {
@@ -1445,18 +1813,7 @@ class GraphBuilder {
1445
1813
  }
1446
1814
  for (const method of service.methods)
1447
1815
  this.#addMember("method", owner, refName, method, `${service.name}.${method.name}`, file.fileName);
1448
- for (const plug of service.plugs) {
1449
- const key = `${refName}
1450
- ${plug.name}`;
1451
- this.#plugs.set(key, [
1452
- ...this.#plugs.get(key) ?? [],
1453
- { owner, target: this.#adaptorIdOf(plug.target, file) }
1454
- ]);
1455
- }
1456
- for (const field of service.fields)
1457
- this.#serviceFields.add(`${owner ?? ""}
1458
- ${refName}
1459
- ${field}`);
1816
+ this.#adaptors.addService(refName, service, file);
1460
1817
  }
1461
1818
  for (const filter of file.filters) {
1462
1819
  if (!filter.name.endsWith("Filter"))
@@ -1712,80 +2069,6 @@ ${dir}`, node);
1712
2069
  this.#digest(node, text, extent);
1713
2070
  return node.id;
1714
2071
  }
1715
- #adaptorIdOf(local, file) {
1716
- const [head, member] = local.split(".");
1717
- const imported = file.imports.find((item) => item.name === head);
1718
- const name = member ?? (imported && imported.imported !== "default" && imported.imported !== "*" ? imported.imported : head);
1719
- const path = imported ? this.#resolver.pathOfSpecifier(file.fileName, imported.from) : null;
1720
- if (imported && path === null && !frameworkPattern.test(imported.from))
1721
- return this.#packageAdaptorOf(name, imported.from);
1722
- const from = imported ? this.#resolver.ownerOfSpecifier(file.fileName, imported.from) : undefined;
1723
- const declared = this.#adaptors.get(name) ?? [];
1724
- const found = from === undefined ? this.#adaptorIn(declared, file.owner, path, file.fileName) ?? declared.find((adaptor) => this.#resolver.visible(adaptor.owner, file.owner)) : this.#adaptorIn(declared, from, path, file.fileName) ?? (from === frameworkOwner ? undefined : declared.find((adaptor) => this.#resolver.visible(adaptor.owner, from)));
1725
- if (found)
1726
- return found.id;
1727
- const reexported = from && from !== frameworkOwner ? this.#packageShimOf(from, name, path) : null;
1728
- if (reexported)
1729
- return this.#packageAdaptorOf(reexported.name, reexported.from);
1730
- const owner = from === frameworkOwner ? null : imported ? from ?? null : file.owner;
1731
- const detail = from === frameworkOwner ? [frameworkOwner] : [];
1732
- return this.#addNode(this.#key("adaptor", owner, name), "adaptor", owner, null, name, null, detail).id;
1733
- }
1734
- #adaptorIn(declared, owner, path, fileName) {
1735
- const own = declared.filter((adaptor) => adaptor.owner === owner);
1736
- if (own.length < 2)
1737
- return own.at(0);
1738
- const pathOf = (adaptor) => this.#source.relative(adaptor.fileName).replace(/\.tsx?$/, "");
1739
- const named = path === null ? own.find((adaptor) => adaptor.fileName === fileName) : own.find((adaptor) => pathOf(adaptor) === path || pathOf(adaptor) === `${path}/index`) ?? own.find((adaptor) => pathOf(adaptor).startsWith(`${path}/`));
1740
- return named ?? own.at(0);
1741
- }
1742
- #pluggedOf({ owner, module }, field) {
1743
- const plugs = this.#plugs.get(`${module}
1744
- ${field}`) ?? [];
1745
- const own = plugs.filter((plug) => plug.owner === owner);
1746
- if (!own.length && this.#serviceFields.has(`${owner ?? ""}
1747
- ${module}
1748
- ${field}`))
1749
- return [];
1750
- const inherited = own.length ? own : plugs.filter((plug) => this.#resolver.visible(plug.owner, owner));
1751
- return [...new Set(inherited.map(({ target }) => target))];
1752
- }
1753
- #packageAdaptorOf(name, specifier) {
1754
- if (frameworkPattern.test(specifier))
1755
- return this.#addNode(this.#key("adaptor", null, name), "adaptor", null, null, name, null, [frameworkOwner]).id;
1756
- const pkg = specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
1757
- return this.#addNode(this.#key("adaptor", pkg, name), "adaptor", null, null, name, null, [pkg]).id;
1758
- }
1759
- #packageShimOf(owner, name, near) {
1760
- const reexport = this.#resolver.reexportOf(owner, name, near);
1761
- const [shim] = reexport?.site.imports ?? [];
1762
- if (reexport && shim && this.#resolver.pathOfSpecifier(reexport.site.fileName, shim.from) === null)
1763
- return { name: reexport.local === "default" ? name : reexport.local, from: shim.from };
1764
- if (reexport || !near)
1765
- return null;
1766
- const packages = new Set;
1767
- for (const [fileName, words] of this.#resolver.filesIn(owner)) {
1768
- const relative = this.#source.relative(fileName);
1769
- const isNear = relative.startsWith(`${near}/`) || relative.replace(/\.tsx?$/, "") === near;
1770
- if (!isNear || !words.includes(`
1771
- export
1772
- `))
1773
- continue;
1774
- for (const [, specifier = ""] of this.#source.readText(fileName)?.matchAll(starExportPattern) ?? [])
1775
- if (this.#resolver.pathOfSpecifier(fileName, specifier) === null)
1776
- packages.add(specifier);
1777
- }
1778
- const [only] = packages;
1779
- return packages.size === 1 && only && !this.#resolver.declares(owner, name) ? { name, from: only } : null;
1780
- }
1781
- #adaptorNodeOf({ fact, owner, fileName, id }) {
1782
- const detail = fact.refName ? [fact.refName] : [];
1783
- const node = this.#addNode(id, "adaptor", owner, null, fact.name, fact.span, detail);
1784
- if (fact.doc && !node.doc)
1785
- node.doc = fact.doc;
1786
- this.#digest(node, this.#source.readText(fileName), fact.extent);
1787
- return node.id;
1788
- }
1789
2072
  #guardNodeOf({ name, owner, span, scope, doc, parts, file, label }) {
1790
2073
  const id = this.#key("guard", owner, file ? `${file}#${name}` : name);
1791
2074
  const node = this.#addNode(id, "guard", owner, null, name, span, scope ? [scope] : [], label ?? name);
@@ -1888,7 +2171,7 @@ st
1888
2171
  visit(source);
1889
2172
  }
1890
2173
  #link(fileName, source, identifier, chain, context, owner) {
1891
- const plugged = chain?.length === 2 && chain[0] === "this" && context.kind === "method" && this.#isServiceThis(identifier) ? this.#pluggedOf(context, chain[1]) : [];
2174
+ const plugged = chain?.length === 2 && chain[0] === "this" && context.kind === "method" && this.#isServiceThis(identifier) ? this.#adaptors.pluggedOf(context.owner, context.module, chain[1]) : [];
1892
2175
  const resolved = plugged.length ? plugged : this.#source.resolve(fileName, identifier).map((target) => this.#targetNodeOf(target)).filter((id) => id !== null);
1893
2176
  const targets = resolved.length ? resolved : this.#plainTargetsOf(chain, identifier.text, context, owner);
1894
2177
  if (!targets.length)
@@ -2333,7 +2616,7 @@ var sourcePattern = /\.(constant|document|service|signal|store)\.ts$/;
2333
2616
  var dictionaryPattern = /\.dictionary\.ts$/;
2334
2617
  var srvkitPattern = /\/srvkit\//;
2335
2618
  var wordPattern = /[A-Za-z_$][\w$]*/g;
2336
- var identifierPattern = /^[A-Za-z_$][\w$]*$/;
2619
+ var identifierPattern2 = /^[A-Za-z_$][\w$]*$/;
2337
2620
  var stateReceivers = new Set(["use", "sel", "get", "do"]);
2338
2621
  var lensFamilies = new Set(["slice", "query", "formSetter", "storeState", "endpoint"]);
2339
2622
  var modellessFamilies = new Set(["query", "storeState", "endpoint"]);
@@ -2442,7 +2725,7 @@ ${[...new Set(text.match(wordPattern))].join(`
2442
2725
  }
2443
2726
  renameAt(givenName, offset, newKey, readText) {
2444
2727
  const sources = this.#sourceEntriesAt(pathOf(givenName), offset).filter((entry) => entry.renamed);
2445
- if (!sources.length || !identifierPattern.test(newKey))
2728
+ if (!sources.length || !identifierPattern2.test(newKey))
2446
2729
  return null;
2447
2730
  return [
2448
2731
  { span: sources[0].span, newText: newKey },
@@ -3152,6 +3435,11 @@ ${union.name}`)));
3152
3435
  const field = this.#memberOf(this.#classOf(receiver), receiver.name.text);
3153
3436
  return field && ts.isPropertyDeclaration(field) ? this.#namesIn(field.type) : new Set;
3154
3437
  }
3438
+ if (ts.isCallExpression(receiver) && ts.isPropertyAccessExpression(receiver.expression) && receiver.expression.expression.kind === ts.SyntaxKind.ThisKeyword) {
3439
+ const field = this.#memberOf(this.#classOf(receiver), receiver.expression.name.text);
3440
+ const type = field && ts.isPropertyDeclaration(field) ? field.type : undefined;
3441
+ return type && ts.isFunctionTypeNode(type) ? this.#namesIn(type.type) : new Set;
3442
+ }
3155
3443
  return this.#declaredTypeNames(receiver) ?? new Set;
3156
3444
  }
3157
3445
  #memberName(name) {