@colbymchenry/codegraph 0.8.0 → 0.9.1
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 +23 -7
- package/npm-shim.js +43 -0
- package/package.json +13 -51
- package/LICENSE +0 -21
- package/dist/bin/codegraph.d.ts +0 -21
- package/dist/bin/codegraph.d.ts.map +0 -1
- package/dist/bin/codegraph.js +0 -1257
- package/dist/bin/codegraph.js.map +0 -1
- package/dist/bin/node-version-check.d.ts +0 -20
- package/dist/bin/node-version-check.d.ts.map +0 -1
- package/dist/bin/node-version-check.js +0 -42
- package/dist/bin/node-version-check.js.map +0 -1
- package/dist/bin/uninstall.d.ts +0 -14
- package/dist/bin/uninstall.d.ts.map +0 -1
- package/dist/bin/uninstall.js +0 -36
- package/dist/bin/uninstall.js.map +0 -1
- package/dist/config.d.ts +0 -51
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -321
- package/dist/config.js.map +0 -1
- package/dist/context/formatter.d.ts +0 -30
- package/dist/context/formatter.d.ts.map +0 -1
- package/dist/context/formatter.js +0 -244
- package/dist/context/formatter.js.map +0 -1
- package/dist/context/index.d.ts +0 -97
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -1050
- package/dist/context/index.js.map +0 -1
- package/dist/db/index.d.ts +0 -72
- package/dist/db/index.d.ts.map +0 -1
- package/dist/db/index.js +0 -200
- package/dist/db/index.js.map +0 -1
- package/dist/db/migrations.d.ts +0 -44
- package/dist/db/migrations.d.ts.map +0 -1
- package/dist/db/migrations.js +0 -131
- package/dist/db/migrations.js.map +0 -1
- package/dist/db/queries.d.ts +0 -253
- package/dist/db/queries.d.ts.map +0 -1
- package/dist/db/queries.js +0 -1207
- package/dist/db/queries.js.map +0 -1
- package/dist/db/schema.sql +0 -151
- package/dist/db/sqlite-adapter.d.ts +0 -52
- package/dist/db/sqlite-adapter.d.ts.map +0 -1
- package/dist/db/sqlite-adapter.js +0 -237
- package/dist/db/sqlite-adapter.js.map +0 -1
- package/dist/directory.d.ts +0 -57
- package/dist/directory.d.ts.map +0 -1
- package/dist/directory.js +0 -264
- package/dist/directory.js.map +0 -1
- package/dist/errors.d.ts +0 -136
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -219
- package/dist/errors.js.map +0 -1
- package/dist/extraction/dfm-extractor.d.ts +0 -31
- package/dist/extraction/dfm-extractor.d.ts.map +0 -1
- package/dist/extraction/dfm-extractor.js +0 -151
- package/dist/extraction/dfm-extractor.js.map +0 -1
- package/dist/extraction/grammars.d.ts +0 -78
- package/dist/extraction/grammars.d.ts.map +0 -1
- package/dist/extraction/grammars.js +0 -322
- package/dist/extraction/grammars.js.map +0 -1
- package/dist/extraction/index.d.ts +0 -130
- package/dist/extraction/index.d.ts.map +0 -1
- package/dist/extraction/index.js +0 -1305
- package/dist/extraction/index.js.map +0 -1
- package/dist/extraction/languages/c-cpp.d.ts +0 -4
- package/dist/extraction/languages/c-cpp.d.ts.map +0 -1
- package/dist/extraction/languages/c-cpp.js +0 -126
- package/dist/extraction/languages/c-cpp.js.map +0 -1
- package/dist/extraction/languages/csharp.d.ts +0 -3
- package/dist/extraction/languages/csharp.d.ts.map +0 -1
- package/dist/extraction/languages/csharp.js +0 -72
- package/dist/extraction/languages/csharp.js.map +0 -1
- package/dist/extraction/languages/dart.d.ts +0 -3
- package/dist/extraction/languages/dart.d.ts.map +0 -1
- package/dist/extraction/languages/dart.js +0 -192
- package/dist/extraction/languages/dart.js.map +0 -1
- package/dist/extraction/languages/go.d.ts +0 -3
- package/dist/extraction/languages/go.d.ts.map +0 -1
- package/dist/extraction/languages/go.js +0 -58
- package/dist/extraction/languages/go.js.map +0 -1
- package/dist/extraction/languages/index.d.ts +0 -10
- package/dist/extraction/languages/index.d.ts.map +0 -1
- package/dist/extraction/languages/index.js +0 -45
- package/dist/extraction/languages/index.js.map +0 -1
- package/dist/extraction/languages/java.d.ts +0 -3
- package/dist/extraction/languages/java.d.ts.map +0 -1
- package/dist/extraction/languages/java.js +0 -64
- package/dist/extraction/languages/java.js.map +0 -1
- package/dist/extraction/languages/javascript.d.ts +0 -3
- package/dist/extraction/languages/javascript.d.ts.map +0 -1
- package/dist/extraction/languages/javascript.js +0 -90
- package/dist/extraction/languages/javascript.js.map +0 -1
- package/dist/extraction/languages/kotlin.d.ts +0 -3
- package/dist/extraction/languages/kotlin.d.ts.map +0 -1
- package/dist/extraction/languages/kotlin.js +0 -253
- package/dist/extraction/languages/kotlin.js.map +0 -1
- package/dist/extraction/languages/pascal.d.ts +0 -3
- package/dist/extraction/languages/pascal.d.ts.map +0 -1
- package/dist/extraction/languages/pascal.js +0 -66
- package/dist/extraction/languages/pascal.js.map +0 -1
- package/dist/extraction/languages/php.d.ts +0 -3
- package/dist/extraction/languages/php.d.ts.map +0 -1
- package/dist/extraction/languages/php.js +0 -107
- package/dist/extraction/languages/php.js.map +0 -1
- package/dist/extraction/languages/python.d.ts +0 -3
- package/dist/extraction/languages/python.d.ts.map +0 -1
- package/dist/extraction/languages/python.js +0 -56
- package/dist/extraction/languages/python.js.map +0 -1
- package/dist/extraction/languages/ruby.d.ts +0 -3
- package/dist/extraction/languages/ruby.d.ts.map +0 -1
- package/dist/extraction/languages/ruby.js +0 -114
- package/dist/extraction/languages/ruby.js.map +0 -1
- package/dist/extraction/languages/rust.d.ts +0 -3
- package/dist/extraction/languages/rust.d.ts.map +0 -1
- package/dist/extraction/languages/rust.js +0 -109
- package/dist/extraction/languages/rust.js.map +0 -1
- package/dist/extraction/languages/scala.d.ts +0 -3
- package/dist/extraction/languages/scala.d.ts.map +0 -1
- package/dist/extraction/languages/scala.js +0 -139
- package/dist/extraction/languages/scala.js.map +0 -1
- package/dist/extraction/languages/swift.d.ts +0 -3
- package/dist/extraction/languages/swift.d.ts.map +0 -1
- package/dist/extraction/languages/swift.js +0 -91
- package/dist/extraction/languages/swift.js.map +0 -1
- package/dist/extraction/languages/typescript.d.ts +0 -3
- package/dist/extraction/languages/typescript.d.ts.map +0 -1
- package/dist/extraction/languages/typescript.js +0 -129
- package/dist/extraction/languages/typescript.js.map +0 -1
- package/dist/extraction/liquid-extractor.d.ts +0 -52
- package/dist/extraction/liquid-extractor.d.ts.map +0 -1
- package/dist/extraction/liquid-extractor.js +0 -313
- package/dist/extraction/liquid-extractor.js.map +0 -1
- package/dist/extraction/parse-worker.d.ts +0 -8
- package/dist/extraction/parse-worker.d.ts.map +0 -1
- package/dist/extraction/parse-worker.js +0 -94
- package/dist/extraction/parse-worker.js.map +0 -1
- package/dist/extraction/svelte-extractor.d.ts +0 -56
- package/dist/extraction/svelte-extractor.d.ts.map +0 -1
- package/dist/extraction/svelte-extractor.js +0 -272
- package/dist/extraction/svelte-extractor.js.map +0 -1
- package/dist/extraction/tree-sitter-helpers.d.ts +0 -28
- package/dist/extraction/tree-sitter-helpers.d.ts.map +0 -1
- package/dist/extraction/tree-sitter-helpers.js +0 -103
- package/dist/extraction/tree-sitter-helpers.js.map +0 -1
- package/dist/extraction/tree-sitter-types.d.ts +0 -179
- package/dist/extraction/tree-sitter-types.d.ts.map +0 -1
- package/dist/extraction/tree-sitter-types.js +0 -10
- package/dist/extraction/tree-sitter-types.js.map +0 -1
- package/dist/extraction/tree-sitter.d.ts +0 -233
- package/dist/extraction/tree-sitter.d.ts.map +0 -1
- package/dist/extraction/tree-sitter.js +0 -2393
- package/dist/extraction/tree-sitter.js.map +0 -1
- package/dist/extraction/vue-extractor.d.ts +0 -36
- package/dist/extraction/vue-extractor.d.ts.map +0 -1
- package/dist/extraction/vue-extractor.js +0 -163
- package/dist/extraction/vue-extractor.js.map +0 -1
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/dist/graph/index.d.ts +0 -8
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js +0 -13
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/queries.d.ts +0 -106
- package/dist/graph/queries.d.ts.map +0 -1
- package/dist/graph/queries.js +0 -366
- package/dist/graph/queries.js.map +0 -1
- package/dist/graph/traversal.d.ts +0 -127
- package/dist/graph/traversal.d.ts.map +0 -1
- package/dist/graph/traversal.js +0 -493
- package/dist/graph/traversal.js.map +0 -1
- package/dist/index.d.ts +0 -447
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -825
- package/dist/index.js.map +0 -1
- package/dist/installer/claude-md-template.d.ts +0 -14
- package/dist/installer/claude-md-template.d.ts.map +0 -1
- package/dist/installer/claude-md-template.js +0 -21
- package/dist/installer/claude-md-template.js.map +0 -1
- package/dist/installer/config-writer.d.ts +0 -29
- package/dist/installer/config-writer.d.ts.map +0 -1
- package/dist/installer/config-writer.js +0 -111
- package/dist/installer/config-writer.js.map +0 -1
- package/dist/installer/index.d.ts +0 -65
- package/dist/installer/index.d.ts.map +0 -1
- package/dist/installer/index.js +0 -406
- package/dist/installer/index.js.map +0 -1
- package/dist/installer/instructions-template.d.ts +0 -28
- package/dist/installer/instructions-template.d.ts.map +0 -1
- package/dist/installer/instructions-template.js +0 -64
- package/dist/installer/instructions-template.js.map +0 -1
- package/dist/installer/targets/claude.d.ts +0 -31
- package/dist/installer/targets/claude.d.ts.map +0 -1
- package/dist/installer/targets/claude.js +0 -308
- package/dist/installer/targets/claude.js.map +0 -1
- package/dist/installer/targets/codex.d.ts +0 -18
- package/dist/installer/targets/codex.d.ts.map +0 -1
- package/dist/installer/targets/codex.js +0 -185
- package/dist/installer/targets/codex.js.map +0 -1
- package/dist/installer/targets/cursor.d.ts +0 -35
- package/dist/installer/targets/cursor.d.ts.map +0 -1
- package/dist/installer/targets/cursor.js +0 -229
- package/dist/installer/targets/cursor.js.map +0 -1
- package/dist/installer/targets/opencode.d.ts +0 -30
- package/dist/installer/targets/opencode.d.ts.map +0 -1
- package/dist/installer/targets/opencode.js +0 -235
- package/dist/installer/targets/opencode.js.map +0 -1
- package/dist/installer/targets/registry.d.ts +0 -35
- package/dist/installer/targets/registry.d.ts.map +0 -1
- package/dist/installer/targets/registry.js +0 -83
- package/dist/installer/targets/registry.js.map +0 -1
- package/dist/installer/targets/shared.d.ts +0 -77
- package/dist/installer/targets/shared.d.ts.map +0 -1
- package/dist/installer/targets/shared.js +0 -246
- package/dist/installer/targets/shared.js.map +0 -1
- package/dist/installer/targets/toml.d.ts +0 -52
- package/dist/installer/targets/toml.d.ts.map +0 -1
- package/dist/installer/targets/toml.js +0 -147
- package/dist/installer/targets/toml.js.map +0 -1
- package/dist/installer/targets/types.d.ts +0 -116
- package/dist/installer/targets/types.d.ts.map +0 -1
- package/dist/installer/targets/types.js +0 -16
- package/dist/installer/targets/types.js.map +0 -1
- package/dist/mcp/index.d.ts +0 -94
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js +0 -453
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/server-instructions.d.ts +0 -19
- package/dist/mcp/server-instructions.d.ts.map +0 -1
- package/dist/mcp/server-instructions.js +0 -71
- package/dist/mcp/server-instructions.js.map +0 -1
- package/dist/mcp/tools.d.ts +0 -257
- package/dist/mcp/tools.d.ts.map +0 -1
- package/dist/mcp/tools.js +0 -1633
- package/dist/mcp/tools.js.map +0 -1
- package/dist/mcp/transport.d.ts +0 -106
- package/dist/mcp/transport.d.ts.map +0 -1
- package/dist/mcp/transport.js +0 -233
- package/dist/mcp/transport.js.map +0 -1
- package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -18
- package/dist/resolution/frameworks/cargo-workspace.d.ts.map +0 -1
- package/dist/resolution/frameworks/cargo-workspace.js +0 -225
- package/dist/resolution/frameworks/cargo-workspace.js.map +0 -1
- package/dist/resolution/frameworks/csharp.d.ts +0 -8
- package/dist/resolution/frameworks/csharp.d.ts.map +0 -1
- package/dist/resolution/frameworks/csharp.js +0 -213
- package/dist/resolution/frameworks/csharp.js.map +0 -1
- package/dist/resolution/frameworks/express.d.ts +0 -8
- package/dist/resolution/frameworks/express.d.ts.map +0 -1
- package/dist/resolution/frameworks/express.js +0 -225
- package/dist/resolution/frameworks/express.js.map +0 -1
- package/dist/resolution/frameworks/go.d.ts +0 -8
- package/dist/resolution/frameworks/go.d.ts.map +0 -1
- package/dist/resolution/frameworks/go.js +0 -158
- package/dist/resolution/frameworks/go.js.map +0 -1
- package/dist/resolution/frameworks/index.d.ts +0 -42
- package/dist/resolution/frameworks/index.d.ts.map +0 -1
- package/dist/resolution/frameworks/index.js +0 -133
- package/dist/resolution/frameworks/index.js.map +0 -1
- package/dist/resolution/frameworks/java.d.ts +0 -8
- package/dist/resolution/frameworks/java.d.ts.map +0 -1
- package/dist/resolution/frameworks/java.js +0 -177
- package/dist/resolution/frameworks/java.js.map +0 -1
- package/dist/resolution/frameworks/laravel.d.ts +0 -13
- package/dist/resolution/frameworks/laravel.d.ts.map +0 -1
- package/dist/resolution/frameworks/laravel.js +0 -248
- package/dist/resolution/frameworks/laravel.js.map +0 -1
- package/dist/resolution/frameworks/nestjs.d.ts +0 -26
- package/dist/resolution/frameworks/nestjs.d.ts.map +0 -1
- package/dist/resolution/frameworks/nestjs.js +0 -374
- package/dist/resolution/frameworks/nestjs.js.map +0 -1
- package/dist/resolution/frameworks/python.d.ts +0 -10
- package/dist/resolution/frameworks/python.d.ts.map +0 -1
- package/dist/resolution/frameworks/python.js +0 -278
- package/dist/resolution/frameworks/python.js.map +0 -1
- package/dist/resolution/frameworks/react.d.ts +0 -8
- package/dist/resolution/frameworks/react.d.ts.map +0 -1
- package/dist/resolution/frameworks/react.js +0 -272
- package/dist/resolution/frameworks/react.js.map +0 -1
- package/dist/resolution/frameworks/ruby.d.ts +0 -8
- package/dist/resolution/frameworks/ruby.d.ts.map +0 -1
- package/dist/resolution/frameworks/ruby.js +0 -198
- package/dist/resolution/frameworks/ruby.js.map +0 -1
- package/dist/resolution/frameworks/rust.d.ts +0 -8
- package/dist/resolution/frameworks/rust.d.ts.map +0 -1
- package/dist/resolution/frameworks/rust.js +0 -207
- package/dist/resolution/frameworks/rust.js.map +0 -1
- package/dist/resolution/frameworks/svelte.d.ts +0 -9
- package/dist/resolution/frameworks/svelte.d.ts.map +0 -1
- package/dist/resolution/frameworks/svelte.js +0 -249
- package/dist/resolution/frameworks/svelte.js.map +0 -1
- package/dist/resolution/frameworks/swift.d.ts +0 -10
- package/dist/resolution/frameworks/swift.d.ts.map +0 -1
- package/dist/resolution/frameworks/swift.js +0 -376
- package/dist/resolution/frameworks/swift.js.map +0 -1
- package/dist/resolution/frameworks/vue.d.ts +0 -9
- package/dist/resolution/frameworks/vue.d.ts.map +0 -1
- package/dist/resolution/frameworks/vue.js +0 -306
- package/dist/resolution/frameworks/vue.js.map +0 -1
- package/dist/resolution/import-resolver.d.ts +0 -40
- package/dist/resolution/import-resolver.d.ts.map +0 -1
- package/dist/resolution/import-resolver.js +0 -663
- package/dist/resolution/import-resolver.js.map +0 -1
- package/dist/resolution/index.d.ts +0 -106
- package/dist/resolution/index.d.ts.map +0 -1
- package/dist/resolution/index.js +0 -709
- package/dist/resolution/index.js.map +0 -1
- package/dist/resolution/name-matcher.d.ts +0 -32
- package/dist/resolution/name-matcher.d.ts.map +0 -1
- package/dist/resolution/name-matcher.js +0 -384
- package/dist/resolution/name-matcher.js.map +0 -1
- package/dist/resolution/path-aliases.d.ts +0 -68
- package/dist/resolution/path-aliases.d.ts.map +0 -1
- package/dist/resolution/path-aliases.js +0 -238
- package/dist/resolution/path-aliases.js.map +0 -1
- package/dist/resolution/strip-comments.d.ts +0 -27
- package/dist/resolution/strip-comments.d.ts.map +0 -1
- package/dist/resolution/strip-comments.js +0 -441
- package/dist/resolution/strip-comments.js.map +0 -1
- package/dist/resolution/types.d.ts +0 -172
- package/dist/resolution/types.d.ts.map +0 -1
- package/dist/resolution/types.js +0 -8
- package/dist/resolution/types.js.map +0 -1
- package/dist/search/query-parser.d.ts +0 -57
- package/dist/search/query-parser.d.ts.map +0 -1
- package/dist/search/query-parser.js +0 -177
- package/dist/search/query-parser.js.map +0 -1
- package/dist/search/query-utils.d.ts +0 -53
- package/dist/search/query-utils.d.ts.map +0 -1
- package/dist/search/query-utils.js +0 -350
- package/dist/search/query-utils.js.map +0 -1
- package/dist/sync/git-hooks.d.ts +0 -45
- package/dist/sync/git-hooks.d.ts.map +0 -1
- package/dist/sync/git-hooks.js +0 -223
- package/dist/sync/git-hooks.js.map +0 -1
- package/dist/sync/index.d.ts +0 -17
- package/dist/sync/index.d.ts.map +0 -1
- package/dist/sync/index.js +0 -28
- package/dist/sync/index.js.map +0 -1
- package/dist/sync/watch-policy.d.ts +0 -48
- package/dist/sync/watch-policy.d.ts.map +0 -1
- package/dist/sync/watch-policy.js +0 -124
- package/dist/sync/watch-policy.js.map +0 -1
- package/dist/sync/watcher.d.ts +0 -81
- package/dist/sync/watcher.d.ts.map +0 -1
- package/dist/sync/watcher.js +0 -194
- package/dist/sync/watcher.js.map +0 -1
- package/dist/types.d.ts +0 -423
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -256
- package/dist/types.js.map +0 -1
- package/dist/ui/glyphs.d.ts +0 -42
- package/dist/ui/glyphs.d.ts.map +0 -1
- package/dist/ui/glyphs.js +0 -78
- package/dist/ui/glyphs.js.map +0 -1
- package/dist/ui/shimmer-progress.d.ts +0 -11
- package/dist/ui/shimmer-progress.d.ts.map +0 -1
- package/dist/ui/shimmer-progress.js +0 -90
- package/dist/ui/shimmer-progress.js.map +0 -1
- package/dist/ui/shimmer-worker.d.ts +0 -2
- package/dist/ui/shimmer-worker.d.ts.map +0 -1
- package/dist/ui/shimmer-worker.js +0 -118
- package/dist/ui/shimmer-worker.js.map +0 -1
- package/dist/ui/types.d.ts +0 -17
- package/dist/ui/types.d.ts.map +0 -1
- package/dist/ui/types.js +0 -3
- package/dist/ui/types.js.map +0 -1
- package/dist/utils.d.ts +0 -205
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -549
- package/dist/utils.js.map +0 -1
- package/scripts/agent-eval/audit.sh +0 -68
- package/scripts/agent-eval/itrun.sh +0 -107
- package/scripts/agent-eval/parse-run.mjs +0 -45
- package/scripts/agent-eval/parse-session.mjs +0 -93
- package/scripts/agent-eval/run-agent.sh +0 -34
- package/scripts/agent-eval/run-all.sh +0 -67
- package/scripts/extract-release-notes.mjs +0 -130
- package/scripts/local-install.sh +0 -41
- package/scripts/patch-tree-sitter-dart.js +0 -112
- package/scripts/release.sh +0 -68
|
@@ -1,663 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Import Resolver
|
|
4
|
-
*
|
|
5
|
-
* Resolves import paths to actual files and symbols.
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.resolveImportPath = resolveImportPath;
|
|
42
|
-
exports.extractImportMappings = extractImportMappings;
|
|
43
|
-
exports.clearImportMappingCache = clearImportMappingCache;
|
|
44
|
-
exports.extractReExports = extractReExports;
|
|
45
|
-
exports.resolveViaImport = resolveViaImport;
|
|
46
|
-
const path = __importStar(require("path"));
|
|
47
|
-
const path_aliases_1 = require("./path-aliases");
|
|
48
|
-
/**
|
|
49
|
-
* Extension resolution order by language
|
|
50
|
-
*/
|
|
51
|
-
const EXTENSION_RESOLUTION = {
|
|
52
|
-
typescript: ['.ts', '.tsx', '.d.ts', '.js', '.jsx', '/index.ts', '/index.tsx', '/index.js'],
|
|
53
|
-
javascript: ['.js', '.jsx', '.mjs', '.cjs', '/index.js', '/index.jsx'],
|
|
54
|
-
tsx: ['.tsx', '.ts', '.d.ts', '.js', '.jsx', '/index.tsx', '/index.ts', '/index.js'],
|
|
55
|
-
jsx: ['.jsx', '.js', '/index.jsx', '/index.js'],
|
|
56
|
-
python: ['.py', '/__init__.py'],
|
|
57
|
-
go: ['.go'],
|
|
58
|
-
rust: ['.rs', '/mod.rs'],
|
|
59
|
-
java: ['.java'],
|
|
60
|
-
csharp: ['.cs'],
|
|
61
|
-
php: ['.php'],
|
|
62
|
-
ruby: ['.rb'],
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Resolve an import path to an actual file
|
|
66
|
-
*/
|
|
67
|
-
function resolveImportPath(importPath, fromFile, language, context) {
|
|
68
|
-
// Skip external/npm packages — but pass the context so the
|
|
69
|
-
// bare-specifier heuristic can consult the project's tsconfig
|
|
70
|
-
// alias map first (custom prefixes like `@components/*` would
|
|
71
|
-
// otherwise be misclassified as npm).
|
|
72
|
-
if (isExternalImport(importPath, language, context)) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
const projectRoot = context.getProjectRoot();
|
|
76
|
-
const fromDir = path.dirname(path.join(projectRoot, fromFile));
|
|
77
|
-
// Handle relative imports
|
|
78
|
-
if (importPath.startsWith('.')) {
|
|
79
|
-
return resolveRelativeImport(importPath, fromDir, language, context);
|
|
80
|
-
}
|
|
81
|
-
// Handle absolute/aliased imports (like @/ or src/)
|
|
82
|
-
return resolveAliasedImport(importPath, projectRoot, language, context);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Check if an import is external (npm package, etc.)
|
|
86
|
-
*
|
|
87
|
-
* `context` is consulted for project-defined path aliases
|
|
88
|
-
* (tsconfig/jsconfig `paths`). Without that check, custom prefixes
|
|
89
|
-
* like `@components/*` would fail the bare-specifier heuristic and
|
|
90
|
-
* be classified as external before alias resolution can run.
|
|
91
|
-
*/
|
|
92
|
-
function isExternalImport(importPath, language, context) {
|
|
93
|
-
// Relative imports are not external
|
|
94
|
-
if (importPath.startsWith('.')) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
// Common external patterns
|
|
98
|
-
if (language === 'typescript' || language === 'javascript' || language === 'tsx' || language === 'jsx') {
|
|
99
|
-
// Node built-ins
|
|
100
|
-
if (['fs', 'path', 'os', 'crypto', 'http', 'https', 'url', 'util', 'events', 'stream', 'child_process', 'buffer'].includes(importPath)) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
// Project-defined alias prefix? Treat as local.
|
|
104
|
-
const aliases = context?.getProjectAliases?.();
|
|
105
|
-
if (aliases) {
|
|
106
|
-
for (const pat of aliases.patterns) {
|
|
107
|
-
if (importPath.startsWith(pat.prefix))
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
// Scoped packages or bare specifiers that don't start with aliases
|
|
112
|
-
if (!importPath.startsWith('@/') && !importPath.startsWith('~/') && !importPath.startsWith('src/')) {
|
|
113
|
-
// Likely an npm package
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (language === 'python') {
|
|
118
|
-
// Standard library modules
|
|
119
|
-
const stdLibs = ['os', 'sys', 'json', 're', 'math', 'datetime', 'collections', 'typing', 'pathlib', 'logging'];
|
|
120
|
-
if (stdLibs.includes(importPath.split('.')[0])) {
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (language === 'go') {
|
|
125
|
-
// Standard library or external packages
|
|
126
|
-
if (!importPath.startsWith('.') && !importPath.includes('/internal/')) {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Resolve a relative import
|
|
134
|
-
*/
|
|
135
|
-
function resolveRelativeImport(importPath, fromDir, language, context) {
|
|
136
|
-
const projectRoot = context.getProjectRoot();
|
|
137
|
-
const extensions = EXTENSION_RESOLUTION[language] || [];
|
|
138
|
-
// Try the path as-is first
|
|
139
|
-
const basePath = path.resolve(fromDir, importPath);
|
|
140
|
-
const relativePath = path.relative(projectRoot, basePath).replace(/\\/g, '/');
|
|
141
|
-
// Try each extension
|
|
142
|
-
for (const ext of extensions) {
|
|
143
|
-
const candidatePath = relativePath + ext;
|
|
144
|
-
if (context.fileExists(candidatePath)) {
|
|
145
|
-
return candidatePath;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// Try without extension (might already have one)
|
|
149
|
-
if (context.fileExists(relativePath)) {
|
|
150
|
-
return relativePath;
|
|
151
|
-
}
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Resolve an aliased/absolute import.
|
|
156
|
-
*
|
|
157
|
-
* Tries, in order:
|
|
158
|
-
* 1. Project-defined `compilerOptions.paths` (tsconfig/jsconfig).
|
|
159
|
-
* Each pattern can have multiple replacements; tried in tsconfig
|
|
160
|
-
* priority order with extension permutations.
|
|
161
|
-
* 2. The legacy hard-coded fallback list (`@/`, `~/`, `src/`, ...)
|
|
162
|
-
* for projects that have aliases but no tsconfig paths block.
|
|
163
|
-
* 3. Direct path lookup (with extensions).
|
|
164
|
-
*/
|
|
165
|
-
function resolveAliasedImport(importPath, projectRoot, language, context) {
|
|
166
|
-
const extensions = EXTENSION_RESOLUTION[language] || [];
|
|
167
|
-
const tryWithExt = (basePath) => {
|
|
168
|
-
for (const ext of extensions) {
|
|
169
|
-
const candidate = basePath + ext;
|
|
170
|
-
if (context.fileExists(candidate))
|
|
171
|
-
return candidate;
|
|
172
|
-
}
|
|
173
|
-
if (context.fileExists(basePath))
|
|
174
|
-
return basePath;
|
|
175
|
-
return null;
|
|
176
|
-
};
|
|
177
|
-
// 1. Project tsconfig/jsconfig paths.
|
|
178
|
-
const aliasMap = context.getProjectAliases?.();
|
|
179
|
-
if (aliasMap) {
|
|
180
|
-
const candidates = (0, path_aliases_1.applyAliases)(importPath, aliasMap, projectRoot);
|
|
181
|
-
for (const c of candidates) {
|
|
182
|
-
const hit = tryWithExt(c);
|
|
183
|
-
if (hit)
|
|
184
|
-
return hit;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// 2. Hard-coded fallback list. Kept for projects that use these
|
|
188
|
-
// conventional aliases without declaring them in tsconfig.
|
|
189
|
-
const fallbackAliases = {
|
|
190
|
-
'@/': 'src/',
|
|
191
|
-
'~/': 'src/',
|
|
192
|
-
'@src/': 'src/',
|
|
193
|
-
'src/': 'src/',
|
|
194
|
-
'@app/': 'app/',
|
|
195
|
-
'app/': 'app/',
|
|
196
|
-
};
|
|
197
|
-
for (const [alias, replacement] of Object.entries(fallbackAliases)) {
|
|
198
|
-
if (importPath.startsWith(alias)) {
|
|
199
|
-
const hit = tryWithExt(importPath.replace(alias, replacement));
|
|
200
|
-
if (hit)
|
|
201
|
-
return hit;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
// 3. Direct path.
|
|
205
|
-
return tryWithExt(importPath);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Extract import mappings from a file
|
|
209
|
-
*/
|
|
210
|
-
function extractImportMappings(_filePath, content, language) {
|
|
211
|
-
const mappings = [];
|
|
212
|
-
if (language === 'typescript' || language === 'javascript' || language === 'tsx' || language === 'jsx') {
|
|
213
|
-
mappings.push(...extractJSImports(content));
|
|
214
|
-
}
|
|
215
|
-
else if (language === 'python') {
|
|
216
|
-
mappings.push(...extractPythonImports(content));
|
|
217
|
-
}
|
|
218
|
-
else if (language === 'go') {
|
|
219
|
-
mappings.push(...extractGoImports(content));
|
|
220
|
-
}
|
|
221
|
-
else if (language === 'php') {
|
|
222
|
-
mappings.push(...extractPHPImports(content));
|
|
223
|
-
}
|
|
224
|
-
return mappings;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Extract JS/TS import mappings
|
|
228
|
-
*/
|
|
229
|
-
function extractJSImports(content) {
|
|
230
|
-
const mappings = [];
|
|
231
|
-
// ES6 imports
|
|
232
|
-
const importRegex = /import\s+(?:(\w+)\s*,?\s*)?(?:\{([^}]+)\})?\s*(?:(\*)\s+as\s+(\w+))?\s*from\s*['"]([^'"]+)['"]/g;
|
|
233
|
-
let match;
|
|
234
|
-
while ((match = importRegex.exec(content)) !== null) {
|
|
235
|
-
const [, defaultImport, namedImports, star, namespaceAlias, source] = match;
|
|
236
|
-
// Default import
|
|
237
|
-
if (defaultImport) {
|
|
238
|
-
mappings.push({
|
|
239
|
-
localName: defaultImport,
|
|
240
|
-
exportedName: 'default',
|
|
241
|
-
source: source,
|
|
242
|
-
isDefault: true,
|
|
243
|
-
isNamespace: false,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
// Named imports
|
|
247
|
-
if (namedImports) {
|
|
248
|
-
const names = namedImports.split(',').map((s) => s.trim());
|
|
249
|
-
for (const name of names) {
|
|
250
|
-
const aliasMatch = name.match(/(\w+)\s+as\s+(\w+)/);
|
|
251
|
-
if (aliasMatch) {
|
|
252
|
-
mappings.push({
|
|
253
|
-
localName: aliasMatch[2],
|
|
254
|
-
exportedName: aliasMatch[1],
|
|
255
|
-
source: source,
|
|
256
|
-
isDefault: false,
|
|
257
|
-
isNamespace: false,
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
else if (name) {
|
|
261
|
-
mappings.push({
|
|
262
|
-
localName: name,
|
|
263
|
-
exportedName: name,
|
|
264
|
-
source: source,
|
|
265
|
-
isDefault: false,
|
|
266
|
-
isNamespace: false,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
// Namespace import
|
|
272
|
-
if (star && namespaceAlias) {
|
|
273
|
-
mappings.push({
|
|
274
|
-
localName: namespaceAlias,
|
|
275
|
-
exportedName: '*',
|
|
276
|
-
source: source,
|
|
277
|
-
isDefault: false,
|
|
278
|
-
isNamespace: true,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
// Require statements
|
|
283
|
-
const requireRegex = /(?:const|let|var)\s+(?:(\w+)|{([^}]+)})\s*=\s*require\(['"]([^'"]+)['"]\)/g;
|
|
284
|
-
while ((match = requireRegex.exec(content)) !== null) {
|
|
285
|
-
const [, defaultName, destructured, source] = match;
|
|
286
|
-
if (defaultName) {
|
|
287
|
-
mappings.push({
|
|
288
|
-
localName: defaultName,
|
|
289
|
-
exportedName: 'default',
|
|
290
|
-
source: source,
|
|
291
|
-
isDefault: true,
|
|
292
|
-
isNamespace: false,
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
if (destructured) {
|
|
296
|
-
const names = destructured.split(',').map((s) => s.trim());
|
|
297
|
-
for (const name of names) {
|
|
298
|
-
const aliasMatch = name.match(/(\w+)\s*:\s*(\w+)/);
|
|
299
|
-
if (aliasMatch) {
|
|
300
|
-
mappings.push({
|
|
301
|
-
localName: aliasMatch[2],
|
|
302
|
-
exportedName: aliasMatch[1],
|
|
303
|
-
source: source,
|
|
304
|
-
isDefault: false,
|
|
305
|
-
isNamespace: false,
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
else if (name) {
|
|
309
|
-
mappings.push({
|
|
310
|
-
localName: name,
|
|
311
|
-
exportedName: name,
|
|
312
|
-
source: source,
|
|
313
|
-
isDefault: false,
|
|
314
|
-
isNamespace: false,
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return mappings;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Extract Python import mappings
|
|
324
|
-
*/
|
|
325
|
-
function extractPythonImports(content) {
|
|
326
|
-
const mappings = [];
|
|
327
|
-
// from X import Y
|
|
328
|
-
const fromImportRegex = /from\s+([\w.]+)\s+import\s+([^#\n]+)/g;
|
|
329
|
-
let match;
|
|
330
|
-
while ((match = fromImportRegex.exec(content)) !== null) {
|
|
331
|
-
const [, source, imports] = match;
|
|
332
|
-
const names = imports.split(',').map((s) => s.trim());
|
|
333
|
-
for (const name of names) {
|
|
334
|
-
const aliasMatch = name.match(/(\w+)\s+as\s+(\w+)/);
|
|
335
|
-
if (aliasMatch) {
|
|
336
|
-
mappings.push({
|
|
337
|
-
localName: aliasMatch[2],
|
|
338
|
-
exportedName: aliasMatch[1],
|
|
339
|
-
source: source,
|
|
340
|
-
isDefault: false,
|
|
341
|
-
isNamespace: false,
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
else if (name && name !== '*') {
|
|
345
|
-
mappings.push({
|
|
346
|
-
localName: name,
|
|
347
|
-
exportedName: name,
|
|
348
|
-
source: source,
|
|
349
|
-
isDefault: false,
|
|
350
|
-
isNamespace: false,
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
// import X
|
|
356
|
-
const importRegex = /^import\s+([\w.]+)(?:\s+as\s+(\w+))?/gm;
|
|
357
|
-
while ((match = importRegex.exec(content)) !== null) {
|
|
358
|
-
const [, source, alias] = match;
|
|
359
|
-
const localName = alias || source.split('.').pop();
|
|
360
|
-
mappings.push({
|
|
361
|
-
localName,
|
|
362
|
-
exportedName: '*',
|
|
363
|
-
source: source,
|
|
364
|
-
isDefault: false,
|
|
365
|
-
isNamespace: true,
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
return mappings;
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Extract Go import mappings
|
|
372
|
-
*/
|
|
373
|
-
function extractGoImports(content) {
|
|
374
|
-
const mappings = [];
|
|
375
|
-
// import "path" or import alias "path"
|
|
376
|
-
const singleImportRegex = /import\s+(?:(\w+)\s+)?["']([^"']+)["']/g;
|
|
377
|
-
let match;
|
|
378
|
-
while ((match = singleImportRegex.exec(content)) !== null) {
|
|
379
|
-
const [, alias, source] = match;
|
|
380
|
-
const packageName = source.split('/').pop();
|
|
381
|
-
mappings.push({
|
|
382
|
-
localName: alias || packageName,
|
|
383
|
-
exportedName: '*',
|
|
384
|
-
source: source,
|
|
385
|
-
isDefault: false,
|
|
386
|
-
isNamespace: true,
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
// import ( ... ) block
|
|
390
|
-
const blockImportRegex = /import\s*\(\s*([^)]+)\s*\)/gs;
|
|
391
|
-
while ((match = blockImportRegex.exec(content)) !== null) {
|
|
392
|
-
const block = match[1];
|
|
393
|
-
const lineRegex = /(?:(\w+)\s+)?["']([^"']+)["']/g;
|
|
394
|
-
let lineMatch;
|
|
395
|
-
while ((lineMatch = lineRegex.exec(block)) !== null) {
|
|
396
|
-
const [, alias, source] = lineMatch;
|
|
397
|
-
const packageName = source.split('/').pop();
|
|
398
|
-
mappings.push({
|
|
399
|
-
localName: alias || packageName,
|
|
400
|
-
exportedName: '*',
|
|
401
|
-
source: source,
|
|
402
|
-
isDefault: false,
|
|
403
|
-
isNamespace: true,
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return mappings;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Extract PHP import mappings (use statements)
|
|
411
|
-
*/
|
|
412
|
-
function extractPHPImports(content) {
|
|
413
|
-
const mappings = [];
|
|
414
|
-
// use Namespace\Class; or use Namespace\Class as Alias;
|
|
415
|
-
const useRegex = /use\s+([\w\\]+)(?:\s+as\s+(\w+))?;/g;
|
|
416
|
-
let match;
|
|
417
|
-
while ((match = useRegex.exec(content)) !== null) {
|
|
418
|
-
const [, fullPath, alias] = match;
|
|
419
|
-
const className = fullPath.split('\\').pop();
|
|
420
|
-
mappings.push({
|
|
421
|
-
localName: alias || className,
|
|
422
|
-
exportedName: className,
|
|
423
|
-
source: fullPath,
|
|
424
|
-
isDefault: false,
|
|
425
|
-
isNamespace: false,
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
return mappings;
|
|
429
|
-
}
|
|
430
|
-
// Cache import mappings per file to avoid re-reading and re-parsing
|
|
431
|
-
const importMappingCache = new Map();
|
|
432
|
-
/**
|
|
433
|
-
* Clear the import mapping cache (call between indexing runs)
|
|
434
|
-
*/
|
|
435
|
-
function clearImportMappingCache() {
|
|
436
|
-
importMappingCache.clear();
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Strip JS line + block comments from `content` while preserving
|
|
440
|
-
* string literals (so `"//"` inside a string stays intact). Used by
|
|
441
|
-
* {@link extractReExports} so commented-out export-from statements
|
|
442
|
-
* don't generate phantom re-export edges.
|
|
443
|
-
*
|
|
444
|
-
* Scanner is deliberately small: it only tracks the three contexts
|
|
445
|
-
* relevant for JS/TS — single-quote string, double-quote string, and
|
|
446
|
-
* template literal. Comment recognition is the JS spec subset, no
|
|
447
|
-
* regex-literal awareness (which is fine for our use case: we don't
|
|
448
|
-
* apply this to function bodies, only to top-level files).
|
|
449
|
-
*/
|
|
450
|
-
function stripJsComments(content) {
|
|
451
|
-
let out = '';
|
|
452
|
-
let i = 0;
|
|
453
|
-
let str = null;
|
|
454
|
-
while (i < content.length) {
|
|
455
|
-
const ch = content[i];
|
|
456
|
-
if (str !== null) {
|
|
457
|
-
out += ch;
|
|
458
|
-
if (ch === '\\' && i + 1 < content.length) {
|
|
459
|
-
out += content[i + 1];
|
|
460
|
-
i += 2;
|
|
461
|
-
continue;
|
|
462
|
-
}
|
|
463
|
-
if (ch === str)
|
|
464
|
-
str = null;
|
|
465
|
-
i++;
|
|
466
|
-
continue;
|
|
467
|
-
}
|
|
468
|
-
if (ch === '"' || ch === "'" || ch === '`') {
|
|
469
|
-
str = ch;
|
|
470
|
-
out += ch;
|
|
471
|
-
i++;
|
|
472
|
-
continue;
|
|
473
|
-
}
|
|
474
|
-
if (ch === '/' && content[i + 1] === '/') {
|
|
475
|
-
while (i < content.length && content[i] !== '\n')
|
|
476
|
-
i++;
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
|
-
if (ch === '/' && content[i + 1] === '*') {
|
|
480
|
-
i += 2;
|
|
481
|
-
while (i < content.length && !(content[i] === '*' && content[i + 1] === '/'))
|
|
482
|
-
i++;
|
|
483
|
-
i += 2;
|
|
484
|
-
continue;
|
|
485
|
-
}
|
|
486
|
-
out += ch;
|
|
487
|
-
i++;
|
|
488
|
-
}
|
|
489
|
-
return out;
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Extract JS/TS re-export declarations from `content`.
|
|
493
|
-
*
|
|
494
|
-
* Recognised forms:
|
|
495
|
-
* export { foo } from './a';
|
|
496
|
-
* export { foo as bar } from './a';
|
|
497
|
-
* export * from './a';
|
|
498
|
-
* export * as ns from './a'; (treated as wildcard for chasing)
|
|
499
|
-
* export { default as Foo } from './a';
|
|
500
|
-
*
|
|
501
|
-
* The walker intentionally stays regex-based — the import-resolver
|
|
502
|
-
* elsewhere in this file already chooses regex over a fresh
|
|
503
|
-
* tree-sitter pass, and this function shares that trade-off. Errors
|
|
504
|
-
* fall through silently; resolution simply skips the broken file.
|
|
505
|
-
*/
|
|
506
|
-
function extractReExports(content, language) {
|
|
507
|
-
if (language !== 'typescript' &&
|
|
508
|
-
language !== 'javascript' &&
|
|
509
|
-
language !== 'tsx' &&
|
|
510
|
-
language !== 'jsx') {
|
|
511
|
-
return [];
|
|
512
|
-
}
|
|
513
|
-
const out = [];
|
|
514
|
-
// Pre-strip block comments + line comments so a commented-out
|
|
515
|
-
// `// export { x } from '...'` doesn't produce a phantom edge.
|
|
516
|
-
// (Template literals are still a possible source of false positives;
|
|
517
|
-
// a project that builds export statements as runtime strings is
|
|
518
|
-
// out of scope.)
|
|
519
|
-
const cleaned = stripJsComments(content);
|
|
520
|
-
// Wildcard: `export * from '...'` or `export * as ns from '...'`
|
|
521
|
-
const wildcardRe = /export\s*\*(?:\s+as\s+\w+)?\s*from\s*['"]([^'"]+)['"]/g;
|
|
522
|
-
let m;
|
|
523
|
-
while ((m = wildcardRe.exec(cleaned)) !== null) {
|
|
524
|
-
out.push({ kind: 'wildcard', source: m[1] });
|
|
525
|
-
}
|
|
526
|
-
// Named: `export { a, b as c } from '...'`
|
|
527
|
-
const namedRe = /export\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g;
|
|
528
|
-
while ((m = namedRe.exec(cleaned)) !== null) {
|
|
529
|
-
const inner = m[1];
|
|
530
|
-
const source = m[2];
|
|
531
|
-
for (const raw of inner.split(',')) {
|
|
532
|
-
const item = raw.trim();
|
|
533
|
-
if (!item)
|
|
534
|
-
continue;
|
|
535
|
-
const aliasMatch = item.match(/^(\w+)\s+as\s+(\w+)$/);
|
|
536
|
-
if (aliasMatch) {
|
|
537
|
-
out.push({
|
|
538
|
-
kind: 'named',
|
|
539
|
-
exportedName: aliasMatch[2],
|
|
540
|
-
originalName: aliasMatch[1],
|
|
541
|
-
source,
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
else if (/^\w+$/.test(item)) {
|
|
545
|
-
out.push({
|
|
546
|
-
kind: 'named',
|
|
547
|
-
exportedName: item,
|
|
548
|
-
originalName: item,
|
|
549
|
-
source,
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
return out;
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Resolve a reference using import mappings
|
|
558
|
-
*/
|
|
559
|
-
function resolveViaImport(ref, context) {
|
|
560
|
-
// Use cached import mappings (avoids re-reading and re-parsing per ref)
|
|
561
|
-
const imports = context.getImportMappings(ref.filePath, ref.language);
|
|
562
|
-
if (imports.length === 0 && !context.readFile(ref.filePath)) {
|
|
563
|
-
return null;
|
|
564
|
-
}
|
|
565
|
-
// Check if the reference name matches any import
|
|
566
|
-
for (const imp of imports) {
|
|
567
|
-
if (imp.localName === ref.referenceName || ref.referenceName.startsWith(imp.localName + '.')) {
|
|
568
|
-
// Resolve the import path
|
|
569
|
-
const resolvedPath = resolveImportPath(imp.source, ref.filePath, ref.language, context);
|
|
570
|
-
if (resolvedPath) {
|
|
571
|
-
const exportedName = imp.isDefault ? 'default' : imp.exportedName;
|
|
572
|
-
const memberName = imp.isNamespace
|
|
573
|
-
? ref.referenceName.replace(imp.localName + '.', '')
|
|
574
|
-
: null;
|
|
575
|
-
const targetNode = findExportedSymbol(resolvedPath, { isDefault: imp.isDefault, isNamespace: imp.isNamespace, exportedName, memberName }, ref.language, context, new Set());
|
|
576
|
-
if (targetNode) {
|
|
577
|
-
return {
|
|
578
|
-
original: ref,
|
|
579
|
-
targetNodeId: targetNode.id,
|
|
580
|
-
confidence: 0.9,
|
|
581
|
-
resolvedBy: 'import',
|
|
582
|
-
};
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
return null;
|
|
588
|
-
}
|
|
589
|
-
/** Recursive depth cap for re-export chain following. Real codebases
|
|
590
|
-
* rarely chain barrels more than 2–3 deep; 8 is a generous safety
|
|
591
|
-
* net that still bounds worst-case work. */
|
|
592
|
-
const REEXPORT_MAX_DEPTH = 8;
|
|
593
|
-
/**
|
|
594
|
-
* Find an exported symbol in `filePath`, following `export { x } from
|
|
595
|
-
* './other'` and `export * from './other'` chains until the original
|
|
596
|
-
* declaration is reached. Cycle-safe via the `visited` set.
|
|
597
|
-
*
|
|
598
|
-
* Without this, every barrel-style import (`import { Foo } from
|
|
599
|
-
* './index'` where `index.ts` only re-exports) used to resolve to
|
|
600
|
-
* nothing — the existing code only looked for declarations IN the
|
|
601
|
-
* resolved file, not declarations the file forwarded.
|
|
602
|
-
*/
|
|
603
|
-
function findExportedSymbol(filePath, want, language, context, visited, depth = 0) {
|
|
604
|
-
if (depth > REEXPORT_MAX_DEPTH)
|
|
605
|
-
return undefined;
|
|
606
|
-
if (visited.has(filePath))
|
|
607
|
-
return undefined;
|
|
608
|
-
visited.add(filePath);
|
|
609
|
-
const nodesInFile = context.getNodesInFile(filePath);
|
|
610
|
-
// 1. Direct hit: the symbol is declared in this file.
|
|
611
|
-
if (want.isDefault) {
|
|
612
|
-
const direct = nodesInFile.find((n) => n.isExported && (n.kind === 'function' || n.kind === 'class'));
|
|
613
|
-
if (direct)
|
|
614
|
-
return direct;
|
|
615
|
-
}
|
|
616
|
-
else if (want.isNamespace && want.memberName) {
|
|
617
|
-
const direct = nodesInFile.find((n) => n.name === want.memberName && n.isExported);
|
|
618
|
-
if (direct)
|
|
619
|
-
return direct;
|
|
620
|
-
}
|
|
621
|
-
else {
|
|
622
|
-
const direct = nodesInFile.find((n) => n.name === want.exportedName && n.isExported);
|
|
623
|
-
if (direct)
|
|
624
|
-
return direct;
|
|
625
|
-
}
|
|
626
|
-
// 2. Re-export hit: the file forwards the symbol to another module.
|
|
627
|
-
const reExports = context.getReExports?.(filePath, language) ?? [];
|
|
628
|
-
if (reExports.length === 0)
|
|
629
|
-
return undefined;
|
|
630
|
-
// Look for explicit `export { want } from './other'` (with optional rename).
|
|
631
|
-
const targetName = want.isDefault ? 'default' : want.exportedName;
|
|
632
|
-
for (const rex of reExports) {
|
|
633
|
-
if (rex.kind === 'named' && rex.exportedName === targetName) {
|
|
634
|
-
const next = resolveImportPath(rex.source, filePath, language, context);
|
|
635
|
-
if (!next)
|
|
636
|
-
continue;
|
|
637
|
-
// After rename: `export { foo as bar } from './x'` — to chase
|
|
638
|
-
// `bar`, we look for `foo` in `./x`.
|
|
639
|
-
const chained = findExportedSymbol(next, {
|
|
640
|
-
isDefault: rex.originalName === 'default',
|
|
641
|
-
isNamespace: false,
|
|
642
|
-
exportedName: rex.originalName,
|
|
643
|
-
memberName: null,
|
|
644
|
-
}, language, context, visited, depth + 1);
|
|
645
|
-
if (chained)
|
|
646
|
-
return chained;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
// 3. Wildcard re-export: `export * from './other'` — try every
|
|
650
|
-
// forwarding source. This is the barrel-of-barrels case.
|
|
651
|
-
for (const rex of reExports) {
|
|
652
|
-
if (rex.kind === 'wildcard') {
|
|
653
|
-
const next = resolveImportPath(rex.source, filePath, language, context);
|
|
654
|
-
if (!next)
|
|
655
|
-
continue;
|
|
656
|
-
const chained = findExportedSymbol(next, want, language, context, visited, depth + 1);
|
|
657
|
-
if (chained)
|
|
658
|
-
return chained;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
return undefined;
|
|
662
|
-
}
|
|
663
|
-
//# sourceMappingURL=import-resolver.js.map
|