electrobun 0.2.0-beta.6 → 0.2.0-beta.8
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/dist/main.js +7 -1
- package/package.json +1 -1
- package/src/cli/index.ts +88 -23
package/dist/main.js
CHANGED
|
@@ -73,8 +73,14 @@ function main() {
|
|
|
73
73
|
let appEntrypointPath;
|
|
74
74
|
if (existsSync(asarPath)) {
|
|
75
75
|
console.log(`[LAUNCHER] Loading app code from ASAR: ${asarPath}`);
|
|
76
|
-
|
|
76
|
+
let asarLibPath;
|
|
77
77
|
let asarLib;
|
|
78
|
+
if (process.platform === "win32") {
|
|
79
|
+
asarLibPath = libPath;
|
|
80
|
+
console.log(`[LAUNCHER] Using native wrapper's ASAR reader: ${asarLibPath}`);
|
|
81
|
+
} else {
|
|
82
|
+
asarLibPath = join(pathToMacOS, `libasar.${suffix}`);
|
|
83
|
+
}
|
|
78
84
|
try {
|
|
79
85
|
asarLib = dlopen(asarLibPath, {
|
|
80
86
|
asar_open: { args: ["cstring"], returns: "ptr" },
|
package/package.json
CHANGED
package/src/cli/index.ts
CHANGED
|
@@ -1120,19 +1120,21 @@ if (commandArg === "init") {
|
|
|
1120
1120
|
// mkdirSync(destLauncherFolder, {recursive: true});
|
|
1121
1121
|
// }
|
|
1122
1122
|
// cpSync(zigLauncherBinarySource, zigLauncherDestination, {recursive: true, dereference: true});
|
|
1123
|
-
// Copy zig launcher for all builds (dev, canary, stable)
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1123
|
+
// Copy zig launcher for all builds (dev, canary, stable) - macOS only
|
|
1124
|
+
if (targetOS === 'macos') {
|
|
1125
|
+
const bunCliLauncherBinarySource = targetPaths.LAUNCHER_RELEASE;
|
|
1126
|
+
const bunCliLauncherDestination = join(appBundleMacOSPath, "launcher") + targetBinExt;
|
|
1127
|
+
const destLauncherFolder = dirname(bunCliLauncherDestination);
|
|
1128
|
+
if (!existsSync(destLauncherFolder)) {
|
|
1129
|
+
// console.info('creating folder: ', destFolder);
|
|
1130
|
+
mkdirSync(destLauncherFolder, { recursive: true });
|
|
1131
|
+
}
|
|
1131
1132
|
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1133
|
+
cpSync(bunCliLauncherBinarySource, bunCliLauncherDestination, {
|
|
1134
|
+
recursive: true,
|
|
1135
|
+
dereference: true,
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1136
1138
|
|
|
1137
1139
|
cpSync(targetPaths.MAIN_JS, join(appBundleFolderResourcesPath, 'main.js'), { dereference: true });
|
|
1138
1140
|
|
|
@@ -1460,13 +1462,42 @@ if (commandArg === "init") {
|
|
|
1460
1462
|
|
|
1461
1463
|
// Copy libasar dynamic library for ASAR support
|
|
1462
1464
|
const libExt = targetOS === 'win' ? '.dll' : targetOS === 'macos' ? '.dylib' : '.so';
|
|
1463
|
-
|
|
1464
|
-
if (
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1465
|
+
|
|
1466
|
+
if (process.platform === 'win32') {
|
|
1467
|
+
// On Windows, copy BOTH x64 and ARM64 DLLs so launcher can choose at runtime
|
|
1468
|
+
// (x64 Bun on ARM64 Windows can't detect real CPU architecture)
|
|
1469
|
+
const x64DistPath = join(ELECTROBUN_DEP_PATH, 'dist-win-x64', 'zig-asar', 'x64', 'libasar.dll');
|
|
1470
|
+
const x64VendorPath = join(ELECTROBUN_DEP_PATH, 'vendors', 'zig-asar', 'x64', 'libasar.dll');
|
|
1471
|
+
const arm64DistPath = join(ELECTROBUN_DEP_PATH, 'dist-win-x64', 'zig-asar', 'arm64', 'libasar.dll');
|
|
1472
|
+
const arm64VendorPath = join(ELECTROBUN_DEP_PATH, 'vendors', 'zig-asar', 'arm64', 'libasar.dll');
|
|
1473
|
+
|
|
1474
|
+
// Copy x64 version as default libasar.dll
|
|
1475
|
+
const x64Source = existsSync(x64DistPath) ? x64DistPath : x64VendorPath;
|
|
1476
|
+
if (existsSync(x64Source)) {
|
|
1477
|
+
cpSync(x64Source, join(appBundleMacOSPath, 'libasar.dll'), {
|
|
1478
|
+
recursive: true,
|
|
1479
|
+
dereference: true,
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
// Copy ARM64 version as libasar-arm64.dll
|
|
1484
|
+
const arm64Source = existsSync(arm64DistPath) ? arm64DistPath : arm64VendorPath;
|
|
1485
|
+
if (existsSync(arm64Source)) {
|
|
1486
|
+
cpSync(arm64Source, join(appBundleMacOSPath, 'libasar-arm64.dll'), {
|
|
1487
|
+
recursive: true,
|
|
1488
|
+
dereference: true,
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
} else {
|
|
1492
|
+
// macOS/Linux: single architecture
|
|
1493
|
+
const asarLibSource = join(dirname(targetPaths.BSPATCH), 'libasar' + libExt);
|
|
1494
|
+
if (existsSync(asarLibSource)) {
|
|
1495
|
+
const asarLibDestination = join(appBundleMacOSPath, 'libasar' + libExt);
|
|
1496
|
+
cpSync(asarLibSource, asarLibDestination, {
|
|
1497
|
+
recursive: true,
|
|
1498
|
+
dereference: true,
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1470
1501
|
}
|
|
1471
1502
|
|
|
1472
1503
|
// transpile developer's bun code
|
|
@@ -1592,7 +1623,26 @@ if (commandArg === "init") {
|
|
|
1592
1623
|
|
|
1593
1624
|
const asarPath = join(appBundleFolderResourcesPath, "app.asar");
|
|
1594
1625
|
const asarUnpackedPath = join(appBundleFolderResourcesPath, "app.asar.unpacked");
|
|
1595
|
-
|
|
1626
|
+
|
|
1627
|
+
// Get zig-asar CLI path - on Windows, try x64 first (most common), fall back to arm64
|
|
1628
|
+
let zigAsarCli: string;
|
|
1629
|
+
if (process.platform === 'win32') {
|
|
1630
|
+
// Try x64 first from dist, then vendors
|
|
1631
|
+
const x64DistPath = join(ELECTROBUN_DEP_PATH, 'dist-win-x64', 'zig-asar', 'x64', 'zig-asar.exe');
|
|
1632
|
+
const x64VendorPath = join(ELECTROBUN_DEP_PATH, 'vendors', 'zig-asar', 'x64', 'zig-asar.exe');
|
|
1633
|
+
const arm64DistPath = join(ELECTROBUN_DEP_PATH, 'dist-win-x64', 'zig-asar', 'arm64', 'zig-asar.exe');
|
|
1634
|
+
const arm64VendorPath = join(ELECTROBUN_DEP_PATH, 'vendors', 'zig-asar', 'arm64', 'zig-asar.exe');
|
|
1635
|
+
|
|
1636
|
+
zigAsarCli = existsSync(x64DistPath) ? x64DistPath :
|
|
1637
|
+
existsSync(x64VendorPath) ? x64VendorPath :
|
|
1638
|
+
existsSync(arm64DistPath) ? arm64DistPath :
|
|
1639
|
+
arm64VendorPath;
|
|
1640
|
+
|
|
1641
|
+
console.log(`Using zig-asar from: ${zigAsarCli}`);
|
|
1642
|
+
} else {
|
|
1643
|
+
zigAsarCli = join(targetPaths.BSPATCH).replace('bspatch', 'zig-asar');
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1596
1646
|
const appDirPath = appBundleAppCodePath;
|
|
1597
1647
|
|
|
1598
1648
|
// Check if app directory exists
|
|
@@ -1619,16 +1669,31 @@ if (commandArg === "init") {
|
|
|
1619
1669
|
];
|
|
1620
1670
|
|
|
1621
1671
|
// Add unpack patterns if any
|
|
1622
|
-
|
|
1623
|
-
|
|
1672
|
+
// Each pattern needs its own --unpack flag
|
|
1673
|
+
for (const pattern of unpackPatterns) {
|
|
1674
|
+
asarArgs.push("--unpack", pattern);
|
|
1624
1675
|
}
|
|
1625
1676
|
|
|
1626
1677
|
// Run zig-asar pack
|
|
1627
|
-
|
|
1678
|
+
let asarResult = Bun.spawnSync([zigAsarCli, ...asarArgs], {
|
|
1628
1679
|
stdio: ["ignore", "inherit", "inherit"],
|
|
1629
1680
|
cwd: projectRoot,
|
|
1630
1681
|
});
|
|
1631
1682
|
|
|
1683
|
+
// If exit code 29 on Windows (binary can't run), try ARM64 version
|
|
1684
|
+
if (asarResult.exitCode === 29 && process.platform === 'win32' && zigAsarCli.includes('x64')) {
|
|
1685
|
+
console.log("x64 binary failed (exit code 29), trying ARM64 version...");
|
|
1686
|
+
const arm64DistPath = join(ELECTROBUN_DEP_PATH, 'dist-win-x64', 'zig-asar', 'arm64', 'zig-asar.exe');
|
|
1687
|
+
const arm64VendorPath = join(ELECTROBUN_DEP_PATH, 'vendors', 'zig-asar', 'arm64', 'zig-asar.exe');
|
|
1688
|
+
zigAsarCli = existsSync(arm64DistPath) ? arm64DistPath : arm64VendorPath;
|
|
1689
|
+
|
|
1690
|
+
console.log(`Retrying with: ${zigAsarCli}`);
|
|
1691
|
+
asarResult = Bun.spawnSync([zigAsarCli, ...asarArgs], {
|
|
1692
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
1693
|
+
cwd: projectRoot,
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1632
1697
|
if (asarResult.exitCode !== 0) {
|
|
1633
1698
|
console.error("ASAR packing failed with exit code:", asarResult.exitCode);
|
|
1634
1699
|
if (asarResult.stderr) {
|