@ff-labs/fff-node 0.11.1-nightly.89c1927 → 0.11.1-nightly.8a29cfd

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/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";
@@ -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
- const packageName = getNpmPackageName();
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 = 2;
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: FFF_CREATE_OPTIONS_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,
@@ -1061,6 +1101,8 @@ function ffiSearchMixed(handle, query, currentFile, maxThreads, pageIndex, pageS
1061
1101
  return parseMixedSearchResult(rawPtr);
1062
1102
  }
1063
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");
1064
1106
  loadLibrary();
1065
1107
  const rawPtr = load({
1066
1108
  library: LIBRARY_KEY,
@@ -1091,7 +1133,7 @@ function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartC
1091
1133
  // before_context
1092
1134
  DataType.U32,
1093
1135
  // after_context
1094
- DataType.Boolean
1136
+ DataType.U8
1095
1137
  // classify_definitions
1096
1138
  ],
1097
1139
  paramsValue: [
@@ -1107,13 +1149,15 @@ function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartC
1107
1149
  enforceTimeBudget,
1108
1150
  beforeContext,
1109
1151
  afterContext,
1110
- classifyDefinitions
1152
+ definitionMode
1111
1153
  ],
1112
1154
  freeResultMemory: false
1113
1155
  });
1114
1156
  return parseGrepResult(rawPtr);
1115
1157
  }
1116
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");
1117
1161
  loadLibrary();
1118
1162
  const rawPtr = load({
1119
1163
  library: LIBRARY_KEY,
@@ -1144,7 +1188,7 @@ function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatch
1144
1188
  // before_context
1145
1189
  DataType.U32,
1146
1190
  // after_context
1147
- DataType.Boolean
1191
+ DataType.U8
1148
1192
  // classify_definitions
1149
1193
  ],
1150
1194
  paramsValue: [
@@ -1160,7 +1204,7 @@ function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatch
1160
1204
  enforceTimeBudget,
1161
1205
  beforeContext,
1162
1206
  afterContext,
1163
- classifyDefinitions
1207
+ definitionMode
1164
1208
  ],
1165
1209
  freeResultMemory: false
1166
1210
  });
@@ -1470,7 +1514,10 @@ var FileFinder = class _FileFinder {
1470
1514
  options.cacheBudgetMaxFileSize ?? 0,
1471
1515
  options.enableFsRootScanning ?? false,
1472
1516
  options.enableHomeDirScanning ?? false,
1473
- options.followSymlinks ?? false
1517
+ options.followSymlinks ?? false,
1518
+ options.extraIgnore?.join("\n") ?? "",
1519
+ options.disableGit ?? false,
1520
+ options.disableIgnoreFiles ?? false
1474
1521
  );
1475
1522
  if (!result.ok) {
1476
1523
  return result;