@codemap-ai/code-index 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/file-discovery.d.ts +36 -0
- package/dist/file-discovery.d.ts.map +1 -0
- package/dist/file-discovery.js +204 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/language-utils.d.ts +10 -0
- package/dist/language-utils.d.ts.map +1 -0
- package/dist/language-utils.js +75 -0
- package/dist/parsers/dart.d.ts +4 -0
- package/dist/parsers/dart.d.ts.map +1 -0
- package/dist/parsers/dart.js +353 -0
- package/dist/parsers/index.d.ts +11 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +32 -0
- package/dist/parsers/java.d.ts +4 -0
- package/dist/parsers/java.d.ts.map +1 -0
- package/dist/parsers/java.js +222 -0
- package/dist/parsers/kotlin.d.ts +4 -0
- package/dist/parsers/kotlin.d.ts.map +1 -0
- package/dist/parsers/kotlin.js +221 -0
- package/dist/parsers/php.d.ts +4 -0
- package/dist/parsers/php.d.ts.map +1 -0
- package/dist/parsers/php.js +215 -0
- package/dist/parsers/python.d.ts +4 -0
- package/dist/parsers/python.d.ts.map +1 -0
- package/dist/parsers/python.js +200 -0
- package/dist/parsers/shared.d.ts +30 -0
- package/dist/parsers/shared.d.ts.map +1 -0
- package/dist/parsers/shared.js +200 -0
- package/dist/parsers/types.d.ts +93 -0
- package/dist/parsers/types.d.ts.map +1 -0
- package/dist/parsers/types.js +12 -0
- package/dist/parsers/typescript.d.ts +5 -0
- package/dist/parsers/typescript.d.ts.map +1 -0
- package/dist/parsers/typescript.js +549 -0
- package/dist/ts-resolver.d.ts +17 -0
- package/dist/ts-resolver.d.ts.map +1 -0
- package/dist/ts-resolver.js +110 -0
- package/package.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 CodeMap
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type RepoFileParseStatus = "parsed" | "skipped" | "too_large" | "binary" | "unsupported" | "error";
|
|
2
|
+
export declare const IGNORED_NAMES: Set<string>;
|
|
3
|
+
export declare const MAX_PARSE_BYTES: number;
|
|
4
|
+
export declare const MAX_PARSE_BYTES_BY_LANGUAGE: Partial<Record<string, number>>;
|
|
5
|
+
export declare const PARSE_TOOL_NAME = "codemap-regex-parser";
|
|
6
|
+
export declare const PARSE_TOOL_VERSION = "0.1.0";
|
|
7
|
+
export interface WorkspaceFileCandidate {
|
|
8
|
+
path: string;
|
|
9
|
+
absolutePath: string;
|
|
10
|
+
dirPath: string;
|
|
11
|
+
baseName: string;
|
|
12
|
+
extension: string | null;
|
|
13
|
+
language: string | null;
|
|
14
|
+
mimeType: string | null;
|
|
15
|
+
sizeBytes: number;
|
|
16
|
+
contentSha256: string | null;
|
|
17
|
+
isText: boolean;
|
|
18
|
+
isBinary: boolean;
|
|
19
|
+
isGenerated: boolean;
|
|
20
|
+
isIgnored: boolean;
|
|
21
|
+
ignoreReason: string | null;
|
|
22
|
+
isParseable: boolean;
|
|
23
|
+
parseStatus: RepoFileParseStatus;
|
|
24
|
+
parserName: string | null;
|
|
25
|
+
parserVersion: string | null;
|
|
26
|
+
lineCount: number | null;
|
|
27
|
+
content: string | null;
|
|
28
|
+
}
|
|
29
|
+
export declare function normalizeRepositoryFilePath(input: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Collect a single file as a WorkspaceFileCandidate.
|
|
32
|
+
* Returns null if the file doesn't exist, is a symlink, or is in an ignored directory.
|
|
33
|
+
*/
|
|
34
|
+
export declare function collectSingleFile(relativePath: string, workspacePath: string): Promise<WorkspaceFileCandidate | null>;
|
|
35
|
+
export declare function collectWorkspaceFiles(workspacePath: string): Promise<WorkspaceFileCandidate[]>;
|
|
36
|
+
//# sourceMappingURL=file-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-discovery.d.ts","sourceRoot":"","sources":["../src/file-discovery.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,mBAAmB,GAC3B,QAAQ,GACR,SAAS,GACT,WAAW,GACX,QAAQ,GACR,aAAa,GACb,OAAO,CAAC;AAEZ,eAAO,MAAM,aAAa,aAUxB,CAAC;AAEH,eAAO,MAAM,eAAe,QAAkB,CAAC;AAC/C,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEvE,CAAC;AAEF,eAAO,MAAM,eAAe,yBAAyB,CAAC;AACtD,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,UASxD;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CA+ExC;AAED,wBAAsB,qBAAqB,CACzC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAgGnC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PARSE_TOOL_VERSION = exports.PARSE_TOOL_NAME = exports.MAX_PARSE_BYTES_BY_LANGUAGE = exports.MAX_PARSE_BYTES = exports.IGNORED_NAMES = void 0;
|
|
7
|
+
exports.normalizeRepositoryFilePath = normalizeRepositoryFilePath;
|
|
8
|
+
exports.collectSingleFile = collectSingleFile;
|
|
9
|
+
exports.collectWorkspaceFiles = collectWorkspaceFiles;
|
|
10
|
+
const promises_1 = require("node:fs/promises");
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const language_utils_js_1 = require("./language-utils.js");
|
|
13
|
+
exports.IGNORED_NAMES = new Set([
|
|
14
|
+
".git",
|
|
15
|
+
".codemap",
|
|
16
|
+
"node_modules",
|
|
17
|
+
"dist",
|
|
18
|
+
"build",
|
|
19
|
+
".next",
|
|
20
|
+
"coverage",
|
|
21
|
+
".turbo",
|
|
22
|
+
".cache",
|
|
23
|
+
]);
|
|
24
|
+
exports.MAX_PARSE_BYTES = 2 * 1024 * 1024;
|
|
25
|
+
exports.MAX_PARSE_BYTES_BY_LANGUAGE = {
|
|
26
|
+
Gettext: 10 * 1024 * 1024,
|
|
27
|
+
};
|
|
28
|
+
exports.PARSE_TOOL_NAME = "codemap-regex-parser";
|
|
29
|
+
exports.PARSE_TOOL_VERSION = "0.1.0";
|
|
30
|
+
function normalizeRepositoryFilePath(input) {
|
|
31
|
+
const normalizedPath = input.trim().replace(/\\/g, "/").replace(/^\/+/, "");
|
|
32
|
+
const resolvedPath = node_path_1.default.posix.normalize(normalizedPath);
|
|
33
|
+
if (!resolvedPath || resolvedPath === "." || resolvedPath.startsWith("../")) {
|
|
34
|
+
throw new Error("File path must stay within the repository root");
|
|
35
|
+
}
|
|
36
|
+
return resolvedPath;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Collect a single file as a WorkspaceFileCandidate.
|
|
40
|
+
* Returns null if the file doesn't exist, is a symlink, or is in an ignored directory.
|
|
41
|
+
*/
|
|
42
|
+
async function collectSingleFile(relativePath, workspacePath) {
|
|
43
|
+
const absolutePath = node_path_1.default.join(workspacePath, relativePath);
|
|
44
|
+
try {
|
|
45
|
+
const entryStats = await (0, promises_1.lstat)(absolutePath);
|
|
46
|
+
if (entryStats.isSymbolicLink() || !entryStats.isFile())
|
|
47
|
+
return null;
|
|
48
|
+
// Check if any parent directory is in IGNORED_NAMES
|
|
49
|
+
const parts = relativePath.split("/");
|
|
50
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
51
|
+
if (exports.IGNORED_NAMES.has(parts[i]))
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const name = node_path_1.default.basename(absolutePath);
|
|
55
|
+
const extension = (0, language_utils_js_1.normalizeExtension)(name);
|
|
56
|
+
const language = (0, language_utils_js_1.inferLanguage)(extension);
|
|
57
|
+
const mimeType = (0, language_utils_js_1.inferMimeType)(extension);
|
|
58
|
+
const sample = await (0, language_utils_js_1.readSampleBuffer)(absolutePath, entryStats.size);
|
|
59
|
+
const isBinary = (0, language_utils_js_1.isBinaryBuffer)(sample);
|
|
60
|
+
const isText = !isBinary;
|
|
61
|
+
const maxParseBytes = (language ? exports.MAX_PARSE_BYTES_BY_LANGUAGE[language] : undefined) ?? exports.MAX_PARSE_BYTES;
|
|
62
|
+
const isParseable = Boolean(language) && isText && entryStats.size <= maxParseBytes;
|
|
63
|
+
const normalizedPath = normalizeRepositoryFilePath(relativePath);
|
|
64
|
+
const dirPath = node_path_1.default.posix.dirname(normalizedPath) === "."
|
|
65
|
+
? ""
|
|
66
|
+
: node_path_1.default.posix.dirname(normalizedPath);
|
|
67
|
+
if (!isParseable) {
|
|
68
|
+
return {
|
|
69
|
+
path: normalizedPath,
|
|
70
|
+
absolutePath,
|
|
71
|
+
dirPath,
|
|
72
|
+
baseName: name,
|
|
73
|
+
extension,
|
|
74
|
+
language,
|
|
75
|
+
mimeType,
|
|
76
|
+
sizeBytes: entryStats.size,
|
|
77
|
+
contentSha256: null,
|
|
78
|
+
isText,
|
|
79
|
+
isBinary,
|
|
80
|
+
isGenerated: false,
|
|
81
|
+
isIgnored: false,
|
|
82
|
+
ignoreReason: null,
|
|
83
|
+
isParseable: false,
|
|
84
|
+
parseStatus: isBinary ? "binary" : entryStats.size > exports.MAX_PARSE_BYTES ? "too_large" : "unsupported",
|
|
85
|
+
parserName: null,
|
|
86
|
+
parserVersion: null,
|
|
87
|
+
lineCount: null,
|
|
88
|
+
content: null,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const content = await (0, promises_1.readFile)(absolutePath, "utf8");
|
|
92
|
+
return {
|
|
93
|
+
path: normalizedPath,
|
|
94
|
+
absolutePath,
|
|
95
|
+
dirPath,
|
|
96
|
+
baseName: name,
|
|
97
|
+
extension,
|
|
98
|
+
language,
|
|
99
|
+
mimeType,
|
|
100
|
+
sizeBytes: entryStats.size,
|
|
101
|
+
contentSha256: (0, language_utils_js_1.buildFileSha256)(content),
|
|
102
|
+
isText: true,
|
|
103
|
+
isBinary: false,
|
|
104
|
+
isGenerated: false,
|
|
105
|
+
isIgnored: false,
|
|
106
|
+
ignoreReason: null,
|
|
107
|
+
isParseable: true,
|
|
108
|
+
parseStatus: "parsed",
|
|
109
|
+
parserName: exports.PARSE_TOOL_NAME,
|
|
110
|
+
parserVersion: exports.PARSE_TOOL_VERSION,
|
|
111
|
+
lineCount: content.split(/\r?\n/).length,
|
|
112
|
+
content,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function collectWorkspaceFiles(workspacePath) {
|
|
120
|
+
const candidates = [];
|
|
121
|
+
async function visit(absolutePath) {
|
|
122
|
+
const entryStats = await (0, promises_1.lstat)(absolutePath);
|
|
123
|
+
if (entryStats.isSymbolicLink())
|
|
124
|
+
return;
|
|
125
|
+
const name = node_path_1.default.basename(absolutePath);
|
|
126
|
+
if (entryStats.isDirectory()) {
|
|
127
|
+
if (exports.IGNORED_NAMES.has(name))
|
|
128
|
+
return;
|
|
129
|
+
const entries = await (0, promises_1.readdir)(absolutePath, { withFileTypes: true });
|
|
130
|
+
for (const entry of entries) {
|
|
131
|
+
await visit(node_path_1.default.join(absolutePath, entry.name));
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (!entryStats.isFile())
|
|
136
|
+
return;
|
|
137
|
+
const relativePath = normalizeRepositoryFilePath(node_path_1.default.relative(workspacePath, absolutePath).split(node_path_1.default.sep).join("/"));
|
|
138
|
+
const extension = (0, language_utils_js_1.normalizeExtension)(name);
|
|
139
|
+
const language = (0, language_utils_js_1.inferLanguage)(extension);
|
|
140
|
+
const mimeType = (0, language_utils_js_1.inferMimeType)(extension);
|
|
141
|
+
const sample = await (0, language_utils_js_1.readSampleBuffer)(absolutePath, entryStats.size);
|
|
142
|
+
const isBinary = (0, language_utils_js_1.isBinaryBuffer)(sample);
|
|
143
|
+
const isText = !isBinary;
|
|
144
|
+
const maxParseBytes = (language ? exports.MAX_PARSE_BYTES_BY_LANGUAGE[language] : undefined) ?? exports.MAX_PARSE_BYTES;
|
|
145
|
+
const isParseable = Boolean(language) && isText && entryStats.size <= maxParseBytes;
|
|
146
|
+
const dirPath = node_path_1.default.posix.dirname(relativePath) === "."
|
|
147
|
+
? ""
|
|
148
|
+
: node_path_1.default.posix.dirname(relativePath);
|
|
149
|
+
if (!isParseable) {
|
|
150
|
+
candidates.push({
|
|
151
|
+
path: relativePath,
|
|
152
|
+
absolutePath,
|
|
153
|
+
dirPath,
|
|
154
|
+
baseName: name,
|
|
155
|
+
extension,
|
|
156
|
+
language,
|
|
157
|
+
mimeType,
|
|
158
|
+
sizeBytes: entryStats.size,
|
|
159
|
+
contentSha256: null,
|
|
160
|
+
isText,
|
|
161
|
+
isBinary,
|
|
162
|
+
isGenerated: false,
|
|
163
|
+
isIgnored: false,
|
|
164
|
+
ignoreReason: null,
|
|
165
|
+
isParseable: false,
|
|
166
|
+
parseStatus: isBinary
|
|
167
|
+
? "binary"
|
|
168
|
+
: entryStats.size > exports.MAX_PARSE_BYTES
|
|
169
|
+
? "too_large"
|
|
170
|
+
: "unsupported",
|
|
171
|
+
parserName: null,
|
|
172
|
+
parserVersion: null,
|
|
173
|
+
lineCount: null,
|
|
174
|
+
content: null,
|
|
175
|
+
});
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const content = await (0, promises_1.readFile)(absolutePath, "utf8");
|
|
179
|
+
candidates.push({
|
|
180
|
+
path: relativePath,
|
|
181
|
+
absolutePath,
|
|
182
|
+
dirPath,
|
|
183
|
+
baseName: name,
|
|
184
|
+
extension,
|
|
185
|
+
language,
|
|
186
|
+
mimeType,
|
|
187
|
+
sizeBytes: entryStats.size,
|
|
188
|
+
contentSha256: (0, language_utils_js_1.buildFileSha256)(content),
|
|
189
|
+
isText: true,
|
|
190
|
+
isBinary: false,
|
|
191
|
+
isGenerated: false,
|
|
192
|
+
isIgnored: false,
|
|
193
|
+
ignoreReason: null,
|
|
194
|
+
isParseable: true,
|
|
195
|
+
parseStatus: "parsed",
|
|
196
|
+
parserName: exports.PARSE_TOOL_NAME,
|
|
197
|
+
parserVersion: exports.PARSE_TOOL_VERSION,
|
|
198
|
+
lineCount: content.split(/\r?\n/).length,
|
|
199
|
+
content,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
await visit(workspacePath);
|
|
203
|
+
return candidates.sort((left, right) => left.path.localeCompare(right.path));
|
|
204
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { collectSingleFile, collectWorkspaceFiles, IGNORED_NAMES, MAX_PARSE_BYTES, MAX_PARSE_BYTES_BY_LANGUAGE, PARSE_TOOL_NAME, PARSE_TOOL_VERSION, type WorkspaceFileCandidate, } from "./file-discovery.js";
|
|
2
|
+
export { BINARY_SAMPLE_BYTES, SOURCE_LANGUAGE_BY_EXTENSION, MIME_TYPE_BY_EXTENSION, buildFileSha256, inferLanguage, inferMimeType, isBinaryBuffer, normalizeExtension, readSampleBuffer, } from "./language-utils.js";
|
|
3
|
+
export { loadTypeScriptResolverConfigs, normalizeWorkspaceRelativePath, type TypeScriptPathAliasPattern, type TypeScriptResolverConfig, } from "./ts-resolver.js";
|
|
4
|
+
export { parseWorkspaceFileSemantics, type ParsedWorkspaceSemantics, } from "./parsers/index.js";
|
|
5
|
+
export type { ParsedCallDraft, ParsedExportDraft, ParsedExternalSymbolDraft, ParsedImportDraft, ParsedParseIssueDraft, ParsedRelationshipDraft, ParsedSymbolDraft, RepoExportKind, RepoFileParseStatus, RepoImportKind, RepoImportResolutionKind, RepoParseIssueSeverity, RepoSymbolKind, RepoSymbolRelationshipKind, } from "./parsers/types.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,2BAA2B,EAC3B,eAAe,EACf,kBAAkB,EAClB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,2BAA2B,EAC3B,KAAK,wBAAwB,GAC9B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,EACd,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseWorkspaceFileSemantics = exports.normalizeWorkspaceRelativePath = exports.loadTypeScriptResolverConfigs = exports.readSampleBuffer = exports.normalizeExtension = exports.isBinaryBuffer = exports.inferMimeType = exports.inferLanguage = exports.buildFileSha256 = exports.MIME_TYPE_BY_EXTENSION = exports.SOURCE_LANGUAGE_BY_EXTENSION = exports.BINARY_SAMPLE_BYTES = exports.PARSE_TOOL_VERSION = exports.PARSE_TOOL_NAME = exports.MAX_PARSE_BYTES_BY_LANGUAGE = exports.MAX_PARSE_BYTES = exports.IGNORED_NAMES = exports.collectWorkspaceFiles = exports.collectSingleFile = void 0;
|
|
4
|
+
var file_discovery_js_1 = require("./file-discovery.js");
|
|
5
|
+
Object.defineProperty(exports, "collectSingleFile", { enumerable: true, get: function () { return file_discovery_js_1.collectSingleFile; } });
|
|
6
|
+
Object.defineProperty(exports, "collectWorkspaceFiles", { enumerable: true, get: function () { return file_discovery_js_1.collectWorkspaceFiles; } });
|
|
7
|
+
Object.defineProperty(exports, "IGNORED_NAMES", { enumerable: true, get: function () { return file_discovery_js_1.IGNORED_NAMES; } });
|
|
8
|
+
Object.defineProperty(exports, "MAX_PARSE_BYTES", { enumerable: true, get: function () { return file_discovery_js_1.MAX_PARSE_BYTES; } });
|
|
9
|
+
Object.defineProperty(exports, "MAX_PARSE_BYTES_BY_LANGUAGE", { enumerable: true, get: function () { return file_discovery_js_1.MAX_PARSE_BYTES_BY_LANGUAGE; } });
|
|
10
|
+
Object.defineProperty(exports, "PARSE_TOOL_NAME", { enumerable: true, get: function () { return file_discovery_js_1.PARSE_TOOL_NAME; } });
|
|
11
|
+
Object.defineProperty(exports, "PARSE_TOOL_VERSION", { enumerable: true, get: function () { return file_discovery_js_1.PARSE_TOOL_VERSION; } });
|
|
12
|
+
var language_utils_js_1 = require("./language-utils.js");
|
|
13
|
+
Object.defineProperty(exports, "BINARY_SAMPLE_BYTES", { enumerable: true, get: function () { return language_utils_js_1.BINARY_SAMPLE_BYTES; } });
|
|
14
|
+
Object.defineProperty(exports, "SOURCE_LANGUAGE_BY_EXTENSION", { enumerable: true, get: function () { return language_utils_js_1.SOURCE_LANGUAGE_BY_EXTENSION; } });
|
|
15
|
+
Object.defineProperty(exports, "MIME_TYPE_BY_EXTENSION", { enumerable: true, get: function () { return language_utils_js_1.MIME_TYPE_BY_EXTENSION; } });
|
|
16
|
+
Object.defineProperty(exports, "buildFileSha256", { enumerable: true, get: function () { return language_utils_js_1.buildFileSha256; } });
|
|
17
|
+
Object.defineProperty(exports, "inferLanguage", { enumerable: true, get: function () { return language_utils_js_1.inferLanguage; } });
|
|
18
|
+
Object.defineProperty(exports, "inferMimeType", { enumerable: true, get: function () { return language_utils_js_1.inferMimeType; } });
|
|
19
|
+
Object.defineProperty(exports, "isBinaryBuffer", { enumerable: true, get: function () { return language_utils_js_1.isBinaryBuffer; } });
|
|
20
|
+
Object.defineProperty(exports, "normalizeExtension", { enumerable: true, get: function () { return language_utils_js_1.normalizeExtension; } });
|
|
21
|
+
Object.defineProperty(exports, "readSampleBuffer", { enumerable: true, get: function () { return language_utils_js_1.readSampleBuffer; } });
|
|
22
|
+
var ts_resolver_js_1 = require("./ts-resolver.js");
|
|
23
|
+
Object.defineProperty(exports, "loadTypeScriptResolverConfigs", { enumerable: true, get: function () { return ts_resolver_js_1.loadTypeScriptResolverConfigs; } });
|
|
24
|
+
Object.defineProperty(exports, "normalizeWorkspaceRelativePath", { enumerable: true, get: function () { return ts_resolver_js_1.normalizeWorkspaceRelativePath; } });
|
|
25
|
+
var index_js_1 = require("./parsers/index.js");
|
|
26
|
+
Object.defineProperty(exports, "parseWorkspaceFileSemantics", { enumerable: true, get: function () { return index_js_1.parseWorkspaceFileSemantics; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const SOURCE_LANGUAGE_BY_EXTENSION: Record<string, string>;
|
|
2
|
+
export declare const MIME_TYPE_BY_EXTENSION: Record<string, string>;
|
|
3
|
+
export declare const BINARY_SAMPLE_BYTES = 8192;
|
|
4
|
+
export declare function normalizeExtension(fileName: string): string | null;
|
|
5
|
+
export declare function inferLanguage(extension: string | null): string | null;
|
|
6
|
+
export declare function inferMimeType(extension: string | null): string | null;
|
|
7
|
+
export declare function isBinaryBuffer(buffer: Buffer): boolean;
|
|
8
|
+
export declare function readSampleBuffer(filePath: string, sizeBytes: number): Promise<Buffer<ArrayBuffer>>;
|
|
9
|
+
export declare function buildFileSha256(content: Buffer | string): string;
|
|
10
|
+
//# sourceMappingURL=language-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-utils.d.ts","sourceRoot":"","sources":["../src/language-utils.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAY/D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAUzD,CAAC;AAEF,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,iBAGlD;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,iBAGrD;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,iBAGrD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,WAK5C;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gCASzE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,UAEvD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BINARY_SAMPLE_BYTES = exports.MIME_TYPE_BY_EXTENSION = exports.SOURCE_LANGUAGE_BY_EXTENSION = void 0;
|
|
7
|
+
exports.normalizeExtension = normalizeExtension;
|
|
8
|
+
exports.inferLanguage = inferLanguage;
|
|
9
|
+
exports.inferMimeType = inferMimeType;
|
|
10
|
+
exports.isBinaryBuffer = isBinaryBuffer;
|
|
11
|
+
exports.readSampleBuffer = readSampleBuffer;
|
|
12
|
+
exports.buildFileSha256 = buildFileSha256;
|
|
13
|
+
const node_crypto_1 = require("node:crypto");
|
|
14
|
+
const promises_1 = require("node:fs/promises");
|
|
15
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
+
exports.SOURCE_LANGUAGE_BY_EXTENSION = {
|
|
17
|
+
ts: "TypeScript",
|
|
18
|
+
tsx: "TypeScript",
|
|
19
|
+
js: "JavaScript",
|
|
20
|
+
jsx: "JavaScript",
|
|
21
|
+
dart: "Dart",
|
|
22
|
+
php: "PHP",
|
|
23
|
+
py: "Python",
|
|
24
|
+
java: "Java",
|
|
25
|
+
kt: "Kotlin",
|
|
26
|
+
kts: "Kotlin",
|
|
27
|
+
po: "Gettext",
|
|
28
|
+
};
|
|
29
|
+
exports.MIME_TYPE_BY_EXTENSION = {
|
|
30
|
+
ts: "text/plain",
|
|
31
|
+
tsx: "text/plain",
|
|
32
|
+
js: "text/javascript",
|
|
33
|
+
jsx: "text/javascript",
|
|
34
|
+
dart: "text/plain",
|
|
35
|
+
php: "text/x-php",
|
|
36
|
+
java: "text/x-java-source",
|
|
37
|
+
kt: "text/x-kotlin",
|
|
38
|
+
kts: "text/x-kotlin",
|
|
39
|
+
};
|
|
40
|
+
exports.BINARY_SAMPLE_BYTES = 8192;
|
|
41
|
+
function normalizeExtension(fileName) {
|
|
42
|
+
const extension = node_path_1.default.extname(fileName).slice(1).trim().toLowerCase();
|
|
43
|
+
return extension || null;
|
|
44
|
+
}
|
|
45
|
+
function inferLanguage(extension) {
|
|
46
|
+
if (!extension)
|
|
47
|
+
return null;
|
|
48
|
+
return exports.SOURCE_LANGUAGE_BY_EXTENSION[extension] ?? null;
|
|
49
|
+
}
|
|
50
|
+
function inferMimeType(extension) {
|
|
51
|
+
if (!extension)
|
|
52
|
+
return null;
|
|
53
|
+
return exports.MIME_TYPE_BY_EXTENSION[extension] ?? null;
|
|
54
|
+
}
|
|
55
|
+
function isBinaryBuffer(buffer) {
|
|
56
|
+
for (const byte of buffer) {
|
|
57
|
+
if (byte === 0)
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
async function readSampleBuffer(filePath, sizeBytes) {
|
|
63
|
+
const handle = await (0, promises_1.open)(filePath, "r");
|
|
64
|
+
try {
|
|
65
|
+
const buffer = Buffer.alloc(Math.min(sizeBytes, exports.BINARY_SAMPLE_BYTES));
|
|
66
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
67
|
+
return buffer.subarray(0, bytesRead);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
await handle.close();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function buildFileSha256(content) {
|
|
74
|
+
return (0, node_crypto_1.createHash)("sha256").update(content).digest("hex");
|
|
75
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkspaceFileCandidate } from "../file-discovery.js";
|
|
2
|
+
import { type ParsedWorkspaceSemantics } from "./types.js";
|
|
3
|
+
export declare function parseDartFile(file: WorkspaceFileCandidate, filePathSet: Set<string>, projectImportId: string): Promise<ParsedWorkspaceSemantics>;
|
|
4
|
+
//# sourceMappingURL=dart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dart.d.ts","sourceRoot":"","sources":["../../src/parsers/dart.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAmE,KAAK,wBAAwB,EAA2E,MAAM,YAAY,CAAC;AAsBrM,wBAAsB,aAAa,CACjC,IAAI,EAAE,sBAAsB,EAC5B,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,wBAAwB,CAAC,CA0EnC"}
|