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 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
- const asarLibPath = join(pathToMacOS, `libasar.${suffix}`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electrobun",
3
- "version": "0.2.0-beta.6",
3
+ "version": "0.2.0-beta.8",
4
4
  "description": "Build ultra fast, tiny, and cross-platform desktop apps with Typescript.",
5
5
  "license": "MIT",
6
6
  "author": "Blackboard Technologies Inc.",
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
- const bunCliLauncherBinarySource = targetPaths.LAUNCHER_RELEASE;
1125
- const bunCliLauncherDestination = join(appBundleMacOSPath, "launcher") + targetBinExt;
1126
- const destLauncherFolder = dirname(bunCliLauncherDestination);
1127
- if (!existsSync(destLauncherFolder)) {
1128
- // console.info('creating folder: ', destFolder);
1129
- mkdirSync(destLauncherFolder, { recursive: true });
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
- cpSync(bunCliLauncherBinarySource, bunCliLauncherDestination, {
1133
- recursive: true,
1134
- dereference: true,
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
- const asarLibSource = join(dirname(targetPaths.BSPATCH), 'libasar' + libExt);
1464
- if (existsSync(asarLibSource)) {
1465
- const asarLibDestination = join(appBundleMacOSPath, 'libasar' + libExt);
1466
- cpSync(asarLibSource, asarLibDestination, {
1467
- recursive: true,
1468
- dereference: true,
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
- const zigAsarCli = join(targetPaths.BSPATCH).replace('bspatch', 'zig-asar');
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
- if (unpackPatterns.length > 0) {
1623
- asarArgs.push("--unpack", unpackPatterns.join(","));
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
- const asarResult = Bun.spawnSync([zigAsarCli, ...asarArgs], {
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) {