t3-code-android-nightly/patches/@ff-labs__fff-node@0.9.4.patch
Julius Marminge 06de59b3d6
build(server): make the CLI bundle loadable as a Node single-executable (#11316)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-13 21:24:20 -07:00

53 lines
1.8 KiB
Diff

diff --git a/dist/src/binary.js b/dist/src/binary.js
index ee181aef5007e4bf34a49479c089ca30f73a320b..327e2c55c83cc4c50d396a3109190ef10af75ca7 100644
--- a/dist/src/binary.js
+++ b/dist/src/binary.js
@@ -7,7 +7,7 @@
*/
import { existsSync, readFileSync } from "node:fs";
import { createRequire } from "node:module";
-import { dirname, join } from "node:path";
+import { dirname, join, sep } from "node:path";
import { fileURLToPath } from "node:url";
import { getLibFilename, getNpmPackageName } from "./platform.js";
/**
@@ -46,6 +46,16 @@ function getPackageDir() {
// Fallback: assume we're one level deep in src/
return dirname(currentDir);
}
+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;
+}
/**
* Check if the binary exists in any known location
*/
@@ -69,7 +77,7 @@ function resolveFromNpmPackage() {
const packageDir = dirname(packageJsonPath);
const binaryPath = join(packageDir, getLibFilename());
if (existsSync(binaryPath)) {
- return binaryPath;
+ return resolveUnpackedAsarPath(binaryPath);
}
}
catch {
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -8,8 +8,9 @@
"types": "dist/src/index.d.ts",
"exports": {
".": {
+ "types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js",
- "types": "./dist/src/index.d.ts"
+ "require": "./dist/src/index.js"
}
},
"files": [