@stupidloud/codegraph 0.9.5 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -116
- package/dist/bin/codegraph.js +52 -82
- package/dist/bin/codegraph.js.map +1 -1
- package/dist/context/formatter.d.ts.map +1 -1
- package/dist/context/formatter.js +25 -6
- package/dist/context/formatter.js.map +1 -1
- package/dist/context/index.d.ts +22 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +257 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/markers.d.ts +19 -0
- package/dist/context/markers.d.ts.map +1 -0
- package/dist/context/markers.js +22 -0
- package/dist/context/markers.js.map +1 -0
- package/dist/db/queries.d.ts +88 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +251 -7
- package/dist/db/queries.js.map +1 -1
- package/dist/db/sqlite-adapter.d.ts +7 -0
- package/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/dist/db/sqlite-adapter.js +3 -0
- package/dist/db/sqlite-adapter.js.map +1 -1
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +6 -20
- package/dist/directory.js.map +1 -1
- package/dist/extraction/generated-detection.d.ts +30 -0
- package/dist/extraction/generated-detection.d.ts.map +1 -0
- package/dist/extraction/generated-detection.js +80 -0
- package/dist/extraction/generated-detection.js.map +1 -0
- package/dist/extraction/grammars.d.ts +17 -1
- package/dist/extraction/grammars.d.ts.map +1 -1
- package/dist/extraction/grammars.js +65 -1
- package/dist/extraction/grammars.js.map +1 -1
- package/dist/extraction/index.d.ts +15 -2
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +206 -98
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/dist/extraction/languages/c-cpp.js +45 -0
- package/dist/extraction/languages/c-cpp.js.map +1 -1
- package/dist/extraction/languages/csharp.d.ts.map +1 -1
- package/dist/extraction/languages/csharp.js +2 -1
- package/dist/extraction/languages/csharp.js.map +1 -1
- package/dist/extraction/languages/go.d.ts.map +1 -1
- package/dist/extraction/languages/go.js +18 -2
- package/dist/extraction/languages/go.js.map +1 -1
- package/dist/extraction/languages/index.d.ts.map +1 -1
- package/dist/extraction/languages/index.js +2 -0
- package/dist/extraction/languages/index.js.map +1 -1
- package/dist/extraction/languages/java.d.ts.map +1 -1
- package/dist/extraction/languages/java.js +6 -0
- package/dist/extraction/languages/java.js.map +1 -1
- package/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/dist/extraction/languages/kotlin.js +6 -0
- package/dist/extraction/languages/kotlin.js.map +1 -1
- package/dist/extraction/languages/objc.d.ts +3 -0
- package/dist/extraction/languages/objc.d.ts.map +1 -0
- package/dist/extraction/languages/objc.js +133 -0
- package/dist/extraction/languages/objc.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
- package/dist/extraction/mybatis-extractor.js +198 -0
- package/dist/extraction/mybatis-extractor.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +14 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +84 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +681 -20
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/extraction/vue-extractor.d.ts +15 -0
- package/dist/extraction/vue-extractor.d.ts.map +1 -1
- package/dist/extraction/vue-extractor.js +88 -0
- package/dist/extraction/vue-extractor.js.map +1 -1
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
- package/dist/extraction/wasm-runtime-flags.js +1 -0
- package/dist/extraction/wasm-runtime-flags.js.map +1 -1
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +5 -2
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +66 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -1
- package/dist/index.js.map +1 -1
- package/dist/installer/config-writer.d.ts +7 -8
- package/dist/installer/config-writer.d.ts.map +1 -1
- package/dist/installer/config-writer.js +7 -27
- package/dist/installer/config-writer.js.map +1 -1
- package/dist/installer/index.d.ts +3 -20
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +8 -39
- package/dist/installer/index.js.map +1 -1
- package/dist/installer/instructions-template.d.ts +11 -21
- package/dist/installer/instructions-template.d.ts.map +1 -1
- package/dist/installer/instructions-template.js +12 -56
- package/dist/installer/instructions-template.js.map +1 -1
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/antigravity.d.ts.map +1 -0
- package/dist/installer/targets/antigravity.js +308 -0
- package/dist/installer/targets/antigravity.js.map +1 -0
- package/dist/installer/targets/claude.d.ts +10 -1
- package/dist/installer/targets/claude.d.ts.map +1 -1
- package/dist/installer/targets/claude.js +25 -40
- package/dist/installer/targets/claude.js.map +1 -1
- package/dist/installer/targets/codex.d.ts.map +1 -1
- package/dist/installer/targets/codex.js +15 -13
- package/dist/installer/targets/codex.js.map +1 -1
- package/dist/installer/targets/cursor.d.ts.map +1 -1
- package/dist/installer/targets/cursor.js +9 -38
- package/dist/installer/targets/cursor.js.map +1 -1
- package/dist/installer/targets/gemini.d.ts +26 -0
- package/dist/installer/targets/gemini.d.ts.map +1 -0
- package/dist/installer/targets/gemini.js +167 -0
- package/dist/installer/targets/gemini.js.map +1 -0
- package/dist/installer/targets/hermes.d.ts.map +1 -1
- package/dist/installer/targets/hermes.js +57 -3
- package/dist/installer/targets/hermes.js.map +1 -1
- package/dist/installer/targets/kiro.d.ts +27 -0
- package/dist/installer/targets/kiro.d.ts.map +1 -0
- package/dist/installer/targets/kiro.js +178 -0
- package/dist/installer/targets/kiro.js.map +1 -0
- package/dist/installer/targets/opencode.d.ts.map +1 -1
- package/dist/installer/targets/opencode.js +15 -13
- package/dist/installer/targets/opencode.js.map +1 -1
- package/dist/installer/targets/registry.d.ts.map +1 -1
- package/dist/installer/targets/registry.js +6 -0
- package/dist/installer/targets/registry.js.map +1 -1
- package/dist/installer/targets/shared.d.ts.map +1 -1
- package/dist/installer/targets/shared.js +3 -2
- package/dist/installer/targets/shared.js.map +1 -1
- package/dist/installer/targets/types.d.ts +1 -16
- package/dist/installer/targets/types.d.ts.map +1 -1
- package/dist/mcp/daemon-paths.d.ts +46 -0
- package/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/dist/mcp/daemon-paths.js +125 -0
- package/dist/mcp/daemon-paths.js.map +1 -0
- package/dist/mcp/daemon.d.ts +161 -0
- package/dist/mcp/daemon.d.ts.map +1 -0
- package/dist/mcp/daemon.js +403 -0
- package/dist/mcp/daemon.js.map +1 -0
- package/dist/mcp/engine.d.ts +105 -0
- package/dist/mcp/engine.d.ts.map +1 -0
- package/dist/mcp/engine.js +270 -0
- package/dist/mcp/engine.js.map +1 -0
- package/dist/mcp/index.d.ts +67 -53
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +315 -388
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/proxy.d.ts +81 -0
- package/dist/mcp/proxy.d.ts.map +1 -0
- package/dist/mcp/proxy.js +510 -0
- package/dist/mcp/proxy.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +21 -21
- package/dist/mcp/session.d.ts +77 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +294 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/tools.d.ts +160 -14
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +1622 -322
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/transport.d.ts +111 -29
- package/dist/mcp/transport.d.ts.map +1 -1
- package/dist/mcp/transport.js +181 -71
- package/dist/mcp/transport.js.map +1 -1
- package/dist/mcp/version.d.ts +19 -0
- package/dist/mcp/version.d.ts.map +1 -0
- package/dist/mcp/version.js +71 -0
- package/dist/mcp/version.js.map +1 -0
- package/dist/resolution/callback-synthesizer.d.ts +10 -0
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/dist/resolution/callback-synthesizer.js +1300 -0
- package/dist/resolution/callback-synthesizer.js.map +1 -0
- package/dist/resolution/frameworks/csharp.d.ts.map +1 -1
- package/dist/resolution/frameworks/csharp.js +36 -8
- package/dist/resolution/frameworks/csharp.js.map +1 -1
- package/dist/resolution/frameworks/drupal.d.ts.map +1 -1
- package/dist/resolution/frameworks/drupal.js +44 -12
- package/dist/resolution/frameworks/drupal.js.map +1 -1
- package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
- package/dist/resolution/frameworks/expo-modules.js +143 -0
- package/dist/resolution/frameworks/expo-modules.js.map +1 -0
- package/dist/resolution/frameworks/express.d.ts.map +1 -1
- package/dist/resolution/frameworks/express.js +102 -19
- package/dist/resolution/frameworks/express.js.map +1 -1
- package/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
- package/dist/resolution/frameworks/fabric.js +354 -0
- package/dist/resolution/frameworks/fabric.js.map +1 -0
- package/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/dist/resolution/frameworks/go.js +6 -3
- package/dist/resolution/frameworks/go.js.map +1 -1
- package/dist/resolution/frameworks/index.d.ts +5 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/dist/resolution/frameworks/index.js +25 -1
- package/dist/resolution/frameworks/index.js.map +1 -1
- package/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/dist/resolution/frameworks/java.js +339 -12
- package/dist/resolution/frameworks/java.js.map +1 -1
- package/dist/resolution/frameworks/laravel.d.ts.map +1 -1
- package/dist/resolution/frameworks/laravel.js +17 -8
- package/dist/resolution/frameworks/laravel.js.map +1 -1
- package/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
- package/dist/resolution/frameworks/nestjs.js +324 -0
- package/dist/resolution/frameworks/nestjs.js.map +1 -1
- package/dist/resolution/frameworks/play.d.ts +19 -0
- package/dist/resolution/frameworks/play.d.ts.map +1 -0
- package/dist/resolution/frameworks/play.js +111 -0
- package/dist/resolution/frameworks/play.js.map +1 -0
- package/dist/resolution/frameworks/python.d.ts.map +1 -1
- package/dist/resolution/frameworks/python.js +134 -16
- package/dist/resolution/frameworks/python.js.map +1 -1
- package/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
- package/dist/resolution/frameworks/react-native.js +360 -0
- package/dist/resolution/frameworks/react-native.js.map +1 -0
- package/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/dist/resolution/frameworks/react.js +96 -3
- package/dist/resolution/frameworks/react.js.map +1 -1
- package/dist/resolution/frameworks/ruby.d.ts.map +1 -1
- package/dist/resolution/frameworks/ruby.js +106 -2
- package/dist/resolution/frameworks/ruby.js.map +1 -1
- package/dist/resolution/frameworks/rust.d.ts.map +1 -1
- package/dist/resolution/frameworks/rust.js +102 -5
- package/dist/resolution/frameworks/rust.js.map +1 -1
- package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift-objc.js +252 -0
- package/dist/resolution/frameworks/swift-objc.js.map +1 -0
- package/dist/resolution/frameworks/swift.d.ts.map +1 -1
- package/dist/resolution/frameworks/swift.js +30 -6
- package/dist/resolution/frameworks/swift.js.map +1 -1
- package/dist/resolution/go-module.d.ts +26 -0
- package/dist/resolution/go-module.d.ts.map +1 -0
- package/dist/resolution/go-module.js +78 -0
- package/dist/resolution/go-module.js.map +1 -0
- package/dist/resolution/import-resolver.d.ts +28 -0
- package/dist/resolution/import-resolver.d.ts.map +1 -1
- package/dist/resolution/import-resolver.js +617 -5
- package/dist/resolution/import-resolver.js.map +1 -1
- package/dist/resolution/index.d.ts +11 -0
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +156 -3
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +212 -0
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
- package/dist/resolution/swift-objc-bridge.js +256 -0
- package/dist/resolution/swift-objc-bridge.js.map +1 -0
- package/dist/resolution/types.d.ts +44 -0
- package/dist/resolution/types.d.ts.map +1 -1
- package/dist/resolution/workspace-packages.d.ts +48 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/dist/resolution/workspace-packages.js +208 -0
- package/dist/resolution/workspace-packages.js.map +1 -0
- package/dist/search/query-utils.d.ts +18 -0
- package/dist/search/query-utils.d.ts.map +1 -1
- package/dist/search/query-utils.js +30 -0
- package/dist/search/query-utils.js.map +1 -1
- package/dist/sync/git-hooks.d.ts.map +1 -1
- package/dist/sync/git-hooks.js +2 -0
- package/dist/sync/git-hooks.js.map +1 -1
- package/dist/sync/index.d.ts +3 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +8 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/watcher.d.ts +212 -8
- package/dist/sync/watcher.d.ts.map +1 -1
- package/dist/sync/watcher.js +465 -51
- package/dist/sync/watcher.js.map +1 -1
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/sync/worktree.d.ts.map +1 -0
- package/dist/sync/worktree.js +137 -0
- package/dist/sync/worktree.js.map +1 -0
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/scripts/agent-eval/arms-F.sh +21 -0
- package/scripts/agent-eval/arms-matrix.sh +37 -0
- package/scripts/agent-eval/bench-readme.sh +28 -0
- package/scripts/agent-eval/bench-why-repo.sh +22 -0
- package/scripts/agent-eval/block-read-hook.sh +19 -0
- package/scripts/agent-eval/hook-settings.json +15 -0
- package/scripts/agent-eval/itrun.sh +24 -11
- package/scripts/agent-eval/parse-arms.mjs +116 -0
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
- package/scripts/agent-eval/probe-context.mjs +21 -0
- package/scripts/agent-eval/probe-explore.mjs +40 -0
- package/scripts/agent-eval/probe-node.mjs +20 -0
- package/scripts/agent-eval/probe-sweep.mjs +119 -0
- package/scripts/agent-eval/probe-trace.mjs +20 -0
- package/scripts/agent-eval/run-arms.sh +56 -0
- package/scripts/agent-eval/seq-matrix.mjs +137 -0
- package/scripts/npm-sdk.js +75 -0
- package/scripts/pack-npm.sh +25 -1
- package/scripts/prepare-release.mjs +270 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Swift ↔ Objective-C bridging rules.
|
|
4
|
+
*
|
|
5
|
+
* Apple's auto-bridging mechanism exposes Swift declarations to the ObjC
|
|
6
|
+
* runtime under a deterministic selector name. The full rule set:
|
|
7
|
+
* https://developer.apple.com/documentation/swift/importing-swift-into-objective-c
|
|
8
|
+
*
|
|
9
|
+
* This module is **pure name math** — given a Swift declaration's base name
|
|
10
|
+
* + parameter external labels (or the raw signature text), produce the
|
|
11
|
+
* bridged ObjC selector(s); given an ObjC selector, produce the
|
|
12
|
+
* candidate Swift base names. No graph/DB access here.
|
|
13
|
+
*
|
|
14
|
+
* Used by `frameworks/swift-objc.ts` (the framework resolver that wires
|
|
15
|
+
* the rules into the resolution pipeline) and by its tests.
|
|
16
|
+
*
|
|
17
|
+
* ─── Bridging cheat sheet ───────────────────────────────────────────────
|
|
18
|
+
*
|
|
19
|
+
* Swift declaration ObjC selector
|
|
20
|
+
* ───────────────────────────────────────── ─────────────────────────
|
|
21
|
+
* func play() play
|
|
22
|
+
* func play(_ song: String) play:
|
|
23
|
+
* func play(song: String) playWithSong:
|
|
24
|
+
* func play(_ song: String, by artist: String) play:by:
|
|
25
|
+
* func play(song: String, by artist: String) playWithSong:by:
|
|
26
|
+
* init(name: String) initWithName:
|
|
27
|
+
* init(name: String, age: Int) initWithName:age:
|
|
28
|
+
* var name: String (getter / setter) name / setName:
|
|
29
|
+
* @objc(custom:) func f(_ x: Int) custom: (literal override)
|
|
30
|
+
*
|
|
31
|
+
* The reverse direction (ObjC → Swift) collapses the bridge: a Swift call
|
|
32
|
+
* site for `play(song:)` reaches us as the bare base name `play` (Swift's
|
|
33
|
+
* tree-sitter call_expression strips parameter labels from the callee
|
|
34
|
+
* name). So `swiftBaseNamesForObjcSelector('playWithSong:')` returns
|
|
35
|
+
* `['play']` — the resolver looks up Swift methods named `play`.
|
|
36
|
+
*/
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.objcSelectorForSwiftMethod = objcSelectorForSwiftMethod;
|
|
39
|
+
exports.objcSelectorForSwiftInit = objcSelectorForSwiftInit;
|
|
40
|
+
exports.objcAccessorsForSwiftProperty = objcAccessorsForSwiftProperty;
|
|
41
|
+
exports.swiftBaseNamesForObjcSelector = swiftBaseNamesForObjcSelector;
|
|
42
|
+
exports.detectExplicitObjcName = detectExplicitObjcName;
|
|
43
|
+
exports.isObjcExposed = isObjcExposed;
|
|
44
|
+
/**
|
|
45
|
+
* Capitalize the first character of a string. Used for the "With"-prefix
|
|
46
|
+
* form on the first selector keyword when the Swift declaration has an
|
|
47
|
+
* explicit first-parameter label (e.g. `func play(song:)` → `playWithSong:`).
|
|
48
|
+
*/
|
|
49
|
+
function capFirst(s) {
|
|
50
|
+
return s.length > 0 ? s.charAt(0).toUpperCase() + s.slice(1) : s;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Lowercase the first character. Used in reverse: `setName:` setter ↔
|
|
54
|
+
* Swift property `name`.
|
|
55
|
+
*/
|
|
56
|
+
function lowerFirst(s) {
|
|
57
|
+
return s.length > 0 ? s.charAt(0).toLowerCase() + s.slice(1) : s;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Compute the auto-bridged ObjC selector for a Swift method declaration.
|
|
61
|
+
*
|
|
62
|
+
* @param baseName The Swift method's base name (e.g. `play`).
|
|
63
|
+
* @param externalLabels Parameter EXTERNAL labels in declaration order;
|
|
64
|
+
* `null` for a `_` (unlabeled) parameter.
|
|
65
|
+
* `[]` for a no-parameter method.
|
|
66
|
+
* @param explicitObjcName If `@objc(customSel:)` was specified, the
|
|
67
|
+
* literal selector — short-circuits the rule
|
|
68
|
+
* and is returned as-is.
|
|
69
|
+
* @returns The ObjC selector (e.g. `playWithSong:by:`), or `null` if it
|
|
70
|
+
* can't be determined.
|
|
71
|
+
*
|
|
72
|
+
* **Method rules:**
|
|
73
|
+
* - No params → base name (no colons)
|
|
74
|
+
* - Single param, `_` label → `baseName:`
|
|
75
|
+
* - Single param, explicit label `L` → `baseNameWithL:`
|
|
76
|
+
* - Multi-param, `_` first label → `baseName:label2:label3:`
|
|
77
|
+
* - Multi-param, explicit first label `L1` → `baseNameWithL1:label2:label3:`
|
|
78
|
+
*
|
|
79
|
+
* Initializer rules are handled by `objcSelectorForSwiftInit`.
|
|
80
|
+
*/
|
|
81
|
+
function objcSelectorForSwiftMethod(baseName, externalLabels, explicitObjcName) {
|
|
82
|
+
if (!baseName)
|
|
83
|
+
return null;
|
|
84
|
+
if (explicitObjcName)
|
|
85
|
+
return explicitObjcName;
|
|
86
|
+
if (externalLabels.length === 0) {
|
|
87
|
+
return baseName;
|
|
88
|
+
}
|
|
89
|
+
const [first, ...rest] = externalLabels;
|
|
90
|
+
// Single param: "_" → "base:" ; "label" → "baseWithLabel:"
|
|
91
|
+
// Multi-param mirrors the same first-keyword formation, then appends each
|
|
92
|
+
// subsequent label as its own keyword. A `null` later label is invalid
|
|
93
|
+
// ObjC (no way to express unlabeled middle params) — keep as `:` to be safe.
|
|
94
|
+
const firstKeyword = first === null || first === undefined || first === '_' || first === ''
|
|
95
|
+
? `${baseName}:`
|
|
96
|
+
: `${baseName}With${capFirst(first)}:`;
|
|
97
|
+
const restKeywords = rest.map((l) => `${l ?? ''}:`).join('');
|
|
98
|
+
return firstKeyword + restKeywords;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Compute the bridged ObjC selector for a Swift `init(...)` declaration.
|
|
102
|
+
*
|
|
103
|
+
* **Init rules** (different from regular methods — Apple always uses
|
|
104
|
+
* `initWith` regardless of whether the first label is `_`):
|
|
105
|
+
* - `init()` → `init`
|
|
106
|
+
* - `init(_ name: String)` → `initWithName:` (uses the INTERNAL
|
|
107
|
+
* name when external is `_`, per Apple's
|
|
108
|
+
* bridging conventions)
|
|
109
|
+
* - `init(name: String)` → `initWithName:`
|
|
110
|
+
* - `init(name: String, age: Int)` → `initWithName:age:`
|
|
111
|
+
*
|
|
112
|
+
* For the `_` case we need the internal (second identifier) name —
|
|
113
|
+
* passed via `internalNames`.
|
|
114
|
+
*/
|
|
115
|
+
function objcSelectorForSwiftInit(externalLabels, internalNames, explicitObjcName) {
|
|
116
|
+
if (explicitObjcName)
|
|
117
|
+
return explicitObjcName;
|
|
118
|
+
if (externalLabels.length === 0) {
|
|
119
|
+
return 'init';
|
|
120
|
+
}
|
|
121
|
+
const [firstExt, ...restExt] = externalLabels;
|
|
122
|
+
const [firstInt] = internalNames;
|
|
123
|
+
// Use the internal name when external is "_"; ObjC needs *some* keyword,
|
|
124
|
+
// and Swift's auto-bridger uses the parameter's local name in this case.
|
|
125
|
+
const firstLabel = firstExt === null || firstExt === '_' || firstExt === ''
|
|
126
|
+
? firstInt
|
|
127
|
+
: firstExt;
|
|
128
|
+
if (!firstLabel)
|
|
129
|
+
return null;
|
|
130
|
+
const firstKeyword = `initWith${capFirst(firstLabel)}:`;
|
|
131
|
+
const restKeywords = restExt
|
|
132
|
+
.map((label, idx) => {
|
|
133
|
+
const internal = internalNames[idx + 1];
|
|
134
|
+
const name = label && label !== '_' ? label : internal ?? '';
|
|
135
|
+
return `${name}:`;
|
|
136
|
+
})
|
|
137
|
+
.join('');
|
|
138
|
+
return firstKeyword + restKeywords;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Compute the bridged ObjC getter + setter for a Swift `@objc` property.
|
|
142
|
+
*
|
|
143
|
+
* - `var name: String` → getter `name`, setter `setName:`
|
|
144
|
+
* - `var isReady: Bool` → getter `isReady`, setter `setIsReady:`
|
|
145
|
+
* (no special `is` handling — Swift's `isReady` stays as `isReady` in ObjC;
|
|
146
|
+
* `@objc(name:)` overrides if a Cocoa-style getter `isReady` / setter
|
|
147
|
+
* `setReady:` pairing is needed — that's the responsibility of the
|
|
148
|
+
* declaration's `@objc(customGetter)` annotation, which we surface via
|
|
149
|
+
* `explicitObjcName`.)
|
|
150
|
+
*/
|
|
151
|
+
function objcAccessorsForSwiftProperty(swiftName, explicitObjcName) {
|
|
152
|
+
if (!swiftName)
|
|
153
|
+
return null;
|
|
154
|
+
// The override syntax `@objc(customGetterName)` re-points the GETTER only;
|
|
155
|
+
// the setter still follows the `setX:` rule but is keyed off the override.
|
|
156
|
+
// (`@objc(getX:setY:)` is not currently supported — that's a rarer
|
|
157
|
+
// shape; can extend later if a real codebase needs it.)
|
|
158
|
+
const getter = explicitObjcName ?? swiftName;
|
|
159
|
+
return {
|
|
160
|
+
getter,
|
|
161
|
+
setter: `set${capFirst(getter)}:`,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Reverse: from an ObjC selector, return the candidate Swift base names
|
|
166
|
+
* the resolver should try when looking for the bridged Swift declaration.
|
|
167
|
+
*
|
|
168
|
+
* Examples:
|
|
169
|
+
* `play` → ['play']
|
|
170
|
+
* `play:` → ['play']
|
|
171
|
+
* `playWithSong:` → ['play', 'playWithSong']
|
|
172
|
+
* `play:by:` → ['play']
|
|
173
|
+
* `playWithSong:by:` → ['play', 'playWithSong']
|
|
174
|
+
* `initWithName:` → ['init'] (init is its own base name)
|
|
175
|
+
* `initWithName:age:` → ['init']
|
|
176
|
+
* `setName:` → ['name', 'setName'] (could be a setter OR a regular func)
|
|
177
|
+
* `tableView:didSel…:` → ['tableView']
|
|
178
|
+
*
|
|
179
|
+
* Returns multiple candidates because the bare base name is ambiguous —
|
|
180
|
+
* `playWithSong:` could correspond to either `func play(song:)` or
|
|
181
|
+
* `func playWithSong(_ x:)` (a Swift method literally named that with a
|
|
182
|
+
* `_` first label). The resolver tries each.
|
|
183
|
+
*/
|
|
184
|
+
function swiftBaseNamesForObjcSelector(selector) {
|
|
185
|
+
if (!selector)
|
|
186
|
+
return [];
|
|
187
|
+
// Strip trailing colons and split into keywords.
|
|
188
|
+
const keywords = selector.replace(/:+$/g, '').split(':');
|
|
189
|
+
const firstKeyword = keywords[0];
|
|
190
|
+
if (!firstKeyword)
|
|
191
|
+
return [];
|
|
192
|
+
const candidates = new Set();
|
|
193
|
+
// Always a candidate: the raw first keyword. Covers
|
|
194
|
+
// `play:` → `play`
|
|
195
|
+
// `play:by:` → `play`
|
|
196
|
+
// `playWithSong:` → `playWithSong` (a literal Swift name)
|
|
197
|
+
// `tableView:...:` → `tableView`
|
|
198
|
+
candidates.add(firstKeyword);
|
|
199
|
+
// `initWith<X>:` and `initWith<X>:<more>:` always reduce to `init`.
|
|
200
|
+
if (firstKeyword.startsWith('initWith')) {
|
|
201
|
+
candidates.add('init');
|
|
202
|
+
}
|
|
203
|
+
// Preposition-prefix patterns: `<base>(With|For|By|In|On|At|From|To|Of|As)<Cap>:`
|
|
204
|
+
// covers both Swift's @objc EXPORT rule (always "With") and Cocoa's
|
|
205
|
+
// IMPORTED selectors which use other prepositions natively (e.g.
|
|
206
|
+
// `objectForKey:`, `stringWithFormat:`, `compareTo:`,
|
|
207
|
+
// `imageNamed:inBundle:`). Strip to recover the Swift base name a caller
|
|
208
|
+
// would use (e.g. `object`, `string`, `compare`, `image`).
|
|
209
|
+
const prepositionMatch = firstKeyword.match(/^([a-z][a-zA-Z0-9]*?)(?:With|For|By|In|On|At|From|To|Of|As)[A-Z]/);
|
|
210
|
+
if (prepositionMatch && prepositionMatch[1]) {
|
|
211
|
+
candidates.add(prepositionMatch[1]);
|
|
212
|
+
}
|
|
213
|
+
// `setX:` could be a property setter — the Swift property is `x` (lowercase).
|
|
214
|
+
// Only fires for the obvious shape: `set` + capital letter + ':' (one param).
|
|
215
|
+
if (keywords.length === 1 &&
|
|
216
|
+
/^set[A-Z]/.test(firstKeyword) &&
|
|
217
|
+
selector.endsWith(':')) {
|
|
218
|
+
const propName = lowerFirst(firstKeyword.slice(3));
|
|
219
|
+
if (propName)
|
|
220
|
+
candidates.add(propName);
|
|
221
|
+
}
|
|
222
|
+
return Array.from(candidates);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Detect whether a Swift method `@objc` declaration uses the `@objc(custom:)`
|
|
226
|
+
* override form, returning the literal selector when present.
|
|
227
|
+
*
|
|
228
|
+
* Regex-based scan over the small chunk of source preceding the declaration —
|
|
229
|
+
* tree-sitter would be more precise but this is only consulted as a fallback
|
|
230
|
+
* when the structured AST isn't available (e.g. resolver-time lookups
|
|
231
|
+
* via `context.readFile`).
|
|
232
|
+
*
|
|
233
|
+
* Returns `null` when the declaration is plain `@objc` (no override) or has
|
|
234
|
+
* no `@objc` attribute at all.
|
|
235
|
+
*/
|
|
236
|
+
function detectExplicitObjcName(sourceSlice) {
|
|
237
|
+
// `@objc(customName:)` or `@objc(custom:name:)` — the parens contents are
|
|
238
|
+
// the literal ObjC selector. Whitespace permitted.
|
|
239
|
+
const m = sourceSlice.match(/@objc\s*\(\s*([^)\s]+)\s*\)/);
|
|
240
|
+
return m && m[1] ? m[1] : null;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Detect whether a Swift declaration is `@objc`-exposed by scanning the
|
|
244
|
+
* source slice that precedes it. Returns true for explicit `@objc`,
|
|
245
|
+
* `@objc(custom:)`, or membership in a `@objcMembers` class (caller's
|
|
246
|
+
* responsibility to pass class-level context if relevant).
|
|
247
|
+
*
|
|
248
|
+
* `@nonobjc` returns false even if `@objc` also appears (per Swift's rule
|
|
249
|
+
* that `@nonobjc` opts out of class-level `@objcMembers`).
|
|
250
|
+
*/
|
|
251
|
+
function isObjcExposed(sourceSlice) {
|
|
252
|
+
if (/@nonobjc\b/.test(sourceSlice))
|
|
253
|
+
return false;
|
|
254
|
+
return /@objc\b/.test(sourceSlice);
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=swift-objc-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swift-objc-bridge.js","sourceRoot":"","sources":["../../src/resolution/swift-objc-bridge.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;AAyCH,gEAwBC;AAiBD,4DA8BC;AAaD,sEAcC;AAsBD,sEA+CC;AAcD,wDAKC;AAWD,sCAGC;AA/OD;;;;GAIG;AACH,SAAS,QAAQ,CAAC,CAAS;IACzB,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,0BAA0B,CACxC,QAAgB,EAChB,cAAiC,EACjC,gBAAgC;IAEhC,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,gBAAgB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;AACjC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAC,WAAmB;IAC/C,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IACjD,OAAO,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -86,6 +86,21 @@ export interface ResolutionContext {
|
|
|
86
86
|
* compile without modification; production resolver implements it.
|
|
87
87
|
*/
|
|
88
88
|
getProjectAliases?(): import('./path-aliases').AliasMap | null;
|
|
89
|
+
/**
|
|
90
|
+
* Go module info from `go.mod` at the project root. Returns `null`
|
|
91
|
+
* when the project has no `go.mod` (non-Go projects, pre-modules
|
|
92
|
+
* Go code, or projects whose modules live in subdirectories). Used
|
|
93
|
+
* by the Go branch of import resolution to distinguish in-module
|
|
94
|
+
* cross-package imports from third-party packages.
|
|
95
|
+
*/
|
|
96
|
+
getGoModule?(): import('./go-module').GoModule | null;
|
|
97
|
+
/**
|
|
98
|
+
* Monorepo workspace member packages, keyed by declared package name.
|
|
99
|
+
* Returns `null` for single-package repos (no `workspaces` field).
|
|
100
|
+
* Lets the resolver treat `@scope/ui/sub` as a local import into the
|
|
101
|
+
* member's directory instead of an external npm package (#629).
|
|
102
|
+
*/
|
|
103
|
+
getWorkspacePackages?(): import('./workspace-packages').WorkspacePackages | null;
|
|
89
104
|
/**
|
|
90
105
|
* Re-exports declared by a file (`export { x } from './other'`,
|
|
91
106
|
* `export * from './other'`). Empty array when the file has none.
|
|
@@ -102,6 +117,13 @@ export interface ResolutionContext {
|
|
|
102
117
|
* without modification.
|
|
103
118
|
*/
|
|
104
119
|
listDirectories?(relativePath: string): string[];
|
|
120
|
+
/**
|
|
121
|
+
* C/C++ include search directories (relative to project root),
|
|
122
|
+
* extracted from compile_commands.json or discovered by heuristic.
|
|
123
|
+
* Used by resolveCppIncludePath to search -I directories when
|
|
124
|
+
* relative resolution fails. Optional so existing callers compile.
|
|
125
|
+
*/
|
|
126
|
+
getCppIncludeDirs?(): string[];
|
|
105
127
|
}
|
|
106
128
|
/**
|
|
107
129
|
* Result of framework-specific file extraction.
|
|
@@ -124,6 +146,14 @@ export interface FrameworkResolver {
|
|
|
124
146
|
detect(context: ResolutionContext): boolean;
|
|
125
147
|
/** Resolve a reference using framework-specific patterns */
|
|
126
148
|
resolve(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
149
|
+
/**
|
|
150
|
+
* Opt a reference NAME through the resolver's name-exists pre-filter, even when
|
|
151
|
+
* no node is named that. Needed for dynamic dispatch where the call target is
|
|
152
|
+
* an attribute/descriptor, not a declared symbol (e.g. Django's
|
|
153
|
+
* `self._iterable_class(...)`, React effect callbacks). Returning true lets the
|
|
154
|
+
* ref reach `resolve()` instead of being dropped for having no name match.
|
|
155
|
+
*/
|
|
156
|
+
claimsReference?(name: string): boolean;
|
|
127
157
|
/**
|
|
128
158
|
* Extract framework-specific nodes and references from a file.
|
|
129
159
|
*
|
|
@@ -133,6 +163,20 @@ export interface FrameworkResolver {
|
|
|
133
163
|
* pipeline; the framework's own `resolve()` is one of the strategies tried.
|
|
134
164
|
*/
|
|
135
165
|
extract?(filePath: string, content: string): FrameworkExtractionResult;
|
|
166
|
+
/**
|
|
167
|
+
* Cross-file finalization pass, called once after all per-file extraction
|
|
168
|
+
* completes (and again on every incremental sync). Used by frameworks where
|
|
169
|
+
* a symbol's final representation depends on a sibling file the per-file
|
|
170
|
+
* `extract()` never saw — e.g. NestJS's `RouterModule.register([...])`
|
|
171
|
+
* sets route prefixes for controllers declared elsewhere.
|
|
172
|
+
*
|
|
173
|
+
* Implementations return route/etc. nodes with mutated fields (typically
|
|
174
|
+
* `name`); the orchestrator persists each via `updateNode`. The node `id`
|
|
175
|
+
* MUST be preserved so existing edges (route → handler, etc.) stay intact;
|
|
176
|
+
* `qualifiedName` SHOULD be preserved so the pass stays idempotent — a
|
|
177
|
+
* second run can recover the original in-file form from `qualifiedName`.
|
|
178
|
+
*/
|
|
179
|
+
postExtract?(context: ResolutionContext): Node[];
|
|
136
180
|
}
|
|
137
181
|
/**
|
|
138
182
|
* Import mapping from a file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/resolution/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,aAAa,EAAE,QAAQ,CAAC;IACxB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,QAAQ,EAAE,QAAQ,CAAC;IACnB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,QAAQ,EAAE,aAAa,CAAC;IACxB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,UAAU,EAAE,aAAa,GAAG,QAAQ,GAAG,gBAAgB,GAAG,WAAW,GAAG,OAAO,GAAG,iBAAiB,GAAG,WAAW,CAAC;CACnH;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,2CAA2C;IAC3C,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,iBAAiB;IACjB,KAAK,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAA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,gEAAgE;IAChE,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JS/TS workspace (monorepo) package resolution.
|
|
3
|
+
*
|
|
4
|
+
* npm / yarn / bun read member packages from the root `package.json`
|
|
5
|
+
* `workspaces` field; pnpm from `pnpm-workspace.yaml`. A cross-package
|
|
6
|
+
* import like `@scope/ui/widgets` is LOCAL to the monorepo, but to a
|
|
7
|
+
* single-package resolver it looks exactly like a third-party npm
|
|
8
|
+
* specifier — so `isExternalImport` flags it external and the
|
|
9
|
+
* consumer↔definition edge is never created. For component barrels
|
|
10
|
+
* (`export { default as X } from './x.svelte'`) that surfaces as a false
|
|
11
|
+
* `0 callers` on a live component (issue #629).
|
|
12
|
+
*
|
|
13
|
+
* This module maps each member package's declared `name` to its
|
|
14
|
+
* directory so the resolver can rewrite `@scope/ui/widgets` →
|
|
15
|
+
* `packages/ui/widgets` and then run normal extension/index resolution.
|
|
16
|
+
*
|
|
17
|
+
* Scope deliberately small for v1 (mirrors path-aliases.ts):
|
|
18
|
+
* - reads `workspaces` (array OR `{ packages: [...] }`) from package.json,
|
|
19
|
+
* plus a minimal `pnpm-workspace.yaml` `packages:` list
|
|
20
|
+
* - expands one level of `*` / `**` globs (`packages/*`, `apps/*`)
|
|
21
|
+
* - subpath resolution is directory-based (`@scope/ui/sub` → `<ui>/sub`);
|
|
22
|
+
* it does NOT yet honour a member's `exports` map or `main` field
|
|
23
|
+
* - returns null when the project declares no workspaces, so single-
|
|
24
|
+
* package repos pay nothing and see no behaviour change.
|
|
25
|
+
*/
|
|
26
|
+
export interface WorkspacePackages {
|
|
27
|
+
/** Member package `name` → directory relative to projectRoot (posix). */
|
|
28
|
+
byName: Map<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load workspace member packages for `projectRoot`. Returns `null` when
|
|
32
|
+
* the project declares no workspaces (the common single-package case) —
|
|
33
|
+
* callers then skip all workspace logic.
|
|
34
|
+
*
|
|
35
|
+
* Cheap to call repeatedly only via the resolver's per-instance cache;
|
|
36
|
+
* this function itself touches the filesystem, so the resolver memoises it
|
|
37
|
+
* the same way it does {@link loadProjectAliases} / {@link loadGoModule}.
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadWorkspacePackages(projectRoot: string): WorkspacePackages | null;
|
|
40
|
+
/**
|
|
41
|
+
* Rewrite a bare workspace import to a path relative to projectRoot,
|
|
42
|
+
* WITHOUT an extension — the caller applies the language's extension/index
|
|
43
|
+
* resolution. `@scope/ui/widgets` → `packages/ui/widgets`; the bare package
|
|
44
|
+
* name `@scope/ui` → its directory. Returns `null` when no member package
|
|
45
|
+
* name matches.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveWorkspaceImport(importPath: string, ws: WorkspacePackages): string | null;
|
|
48
|
+
//# sourceMappingURL=workspace-packages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-packages.d.ts","sourceRoot":"","sources":["../../src/resolution/workspace-packages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAMH,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAgBnF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,iBAAiB,GACpB,MAAM,GAAG,IAAI,CAaf"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* JS/TS workspace (monorepo) package resolution.
|
|
4
|
+
*
|
|
5
|
+
* npm / yarn / bun read member packages from the root `package.json`
|
|
6
|
+
* `workspaces` field; pnpm from `pnpm-workspace.yaml`. A cross-package
|
|
7
|
+
* import like `@scope/ui/widgets` is LOCAL to the monorepo, but to a
|
|
8
|
+
* single-package resolver it looks exactly like a third-party npm
|
|
9
|
+
* specifier — so `isExternalImport` flags it external and the
|
|
10
|
+
* consumer↔definition edge is never created. For component barrels
|
|
11
|
+
* (`export { default as X } from './x.svelte'`) that surfaces as a false
|
|
12
|
+
* `0 callers` on a live component (issue #629).
|
|
13
|
+
*
|
|
14
|
+
* This module maps each member package's declared `name` to its
|
|
15
|
+
* directory so the resolver can rewrite `@scope/ui/widgets` →
|
|
16
|
+
* `packages/ui/widgets` and then run normal extension/index resolution.
|
|
17
|
+
*
|
|
18
|
+
* Scope deliberately small for v1 (mirrors path-aliases.ts):
|
|
19
|
+
* - reads `workspaces` (array OR `{ packages: [...] }`) from package.json,
|
|
20
|
+
* plus a minimal `pnpm-workspace.yaml` `packages:` list
|
|
21
|
+
* - expands one level of `*` / `**` globs (`packages/*`, `apps/*`)
|
|
22
|
+
* - subpath resolution is directory-based (`@scope/ui/sub` → `<ui>/sub`);
|
|
23
|
+
* it does NOT yet honour a member's `exports` map or `main` field
|
|
24
|
+
* - returns null when the project declares no workspaces, so single-
|
|
25
|
+
* package repos pay nothing and see no behaviour change.
|
|
26
|
+
*/
|
|
27
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
30
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
31
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
32
|
+
}
|
|
33
|
+
Object.defineProperty(o, k2, desc);
|
|
34
|
+
}) : (function(o, m, k, k2) {
|
|
35
|
+
if (k2 === undefined) k2 = k;
|
|
36
|
+
o[k2] = m[k];
|
|
37
|
+
}));
|
|
38
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
39
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
40
|
+
}) : function(o, v) {
|
|
41
|
+
o["default"] = v;
|
|
42
|
+
});
|
|
43
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
44
|
+
var ownKeys = function(o) {
|
|
45
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
46
|
+
var ar = [];
|
|
47
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
48
|
+
return ar;
|
|
49
|
+
};
|
|
50
|
+
return ownKeys(o);
|
|
51
|
+
};
|
|
52
|
+
return function (mod) {
|
|
53
|
+
if (mod && mod.__esModule) return mod;
|
|
54
|
+
var result = {};
|
|
55
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
56
|
+
__setModuleDefault(result, mod);
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
})();
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.loadWorkspacePackages = loadWorkspacePackages;
|
|
62
|
+
exports.resolveWorkspaceImport = resolveWorkspaceImport;
|
|
63
|
+
const fs = __importStar(require("fs"));
|
|
64
|
+
const path = __importStar(require("path"));
|
|
65
|
+
const errors_1 = require("../errors");
|
|
66
|
+
/**
|
|
67
|
+
* Load workspace member packages for `projectRoot`. Returns `null` when
|
|
68
|
+
* the project declares no workspaces (the common single-package case) —
|
|
69
|
+
* callers then skip all workspace logic.
|
|
70
|
+
*
|
|
71
|
+
* Cheap to call repeatedly only via the resolver's per-instance cache;
|
|
72
|
+
* this function itself touches the filesystem, so the resolver memoises it
|
|
73
|
+
* the same way it does {@link loadProjectAliases} / {@link loadGoModule}.
|
|
74
|
+
*/
|
|
75
|
+
function loadWorkspacePackages(projectRoot) {
|
|
76
|
+
const patterns = readWorkspaceGlobs(projectRoot);
|
|
77
|
+
if (patterns.length === 0)
|
|
78
|
+
return null;
|
|
79
|
+
const byName = new Map();
|
|
80
|
+
for (const pattern of patterns) {
|
|
81
|
+
for (const dir of expandWorkspaceGlob(projectRoot, pattern)) {
|
|
82
|
+
const pkgName = readPackageName(path.join(projectRoot, dir));
|
|
83
|
+
// First declaration wins — workspace patterns are tried in order.
|
|
84
|
+
if (pkgName && !byName.has(pkgName))
|
|
85
|
+
byName.set(pkgName, dir);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (byName.size === 0)
|
|
89
|
+
return null;
|
|
90
|
+
(0, errors_1.logDebug)('workspace packages loaded', { count: byName.size });
|
|
91
|
+
return { byName };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Rewrite a bare workspace import to a path relative to projectRoot,
|
|
95
|
+
* WITHOUT an extension — the caller applies the language's extension/index
|
|
96
|
+
* resolution. `@scope/ui/widgets` → `packages/ui/widgets`; the bare package
|
|
97
|
+
* name `@scope/ui` → its directory. Returns `null` when no member package
|
|
98
|
+
* name matches.
|
|
99
|
+
*/
|
|
100
|
+
function resolveWorkspaceImport(importPath, ws) {
|
|
101
|
+
// Longest matching package name wins, so `@scope/ui/core` prefers a
|
|
102
|
+
// `@scope/ui/core` package over a `@scope/ui` one when both exist.
|
|
103
|
+
let bestName = null;
|
|
104
|
+
for (const name of ws.byName.keys()) {
|
|
105
|
+
if (importPath === name || importPath.startsWith(name + '/')) {
|
|
106
|
+
if (!bestName || name.length > bestName.length)
|
|
107
|
+
bestName = name;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (!bestName)
|
|
111
|
+
return null;
|
|
112
|
+
const dir = ws.byName.get(bestName);
|
|
113
|
+
const subpath = importPath.slice(bestName.length); // '' or '/widgets'
|
|
114
|
+
return (dir + subpath).replace(/\/{2,}/g, '/');
|
|
115
|
+
}
|
|
116
|
+
/** Read workspace glob patterns from package.json + pnpm-workspace.yaml. */
|
|
117
|
+
function readWorkspaceGlobs(projectRoot) {
|
|
118
|
+
const out = [];
|
|
119
|
+
// package.json `workspaces` (npm / yarn / bun): array, or Yarn's
|
|
120
|
+
// `{ packages: [...], nohoist: [...] }` object form.
|
|
121
|
+
try {
|
|
122
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf-8'));
|
|
123
|
+
const ws = pkg?.workspaces;
|
|
124
|
+
if (Array.isArray(ws)) {
|
|
125
|
+
out.push(...ws.filter((w) => typeof w === 'string'));
|
|
126
|
+
}
|
|
127
|
+
else if (ws && Array.isArray(ws.packages)) {
|
|
128
|
+
out.push(...ws.packages.filter((w) => typeof w === 'string'));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
/* no / invalid package.json — not a workspace root */
|
|
133
|
+
}
|
|
134
|
+
// pnpm-workspace.yaml `packages:` list. Parsed with a minimal line
|
|
135
|
+
// scanner so we don't pull in a YAML dependency.
|
|
136
|
+
try {
|
|
137
|
+
const yaml = fs.readFileSync(path.join(projectRoot, 'pnpm-workspace.yaml'), 'utf-8');
|
|
138
|
+
out.push(...parsePnpmPackages(yaml));
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
/* no pnpm-workspace.yaml */
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Minimal pnpm-workspace.yaml `packages:` extractor. Handles the only shape
|
|
147
|
+
* pnpm actually uses:
|
|
148
|
+
* packages:
|
|
149
|
+
* - 'packages/*'
|
|
150
|
+
* - "apps/*"
|
|
151
|
+
* - tools/build
|
|
152
|
+
*/
|
|
153
|
+
function parsePnpmPackages(yaml) {
|
|
154
|
+
const out = [];
|
|
155
|
+
const lines = yaml.split(/\r?\n/);
|
|
156
|
+
let inPackages = false;
|
|
157
|
+
for (const line of lines) {
|
|
158
|
+
if (/^\s*packages\s*:/.test(line)) {
|
|
159
|
+
inPackages = true;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (inPackages) {
|
|
163
|
+
const item = line.match(/^\s*-\s*(.+?)\s*$/);
|
|
164
|
+
if (item) {
|
|
165
|
+
out.push(item[1].replace(/^['"]|['"]$/g, ''));
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
// A non-list, non-blank line ends the `packages:` block.
|
|
169
|
+
if (line.trim() !== '' && !/^\s/.test(line))
|
|
170
|
+
inPackages = false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
/** Expand one level of a `packages/*` / `apps/**` glob to member dirs. */
|
|
176
|
+
function expandWorkspaceGlob(projectRoot, pattern) {
|
|
177
|
+
const norm = pattern.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
178
|
+
const star = norm.indexOf('*');
|
|
179
|
+
if (star === -1)
|
|
180
|
+
return [norm]; // exact directory
|
|
181
|
+
// Everything before the wildcard segment is the base to enumerate.
|
|
182
|
+
const base = norm.slice(0, star).replace(/\/+$/, '');
|
|
183
|
+
let entries;
|
|
184
|
+
try {
|
|
185
|
+
entries = fs.readdirSync(path.join(projectRoot, base), { withFileTypes: true });
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
190
|
+
const out = [];
|
|
191
|
+
for (const e of entries) {
|
|
192
|
+
if (!e.isDirectory() || e.name.startsWith('.') || e.name === 'node_modules')
|
|
193
|
+
continue;
|
|
194
|
+
out.push(base ? `${base}/${e.name}` : e.name);
|
|
195
|
+
}
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
/** Read the `name` field from a member directory's package.json. */
|
|
199
|
+
function readPackageName(dirAbs) {
|
|
200
|
+
try {
|
|
201
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(dirAbs, 'package.json'), 'utf-8'));
|
|
202
|
+
return typeof pkg?.name === 'string' && pkg.name ? pkg.name : null;
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=workspace-packages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-packages.js","sourceRoot":"","sources":["../../src/resolution/workspace-packages.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBH,sDAgBC;AASD,wDAgBC;AA3DD,uCAAyB;AACzB,2CAA6B;AAC7B,sCAAqC;AAOrC;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CAAC,WAAmB;IACvD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACjD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEvC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,KAAK,MAAM,GAAG,IAAI,mBAAmB,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC;YAC5D,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;YAC7D,kEAAkE;YAClE,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;gBAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEnC,IAAA,iBAAQ,EAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC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AC,CAAC,IAAI,KAAK,cAAc;YAAE,SAAS;QACtF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,oEAAoE;AACpE,SAAS,eAAe,CAAC,MAAc;IACrC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QACpF,OAAO,OAAO,GAAG,EAAE,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -50,4 +50,22 @@ export declare function nameMatchBonus(nodeName: string, query: string): number;
|
|
|
50
50
|
* Functions and classes are typically more relevant than variables/imports
|
|
51
51
|
*/
|
|
52
52
|
export declare function kindBonus(kind: Node['kind']): number;
|
|
53
|
+
/**
|
|
54
|
+
* Whether a query token looks like a code identifier the user deliberately typed
|
|
55
|
+
* (camelCase / PascalCase-with-internal-caps / snake_case / has a digit) rather
|
|
56
|
+
* than a plain dictionary word ("flat", "object", "screen").
|
|
57
|
+
*
|
|
58
|
+
* Used to decide whether an EXACT name match earns the "the user named this
|
|
59
|
+
* symbol" exemption from single-term dampening. A common English word that
|
|
60
|
+
* happens to exact-match an unrelated symbol — the query "flat object" matching
|
|
61
|
+
* a constant named `FLAT` — must NOT get that exemption, or the +exact-name
|
|
62
|
+
* bonus floats it to the top of a prose query on its own.
|
|
63
|
+
*
|
|
64
|
+
* Classifies the token AS THE USER TYPED IT, not the matched symbol's name:
|
|
65
|
+
* "flat" (lowercase, descriptive) is non-distinctive even though it matches
|
|
66
|
+
* `FLAT`. A leading-capital-only word ("Screen", "Zustand") is also treated as
|
|
67
|
+
* a plain word — sentence-start capitalization and proper nouns aren't reliable
|
|
68
|
+
* identifier signals.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isDistinctiveIdentifier(token: string): boolean;
|
|
53
71
|
//# sourceMappingURL=query-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-utils.d.ts","sourceRoot":"","sources":["../../src/search/query-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,UAAU,aAkBrB,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAyDtD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,EAAE,CA2DzF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA4B1E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAuCpD;AAmBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAuCtE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CA0BpD"}
|
|
1
|
+
{"version":3,"file":"query-utils.d.ts","sourceRoot":"","sources":["../../src/search/query-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;A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