electrobun 0.7.1 → 0.7.2-beta.0

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/cli/index.ts +72 -69
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electrobun",
3
- "version": "0.7.1",
3
+ "version": "0.7.2-beta.0",
4
4
  "description": "Build ultra fast, tiny, and cross-platform desktop apps with Typescript.",
5
5
  "license": "MIT",
6
6
  "author": "Blackboard Technologies Inc.",
@@ -34,7 +34,7 @@
34
34
  "dev": "bun install && bun build:dev && bun build:cli && cd ../kitchen && bun install && bun build:dev && bun start",
35
35
  "dev:clean": "cd ../kitchen && rm -rf node_modules && rm -rf vendors/cef && cd ../package && bun dev",
36
36
  "dev:rerun": "cd ../kitchen && bun start",
37
- "dev:canary": "bun install && bun build:release && cd ../kitchen && bun install && bun build:canary && bun start:canary",
37
+ "dev:canary": "bun install && bun build:release && bun build:cli && cd ../kitchen && bun install && bun build:canary",
38
38
  "run:template": "bun install && bun build:dev && bun build:cli && cd ../templates/interactive-playground && bun install && bun build:dev && bun start",
39
39
  "dev:docs": "cd ../documentation && bun start",
40
40
  "build:docs:release": "cd ../documentation && bun run build",
package/src/cli/index.ts CHANGED
@@ -1120,22 +1120,19 @@ 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) - 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
- }
1132
-
1133
- cpSync(bunCliLauncherBinarySource, bunCliLauncherDestination, {
1134
- recursive: true,
1135
- dereference: true,
1136
- });
1123
+ // Copy zig launcher for all platforms
1124
+ const bunCliLauncherBinarySource = targetPaths.LAUNCHER_RELEASE;
1125
+ const bunCliLauncherDestination = join(appBundleMacOSPath, "launcher") + targetBinExt;
1126
+ const destLauncherFolder = dirname(bunCliLauncherDestination);
1127
+ if (!existsSync(destLauncherFolder)) {
1128
+ mkdirSync(destLauncherFolder, { recursive: true });
1137
1129
  }
1138
1130
 
1131
+ cpSync(bunCliLauncherBinarySource, bunCliLauncherDestination, {
1132
+ recursive: true,
1133
+ dereference: true,
1134
+ });
1135
+
1139
1136
  cpSync(targetPaths.MAIN_JS, join(appBundleFolderResourcesPath, 'main.js'), { dereference: true });
1140
1137
 
1141
1138
  // Bun runtime binary
@@ -1913,13 +1910,32 @@ if (commandArg === "init") {
1913
1910
  buildEnvironment === "stable"
1914
1911
  ? `${baseVolumeName}-stable`
1915
1912
  : baseVolumeName;
1916
- // hdiutil create -volname "YourAppName" -srcfolder /path/to/YourApp.app -ov -format UDZO YourAppName.dmg
1913
+
1914
+ // Create a staging directory for DMG contents (app + Applications shortcut)
1915
+ const dmgStagingDir = join(buildFolder, '.dmg-staging');
1916
+ if (existsSync(dmgStagingDir)) {
1917
+ rmSync(dmgStagingDir, { recursive: true });
1918
+ }
1919
+ mkdirSync(dmgStagingDir, { recursive: true });
1920
+
1921
+ // Copy the app bundle to the staging directory
1922
+ const stagedAppPath = join(dmgStagingDir, basename(selfExtractingBundle.appBundleFolderPath));
1923
+ execSync(`cp -R ${escapePathForTerminal(selfExtractingBundle.appBundleFolderPath)} ${escapePathForTerminal(stagedAppPath)}`);
1924
+
1925
+ // Create a symlink to /Applications for easy drag-and-drop installation
1926
+ const applicationsLink = join(dmgStagingDir, 'Applications');
1927
+ symlinkSync('/Applications', applicationsLink);
1928
+
1929
+ // hdiutil create -volname "YourAppName" -srcfolder /path/to/staging -ov -format UDZO YourAppName.dmg
1917
1930
  // Note: use ULFO (lzfse) for better compatibility with large CEF frameworks and modern macOS
1918
1931
  execSync(
1919
1932
  `hdiutil create -volname "${dmgVolumeName}" -srcfolder ${escapePathForTerminal(
1920
- selfExtractingBundle.appBundleFolderPath
1933
+ dmgStagingDir
1921
1934
  )} -ov -format ULFO ${escapePathForTerminal(dmgCreationPath)}`
1922
1935
  );
1936
+
1937
+ // Clean up staging directory
1938
+ rmSync(dmgStagingDir, { recursive: true });
1923
1939
  if (buildEnvironment === "stable" && dmgCreationPath !== finalDmgPath) {
1924
1940
  renameSync(dmgCreationPath, finalDmgPath);
1925
1941
  }
@@ -1977,29 +1993,8 @@ Categories=Application;
1977
1993
  // Make desktop file executable
1978
1994
  execSync(`chmod +x ${escapePathForTerminal(desktopFilePath)}`);
1979
1995
 
1980
- // Create user-friendly launcher script
1981
- const launcherScriptContent = `#!/bin/bash
1982
- # ${config.package?.name || config.app.name} Launcher
1983
- # This script launches the application from any location
1984
-
1985
- # Get the directory where this script is located
1986
- SCRIPT_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
1987
-
1988
- # Find the launcher binary relative to this script
1989
- LAUNCHER_BINARY="\$SCRIPT_DIR/bin/launcher"
1990
-
1991
- if [ ! -x "\$LAUNCHER_BINARY" ]; then
1992
- echo "Error: Could not find launcher binary at \$LAUNCHER_BINARY"
1993
- exit 1
1994
- fi
1995
-
1996
- # Launch the application
1997
- exec "\$LAUNCHER_BINARY" "\$@"
1998
- `;
1999
-
2000
- const launcherScriptPath = join(appBundleFolderPath, `${appFileName}.sh`);
2001
- writeFileSync(launcherScriptPath, launcherScriptContent);
2002
- execSync(`chmod +x ${escapePathForTerminal(launcherScriptPath)}`);
1996
+ // Note: No longer creating shell script wrapper - users can run bin/launcher directly
1997
+ // or use the symlink created by the self-extractor
2003
1998
 
2004
1999
  // Create self-extracting Linux binary (similar to Windows approach)
2005
2000
  const selfExtractingLinuxPath = await createLinuxSelfExtractingBinary(
@@ -2017,10 +2012,10 @@ exec "\$LAUNCHER_BINARY" "\$@"
2017
2012
  // Also keep the raw .run for backwards compatibility (optional)
2018
2013
  // artifactsToUpload.push(selfExtractingLinuxPath);
2019
2014
 
2020
- // On Linux, create a tar.gz of the bundle
2015
+ // On Linux, create a tar.gz of the bundle (for build process, not uploaded to artifacts)
2021
2016
  const linuxTarPath = join(buildFolder, `${appFileName}.tar.gz`);
2022
2017
  execSync(`tar -czf ${escapePathForTerminal(linuxTarPath)} -C ${escapePathForTerminal(buildFolder)} ${escapePathForTerminal(basename(appBundleFolderPath))}`);
2023
- artifactsToUpload.push(linuxTarPath);
2018
+ // Note: Not adding to artifactsToUpload - we use .tar.zst for updates and .run.tar.gz for distribution
2024
2019
  }
2025
2020
  }
2026
2021
 
@@ -2199,40 +2194,48 @@ exec "\$LAUNCHER_BINARY" "\$@"
2199
2194
  throw new Error(`Unsupported OS: ${OS}`);
2200
2195
  }
2201
2196
 
2202
- if (OS === 'macos') {
2203
- // Use the zig launcher for all builds (dev, canary, stable)
2204
- mainProc = Bun.spawn([join(bundleExecPath, 'launcher')], {
2205
- stdio: ['inherit', 'inherit', 'inherit'],
2206
- cwd: bundleExecPath
2207
- })
2208
- } else if (OS === 'win') {
2209
- // Try the main process - use relative path to Resources folder
2210
- mainProc = Bun.spawn(['./bun.exe', '../Resources/main.js'], {
2211
- stdio: ['inherit', 'inherit', 'inherit'],
2212
- cwd: bundleExecPath,
2213
- onExit: (proc, exitCode, signalCode, error) => {
2214
- console.log('Bun process exited:', { exitCode, signalCode, error });
2215
- }
2216
- })
2217
- } else if (OS === 'linux') {
2218
- let env = { ...process.env };
2219
-
2220
- // Add LD_PRELOAD for CEF libraries to fix static TLS allocation issues
2221
- if (config.build.linux?.bundleCEF) {
2222
- const cefLibs = ['./libcef.so', './libvk_swiftshader.so'];
2223
- const existingCefLibs = cefLibs.filter(lib => existsSync(join(bundleExecPath, lib)));
2197
+ if (OS === 'macos' || OS === 'linux') {
2198
+ // For Linux dev mode, update libNativeWrapper.so based on bundleCEF setting
2199
+ if (OS === 'linux') {
2200
+ const currentLibPath = join(bundleExecPath, 'libNativeWrapper.so');
2201
+ const targetPaths = getPlatformPaths('linux', ARCH);
2202
+ const correctLibSource = config.build.linux?.bundleCEF
2203
+ ? targetPaths.NATIVE_WRAPPER_LINUX_CEF
2204
+ : targetPaths.NATIVE_WRAPPER_LINUX;
2224
2205
 
2225
- if (existingCefLibs.length > 0) {
2226
- env['LD_PRELOAD'] = existingCefLibs.join(':');
2227
- console.log(`Using LD_PRELOAD for CEF: ${env['LD_PRELOAD']}`);
2206
+ if (existsSync(correctLibSource)) {
2207
+ try {
2208
+ cpSync(correctLibSource, currentLibPath, { dereference: true });
2209
+ console.log(`Updated libNativeWrapper.so for ${config.build.linux?.bundleCEF ? 'CEF' : 'GTK-only'} mode`);
2210
+ } catch (error) {
2211
+ console.warn('Failed to update libNativeWrapper.so:', error);
2212
+ }
2228
2213
  }
2229
2214
  }
2230
2215
 
2231
- mainProc = Bun.spawn([join(bundleExecPath, 'bun'), join(bundleResourcesPath, 'main.js')], {
2216
+ // Use the zig launcher for macOS and Linux
2217
+ mainProc = Bun.spawn([join(bundleExecPath, 'launcher')], {
2232
2218
  stdio: ['inherit', 'inherit', 'inherit'],
2233
- cwd: bundleExecPath,
2234
- env
2219
+ cwd: bundleExecPath
2235
2220
  })
2221
+ } else if (OS === 'win') {
2222
+ // Windows: Use launcher if available, otherwise fallback to direct execution
2223
+ const launcherPath = join(bundleExecPath, 'launcher.exe');
2224
+ if (existsSync(launcherPath)) {
2225
+ mainProc = Bun.spawn([launcherPath], {
2226
+ stdio: ['inherit', 'inherit', 'inherit'],
2227
+ cwd: bundleExecPath
2228
+ })
2229
+ } else {
2230
+ // Fallback for older builds
2231
+ mainProc = Bun.spawn(['./bun.exe', '../Resources/main.js'], {
2232
+ stdio: ['inherit', 'inherit', 'inherit'],
2233
+ cwd: bundleExecPath,
2234
+ onExit: (proc, exitCode, signalCode, error) => {
2235
+ console.log('Bun process exited:', { exitCode, signalCode, error });
2236
+ }
2237
+ })
2238
+ }
2236
2239
  }
2237
2240
 
2238
2241
  process.on("SIGINT", () => {