@ff-labs/fff-node 0.11.0 → 0.11.1-nightly.056fca0
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 +12 -12
- package/dist/fff-api.d.ts.map +1 -1
- package/dist/ffi.d.ts +3 -3
- package/dist/ffi.d.ts.map +1 -1
- package/dist/index.cjs +45 -8
- 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 +45 -8
- 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";
|
|
@@ -445,6 +476,7 @@ var FFF_SCORE_STRUCT = {
|
|
|
445
476
|
distance_penalty: DataType.I32,
|
|
446
477
|
current_file_penalty: DataType.I32,
|
|
447
478
|
combo_match_boost: DataType.I32,
|
|
479
|
+
path_alignment_bonus: DataType.I32,
|
|
448
480
|
exact_match: DataType.U8,
|
|
449
481
|
match_type: DataType.External
|
|
450
482
|
};
|
|
@@ -518,8 +550,8 @@ var FFF_GREP_MATCH_STRUCT = {
|
|
|
518
550
|
match_ranges_count: DataType.U32,
|
|
519
551
|
context_before_count: DataType.U32,
|
|
520
552
|
context_after_count: DataType.U32,
|
|
521
|
-
fuzzy_score: DataType.
|
|
522
|
-
//
|
|
553
|
+
fuzzy_score: DataType.I16,
|
|
554
|
+
// u16 in C; ffi-rs has no U16, so read I16 and mask (#888)
|
|
523
555
|
has_fuzzy_score: DataType.U8,
|
|
524
556
|
is_binary: DataType.U8,
|
|
525
557
|
is_definition: DataType.U8
|
|
@@ -560,6 +592,7 @@ function readScoreFromRaw(raw) {
|
|
|
560
592
|
distancePenalty: raw.distance_penalty,
|
|
561
593
|
currentFilePenalty: raw.current_file_penalty,
|
|
562
594
|
comboMatchBoost: raw.combo_match_boost,
|
|
595
|
+
pathAlignmentBonus: raw.path_alignment_bonus,
|
|
563
596
|
exactMatch: raw.exact_match !== 0,
|
|
564
597
|
matchType: readCString(raw.match_type) ?? ""
|
|
565
598
|
};
|
|
@@ -660,7 +693,7 @@ function readGrepMatchFromRaw(raw) {
|
|
|
660
693
|
matchRanges
|
|
661
694
|
};
|
|
662
695
|
if (raw.has_fuzzy_score !== 0) {
|
|
663
|
-
match.fuzzyScore = raw.fuzzy_score;
|
|
696
|
+
match.fuzzyScore = raw.fuzzy_score & 65535;
|
|
664
697
|
}
|
|
665
698
|
if (raw.context_before_count > 0) {
|
|
666
699
|
match.contextBefore = readCStringArray(raw.context_before, raw.context_before_count);
|
|
@@ -1059,6 +1092,8 @@ function ffiSearchMixed(handle, query, currentFile, maxThreads, pageIndex, pageS
|
|
|
1059
1092
|
return parseMixedSearchResult(rawPtr);
|
|
1060
1093
|
}
|
|
1061
1094
|
function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartCase, fileOffset, pageLimit, timeBudgetMs, enforceTimeBudget, beforeContext, afterContext, classifyDefinitions) {
|
|
1095
|
+
const definitionMode = definitionModeToInt(classifyDefinitions);
|
|
1096
|
+
if (definitionMode === void 0) return err("Invalid classifyDefinitions mode");
|
|
1062
1097
|
loadLibrary();
|
|
1063
1098
|
const rawPtr = load({
|
|
1064
1099
|
library: LIBRARY_KEY,
|
|
@@ -1089,7 +1124,7 @@ function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartC
|
|
|
1089
1124
|
// before_context
|
|
1090
1125
|
DataType.U32,
|
|
1091
1126
|
// after_context
|
|
1092
|
-
DataType.
|
|
1127
|
+
DataType.U8
|
|
1093
1128
|
// classify_definitions
|
|
1094
1129
|
],
|
|
1095
1130
|
paramsValue: [
|
|
@@ -1105,13 +1140,15 @@ function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartC
|
|
|
1105
1140
|
enforceTimeBudget,
|
|
1106
1141
|
beforeContext,
|
|
1107
1142
|
afterContext,
|
|
1108
|
-
|
|
1143
|
+
definitionMode
|
|
1109
1144
|
],
|
|
1110
1145
|
freeResultMemory: false
|
|
1111
1146
|
});
|
|
1112
1147
|
return parseGrepResult(rawPtr);
|
|
1113
1148
|
}
|
|
1114
1149
|
function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatchesPerFile, smartCase, fileOffset, pageLimit, timeBudgetMs, enforceTimeBudget, beforeContext, afterContext, classifyDefinitions) {
|
|
1150
|
+
const definitionMode = definitionModeToInt(classifyDefinitions);
|
|
1151
|
+
if (definitionMode === void 0) return err("Invalid classifyDefinitions mode");
|
|
1115
1152
|
loadLibrary();
|
|
1116
1153
|
const rawPtr = load({
|
|
1117
1154
|
library: LIBRARY_KEY,
|
|
@@ -1142,7 +1179,7 @@ function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatch
|
|
|
1142
1179
|
// before_context
|
|
1143
1180
|
DataType.U32,
|
|
1144
1181
|
// after_context
|
|
1145
|
-
DataType.
|
|
1182
|
+
DataType.U8
|
|
1146
1183
|
// classify_definitions
|
|
1147
1184
|
],
|
|
1148
1185
|
paramsValue: [
|
|
@@ -1158,7 +1195,7 @@ function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatch
|
|
|
1158
1195
|
enforceTimeBudget,
|
|
1159
1196
|
beforeContext,
|
|
1160
1197
|
afterContext,
|
|
1161
|
-
|
|
1198
|
+
definitionMode
|
|
1162
1199
|
],
|
|
1163
1200
|
freeResultMemory: false
|
|
1164
1201
|
});
|