Open History to see the last commit
1diff --git a/package.json b/package.json
2--- a/package.json
3+++ b/package.json
4@@ -11,7 +11,7 @@
5 ".": {
6 "types": "./dist/index.d.ts",
7 "import": "./dist/index.js",
8- "require": "./dist/index.cjs",
9+ "require": "./dist/index.js",
10 "default": "./dist/index.js"
11 },
12 "./package.json": "./package.json"
13diff --git a/dist/fff-api.d.ts b/dist/fff-api.d.ts
14--- a/dist/fff-api.d.ts
15+++ b/dist/fff-api.d.ts
16@@ -199,7 +199,7 @@ export type Location = {
17 export interface SearchResult {
18 /** Matched file items */
19 items: FileItem[];
20- /** Corresponding scores for each item */
21+ /** 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). */
22 scores: Score[];
23 /** Total number of files that matched */
24 totalMatched: number;
25@@ -238,7 +238,7 @@ export interface DirSearchOptions {
26 export interface DirSearchResult {
27 /** Matched directory items */
28 items: DirItem[];
29- /** Corresponding scores for each item */
30+ /** 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). */
31 scores: Score[];
32 /** Total number of directories that matched */
33 totalMatched: number;
34@@ -262,7 +262,7 @@ export type MixedItem = {
35 export interface MixedSearchResult {
36 /** Matched items (files and directories interleaved by score) */
37 items: MixedItem[];
38- /** Corresponding scores for each item */
39+ /** 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). */
40 scores: Score[];
41 /** Total number of items (files + dirs) that matched */
42 totalMatched: number;
43diff --git a/dist/index.js b/dist/index.js
44--- a/dist/index.js
45+++ b/dist/index.js
46@@ -1,7 +1,7 @@
47 // src/binary.ts
48 import { existsSync, readFileSync } from "fs";
49 import { createRequire } from "module";
50-import { dirname, join } from "path";
51+import { dirname, join, sep } from "path";
52 import { fileURLToPath } from "url";
54 // src/platform.ts
55@@ -120,6 +120,16 @@ function getPackageDir() {
56 function binaryExists() {
57 return findBinary() !== null;
58 }
59+function resolveUnpackedAsarPath(binaryPath) {
60+ const pathSegments = binaryPath.split(sep);
61+ const asarIndex = pathSegments.findLastIndex((segment) => segment.endsWith(".asar"));
62+ if (asarIndex === -1) {
63+ return binaryPath;
64+ }
65+ pathSegments[asarIndex] = `${pathSegments[asarIndex]}.unpacked`;
66+ const unpackedPath = pathSegments.join(sep);
67+ return existsSync(unpackedPath) ? unpackedPath : binaryPath;
68+}
69 function resolveFromNpmPackage() {
70 const packageName = getNpmPackageName();
71 try {
72@@ -128,7 +138,7 @@ function resolveFromNpmPackage() {
73 const packageDir = dirname(packageJsonPath);
74 const binaryPath = join(packageDir, getLibFilename());
75 if (existsSync(binaryPath)) {
76- return binaryPath;
77+ return resolveUnpackedAsarPath(binaryPath);
78 }
79 } catch {
80 }
81@@ -262,6 +272,7 @@ function snakeToCamel(obj) {
82 return result;
83 }
84 function readCString(ptr) {
85+ if (typeof ptr === "string") return ptr;
86 if (isNullPointer(ptr)) return null;
87 try {
88 const [str] = restorePointer({
89@@ -426,9 +437,9 @@ function ffiDestroy(handle) {
90 });
91 }
92 var FFF_FILE_ITEM_STRUCT = {
93- relative_path: DataType.External,
94- file_name: DataType.External,
95- git_status: DataType.External,
96+ relative_path: DataType.String,
97+ file_name: DataType.String,
98+ git_status: DataType.String,
99 size: DataType.U64,
100 modified: DataType.U64,
101 access_frecency_score: DataType.I64,
102@@ -445,8 +456,9 @@ var FFF_SCORE_STRUCT = {
103 distance_penalty: DataType.I32,
104 current_file_penalty: DataType.I32,
105 combo_match_boost: DataType.I32,
106+ path_alignment_bonus: DataType.I32,
107 exact_match: DataType.U8,
108- match_type: DataType.External
109+ match_type: DataType.String
110 };
111 var FFF_SEARCH_RESULT_STRUCT = {
112 items: DataType.External,
113@@ -462,8 +474,8 @@ var FFF_SEARCH_RESULT_STRUCT = {
114 location_end_col: DataType.I32
115 };
116 var FFF_DIR_ITEM_STRUCT = {
117- relative_path: DataType.External,
118- dir_name: DataType.External,
119+ relative_path: DataType.String,
120+ dir_name: DataType.String,
121 max_access_frecency: DataType.I32
122 };
123 var FFF_DIR_SEARCH_RESULT_STRUCT = {
124@@ -475,9 +487,9 @@ var FFF_DIR_SEARCH_RESULT_STRUCT = {
125 };
126 var FFF_MIXED_ITEM_STRUCT = {
127 item_type: DataType.U8,
128- relative_path: DataType.External,
129- display_name: DataType.External,
130- git_status: DataType.External,
131+ relative_path: DataType.String,
132+ display_name: DataType.String,
133+ git_status: DataType.String,
134 size: DataType.U64,
135 modified: DataType.U64,
136 access_frecency_score: DataType.I64,
137@@ -500,10 +512,10 @@ var FFF_MIXED_SEARCH_RESULT_STRUCT = {
138 location_end_col: DataType.I32
139 };
140 var FFF_GREP_MATCH_STRUCT = {
141- relative_path: DataType.External,
142- file_name: DataType.External,
143- git_status: DataType.External,
144- line_content: DataType.External,
145+ relative_path: DataType.String,
146+ file_name: DataType.String,
147+ git_status: DataType.String,
148+ line_content: DataType.String,
149 match_ranges: DataType.External,
150 context_before: DataType.External,
151 context_after: DataType.External,
152@@ -598,18 +610,13 @@ function readMixedItemFromRaw(raw) {
153 }
154 function callAccessor(funcName, resultPtr, index, structDef) {
155 loadLibrary();
156- const elemPtr = load({
157+ return load({
158 library: LIBRARY_KEY,
159 funcName,
160- retType: DataType.External,
161+ retType: structDef,
162 paramsType: [DataType.External, DataType.U32],
163 paramsValue: [resultPtr, index]
164 });
165- const [raw] = restorePointer({
166- retType: [structDef],
167- paramsValue: wrapPointer([elemPtr])
168- });
169- return raw;
170 }
171 function ptrOffset(base, bytes) {
172 return load({
173@@ -766,6 +773,7 @@ function parseSearchResult(rawPtr) {
174 }
175 const items = [];
176 const scores = [];
177+ const includeScores = count <= 200;
178 for (let i = 0; i < count; i++) {
179 const rawItem = callAccessor(
180 "fff_search_result_get_item",
181@@ -774,13 +782,15 @@ function parseSearchResult(rawPtr) {
182 FFF_FILE_ITEM_STRUCT
183 );
184 items.push(readFileItemFromRaw(rawItem));
185- const rawScore = callAccessor(
186- "fff_search_result_get_score",
187- handlePtr,
188- i,
189- FFF_SCORE_STRUCT
190- );
191- scores.push(readScoreFromRaw(rawScore));
192+ if (includeScores) {
193+ const rawScore = callAccessor(
194+ "fff_search_result_get_score",
195+ handlePtr,
196+ i,
197+ FFF_SCORE_STRUCT
198+ );
199+ scores.push(readScoreFromRaw(rawScore));
200+ }
201 }
202 load({
203 library: LIBRARY_KEY,
204@@ -824,6 +834,7 @@ function parseDirSearchResult(rawPtr) {
205 const count = sr.count;
206 const items = [];
207 const scores = [];
208+ const includeScores = count <= 200;
209 for (let i = 0; i < count; i++) {
210 const rawItem = callAccessor(
211 "fff_dir_search_result_get_item",
212@@ -832,13 +843,15 @@ function parseDirSearchResult(rawPtr) {
213 FFF_DIR_ITEM_STRUCT
214 );
215 items.push(readDirItemFromRaw(rawItem));
216- const rawScore = callAccessor(
217- "fff_dir_search_result_get_score",
218- handlePtr,
219- i,
220- FFF_SCORE_STRUCT
221- );
222- scores.push(readScoreFromRaw(rawScore));
223+ if (includeScores) {
224+ const rawScore = callAccessor(
225+ "fff_dir_search_result_get_score",
226+ handlePtr,
227+ i,
228+ FFF_SCORE_STRUCT
229+ );
230+ scores.push(readScoreFromRaw(rawScore));
231+ }
232 }
233 load({
234 library: LIBRARY_KEY,
235@@ -897,6 +910,7 @@ function parseMixedSearchResult(rawPtr) {
236 }
237 const items = [];
238 const scores = [];
239+ const includeScores = count <= 200;
240 for (let i = 0; i < count; i++) {
241 const rawItem = callAccessor(
242 "fff_mixed_search_result_get_item",
243@@ -905,13 +919,15 @@ function parseMixedSearchResult(rawPtr) {
244 FFF_MIXED_ITEM_STRUCT
245 );
246 items.push(readMixedItemFromRaw(rawItem));
247- const rawScore = callAccessor(
248- "fff_mixed_search_result_get_score",
249- handlePtr,
250- i,
251- FFF_SCORE_STRUCT
252- );
253- scores.push(readScoreFromRaw(rawScore));
254+ if (includeScores) {
255+ const rawScore = callAccessor(
256+ "fff_mixed_search_result_get_score",
257+ handlePtr,
258+ i,
259+ FFF_SCORE_STRUCT
260+ );
261+ scores.push(readScoreFromRaw(rawScore));
262+ }
263 }
264 load({
265 library: LIBRARY_KEY,