@dimensional-innovations/electron-background 2.2.3 → 2.3.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.
- package/README.md +0 -14
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +1 -1
- package/dist/AutoStart.d.ts +0 -28
- package/dist/AutoStart.js +0 -74
package/README.md
CHANGED
|
@@ -72,20 +72,6 @@ init({
|
|
|
72
72
|
});
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
### AutoStart
|
|
76
|
-
Registers the application as a login item so it launches automatically at system startup. On Windows, boot-initiated launches are detected via a `--autostart` argument, allowing an optional delay before initialization. On macOS/Linux the delay is skipped since boot detection is not reliable.
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
// Default: 30-second delay on boot launches
|
|
80
|
-
new AutoStart()
|
|
81
|
-
|
|
82
|
-
// Custom delay (in seconds)
|
|
83
|
-
new AutoStart(true, { startupDelay: 60 })
|
|
84
|
-
|
|
85
|
-
// No delay on boot launches
|
|
86
|
-
new AutoStart(true, { startupDelay: 0 })
|
|
87
|
-
```
|
|
88
|
-
|
|
89
75
|
### AutoUpdater
|
|
90
76
|
Starts the auto update process, checking for updates every 3 minutes and automatically installing the update once one is found.
|
|
91
77
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./AutoStart"), exports);
|
|
18
17
|
__exportStar(require("./AutoUpdater"), exports);
|
|
19
18
|
__exportStar(require("./BrowserWindow"), exports);
|
|
20
19
|
__exportStar(require("./DevTools"), exports);
|
package/package.json
CHANGED
package/dist/AutoStart.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { BrowserWindowInitContext, NonBrowserWindowInitContext, InitPlugin } from './init';
|
|
2
|
-
export interface AutoStartOptions {
|
|
3
|
-
/** Delay in seconds before initialization on boot launches (0 = no delay). Default: 30 */
|
|
4
|
-
startupDelay?: number;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Registers the application as a login item for automatic startup and optionally
|
|
8
|
-
* delays window creation on boot. The delay runs in `afterReady` — before the
|
|
9
|
-
* BrowserWindow is created — giving the GPU and display time to initialize after
|
|
10
|
-
* a system reboot. The delay only applies when the app was auto-started at system
|
|
11
|
-
* boot (detected via the `--autostart` process argument on Windows).
|
|
12
|
-
*
|
|
13
|
-
* On macOS/Linux, boot detection is not reliably possible, so the delay is always
|
|
14
|
-
* skipped — the app launches instantly regardless of how it was started.
|
|
15
|
-
*/
|
|
16
|
-
export declare class AutoStart implements InitPlugin {
|
|
17
|
-
private readonly enabled;
|
|
18
|
-
private readonly startupDelay;
|
|
19
|
-
/**
|
|
20
|
-
* @param enabled - Whether auto-start is active. Defaults to `app.isPackaged`.
|
|
21
|
-
* @param options - Configuration options for startup behavior.
|
|
22
|
-
*/
|
|
23
|
-
constructor(enabled?: boolean, options?: AutoStartOptions);
|
|
24
|
-
/** Returns true when the app was launched by the OS login item (Windows only). */
|
|
25
|
-
private isAutoStartLaunch;
|
|
26
|
-
afterReady(context: NonBrowserWindowInitContext): Promise<void>;
|
|
27
|
-
afterLoad(context: BrowserWindowInitContext): Promise<void>;
|
|
28
|
-
}
|
package/dist/AutoStart.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AutoStart = void 0;
|
|
13
|
-
const electron_1 = require("electron");
|
|
14
|
-
/** Argument passed to the login item so boot launches can be detected. */
|
|
15
|
-
const AUTOSTART_ARG = '--autostart';
|
|
16
|
-
/**
|
|
17
|
-
* Registers the application as a login item for automatic startup and optionally
|
|
18
|
-
* delays window creation on boot. The delay runs in `afterReady` — before the
|
|
19
|
-
* BrowserWindow is created — giving the GPU and display time to initialize after
|
|
20
|
-
* a system reboot. The delay only applies when the app was auto-started at system
|
|
21
|
-
* boot (detected via the `--autostart` process argument on Windows).
|
|
22
|
-
*
|
|
23
|
-
* On macOS/Linux, boot detection is not reliably possible, so the delay is always
|
|
24
|
-
* skipped — the app launches instantly regardless of how it was started.
|
|
25
|
-
*/
|
|
26
|
-
class AutoStart {
|
|
27
|
-
/**
|
|
28
|
-
* @param enabled - Whether auto-start is active. Defaults to `app.isPackaged`.
|
|
29
|
-
* @param options - Configuration options for startup behavior.
|
|
30
|
-
*/
|
|
31
|
-
constructor(enabled, options = {}) {
|
|
32
|
-
var _a;
|
|
33
|
-
this.enabled = enabled !== null && enabled !== void 0 ? enabled : electron_1.app.isPackaged;
|
|
34
|
-
this.startupDelay = (_a = options.startupDelay) !== null && _a !== void 0 ? _a : 30;
|
|
35
|
-
}
|
|
36
|
-
/** Returns true when the app was launched by the OS login item (Windows only). */
|
|
37
|
-
isAutoStartLaunch() {
|
|
38
|
-
return process.platform === 'win32' && process.argv.includes(AUTOSTART_ARG);
|
|
39
|
-
}
|
|
40
|
-
afterReady(context) {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
if (!this.enabled)
|
|
43
|
-
return;
|
|
44
|
-
if (this.startupDelay > 0 && this.isAutoStartLaunch()) {
|
|
45
|
-
context.log.info(`[AutoStart] Boot launch detected — delaying ${this.startupDelay}s before window creation`);
|
|
46
|
-
yield new Promise(resolve => setTimeout(resolve, this.startupDelay * 1000));
|
|
47
|
-
}
|
|
48
|
-
else if (this.startupDelay > 0) {
|
|
49
|
-
context.log.info('[AutoStart] Manual launch — skipping startup delay');
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
afterLoad(context) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
if (!this.enabled) {
|
|
56
|
-
context.log.info('[AutoStart] Disabled (not packaged)');
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
if (process.platform === 'win32') {
|
|
61
|
-
electron_1.app.setLoginItemSettings({ openAtLogin: true, args: [AUTOSTART_ARG] });
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
electron_1.app.setLoginItemSettings({ openAtLogin: true });
|
|
65
|
-
}
|
|
66
|
-
context.log.info('[AutoStart] Registered as login item');
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
context.log.error('[AutoStart] Failed to register login item:', err);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.AutoStart = AutoStart;
|