electrobun 0.0.19-beta.71 → 0.0.19-beta.72

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.
@@ -5,7 +5,22 @@ import tar from "tar";
5
5
  import { ZstdInit } from "@oneidentity/zstd-js/wasm";
6
6
  import { OS as currentOS, ARCH as currentArch } from '../../shared/platform';
7
7
 
8
- const appSupportDir = join(homedir(), "Library", "Application Support");
8
+ // Cross-platform app data directory
9
+ function getAppDataDir(): string {
10
+ switch (currentOS) {
11
+ case 'macos':
12
+ return join(homedir(), "Library", "Application Support");
13
+ case 'win':
14
+ // Use APPDATA environment variable or fallback to default location
15
+ return process.env.APPDATA || join(homedir(), "AppData", "Roaming");
16
+ case 'linux':
17
+ // Use XDG_CONFIG_HOME or fallback to ~/.config
18
+ return process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
19
+ default:
20
+ // Fallback to home directory with .config
21
+ return join(homedir(), ".config");
22
+ }
23
+ }
9
24
 
10
25
  // todo (yoav): share type with cli
11
26
  let localInfo: {
@@ -214,10 +229,20 @@ const Updater = {
214
229
  if (currentHash !== latestHash) {
215
230
  const cacheBuster = Math.random().toString(36).substring(7);
216
231
  const platformFolder = `${localInfo.channel}-${currentOS}-${currentArch}`;
232
+ // Platform-specific tarball naming
233
+ let tarballName: string;
234
+ if (currentOS === 'macos') {
235
+ tarballName = `${appFileName}.app.tar.zst`;
236
+ } else if (currentOS === 'win') {
237
+ tarballName = `${appFileName}.tar.zst`;
238
+ } else {
239
+ tarballName = `${appFileName}.tar.zst`;
240
+ }
241
+
217
242
  const urlToLatestTarball = join(
218
243
  localInfo.bucketUrl,
219
244
  platformFolder,
220
- `${appFileName}.app.tar.zst`
245
+ tarballName
221
246
  );
222
247
  const prevVersionCompressedTarballPath = join(
223
248
  appDataFolder,
@@ -294,16 +319,24 @@ const Updater = {
294
319
  file: latestTarPath,
295
320
  cwd: extractionFolder,
296
321
  onentry: (entry) => {
297
- // find the first .app bundle in the tarball
298
- // Some apps may have nested .app bundles
299
- if (!appBundleSubpath && entry.path.endsWith(".app/")) {
300
- appBundleSubpath = entry.path;
322
+ if (currentOS === 'macos') {
323
+ // find the first .app bundle in the tarball
324
+ // Some apps may have nested .app bundles
325
+ if (!appBundleSubpath && entry.path.endsWith(".app/")) {
326
+ appBundleSubpath = entry.path;
327
+ }
328
+ } else {
329
+ // For Windows/Linux, look for the main executable
330
+ // This assumes the tarball contains the app at the root
331
+ if (!appBundleSubpath) {
332
+ appBundleSubpath = "./";
333
+ }
301
334
  }
302
335
  },
303
336
  });
304
337
 
305
338
  if (!appBundleSubpath) {
306
- console.error("Failed to find app bundle in tarball");
339
+ console.error("Failed to find app in tarball");
307
340
  return;
308
341
  }
309
342
 
@@ -311,14 +344,22 @@ const Updater = {
311
344
  const newAppBundlePath = resolve(
312
345
  join(extractionFolder, appBundleSubpath)
313
346
  );
314
- // Note: dirname(process.execPath) is the path to the running app bundle's
315
- // Contents/MacOS directory
316
- const runningAppBundlePath = resolve(
317
- dirname(process.execPath),
318
- "..",
319
- ".."
320
- );
321
- const backupAppBundlePath = join(extractionFolder, "backup.app");
347
+ // Platform-specific app path calculation
348
+ let runningAppBundlePath: string;
349
+ if (currentOS === 'macos') {
350
+ // On macOS, executable is at Contents/MacOS/binary inside .app bundle
351
+ runningAppBundlePath = resolve(
352
+ dirname(process.execPath),
353
+ "..",
354
+ ".."
355
+ );
356
+ } else {
357
+ // On Windows/Linux, the executable is the app itself
358
+ runningAppBundlePath = process.execPath;
359
+ }
360
+ // Platform-specific backup naming
361
+ const backupName = currentOS === 'macos' ? "backup.app" : "backup";
362
+ const backupAppBundlePath = join(extractionFolder, backupName);
322
363
 
323
364
  try {
324
365
  // const backupState = statSync(backupAppBundlePath);
@@ -334,7 +375,20 @@ const Updater = {
334
375
  return;
335
376
  }
336
377
 
337
- await Bun.spawn(["open", runningAppBundlePath]);
378
+ // Cross-platform app launch
379
+ switch (currentOS) {
380
+ case 'macos':
381
+ await Bun.spawn(["open", runningAppBundlePath]);
382
+ break;
383
+ case 'win':
384
+ // On Windows, the runningAppBundlePath would be the .exe file
385
+ await Bun.spawn([runningAppBundlePath]);
386
+ break;
387
+ case 'linux':
388
+ // On Linux, directly execute the binary
389
+ await Bun.spawn([runningAppBundlePath]);
390
+ break;
391
+ }
338
392
  process.exit(0);
339
393
  }
340
394
  }
@@ -349,7 +403,7 @@ const Updater = {
349
403
  appDataFolder: async () => {
350
404
  await Updater.getLocallocalInfo();
351
405
  const appDataFolder = join(
352
- appSupportDir,
406
+ getAppDataDir(),
353
407
  localInfo.identifier,
354
408
  localInfo.name
355
409
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electrobun",
3
- "version": "0.0.19-beta.71",
3
+ "version": "0.0.19-beta.72",
4
4
  "description": "Build ultra fast, tiny, and cross-platform desktop apps with Typescript.",
5
5
  "license": "MIT",
6
6
  "author": "Blackboard Technologies Inc.",
@@ -1,17 +1,12 @@
1
1
  {
2
- "name": "HelloWorld",
3
- "id": "com.example.helloworld",
4
- "version": "1.0.0",
5
- "author": "Your Name",
6
- "description": "A simple Electrobun hello world app",
7
- "main": "src/bun/index.ts",
8
- "views": {
9
- "main": {
10
- "html": "src/mainview/index.html",
11
- "preload": "src/mainview/index.ts"
12
- }
13
- },
14
- "build": {
15
- "placeholderIcon": true
16
- }
2
+ "app": {
3
+ "name": "hellow-world",
4
+ "identifier": "helloworld.electrobun.dev",
5
+ "version": "0.0.1"
6
+ },
7
+ "build": {
8
+ "mac": {
9
+ "bundleCEF": false
10
+ }
11
+ },
17
12
  }