@ff-labs/fff-node 0.11.0 → 0.11.1-nightly.012980d
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 +14 -0
- package/dist/binary.d.ts +4 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/fff-api.d.ts +18 -12
- package/dist/fff-api.d.ts.map +1 -1
- package/dist/ffi.d.ts +4 -4
- package/dist/ffi.d.ts.map +1 -1
- package/dist/finder.d.ts.map +1 -1
- package/dist/index.cjs +63 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +63 -14
- package/dist/index.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/package.json +12 -11
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
*/
|
|
41
41
|
export { binaryExists, findBinary } from "./binary.js";
|
|
42
42
|
export { closeLibrary } from "./ffi.js";
|
|
43
|
-
export type { DbHealth, DirItem, DirSearchOptions, DirSearchResult, FileFinderApi, FileItem, GrepCursor, GrepMatch, GrepMode, GrepOptions, GrepResult, HealthCheck, InitOptions, Location, MixedItem, MixedSearchResult, MultiGrepOptions, Result, ScanProgress, Score, SearchOptions, SearchResult, WatchBatchCallback, WatchEvent, WatchEventKind, WatchOptions, WatchUnsubscribe, } from "./fff-api.js";
|
|
43
|
+
export type { DbHealth, DirItem, DirSearchOptions, DirSearchResult, FileFinderApi, FileItem, GrepCursor, GrepMatch, GrepMode, DefinitionMode, GrepOptions, GrepResult, HealthCheck, InitOptions, Location, MixedItem, MixedSearchResult, MultiGrepOptions, Result, ScanProgress, Score, SearchOptions, SearchResult, WatchBatchCallback, WatchEvent, WatchEventKind, WatchOptions, WatchUnsubscribe, } from "./fff-api.js";
|
|
44
44
|
export { err, ok } from "./fff-api.js";
|
|
45
45
|
export { FileFinder } from "./finder.js";
|
|
46
46
|
export { getLibExtension, getLibFilename, getNpmPackageName, getTriple, } from "./platform.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EACV,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,QAAQ,EACR,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,EACN,YAAY,EACZ,KAAK,EACL,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,YAAY,EACZ,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,SAAS,GACV,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EACV,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,QAAQ,EACR,UAAU,EACV,SAAS,EACT,QAAQ,EACR,cAAc,EACd,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,EACN,YAAY,EACZ,KAAK,EACL,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,YAAY,EACZ,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,SAAS,GACV,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,8 @@ function getTriple() {
|
|
|
18
18
|
osName = detectLinuxLibc();
|
|
19
19
|
} else if (platform === "win32") {
|
|
20
20
|
osName = "pc-windows-msvc";
|
|
21
|
+
} else if (platform === "freebsd") {
|
|
22
|
+
osName = "unknown-freebsd";
|
|
21
23
|
} else {
|
|
22
24
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
23
25
|
}
|
|
@@ -121,7 +123,12 @@ function binaryExists() {
|
|
|
121
123
|
return findBinary() !== null;
|
|
122
124
|
}
|
|
123
125
|
function resolveFromNpmPackage() {
|
|
124
|
-
|
|
126
|
+
let packageName;
|
|
127
|
+
try {
|
|
128
|
+
packageName = getNpmPackageName();
|
|
129
|
+
} catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
125
132
|
try {
|
|
126
133
|
const require2 = createRequire(join(getPackageDir(), "package.json"));
|
|
127
134
|
const packageJsonPath = require2.resolve(`${packageName}/package.json`);
|
|
@@ -154,6 +161,13 @@ function isDevWorkspace() {
|
|
|
154
161
|
return existsSync(join(workspaceRoot, "Cargo.toml"));
|
|
155
162
|
}
|
|
156
163
|
function findBinary() {
|
|
164
|
+
const override = process.env["FFF_C_LIB"];
|
|
165
|
+
if (override) {
|
|
166
|
+
if (!existsSync(override)) {
|
|
167
|
+
throw new Error(`FFF_C_LIB points to a file that does not exist: ${override}`);
|
|
168
|
+
}
|
|
169
|
+
return override;
|
|
170
|
+
}
|
|
157
171
|
if (isDevWorkspace()) {
|
|
158
172
|
const binPath = join(getPackageDir(), "bin", getLibFilename());
|
|
159
173
|
if (existsSync(binPath)) return binPath;
|
|
@@ -194,6 +208,23 @@ function err(error) {
|
|
|
194
208
|
function createGrepCursor(offset) {
|
|
195
209
|
return { __brand: "GrepCursor", _offset: offset };
|
|
196
210
|
}
|
|
211
|
+
function definitionModeToInt(mode) {
|
|
212
|
+
switch (mode) {
|
|
213
|
+
case void 0:
|
|
214
|
+
case false:
|
|
215
|
+
case "off":
|
|
216
|
+
return 0;
|
|
217
|
+
case true:
|
|
218
|
+
case "classify":
|
|
219
|
+
return 1;
|
|
220
|
+
case "definition_only":
|
|
221
|
+
return 2;
|
|
222
|
+
case "usage_only":
|
|
223
|
+
return 3;
|
|
224
|
+
default:
|
|
225
|
+
return void 0;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
197
228
|
|
|
198
229
|
// src/ffi.ts
|
|
199
230
|
var LIBRARY_KEY = "fff_c";
|
|
@@ -213,9 +244,13 @@ var FFF_CREATE_OPTIONS_STRUCT = {
|
|
|
213
244
|
cache_budget_max_file_size: DataType.U64,
|
|
214
245
|
enable_fs_root_scanning: DataType.U8,
|
|
215
246
|
enable_home_dir_scanning: DataType.U8,
|
|
216
|
-
follow_symlinks: DataType.U8
|
|
247
|
+
follow_symlinks: DataType.U8,
|
|
248
|
+
extra_ignore: DataType.String,
|
|
249
|
+
disable_git: DataType.U8,
|
|
250
|
+
disable_ignore_files: DataType.U8
|
|
217
251
|
};
|
|
218
|
-
var FFF_CREATE_OPTIONS_VERSION =
|
|
252
|
+
var FFF_CREATE_OPTIONS_VERSION = 3;
|
|
253
|
+
var LEGACY_CREATE_OPTIONS_VERSION = 2;
|
|
219
254
|
var GREP_MODE_PLAIN = 0;
|
|
220
255
|
var GREP_MODE_REGEX = 1;
|
|
221
256
|
var GREP_MODE_FUZZY = 2;
|
|
@@ -367,10 +402,12 @@ function freeString(ptr) {
|
|
|
367
402
|
} catch {
|
|
368
403
|
}
|
|
369
404
|
}
|
|
370
|
-
function ffiCreate(basePath, frecencyDbPath, historyDbPath, _useUnsafeNoLock, enableMmapCache, enableContentIndexing, watch, aiMode, logFilePath, logLevel, cacheBudgetMaxFiles, cacheBudgetMaxBytes, cacheBudgetMaxFileSize, enableFsRootScanning, enableHomeDirScanning, followSymlinks) {
|
|
405
|
+
function ffiCreate(basePath, frecencyDbPath, historyDbPath, _useUnsafeNoLock, enableMmapCache, enableContentIndexing, watch, aiMode, logFilePath, logLevel, cacheBudgetMaxFiles, cacheBudgetMaxBytes, cacheBudgetMaxFileSize, enableFsRootScanning, enableHomeDirScanning, followSymlinks, extraIgnore, disableGit = false, disableIgnoreFiles = false) {
|
|
406
|
+
if (extraIgnore.includes("\0")) return err("extraIgnore cannot contain NUL bytes");
|
|
371
407
|
loadLibrary();
|
|
408
|
+
const version = extraIgnore || disableGit || disableIgnoreFiles ? FFF_CREATE_OPTIONS_VERSION : LEGACY_CREATE_OPTIONS_VERSION;
|
|
372
409
|
const optsValue = {
|
|
373
|
-
version
|
|
410
|
+
version,
|
|
374
411
|
base_path: basePath,
|
|
375
412
|
frecency_db_path: frecencyDbPath,
|
|
376
413
|
history_db_path: historyDbPath,
|
|
@@ -385,7 +422,10 @@ function ffiCreate(basePath, frecencyDbPath, historyDbPath, _useUnsafeNoLock, en
|
|
|
385
422
|
cache_budget_max_file_size: cacheBudgetMaxFileSize,
|
|
386
423
|
enable_fs_root_scanning: enableFsRootScanning ? 1 : 0,
|
|
387
424
|
enable_home_dir_scanning: enableHomeDirScanning ? 1 : 0,
|
|
388
|
-
follow_symlinks: followSymlinks ? 1 : 0
|
|
425
|
+
follow_symlinks: followSymlinks ? 1 : 0,
|
|
426
|
+
extra_ignore: extraIgnore,
|
|
427
|
+
disable_git: disableGit ? 1 : 0,
|
|
428
|
+
disable_ignore_files: disableIgnoreFiles ? 1 : 0
|
|
389
429
|
};
|
|
390
430
|
const rawPtr = load({
|
|
391
431
|
library: LIBRARY_KEY,
|
|
@@ -445,6 +485,7 @@ var FFF_SCORE_STRUCT = {
|
|
|
445
485
|
distance_penalty: DataType.I32,
|
|
446
486
|
current_file_penalty: DataType.I32,
|
|
447
487
|
combo_match_boost: DataType.I32,
|
|
488
|
+
path_alignment_bonus: DataType.I32,
|
|
448
489
|
exact_match: DataType.U8,
|
|
449
490
|
match_type: DataType.External
|
|
450
491
|
};
|
|
@@ -518,8 +559,8 @@ var FFF_GREP_MATCH_STRUCT = {
|
|
|
518
559
|
match_ranges_count: DataType.U32,
|
|
519
560
|
context_before_count: DataType.U32,
|
|
520
561
|
context_after_count: DataType.U32,
|
|
521
|
-
fuzzy_score: DataType.
|
|
522
|
-
//
|
|
562
|
+
fuzzy_score: DataType.I16,
|
|
563
|
+
// u16 in C; ffi-rs has no U16, so read I16 and mask (#888)
|
|
523
564
|
has_fuzzy_score: DataType.U8,
|
|
524
565
|
is_binary: DataType.U8,
|
|
525
566
|
is_definition: DataType.U8
|
|
@@ -560,6 +601,7 @@ function readScoreFromRaw(raw) {
|
|
|
560
601
|
distancePenalty: raw.distance_penalty,
|
|
561
602
|
currentFilePenalty: raw.current_file_penalty,
|
|
562
603
|
comboMatchBoost: raw.combo_match_boost,
|
|
604
|
+
pathAlignmentBonus: raw.path_alignment_bonus,
|
|
563
605
|
exactMatch: raw.exact_match !== 0,
|
|
564
606
|
matchType: readCString(raw.match_type) ?? ""
|
|
565
607
|
};
|
|
@@ -660,7 +702,7 @@ function readGrepMatchFromRaw(raw) {
|
|
|
660
702
|
matchRanges
|
|
661
703
|
};
|
|
662
704
|
if (raw.has_fuzzy_score !== 0) {
|
|
663
|
-
match.fuzzyScore = raw.fuzzy_score;
|
|
705
|
+
match.fuzzyScore = raw.fuzzy_score & 65535;
|
|
664
706
|
}
|
|
665
707
|
if (raw.context_before_count > 0) {
|
|
666
708
|
match.contextBefore = readCStringArray(raw.context_before, raw.context_before_count);
|
|
@@ -1059,6 +1101,8 @@ function ffiSearchMixed(handle, query, currentFile, maxThreads, pageIndex, pageS
|
|
|
1059
1101
|
return parseMixedSearchResult(rawPtr);
|
|
1060
1102
|
}
|
|
1061
1103
|
function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartCase, fileOffset, pageLimit, timeBudgetMs, enforceTimeBudget, beforeContext, afterContext, classifyDefinitions) {
|
|
1104
|
+
const definitionMode = definitionModeToInt(classifyDefinitions);
|
|
1105
|
+
if (definitionMode === void 0) return err("Invalid classifyDefinitions mode");
|
|
1062
1106
|
loadLibrary();
|
|
1063
1107
|
const rawPtr = load({
|
|
1064
1108
|
library: LIBRARY_KEY,
|
|
@@ -1089,7 +1133,7 @@ function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartC
|
|
|
1089
1133
|
// before_context
|
|
1090
1134
|
DataType.U32,
|
|
1091
1135
|
// after_context
|
|
1092
|
-
DataType.
|
|
1136
|
+
DataType.U8
|
|
1093
1137
|
// classify_definitions
|
|
1094
1138
|
],
|
|
1095
1139
|
paramsValue: [
|
|
@@ -1105,13 +1149,15 @@ function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartC
|
|
|
1105
1149
|
enforceTimeBudget,
|
|
1106
1150
|
beforeContext,
|
|
1107
1151
|
afterContext,
|
|
1108
|
-
|
|
1152
|
+
definitionMode
|
|
1109
1153
|
],
|
|
1110
1154
|
freeResultMemory: false
|
|
1111
1155
|
});
|
|
1112
1156
|
return parseGrepResult(rawPtr);
|
|
1113
1157
|
}
|
|
1114
1158
|
function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatchesPerFile, smartCase, fileOffset, pageLimit, timeBudgetMs, enforceTimeBudget, beforeContext, afterContext, classifyDefinitions) {
|
|
1159
|
+
const definitionMode = definitionModeToInt(classifyDefinitions);
|
|
1160
|
+
if (definitionMode === void 0) return err("Invalid classifyDefinitions mode");
|
|
1115
1161
|
loadLibrary();
|
|
1116
1162
|
const rawPtr = load({
|
|
1117
1163
|
library: LIBRARY_KEY,
|
|
@@ -1142,7 +1188,7 @@ function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatch
|
|
|
1142
1188
|
// before_context
|
|
1143
1189
|
DataType.U32,
|
|
1144
1190
|
// after_context
|
|
1145
|
-
DataType.
|
|
1191
|
+
DataType.U8
|
|
1146
1192
|
// classify_definitions
|
|
1147
1193
|
],
|
|
1148
1194
|
paramsValue: [
|
|
@@ -1158,7 +1204,7 @@ function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatch
|
|
|
1158
1204
|
enforceTimeBudget,
|
|
1159
1205
|
beforeContext,
|
|
1160
1206
|
afterContext,
|
|
1161
|
-
|
|
1207
|
+
definitionMode
|
|
1162
1208
|
],
|
|
1163
1209
|
freeResultMemory: false
|
|
1164
1210
|
});
|
|
@@ -1468,7 +1514,10 @@ var FileFinder = class _FileFinder {
|
|
|
1468
1514
|
options.cacheBudgetMaxFileSize ?? 0,
|
|
1469
1515
|
options.enableFsRootScanning ?? false,
|
|
1470
1516
|
options.enableHomeDirScanning ?? false,
|
|
1471
|
-
options.followSymlinks ?? false
|
|
1517
|
+
options.followSymlinks ?? false,
|
|
1518
|
+
options.extraIgnore?.join("\n") ?? "",
|
|
1519
|
+
options.disableGit ?? false,
|
|
1520
|
+
options.disableIgnoreFiles ?? false
|
|
1472
1521
|
);
|
|
1473
1522
|
if (!result.ok) {
|
|
1474
1523
|
return result;
|