@dimensional-innovations/electron-background 2.2.3 → 2.3.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
@@ -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
 
@@ -32,8 +32,8 @@ class AutoUpdater {
32
32
  this.enabled = enabled;
33
33
  this.options = options;
34
34
  }
35
- afterLoad({ log }) {
36
- return __awaiter(this, void 0, void 0, function* () {
35
+ afterLoad(_a) {
36
+ return __awaiter(this, arguments, void 0, function* ({ log }) {
37
37
  const { channel } = this.options;
38
38
  if (this.enabled && channel) {
39
39
  this.startAutoUpdater(channel);
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -104,8 +114,8 @@ class FullScreenBrowserWindow extends DefaultBrowserWindow {
104
114
  super(options);
105
115
  this.enabled = enabled;
106
116
  }
107
- beforeLoad({ browserWindow }) {
108
- return __awaiter(this, void 0, void 0, function* () {
117
+ beforeLoad(_a) {
118
+ return __awaiter(this, arguments, void 0, function* ({ browserWindow }) {
109
119
  if (!this.enabled) {
110
120
  return;
111
121
  }
package/dist/DevTools.js CHANGED
@@ -35,8 +35,8 @@ class DevTools {
35
35
  this.devTools = devTools;
36
36
  this.enabled = enabled;
37
37
  }
38
- beforeLoad({ browserWindow }) {
39
- return __awaiter(this, void 0, void 0, function* () {
38
+ beforeLoad(_a) {
39
+ return __awaiter(this, arguments, void 0, function* ({ browserWindow }) {
40
40
  if (!this.enabled) {
41
41
  return;
42
42
  }
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createFileProtocol = exports.StaticFileDir = void 0;
12
+ exports.StaticFileDir = void 0;
13
+ exports.createFileProtocol = createFileProtocol;
13
14
  const electron_1 = require("electron");
14
15
  const path_1 = require("path");
15
16
  /**
@@ -51,4 +52,3 @@ function createFileProtocol(scheme, sourceDirectory) {
51
52
  respond({ path });
52
53
  });
53
54
  }
54
- exports.createFileProtocol = createFileProtocol;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './AutoStart';
2
1
  export * from './AutoUpdater';
3
2
  export * from './BrowserWindow';
4
3
  export * from './DevTools';
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/dist/init.js CHANGED
@@ -12,7 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.init = exports.InitContext = void 0;
15
+ exports.InitContext = void 0;
16
+ exports.init = init;
16
17
  const electron_1 = require("electron");
17
18
  const electron_log_1 = __importDefault(require("electron-log"));
18
19
  /**
@@ -64,8 +65,8 @@ function runPluginPhase(plugins, phase, context, logger) {
64
65
  * @param options - Options used to define how the application is initialized.
65
66
  * @returns - The final state of the init context, including the created browser window for additional setup.
66
67
  */
67
- function init({ appUrl, browserWindowOptions = { height: 1920, width: 1080, backgroundColor: '#000' }, plugins = [], }) {
68
- return __awaiter(this, void 0, void 0, function* () {
68
+ function init(_a) {
69
+ return __awaiter(this, arguments, void 0, function* ({ appUrl, browserWindowOptions = { height: 1920, width: 1080, backgroundColor: '#000' }, plugins = [], }) {
69
70
  process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';
70
71
  electron_1.app.on('window-all-closed', electron_1.app.quit);
71
72
  process.on('message', (data) => {
@@ -93,4 +94,3 @@ function init({ appUrl, browserWindowOptions = { height: 1920, width: 1080, back
93
94
  return context;
94
95
  });
95
96
  }
96
- exports.init = init;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimensional-innovations/electron-background",
3
- "version": "2.2.3",
3
+ "version": "2.3.1",
4
4
  "description": "the background script for electron apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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;