@dimensional-innovations/electron-background 2.2.0 → 2.2.1

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 CHANGED
@@ -73,7 +73,7 @@ init({
73
73
  ```
74
74
 
75
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 window creation. On macOS/Linux the delay is skipped since boot detection is not reliable.
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
77
 
78
78
  ```typescript
79
79
  // Default: 30-second delay on boot launches
@@ -1,12 +1,12 @@
1
- import { InitPlugin, NonBrowserWindowInitContext } from './init';
1
+ import { BrowserWindowInitContext, InitPlugin, NonBrowserWindowInitContext } from './init';
2
2
  export interface AutoStartOptions {
3
- /** Delay in seconds before window creation on boot launches (0 = no delay). Default: 30 */
3
+ /** Delay in seconds before initialization on boot launches (0 = no delay). Default: 30 */
4
4
  startupDelay?: number;
5
5
  }
6
6
  /**
7
7
  * Registers the application as a login item for automatic startup and optionally
8
- * delays window creation. The delay only applies when the app was auto-started at
9
- * system boot (detected via the `--autostart` process argument on Windows).
8
+ * delays initialization on boot. The delay only applies when the app was auto-started
9
+ * at system boot (detected via the `--autostart` process argument on Windows).
10
10
  *
11
11
  * On macOS/Linux, boot detection is not reliably possible, so the delay is always
12
12
  * skipped — the app launches instantly regardless of how it was started.
@@ -21,5 +21,6 @@ export declare class AutoStart implements InitPlugin {
21
21
  constructor(enabled?: boolean, options?: AutoStartOptions);
22
22
  /** Returns true when the app was launched by the OS login item (Windows only). */
23
23
  private isAutoStartLaunch;
24
- afterReady(context: NonBrowserWindowInitContext): Promise<void>;
24
+ beforeReady(context: NonBrowserWindowInitContext): Promise<void>;
25
+ afterLoad(context: BrowserWindowInitContext): Promise<void>;
25
26
  }
package/dist/AutoStart.js CHANGED
@@ -15,8 +15,8 @@ const electron_1 = require("electron");
15
15
  const AUTOSTART_ARG = '--autostart';
16
16
  /**
17
17
  * Registers the application as a login item for automatic startup and optionally
18
- * delays window creation. The delay only applies when the app was auto-started at
19
- * system boot (detected via the `--autostart` process argument on Windows).
18
+ * delays initialization on boot. The delay only applies when the app was auto-started
19
+ * at system boot (detected via the `--autostart` process argument on Windows).
20
20
  *
21
21
  * On macOS/Linux, boot detection is not reliably possible, so the delay is always
22
22
  * skipped — the app launches instantly regardless of how it was started.
@@ -35,14 +35,25 @@ class AutoStart {
35
35
  isAutoStartLaunch() {
36
36
  return process.platform === 'win32' && process.argv.includes(AUTOSTART_ARG);
37
37
  }
38
- afterReady(context) {
38
+ beforeReady(context) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (!this.enabled)
41
+ return;
42
+ if (this.startupDelay > 0 && this.isAutoStartLaunch()) {
43
+ context.log.info(`[AutoStart] Boot launch detected — delaying ${this.startupDelay}s before initialization`);
44
+ yield new Promise(resolve => setTimeout(resolve, this.startupDelay * 1000));
45
+ }
46
+ else if (this.startupDelay > 0) {
47
+ context.log.info('[AutoStart] Manual launch — skipping startup delay');
48
+ }
49
+ });
50
+ }
51
+ afterLoad(context) {
39
52
  return __awaiter(this, void 0, void 0, function* () {
40
53
  if (!this.enabled) {
41
54
  context.log.info('[AutoStart] Disabled (not packaged)');
42
55
  return;
43
56
  }
44
- // On Windows, include the autostart arg so boot launches can be distinguished
45
- // from manual launches. On other platforms, no args needed.
46
57
  try {
47
58
  if (process.platform === 'win32') {
48
59
  electron_1.app.setLoginItemSettings({ openAtLogin: true, args: [AUTOSTART_ARG] });
@@ -55,15 +66,6 @@ class AutoStart {
55
66
  catch (err) {
56
67
  context.log.error('[AutoStart] Failed to register login item:', err);
57
68
  }
58
- if (this.startupDelay > 0 && this.isAutoStartLaunch()) {
59
- context.log.info(`[AutoStart] Boot launch detected — delaying ${this.startupDelay}s before window creation`);
60
- yield new Promise(resolve => {
61
- setTimeout(resolve, this.startupDelay * 1000);
62
- });
63
- }
64
- else if (this.startupDelay > 0) {
65
- context.log.info('[AutoStart] Manual launch — skipping startup delay');
66
- }
67
69
  });
68
70
  }
69
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimensional-innovations/electron-background",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "the background script for electron apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",