@ff-labs/pi-fff 0.10.3 → 0.10.4-nightly.d4c416c
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/package.json +3 -3
- package/src/sdk.ts +15 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ff-labs/pi-fff",
|
|
3
3
|
"public": true,
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.4-nightly.d4c416c",
|
|
5
5
|
"description": "pi extension: FFF-powered fuzzy file and content search",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"typecheck": "tsc --noEmit"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@ff-labs/fff-bun": "0.10.
|
|
44
|
-
"@ff-labs/fff-node": "0.10.
|
|
43
|
+
"@ff-labs/fff-bun": "0.10.4-nightly.d4c416c",
|
|
44
|
+
"@ff-labs/fff-node": "0.10.4-nightly.d4c416c"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@earendil-works/pi-coding-agent": "*",
|
package/src/sdk.ts
CHANGED
|
@@ -22,8 +22,21 @@ function detectRuntime(): "bun" | "node" {
|
|
|
22
22
|
export function loadSdk(): Promise<{ FileFinder: FileFinderStatic }> {
|
|
23
23
|
if (sdkPromise) return sdkPromise;
|
|
24
24
|
|
|
25
|
+
// Pi reloads extension modules with jiti moduleCache:false, so this module
|
|
26
|
+
// is re-executed on every /reload. Re-importing the fff-bun module graph
|
|
27
|
+
// (which top-level awaits a `type: "file"` import of the native .so) hangs
|
|
28
|
+
// forever inside the Bun-compiled pi binary. Cache the first import on
|
|
29
|
+
// globalThis so reloads reuse the resolved module instead of re-importing.
|
|
30
|
+
const g = globalThis as Record<string, unknown>;
|
|
31
|
+
if (g.__fffSdkPromiseGlobal) {
|
|
32
|
+
sdkPromise = g.__fffSdkPromiseGlobal as Promise<{ FileFinder: FileFinderStatic }>;
|
|
33
|
+
return sdkPromise;
|
|
34
|
+
}
|
|
35
|
+
|
|
25
36
|
// default to node as it seems like default option
|
|
26
37
|
const pkg = detectRuntime() === "bun" ? "@ff-labs/fff-bun" : "@ff-labs/fff-node";
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
const p = import(pkg) as Promise<{ FileFinder: FileFinderStatic }>;
|
|
39
|
+
sdkPromise = p;
|
|
40
|
+
(globalThis as Record<string, unknown>).__fffSdkPromiseGlobal = p;
|
|
41
|
+
return p;
|
|
29
42
|
}
|