Files

652 lines
24 KiB
Diff

diff --git a/dist/fff-api.d.ts b/dist/fff-api.d.ts
index 0f90eedca20655ccd30b8f28e433b2094341fbdf..c2ef86927d6e3ab0e8584330fa0ac3fdacc06cf5 100644
--- a/dist/fff-api.d.ts
+++ b/dist/fff-api.d.ts
@@ -199,7 +199,7 @@ export type Location = {
export interface SearchResult {
/** Matched file items */
items: FileItem[];
- /** Corresponding scores for each item */
+ /** Corresponding scores for each item. Empty when the page has more than 200 items (patched in T3 Code to skip per-item score FFI calls). */
scores: Score[];
/** Total number of files that matched */
totalMatched: number;
@@ -238,7 +238,7 @@ export interface DirSearchOptions {
export interface DirSearchResult {
/** Matched directory items */
items: DirItem[];
- /** Corresponding scores for each item */
+ /** Corresponding scores for each item. Empty when the page has more than 200 items (patched in T3 Code to skip per-item score FFI calls). */
scores: Score[];
/** Total number of directories that matched */
totalMatched: number;
@@ -262,7 +262,7 @@ export type MixedItem = {
export interface MixedSearchResult {
/** Matched items (files and directories interleaved by score) */
items: MixedItem[];
- /** Corresponding scores for each item */
+ /** Corresponding scores for each item. Empty when the page has more than 200 items (patched in T3 Code to skip per-item score FFI calls). */
scores: Score[];
/** Total number of items (files + dirs) that matched */
totalMatched: number;
diff --git a/dist/finder.d.ts b/dist/finder.d.ts
index 452102d720cc19b0560cfc9e2f1a320687047c92..704b52c3d076c50c3bf15e96a574385c9862670c 100644
--- a/dist/finder.d.ts
+++ b/dist/finder.d.ts
@@ -242,6 +242,18 @@ export declare class FileFinder implements FileFinderApi {
* background watcher might have missed.
*/
scanFiles(): Result<void>;
+ /**
+ * Trigger a rescan without blocking the JS thread. Patched in T3 Code.
+ */
+ scanFilesAsync(): Promise<Result<void>>;
+ /** `fileSearch` without blocking the JS thread. Patched in T3 Code. */
+ fileSearchAsync(query: string, options?: SearchOptions): Promise<Result<SearchResult>>;
+ /** `directorySearch` without blocking the JS thread. Patched in T3 Code. */
+ directorySearchAsync(query: string, options?: DirSearchOptions): Promise<Result<DirSearchResult>>;
+ /** `mixedSearch` without blocking the JS thread. Patched in T3 Code. */
+ mixedSearchAsync(query: string, options?: SearchOptions): Promise<Result<MixedSearchResult>>;
+ /** `grep` without blocking the JS thread. Patched in T3 Code. */
+ grepAsync(query: string, options?: GrepOptions): Promise<Result<GrepResult>>;
/**
* Check if a scan is currently in progress.
*/
@@ -254,6 +266,10 @@ export declare class FileFinder implements FileFinderApi {
* Get the current scan progress.
*/
getScanProgress(): Result<ScanProgress>;
+ /**
+ * Read scan progress without blocking the JS thread. Patched in T3 Code.
+ */
+ getScanProgressAsync(): Promise<Result<ScanProgress>>;
/**
* Wait for the initial file scan to complete.
* Non-blocking: polls `isScanning` and yields to the event loop between checks.
@@ -360,6 +376,8 @@ export declare class FileFinder implements FileFinderApi {
*/
watch(callback: WatchBatchCallback, options?: WatchOptions): Result<WatchUnsubscribe>;
watch(pattern: string, callback: WatchBatchCallback, options?: WatchOptions): Result<WatchUnsubscribe>;
+ /** `watch(callback)` without blocking the JS thread. Patched in T3 Code. */
+ watchAsync(callback: WatchBatchCallback, options?: WatchOptions): Promise<Result<WatchUnsubscribe>>;
/**
* Get health check information.
*
diff --git a/dist/index.js b/dist/index.js
index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..69bfa2cc9023103f52cc469bbec917eab68fa806 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1,7 +1,7 @@
// src/binary.ts
import { existsSync, readFileSync } from "fs";
import { createRequire } from "module";
-import { dirname, join } from "path";
+import { dirname, join, sep } from "path";
import { fileURLToPath } from "url";
// src/platform.ts
@@ -120,6 +120,16 @@ function getPackageDir() {
function binaryExists() {
return findBinary() !== null;
}
+function resolveUnpackedAsarPath(binaryPath) {
+ const pathSegments = binaryPath.split(sep);
+ const asarIndex = pathSegments.findLastIndex((segment) => segment.endsWith(".asar"));
+ if (asarIndex === -1) {
+ return binaryPath;
+ }
+ pathSegments[asarIndex] = `${pathSegments[asarIndex]}.unpacked`;
+ const unpackedPath = pathSegments.join(sep);
+ return existsSync(unpackedPath) ? unpackedPath : binaryPath;
+}
function resolveFromNpmPackage() {
const packageName = getNpmPackageName();
try {
@@ -128,7 +138,7 @@ function resolveFromNpmPackage() {
const packageDir = dirname(packageJsonPath);
const binaryPath = join(packageDir, getLibFilename());
if (existsSync(binaryPath)) {
- return binaryPath;
+ return resolveUnpackedAsarPath(binaryPath);
}
} catch {
}
@@ -262,6 +272,7 @@ function snakeToCamel(obj) {
return result;
}
function readCString(ptr) {
+ if (typeof ptr === "string") return ptr;
if (isNullPointer(ptr)) return null;
try {
const [str] = restorePointer({
@@ -303,6 +314,26 @@ function freeResult(resultPtr) {
function readResultEnvelope(funcName, paramsType, paramsValue) {
loadLibrary();
const { rawPtr, struct: structData } = callRaw(funcName, paramsType, paramsValue);
+ return envelopeFromRaw(rawPtr, structData);
+}
+async function readResultEnvelopeOnNativeThread(funcName, paramsType, paramsValue) {
+ loadLibrary();
+ const rawPtr = await load({
+ library: LIBRARY_KEY,
+ funcName,
+ retType: DataType.External,
+ paramsType,
+ paramsValue,
+ freeResultMemory: false,
+ runInNewThread: true
+ });
+ const [structData] = restorePointer({
+ retType: [FFF_RESULT_STRUCT],
+ paramsValue: wrapPointer([rawPtr])
+ });
+ return envelopeFromRaw(rawPtr, structData);
+}
+function envelopeFromRaw(rawPtr, structData) {
if (structData.success === 0) {
const errorStr = readCString(structData.error);
freeResult(rawPtr);
@@ -311,13 +342,17 @@ function readResultEnvelope(funcName, paramsType, paramsValue) {
return { rawPtr, struct: structData };
}
function callVoidResult(funcName, paramsType, paramsValue) {
- const res = readResultEnvelope(funcName, paramsType, paramsValue);
+ return voidResultFromEnvelope(readResultEnvelope(funcName, paramsType, paramsValue));
+}
+function voidResultFromEnvelope(res) {
if ("ok" in res) return res;
freeResult(res.rawPtr);
return { ok: true, value: void 0 };
}
function callIntResult(funcName, paramsType, paramsValue) {
- const res = readResultEnvelope(funcName, paramsType, paramsValue);
+ return intResultFromEnvelope(readResultEnvelope(funcName, paramsType, paramsValue));
+}
+function intResultFromEnvelope(res) {
if ("ok" in res) return res;
const value = Number(res.struct.int_value);
freeResult(res.rawPtr);
@@ -417,18 +452,20 @@ function ffiCreate(basePath, frecencyDbPath, historyDbPath, _useUnsafeNoLock, en
}
function ffiDestroy(handle) {
loadLibrary();
- load({
+ return load({
library: LIBRARY_KEY,
funcName: "fff_destroy",
retType: DataType.Void,
paramsType: [DataType.External],
- paramsValue: [handle]
+ paramsValue: [handle],
+ runInNewThread: true
+ }).catch(() => {
});
}
var FFF_FILE_ITEM_STRUCT = {
- relative_path: DataType.External,
- file_name: DataType.External,
- git_status: DataType.External,
+ relative_path: DataType.String,
+ file_name: DataType.String,
+ git_status: DataType.String,
size: DataType.U64,
modified: DataType.U64,
access_frecency_score: DataType.I64,
@@ -445,8 +482,9 @@ var FFF_SCORE_STRUCT = {
distance_penalty: DataType.I32,
current_file_penalty: DataType.I32,
combo_match_boost: DataType.I32,
+ path_alignment_bonus: DataType.I32,
exact_match: DataType.U8,
- match_type: DataType.External
+ match_type: DataType.String
};
var FFF_SEARCH_RESULT_STRUCT = {
items: DataType.External,
@@ -462,8 +500,8 @@ var FFF_SEARCH_RESULT_STRUCT = {
location_end_col: DataType.I32
};
var FFF_DIR_ITEM_STRUCT = {
- relative_path: DataType.External,
- dir_name: DataType.External,
+ relative_path: DataType.String,
+ dir_name: DataType.String,
max_access_frecency: DataType.I32
};
var FFF_DIR_SEARCH_RESULT_STRUCT = {
@@ -475,9 +513,9 @@ var FFF_DIR_SEARCH_RESULT_STRUCT = {
};
var FFF_MIXED_ITEM_STRUCT = {
item_type: DataType.U8,
- relative_path: DataType.External,
- display_name: DataType.External,
- git_status: DataType.External,
+ relative_path: DataType.String,
+ display_name: DataType.String,
+ git_status: DataType.String,
size: DataType.U64,
modified: DataType.U64,
access_frecency_score: DataType.I64,
@@ -500,10 +538,10 @@ var FFF_MIXED_SEARCH_RESULT_STRUCT = {
location_end_col: DataType.I32
};
var FFF_GREP_MATCH_STRUCT = {
- relative_path: DataType.External,
- file_name: DataType.External,
- git_status: DataType.External,
- line_content: DataType.External,
+ relative_path: DataType.String,
+ file_name: DataType.String,
+ git_status: DataType.String,
+ line_content: DataType.String,
match_ranges: DataType.External,
context_before: DataType.External,
context_after: DataType.External,
@@ -598,18 +636,13 @@ function readMixedItemFromRaw(raw) {
}
function callAccessor(funcName, resultPtr, index, structDef) {
loadLibrary();
- const elemPtr = load({
+ return load({
library: LIBRARY_KEY,
funcName,
- retType: DataType.External,
+ retType: structDef,
paramsType: [DataType.External, DataType.U32],
paramsValue: [resultPtr, index]
});
- const [raw] = restorePointer({
- retType: [structDef],
- paramsValue: wrapPointer([elemPtr])
- });
- return raw;
}
function ptrOffset(base, bytes) {
return load({
@@ -766,6 +799,7 @@ function parseSearchResult(rawPtr) {
}
const items = [];
const scores = [];
+ const includeScores = count <= 200;
for (let i = 0; i < count; i++) {
const rawItem = callAccessor(
"fff_search_result_get_item",
@@ -774,13 +808,15 @@ function parseSearchResult(rawPtr) {
FFF_FILE_ITEM_STRUCT
);
items.push(readFileItemFromRaw(rawItem));
- const rawScore = callAccessor(
- "fff_search_result_get_score",
- handlePtr,
- i,
- FFF_SCORE_STRUCT
- );
- scores.push(readScoreFromRaw(rawScore));
+ if (includeScores) {
+ const rawScore = callAccessor(
+ "fff_search_result_get_score",
+ handlePtr,
+ i,
+ FFF_SCORE_STRUCT
+ );
+ scores.push(readScoreFromRaw(rawScore));
+ }
}
load({
library: LIBRARY_KEY,
@@ -824,6 +860,7 @@ function parseDirSearchResult(rawPtr) {
const count = sr.count;
const items = [];
const scores = [];
+ const includeScores = count <= 200;
for (let i = 0; i < count; i++) {
const rawItem = callAccessor(
"fff_dir_search_result_get_item",
@@ -832,13 +869,15 @@ function parseDirSearchResult(rawPtr) {
FFF_DIR_ITEM_STRUCT
);
items.push(readDirItemFromRaw(rawItem));
- const rawScore = callAccessor(
- "fff_dir_search_result_get_score",
- handlePtr,
- i,
- FFF_SCORE_STRUCT
- );
- scores.push(readScoreFromRaw(rawScore));
+ if (includeScores) {
+ const rawScore = callAccessor(
+ "fff_dir_search_result_get_score",
+ handlePtr,
+ i,
+ FFF_SCORE_STRUCT
+ );
+ scores.push(readScoreFromRaw(rawScore));
+ }
}
load({
library: LIBRARY_KEY,
@@ -897,6 +936,7 @@ function parseMixedSearchResult(rawPtr) {
}
const items = [];
const scores = [];
+ const includeScores = count <= 200;
for (let i = 0; i < count; i++) {
const rawItem = callAccessor(
"fff_mixed_search_result_get_item",
@@ -905,13 +945,15 @@ function parseMixedSearchResult(rawPtr) {
FFF_MIXED_ITEM_STRUCT
);
items.push(readMixedItemFromRaw(rawItem));
- const rawScore = callAccessor(
- "fff_mixed_search_result_get_score",
- handlePtr,
- i,
- FFF_SCORE_STRUCT
- );
- scores.push(readScoreFromRaw(rawScore));
+ if (includeScores) {
+ const rawScore = callAccessor(
+ "fff_mixed_search_result_get_score",
+ handlePtr,
+ i,
+ FFF_SCORE_STRUCT
+ );
+ scores.push(readScoreFromRaw(rawScore));
+ }
}
load({
library: LIBRARY_KEY,
@@ -932,7 +974,7 @@ function parseMixedSearchResult(rawPtr) {
}
return { ok: true, value: result };
}
-function ffiSearch(handle, query, currentFile, maxThreads, pageIndex, pageSize, comboBoostMultiplier, minComboCount) {
+function ffiSearch(handle, query, currentFile, maxThreads, pageIndex, pageSize, comboBoostMultiplier, minComboCount, onNativeThread = false) {
loadLibrary();
const rawPtr = load({
library: LIBRARY_KEY,
@@ -966,9 +1008,10 @@ function ffiSearch(handle, query, currentFile, maxThreads, pageIndex, pageSize,
comboBoostMultiplier,
minComboCount
],
- freeResultMemory: false
+ freeResultMemory: false,
+ runInNewThread: onNativeThread
});
- return parseSearchResult(rawPtr);
+ return onNativeThread ? rawPtr.then(parseSearchResult) : parseSearchResult(rawPtr);
}
function ffiGlob(handle, pattern, currentFile, maxThreads, pageIndex, pageSize) {
loadLibrary();
@@ -995,7 +1038,7 @@ function ffiGlob(handle, pattern, currentFile, maxThreads, pageIndex, pageSize)
});
return parseSearchResult(rawPtr);
}
-function ffiSearchDirectories(handle, query, currentFile, maxThreads, pageIndex, pageSize) {
+function ffiSearchDirectories(handle, query, currentFile, maxThreads, pageIndex, pageSize, onNativeThread = false) {
loadLibrary();
const rawPtr = load({
library: LIBRARY_KEY,
@@ -1016,11 +1059,12 @@ function ffiSearchDirectories(handle, query, currentFile, maxThreads, pageIndex,
// page_size
],
paramsValue: [handle, query, currentFile ?? "", maxThreads, pageIndex, pageSize],
- freeResultMemory: false
+ freeResultMemory: false,
+ runInNewThread: onNativeThread
});
- return parseDirSearchResult(rawPtr);
+ return onNativeThread ? rawPtr.then(parseDirSearchResult) : parseDirSearchResult(rawPtr);
}
-function ffiSearchMixed(handle, query, currentFile, maxThreads, pageIndex, pageSize, comboBoostMultiplier, minComboCount) {
+function ffiSearchMixed(handle, query, currentFile, maxThreads, pageIndex, pageSize, comboBoostMultiplier, minComboCount, onNativeThread = false) {
loadLibrary();
const rawPtr = load({
library: LIBRARY_KEY,
@@ -1054,11 +1098,12 @@ function ffiSearchMixed(handle, query, currentFile, maxThreads, pageIndex, pageS
comboBoostMultiplier,
minComboCount
],
- freeResultMemory: false
+ freeResultMemory: false,
+ runInNewThread: onNativeThread
});
- return parseMixedSearchResult(rawPtr);
+ return onNativeThread ? rawPtr.then(parseMixedSearchResult) : parseMixedSearchResult(rawPtr);
}
-function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartCase, fileOffset, pageLimit, timeBudgetMs, enforceTimeBudget, beforeContext, afterContext, classifyDefinitions) {
+function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartCase, fileOffset, pageLimit, timeBudgetMs, enforceTimeBudget, beforeContext, afterContext, classifyDefinitions, onNativeThread = false) {
loadLibrary();
const rawPtr = load({
library: LIBRARY_KEY,
@@ -1107,9 +1152,10 @@ function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartC
afterContext,
classifyDefinitions
],
- freeResultMemory: false
+ freeResultMemory: false,
+ runInNewThread: onNativeThread
});
- return parseGrepResult(rawPtr);
+ return onNativeThread ? rawPtr.then(parseGrepResult) : parseGrepResult(rawPtr);
}
function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatchesPerFile, smartCase, fileOffset, pageLimit, timeBudgetMs, enforceTimeBudget, beforeContext, afterContext, classifyDefinitions) {
loadLibrary();
@@ -1188,7 +1234,11 @@ var FFF_SCAN_PROGRESS_STRUCT = {
};
function ffiGetScanProgress(handle) {
loadLibrary();
- const res = readResultEnvelope("fff_get_scan_progress", [DataType.External], [handle]);
+ return scanProgressFromEnvelope(
+ readResultEnvelope("fff_get_scan_progress", [DataType.External], [handle])
+ );
+}
+function scanProgressFromEnvelope(res) {
if ("ok" in res) return res;
const handlePtr = res.struct.handle;
freeResult(res.rawPtr);
@@ -1429,6 +1479,10 @@ var FileFinder = class _FileFinder {
handle;
/** Native ids of this instance's active watch subscriptions. */
watchers = /* @__PURE__ */ new Set();
+ /** Patched in T3 Code: in-flight native-thread calls by function name. */
+ nativeThreadCalls = /* @__PURE__ */ new Map();
+ /** Patched in T3 Code: the last search queued on a native thread. */
+ nativeSearchTail = null;
constructor(handle) {
this.handle = handle;
}
@@ -1485,11 +1539,147 @@ var FileFinder = class _FileFinder {
destroy() {
if (this.handle !== null) {
const handle = this.handle;
- ffiDestroy(handle);
+ const watchers = this.watchers;
this.handle = null;
- ffiWatchCleanupAfterDestroy(handle, this.watchers);
- this.watchers.clear();
+ this.watchers = /* @__PURE__ */ new Set();
+ // Patched in T3 Code: freeing the handle waits on the picker lock, so it runs on a
+ // native thread, after any native-thread call still using the handle.
+ const release = () => ffiDestroy(handle).finally(() => {
+ ffiWatchCleanupAfterDestroy(handle, watchers);
+ });
+ const pending = [...this.nativeThreadCalls.values()];
+ if (this.nativeSearchTail) pending.push(this.nativeSearchTail);
+ if (pending.length > 0) {
+ Promise.allSettled(pending).then(release);
+ } else {
+ release();
+ }
+ }
+ }
+ /**
+ * Patched in T3 Code: runs a handle-only call on a libuv pool thread so waiting on fff's
+ * picker lock never blocks the JS thread. Concurrent callers share one call, so one finder
+ * holds at most one pool thread per function.
+ */
+ callOnNativeThread(funcName, fromEnvelope) {
+ const guard = this.ensureAlive();
+ if (!guard.ok) return Promise.resolve(guard);
+ const pending = this.nativeThreadCalls.get(funcName);
+ if (pending) return pending;
+ const call = readResultEnvelopeOnNativeThread(funcName, [DataType.External], [guard.value]).then(fromEnvelope, (cause) => err(String(cause))).finally(() => {
+ this.nativeThreadCalls.delete(funcName);
+ });
+ this.nativeThreadCalls.set(funcName, call);
+ return call;
+ }
+ /**
+ * Patched in T3 Code: runs a search or subscription on a libuv pool thread. They run one at a
+ * time per finder, so while fff's watcher holds the picker lock a finder holds at most one pool
+ * thread.
+ */
+ searchOnNativeThread(search) {
+ const guard = this.ensureAlive();
+ if (!guard.ok) return Promise.resolve(guard);
+ const call = (this.nativeSearchTail ?? Promise.resolve()).then(() => {
+ const alive = this.ensureAlive();
+ return alive.ok ? search(alive.value) : alive;
+ }).catch((cause) => err(String(cause)));
+ this.nativeSearchTail = call;
+ call.finally(() => {
+ if (this.nativeSearchTail === call) this.nativeSearchTail = null;
+ });
+ return call;
+ }
+ /** Patched in T3 Code: `fileSearch` without blocking the JS thread. */
+ fileSearchAsync(query, options) {
+ return this.searchOnNativeThread((handle) => ffiSearch(
+ handle,
+ query,
+ options?.currentFile ?? "",
+ options?.maxThreads ?? 0,
+ options?.pageIndex ?? 0,
+ options?.pageSize ?? 0,
+ options?.comboBoostMultiplier ?? 0,
+ options?.minComboCount ?? 0,
+ true
+ ));
+ }
+ /** Patched in T3 Code: `directorySearch` without blocking the JS thread. */
+ directorySearchAsync(query, options) {
+ return this.searchOnNativeThread((handle) => ffiSearchDirectories(
+ handle,
+ query,
+ options?.currentFile ?? null,
+ options?.maxThreads ?? 0,
+ options?.pageIndex ?? 0,
+ options?.pageSize ?? 0,
+ true
+ ));
+ }
+ /** Patched in T3 Code: `mixedSearch` without blocking the JS thread. */
+ mixedSearchAsync(query, options) {
+ return this.searchOnNativeThread((handle) => ffiSearchMixed(
+ handle,
+ query,
+ options?.currentFile ?? "",
+ options?.maxThreads ?? 0,
+ options?.pageIndex ?? 0,
+ options?.pageSize ?? 0,
+ options?.comboBoostMultiplier ?? 0,
+ options?.minComboCount ?? 0,
+ true
+ ));
+ }
+ /**
+ * Patched in T3 Code: `watch` without blocking the JS thread. Subscribing takes the picker lock,
+ * which fff's watcher holds while it indexes a new directory.
+ */
+ watchAsync(callback, options) {
+ if (typeof callback !== "function") {
+ return Promise.resolve(err("watch callback must be a function"));
}
+ const ignore = options?.ignore ?? [];
+ return this.searchOnNativeThread(async (handle) => {
+ const registered = ensureWatchCallbackRegistered(handle);
+ if (!registered.ok) return registered;
+ const created = intResultFromEnvelope(await readResultEnvelopeOnNativeThread(
+ "fff_watch_args",
+ [DataType.External, DataType.String, DataType.StringArray, DataType.U32],
+ [handle, "", ignore, ignore.length]
+ ));
+ if (!created.ok) return created;
+ // fff_destroy drops the native subscription of a finder destroyed meanwhile.
+ if (this.handle !== handle) return this.ensureAlive();
+ const watchId = created.value;
+ watchHandlers.set(watchId, callback);
+ this.watchers.add(watchId);
+ return {
+ ok: true,
+ value: () => {
+ if (!this.watchers.delete(watchId)) return;
+ if (this.handle !== null) ffiUnwatch(this.handle, watchId);
+ }
+ };
+ });
+ }
+ /** Patched in T3 Code: `grep` without blocking the JS thread. */
+ grepAsync(query, options) {
+ return this.searchOnNativeThread((handle) => ffiLiveGrep(
+ handle,
+ query,
+ options?.mode ?? "plain",
+ options?.maxFileSize ?? 0,
+ options?.maxMatchesPerFile ?? 0,
+ options?.smartCase ?? true,
+ options?.cursor?._offset ?? 0,
+ options?.pageSize ?? 0,
+ options?.timeBudgetMs ?? 0,
+ options?.enforceTimeBudget ?? false,
+ options?.beforeContext ?? 0,
+ options?.afterContext ?? 0,
+ options?.classifyDefinitions ?? false,
+ true
+ ));
}
/**
* Check if this instance has been destroyed.
@@ -1757,6 +1947,18 @@ var FileFinder = class _FileFinder {
if (!guard.ok) return guard;
return ffiScanFiles(guard.value);
}
+ /**
+ * Trigger a rescan without blocking the JS thread. Patched in T3 Code.
+ */
+ scanFilesAsync() {
+ return this.callOnNativeThread("fff_scan_files", voidResultFromEnvelope);
+ }
+ /**
+ * Read scan progress without blocking the JS thread. Patched in T3 Code.
+ */
+ getScanProgressAsync() {
+ return this.callOnNativeThread("fff_get_scan_progress", scanProgressFromEnvelope);
+ }
/**
* Check if a scan is currently in progress.
*/
@@ -1838,7 +2040,8 @@ var FileFinder = class _FileFinder {
if (!guard.ok) return guard;
const deadline = Date.now() + timeoutMs;
while (true) {
- const progress = this.getScanProgress();
+ // Patched in T3 Code: the progress read takes the picker lock.
+ const progress = await this.getScanProgressAsync();
if (!progress.ok) return progress;
if (!progress.value.isScanning && progress.value.isWarmupComplete) {
return { ok: true, value: true };
diff --git a/package.json b/package.json
index e000a78b3f79826200979ebb3fe297b599bcea67..84325461c2d963cb42cf72267079d36a419c1398 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
- "require": "./dist/index.cjs",
+ "require": "./dist/index.js",
"default": "./dist/index.js"
},
"./package.json": "./package.json"