| 1 | diff --git a/package.json b/package.json |
| 2 | index e000a78..8432546 100644 |
| 3 | --- a/package.json |
| 4 | +++ b/package.json |
| 5 | @@ -11,7 +11,7 @@ |
| 6 | ".": { |
| 7 | "types": "./dist/index.d.ts", |
| 8 | "import": "./dist/index.js", |
| 9 | - "require": "./dist/index.cjs", |
| 10 | + "require": "./dist/index.js", |
| 11 | "default": "./dist/index.js" |
| 12 | }, |
| 13 | "./package.json": "./package.json" |
| 14 | diff --git a/dist/index.js b/dist/index.js |
| 15 | index 7c1d722..1d0bc27 100644 |
| 16 | --- a/dist/index.js |
| 17 | +++ b/dist/index.js |
| 18 | @@ -1,7 +1,7 @@ |
| 19 | // src/binary.ts |
| 20 | import { existsSync, readFileSync } from "fs"; |
| 21 | import { createRequire } from "module"; |
| 22 | -import { dirname, join } from "path"; |
| 23 | +import { dirname, join, sep } from "path"; |
| 24 | import { fileURLToPath } from "url"; |
| 25 | |
| 26 | // src/platform.ts |
| 27 | @@ -120,6 +120,16 @@ function getPackageDir() { |
| 28 | function binaryExists() { |
| 29 | return findBinary() !== null; |
| 30 | } |
| 31 | +function resolveUnpackedAsarPath(binaryPath) { |
| 32 | + const pathSegments = binaryPath.split(sep); |
| 33 | + const asarIndex = pathSegments.findLastIndex((segment) => segment.endsWith(".asar")); |
| 34 | + if (asarIndex === -1) { |
| 35 | + return binaryPath; |
| 36 | + } |
| 37 | + pathSegments[asarIndex] = `${pathSegments[asarIndex]}.unpacked`; |
| 38 | + const unpackedPath = pathSegments.join(sep); |
| 39 | + return existsSync(unpackedPath) ? unpackedPath : binaryPath; |
| 40 | +} |
| 41 | function resolveFromNpmPackage() { |
| 42 | const packageName = getNpmPackageName(); |
| 43 | try { |
| 44 | @@ -128,7 +138,7 @@ function resolveFromNpmPackage() { |
| 45 | const packageDir = dirname(packageJsonPath); |
| 46 | const binaryPath = join(packageDir, getLibFilename()); |
| 47 | if (existsSync(binaryPath)) { |
| 48 | - return binaryPath; |
| 49 | + return resolveUnpackedAsarPath(binaryPath); |
| 50 | } |
| 51 | } catch { |
| 52 | } |