@dimensional-innovations/electron-background 2.3.0 → 3.0.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 +340 -49
- package/dist/InitContext.d.ts +40 -0
- package/dist/InitContext.js +23 -0
- package/dist/InitPlugin.d.ts +39 -0
- package/dist/InitPlugin.js +2 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.js +12 -8
- package/dist/init.d.ts +10 -92
- package/dist/init.js +47 -60
- package/dist/{AutoUpdater.d.ts → plugins/AutoUpdater.d.ts} +8 -5
- package/dist/{AutoUpdater.js → plugins/AutoUpdater.js} +5 -5
- package/dist/{DevTools.d.ts → plugins/DevTools.d.ts} +4 -3
- package/dist/{DevTools.js → plugins/DevTools.js} +2 -2
- package/dist/{NodeHeartbeat.d.ts → plugins/NodeHeartbeat.d.ts} +8 -5
- package/dist/{NodeHeartbeat.js → plugins/NodeHeartbeat.js} +3 -3
- package/dist/{PrivilegedSchemes.d.ts → plugins/PrivilegedSchemes.d.ts} +2 -2
- package/dist/plugins/PrivilegedSchemes.js +27 -0
- package/dist/{SingleInstance.d.ts → plugins/SingleInstance.d.ts} +3 -2
- package/dist/{SingleInstance.js → plugins/SingleInstance.js} +3 -4
- package/dist/plugins/StaticFileDir.d.ts +16 -0
- package/dist/{StaticFileDir.js → plugins/StaticFileDir.js} +1 -2
- package/dist/{TouchEvents.d.ts → plugins/TouchEvents.d.ts} +2 -2
- package/dist/plugins/TouchEvents.js +14 -0
- package/dist/windows/AppBrowserWindow.d.ts +28 -0
- package/dist/{TouchEvents.js → windows/AppBrowserWindow.js} +16 -6
- package/dist/windows/FullScreenBrowserWindow.d.ts +17 -0
- package/dist/windows/FullScreenBrowserWindow.js +55 -0
- package/dist/windows/KioskBrowserWindow.d.ts +15 -0
- package/dist/windows/KioskBrowserWindow.js +32 -0
- package/dist/windows/util.d.ts +11 -0
- package/dist/windows/util.js +25 -0
- package/package.json +1 -1
- package/dist/BrowserWindow.d.ts +0 -47
- package/dist/BrowserWindow.js +0 -129
- package/dist/PrivilegedSchemes.js +0 -37
- package/dist/StaticFileDir.d.ts +0 -26
package/dist/init.d.ts
CHANGED
|
@@ -1,98 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The url used to load the application.
|
|
8
|
-
*/
|
|
9
|
-
appUrl: string;
|
|
10
|
-
/**
|
|
11
|
-
* Options used to create the BrowserWindow. These can be modified in `beforeReady` or
|
|
12
|
-
* `beforeLoad` methods to change the created BrowserWindow.
|
|
13
|
-
*/
|
|
14
|
-
browserWindowOptions: BrowserWindowConstructorOptions;
|
|
15
|
-
/**
|
|
16
|
-
* The log instance. This should be used over `console` in plugin implementations.
|
|
17
|
-
*/
|
|
18
|
-
log: Pick<Console, 'error' | 'warn' | 'info' | 'debug'>;
|
|
19
|
-
constructor(
|
|
20
|
-
/**
|
|
21
|
-
* The url used to load the application.
|
|
22
|
-
*/
|
|
23
|
-
appUrl: string,
|
|
24
|
-
/**
|
|
25
|
-
* Options used to create the BrowserWindow. These can be modified in `beforeReady` or
|
|
26
|
-
* `beforeLoad` methods to change the created BrowserWindow.
|
|
27
|
-
*/
|
|
28
|
-
browserWindowOptions: BrowserWindowConstructorOptions,
|
|
29
|
-
/**
|
|
30
|
-
* The log instance. This should be used over `console` in plugin implementations.
|
|
31
|
-
*/
|
|
32
|
-
log: Pick<Console, 'error' | 'warn' | 'info' | 'debug'>);
|
|
33
|
-
/**
|
|
34
|
-
* The main browser window that the app is loaded into. This is available in the context
|
|
35
|
-
* in the `beforeLoad` and `afterLoad` method.
|
|
36
|
-
*/
|
|
37
|
-
browserWindow?: BrowserWindow;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Represents the InitContext before the BrowserWindow has been set. Used in the
|
|
41
|
-
* "beforeReady" and "afterReady" methods.
|
|
42
|
-
*/
|
|
43
|
-
export type NonBrowserWindowInitContext = Omit<InitContext, 'browserWindow'>;
|
|
44
|
-
/**
|
|
45
|
-
* Represents the InitContext after the BrowserWindow has been set. Used in the
|
|
46
|
-
* "beforeLoad" and "afterLoad" methods.
|
|
47
|
-
*/
|
|
48
|
-
export type BrowserWindowInitContext = Omit<InitContext, 'browserWindow'> & Required<Pick<InitContext, 'browserWindow'>>;
|
|
49
|
-
/**
|
|
50
|
-
* A plugin is used to execute logic at various stages during the init process.
|
|
51
|
-
*
|
|
52
|
-
* Implementations can define one or more of the optional methods to customize
|
|
53
|
-
* application instance.
|
|
54
|
-
*/
|
|
55
|
-
export interface InitPlugin {
|
|
56
|
-
/**
|
|
57
|
-
* beforeReady is executed before the `app.whenReady()` promise resolves.
|
|
58
|
-
*
|
|
59
|
-
* @param context - The current InitContext instance.
|
|
60
|
-
*/
|
|
61
|
-
beforeReady?(context: NonBrowserWindowInitContext): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* afterReady is executed after the `app.whenReady()` promise resolves, but before the
|
|
64
|
-
* BrowserWindow is created.
|
|
65
|
-
*
|
|
66
|
-
* @param context - The current InitContext instance.
|
|
67
|
-
*/
|
|
68
|
-
afterReady?(context: NonBrowserWindowInitContext): Promise<void>;
|
|
1
|
+
import { NonBrowserWindowInitContext } from './InitContext';
|
|
2
|
+
import { InitPlugin } from './InitPlugin';
|
|
3
|
+
import { AppBrowserWindow } from './windows/AppBrowserWindow';
|
|
4
|
+
export interface InitOptions<T> {
|
|
5
|
+
config: () => T | Promise<T>;
|
|
69
6
|
/**
|
|
70
|
-
*
|
|
71
|
-
* has been loaded into the window.
|
|
72
|
-
*
|
|
73
|
-
* @param context - The current InitContext instance.
|
|
74
|
-
*/
|
|
75
|
-
beforeLoad?(context: BrowserWindowInitContext): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* afterLoad is executed after the application has been loaded into the browserWindow.
|
|
78
|
-
*
|
|
79
|
-
* @param context - The current InitContext instance.
|
|
80
|
-
*/
|
|
81
|
-
afterLoad?(context: BrowserWindowInitContext): Promise<void>;
|
|
82
|
-
}
|
|
83
|
-
export interface InitOptions {
|
|
84
|
-
/**
|
|
85
|
-
* The url to load once the the app has been created.
|
|
86
|
-
*/
|
|
87
|
-
appUrl: string;
|
|
88
|
-
/**
|
|
89
|
-
* The default browser window options
|
|
7
|
+
* The list of plugins to load with the application.
|
|
90
8
|
*/
|
|
91
|
-
|
|
9
|
+
plugins?: Array<InitPlugin<T>>;
|
|
92
10
|
/**
|
|
93
|
-
* The
|
|
11
|
+
* The windows to create during the init process.
|
|
94
12
|
*/
|
|
95
|
-
|
|
13
|
+
windows: Array<(context: NonBrowserWindowInitContext<T>) => AppBrowserWindow>;
|
|
96
14
|
}
|
|
97
15
|
/**
|
|
98
16
|
* Initializes the application, creating a browser window, and loads the provided app url.
|
|
@@ -100,4 +18,4 @@ export interface InitOptions {
|
|
|
100
18
|
* @param options - Options used to define how the application is initialized.
|
|
101
19
|
* @returns - The final state of the init context, including the created browser window for additional setup.
|
|
102
20
|
*/
|
|
103
|
-
export declare function init({
|
|
21
|
+
export declare function init<T>({ config, windows, plugins, }: InitOptions<T>): Promise<void>;
|
package/dist/init.js
CHANGED
|
@@ -12,38 +12,61 @@ 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 =
|
|
15
|
+
exports.init = init;
|
|
16
16
|
const electron_1 = require("electron");
|
|
17
17
|
const electron_log_1 = __importDefault(require("electron-log"));
|
|
18
|
+
const InitContext_1 = require("./InitContext");
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* Initializes the application, creating a browser window, and loads the provided app url.
|
|
21
|
+
*
|
|
22
|
+
* @param options - Options used to define how the application is initialized.
|
|
23
|
+
* @returns - The final state of the init context, including the created browser window for additional setup.
|
|
20
24
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
function init(_a) {
|
|
26
|
+
return __awaiter(this, arguments, void 0, function* ({ config, windows, plugins = [], }) {
|
|
27
|
+
if (windows.length === 0) {
|
|
28
|
+
throw new Error('At least 1 window must be defined.');
|
|
29
|
+
}
|
|
30
|
+
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';
|
|
31
|
+
electron_1.app.on('window-all-closed', electron_1.app.quit);
|
|
32
|
+
process.on('message', (data) => {
|
|
33
|
+
if (data === 'graceful-exit')
|
|
34
|
+
electron_1.app.quit();
|
|
35
|
+
});
|
|
36
|
+
process.on('SIGTERM', electron_1.app.quit);
|
|
37
|
+
let context = new InitContext_1.InitContext(electron_log_1.default);
|
|
38
|
+
for (const plugin of plugins) {
|
|
39
|
+
if (plugin.beforeReady) {
|
|
40
|
+
try {
|
|
41
|
+
plugin.beforeReady(context);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
context.log.error(`[init] Plugin "${getPluginName(plugin)}" threw during beforeReady:`, err);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
yield electron_1.app.whenReady();
|
|
49
|
+
context = new InitContext_1.InitContext(electron_log_1.default, yield config());
|
|
50
|
+
yield runPluginPhase(plugins, 'afterReady', context);
|
|
51
|
+
for (const windowFactory of windows) {
|
|
52
|
+
const window = windowFactory(context);
|
|
53
|
+
const windowContext = new InitContext_1.InitContext(context.log, context.config, window);
|
|
54
|
+
yield runPluginPhase(plugins, 'beforeLoad', windowContext);
|
|
55
|
+
try {
|
|
56
|
+
yield windowContext.browserWindow.loadApp();
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
electron_log_1.default.error('[init] Failed to load app URL:', err);
|
|
60
|
+
}
|
|
61
|
+
yield runPluginPhase(plugins, 'afterLoad', windowContext);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
40
64
|
}
|
|
41
|
-
exports.InitContext = InitContext;
|
|
42
65
|
function getPluginName(plugin) {
|
|
43
66
|
var _a;
|
|
44
67
|
return ((_a = plugin.constructor) === null || _a === void 0 ? void 0 : _a.name) || 'UnknownPlugin';
|
|
45
68
|
}
|
|
46
|
-
function runPluginPhase(plugins, phase, context
|
|
69
|
+
function runPluginPhase(plugins, phase, context) {
|
|
47
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
71
|
for (const plugin of plugins) {
|
|
49
72
|
const method = plugin[phase];
|
|
@@ -52,45 +75,9 @@ function runPluginPhase(plugins, phase, context, logger) {
|
|
|
52
75
|
yield method.call(plugin, context);
|
|
53
76
|
}
|
|
54
77
|
catch (err) {
|
|
55
|
-
|
|
78
|
+
context.log.error(`[init] Plugin "${getPluginName(plugin)}" threw during ${phase}:`, err);
|
|
56
79
|
}
|
|
57
80
|
}
|
|
58
81
|
}
|
|
59
82
|
});
|
|
60
83
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Initializes the application, creating a browser window, and loads the provided app url.
|
|
63
|
-
*
|
|
64
|
-
* @param options - Options used to define how the application is initialized.
|
|
65
|
-
* @returns - The final state of the init context, including the created browser window for additional setup.
|
|
66
|
-
*/
|
|
67
|
-
function init({ appUrl, browserWindowOptions = { height: 1920, width: 1080, backgroundColor: '#000' }, plugins = [], }) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';
|
|
70
|
-
electron_1.app.on('window-all-closed', electron_1.app.quit);
|
|
71
|
-
process.on('message', (data) => {
|
|
72
|
-
if (data === 'graceful-exit')
|
|
73
|
-
electron_1.app.quit();
|
|
74
|
-
});
|
|
75
|
-
process.on('SIGTERM', electron_1.app.quit);
|
|
76
|
-
const context = new InitContext(appUrl, browserWindowOptions, electron_log_1.default);
|
|
77
|
-
yield runPluginPhase(plugins, 'beforeReady', context, electron_log_1.default);
|
|
78
|
-
yield electron_1.app.whenReady();
|
|
79
|
-
yield runPluginPhase(plugins, 'afterReady', context, electron_log_1.default);
|
|
80
|
-
context.browserWindow = new electron_1.BrowserWindow(context.browserWindowOptions);
|
|
81
|
-
yield runPluginPhase(plugins, 'beforeLoad', context, electron_log_1.default);
|
|
82
|
-
try {
|
|
83
|
-
yield context.browserWindow.loadURL(context.appUrl);
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
electron_log_1.default.error('[init] Failed to load app URL:', err);
|
|
87
|
-
}
|
|
88
|
-
if (context.browserWindow && !context.browserWindow.isDestroyed() && !context.browserWindow.isVisible()) {
|
|
89
|
-
context.browserWindow.show();
|
|
90
|
-
}
|
|
91
|
-
yield runPluginPhase(plugins, 'afterLoad', context, electron_log_1.default);
|
|
92
|
-
context.browserWindow.on('closed', () => context.browserWindow = undefined);
|
|
93
|
-
return context;
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
exports.init = init;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InitPlugin } from '../InitPlugin';
|
|
2
|
+
import { NonBrowserWindowInitContext } from '../InitContext';
|
|
2
3
|
/**
|
|
3
4
|
* Options for configuring the AutoUpdater plugin.
|
|
4
5
|
*/
|
|
@@ -15,15 +16,17 @@ export interface AutoUpdaterOptions {
|
|
|
15
16
|
*
|
|
16
17
|
* For more info, see https://www.electron.build/auto-update
|
|
17
18
|
*/
|
|
18
|
-
export declare class AutoUpdater
|
|
19
|
-
|
|
19
|
+
export declare class AutoUpdater<T extends {
|
|
20
|
+
autoUpdateChannel?: string;
|
|
21
|
+
}> implements InitPlugin<T> {
|
|
20
22
|
private readonly options;
|
|
23
|
+
private readonly enabled;
|
|
21
24
|
/**
|
|
22
25
|
* @constructor
|
|
23
26
|
*
|
|
24
27
|
* @param enabled - Indicates if the plugin is enabled. Used to disable the plugin in development. Defaults to `app.isPackaged`.
|
|
25
28
|
*/
|
|
26
|
-
constructor(
|
|
27
|
-
|
|
29
|
+
constructor(options?: AutoUpdaterOptions, enabled?: boolean);
|
|
30
|
+
afterReady({ config, log }: NonBrowserWindowInitContext<T>): Promise<void>;
|
|
28
31
|
private startAutoUpdater;
|
|
29
32
|
}
|
|
@@ -28,13 +28,13 @@ class AutoUpdater {
|
|
|
28
28
|
*
|
|
29
29
|
* @param enabled - Indicates if the plugin is enabled. Used to disable the plugin in development. Defaults to `app.isPackaged`.
|
|
30
30
|
*/
|
|
31
|
-
constructor(enabled = electron_1.app.isPackaged
|
|
32
|
-
this.enabled = enabled;
|
|
31
|
+
constructor(options = {}, enabled = electron_1.app.isPackaged) {
|
|
33
32
|
this.options = options;
|
|
33
|
+
this.enabled = enabled;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
return __awaiter(this,
|
|
37
|
-
const
|
|
35
|
+
afterReady(_a) {
|
|
36
|
+
return __awaiter(this, arguments, void 0, function* ({ config, log }) {
|
|
37
|
+
const channel = this.options.channel || config.autoUpdateChannel;
|
|
38
38
|
if (this.enabled && channel) {
|
|
39
39
|
this.startAutoUpdater(channel);
|
|
40
40
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ExtensionReference } from 'electron-devtools-installer';
|
|
2
|
-
import {
|
|
2
|
+
import { InitPlugin } from '../InitPlugin';
|
|
3
|
+
import { BrowserWindowInitContext } from '../InitContext';
|
|
3
4
|
export type Extension = ExtensionReference;
|
|
4
5
|
export declare const DevToolExtensions: {
|
|
5
6
|
readonly EMBER_INSPECTOR: ExtensionReference;
|
|
@@ -13,7 +14,7 @@ export declare const DevToolExtensions: {
|
|
|
13
14
|
/**
|
|
14
15
|
* Installs dev tools extensions and opens the devTools panel.
|
|
15
16
|
*/
|
|
16
|
-
export declare class DevTools implements InitPlugin {
|
|
17
|
+
export declare class DevTools implements InitPlugin<unknown> {
|
|
17
18
|
private readonly devTools;
|
|
18
19
|
private readonly enabled;
|
|
19
20
|
/**
|
|
@@ -23,5 +24,5 @@ export declare class DevTools implements InitPlugin {
|
|
|
23
24
|
* @param enabled - Indicates if the plugin is enabled. Used to disable the plugin when the app is packaged. Defaults to `!app.isPackaged`.
|
|
24
25
|
*/
|
|
25
26
|
constructor(devTools: Array<ExtensionReference>, enabled?: boolean);
|
|
26
|
-
beforeLoad({ browserWindow }: BrowserWindowInitContext): Promise<void>;
|
|
27
|
+
beforeLoad({ browserWindow }: BrowserWindowInitContext<unknown>): Promise<void>;
|
|
27
28
|
}
|
|
@@ -35,8 +35,8 @@ class DevTools {
|
|
|
35
35
|
this.devTools = devTools;
|
|
36
36
|
this.enabled = enabled;
|
|
37
37
|
}
|
|
38
|
-
beforeLoad(
|
|
39
|
-
return __awaiter(this,
|
|
38
|
+
beforeLoad(_a) {
|
|
39
|
+
return __awaiter(this, arguments, void 0, function* ({ browserWindow }) {
|
|
40
40
|
if (!this.enabled) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { InitContext,
|
|
1
|
+
import { InitContext, NonBrowserWindowInitContext } from '../InitContext';
|
|
2
|
+
import { InitPlugin } from '../InitPlugin';
|
|
2
3
|
/**
|
|
3
4
|
* Options used to define the request used to monitor the app.
|
|
4
5
|
*/
|
|
@@ -16,7 +17,7 @@ export interface HeartbeatOptions {
|
|
|
16
17
|
/**
|
|
17
18
|
* Starts a "heartbeat", which sends a request to the provided url on an interval.
|
|
18
19
|
*/
|
|
19
|
-
export declare class Heartbeat implements InitPlugin {
|
|
20
|
+
export declare class Heartbeat<T> implements InitPlugin<T> {
|
|
20
21
|
private readonly options;
|
|
21
22
|
private readonly enabled;
|
|
22
23
|
/**
|
|
@@ -26,7 +27,7 @@ export declare class Heartbeat implements InitPlugin {
|
|
|
26
27
|
* @param enabled - Indicates if the plugin is enabled. Used to disable the plugin during development. Defaults to `app.isPackaged`.
|
|
27
28
|
*/
|
|
28
29
|
constructor(options: HeartbeatOptions, enabled?: boolean);
|
|
29
|
-
|
|
30
|
+
afterReady(context: NonBrowserWindowInitContext<T>): Promise<void>;
|
|
30
31
|
}
|
|
31
32
|
export interface BetterStackHeartbeatOptions {
|
|
32
33
|
/**
|
|
@@ -45,7 +46,9 @@ export interface BetterStackHeartbeatOptions {
|
|
|
45
46
|
/**
|
|
46
47
|
* Starts a "heartbeat" by sending a request to https://betterstack.com on an interval. Requires the apiKey to be in the app config.
|
|
47
48
|
*/
|
|
48
|
-
export declare class BetterStackHeartbeat
|
|
49
|
+
export declare class BetterStackHeartbeat<T extends {
|
|
50
|
+
heartbeatApiKey?: string;
|
|
51
|
+
}> implements InitPlugin<T> {
|
|
49
52
|
private readonly enabled;
|
|
50
53
|
private readonly options;
|
|
51
54
|
/**
|
|
@@ -55,5 +58,5 @@ export declare class BetterStackHeartbeat implements InitPlugin {
|
|
|
55
58
|
* @param options - Options that used to start the heartbeat.
|
|
56
59
|
*/
|
|
57
60
|
constructor(enabled?: boolean, options?: BetterStackHeartbeatOptions);
|
|
58
|
-
|
|
61
|
+
afterReady(context: NonBrowserWindowInitContext<T>): Promise<void>;
|
|
59
62
|
}
|
|
@@ -29,7 +29,7 @@ class Heartbeat {
|
|
|
29
29
|
this.options = options;
|
|
30
30
|
this.enabled = enabled;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
afterReady(context) {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
if (!this.enabled)
|
|
35
35
|
return;
|
|
@@ -55,9 +55,9 @@ class BetterStackHeartbeat {
|
|
|
55
55
|
this.enabled = enabled;
|
|
56
56
|
this.options = options;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
afterReady(context) {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const heartbeatApiKey = this.options.heartbeatApiKey;
|
|
60
|
+
const heartbeatApiKey = this.options.heartbeatApiKey || context.config.heartbeatApiKey;
|
|
61
61
|
if (this.enabled && heartbeatApiKey && typeof heartbeatApiKey === 'string') {
|
|
62
62
|
const url = this.options.isBetterStack
|
|
63
63
|
? `https://uptime.betterstack.com/api/v1/heartbeat/${heartbeatApiKey}`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InitPlugin } from '
|
|
1
|
+
import { InitPlugin } from '../InitPlugin';
|
|
2
2
|
/**
|
|
3
3
|
* Registers schemes as privileged.
|
|
4
4
|
*/
|
|
@@ -10,5 +10,5 @@ export declare class PrivilegedSchemes implements InitPlugin {
|
|
|
10
10
|
* @param schemes - The schemes to register as privileged.
|
|
11
11
|
*/
|
|
12
12
|
constructor(schemes: Array<string>);
|
|
13
|
-
beforeReady():
|
|
13
|
+
beforeReady(): false;
|
|
14
14
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrivilegedSchemes = void 0;
|
|
4
|
+
const electron_1 = require("electron");
|
|
5
|
+
/**
|
|
6
|
+
* Registers schemes as privileged.
|
|
7
|
+
*/
|
|
8
|
+
class PrivilegedSchemes {
|
|
9
|
+
/**
|
|
10
|
+
* @constructor
|
|
11
|
+
*
|
|
12
|
+
* @param schemes - The schemes to register as privileged.
|
|
13
|
+
*/
|
|
14
|
+
constructor(schemes) {
|
|
15
|
+
this.schemes = schemes;
|
|
16
|
+
}
|
|
17
|
+
beforeReady() {
|
|
18
|
+
const customSchemes = this.schemes
|
|
19
|
+
.map((scheme) => ({
|
|
20
|
+
scheme,
|
|
21
|
+
privileges: { secure: true, standard: true, supportFetchAPI: true },
|
|
22
|
+
}));
|
|
23
|
+
electron_1.protocol.registerSchemesAsPrivileged(customSchemes);
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.PrivilegedSchemes = PrivilegedSchemes;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { InitContext
|
|
1
|
+
import { InitContext } from '../InitContext';
|
|
2
|
+
import { InitPlugin } from '../InitPlugin';
|
|
2
3
|
/**
|
|
3
4
|
* Enforces that only a single instance of the app can run at the same time.
|
|
4
5
|
* If a second instance of the is opened, the second instance is closed and
|
|
5
6
|
* the first instance is brought back into focus.
|
|
6
7
|
*/
|
|
7
8
|
export declare class SingleInstance implements InitPlugin {
|
|
8
|
-
beforeReady():
|
|
9
|
+
beforeReady(): false;
|
|
9
10
|
afterReady(context: InitContext): Promise<void>;
|
|
10
11
|
}
|
|
@@ -18,12 +18,11 @@ const electron_1 = require("electron");
|
|
|
18
18
|
*/
|
|
19
19
|
class SingleInstance {
|
|
20
20
|
beforeReady() {
|
|
21
|
-
|
|
22
|
-
if (electron_1.app.requestSingleInstanceLock())
|
|
23
|
-
return;
|
|
21
|
+
if (!electron_1.app.requestSingleInstanceLock()) {
|
|
24
22
|
electron_1.app.quit();
|
|
25
23
|
process.exit(0);
|
|
26
|
-
}
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
27
26
|
}
|
|
28
27
|
afterReady(context) {
|
|
29
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InitPlugin } from '../InitPlugin';
|
|
2
|
+
/**
|
|
3
|
+
* Registers a custom scheme to serve static files.
|
|
4
|
+
*/
|
|
5
|
+
export declare class StaticFileDir implements InitPlugin {
|
|
6
|
+
private readonly scheme;
|
|
7
|
+
private readonly dir;
|
|
8
|
+
/**
|
|
9
|
+
* @constructor
|
|
10
|
+
*
|
|
11
|
+
* @param scheme - The scheme to serve the files from.
|
|
12
|
+
* @param dir - The directory where the static files are located.
|
|
13
|
+
*/
|
|
14
|
+
constructor(scheme: string, dir: string);
|
|
15
|
+
afterReady(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.StaticFileDir = void 0;
|
|
13
13
|
const electron_1 = require("electron");
|
|
14
14
|
const path_1 = require("path");
|
|
15
15
|
/**
|
|
@@ -51,4 +51,3 @@ function createFileProtocol(scheme, sourceDirectory) {
|
|
|
51
51
|
respond({ path });
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
exports.createFileProtocol = createFileProtocol;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TouchEvents = void 0;
|
|
4
|
+
const electron_1 = require("electron");
|
|
5
|
+
/**
|
|
6
|
+
* Enables touch events in the app.
|
|
7
|
+
*/
|
|
8
|
+
class TouchEvents {
|
|
9
|
+
beforeReady() {
|
|
10
|
+
electron_1.app.commandLine.appendSwitch('touch-events', 'enabled');
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.TouchEvents = TouchEvents;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BrowserWindow, BrowserWindowConstructorOptions } from "electron";
|
|
2
|
+
/**
|
|
3
|
+
* Options used to create a new Application Window.
|
|
4
|
+
*
|
|
5
|
+
* AppBrowserWindow extends Electron's BrowserWindow and so any options for the BrowserWindow
|
|
6
|
+
* are accepted here. For more info see: https://electronjs.org/docs/api/structures/browser-window-options
|
|
7
|
+
*/
|
|
8
|
+
export interface AppBrowserWindowConstructorOptions extends BrowserWindowConstructorOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The url to the application to load. This loaded by the AppBrowserWindow whenever loadApp
|
|
11
|
+
* is called.
|
|
12
|
+
*/
|
|
13
|
+
appUrl: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Extends Electron's BrowserWindow to add support for loading a single app through a url
|
|
17
|
+
* provided when the window is constructed.
|
|
18
|
+
*/
|
|
19
|
+
export declare class AppBrowserWindow extends BrowserWindow {
|
|
20
|
+
private readonly appUrl;
|
|
21
|
+
constructor(options: AppBrowserWindowConstructorOptions);
|
|
22
|
+
/**
|
|
23
|
+
* Loads the predefined app.
|
|
24
|
+
*
|
|
25
|
+
* @returns - A promise that is resolved as the app is loaded.
|
|
26
|
+
*/
|
|
27
|
+
loadApp(): Promise<void>;
|
|
28
|
+
}
|
|
@@ -9,16 +9,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.AppBrowserWindow = void 0;
|
|
13
13
|
const electron_1 = require("electron");
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Extends Electron's BrowserWindow to add support for loading a single app through a url
|
|
16
|
+
* provided when the window is constructed.
|
|
16
17
|
*/
|
|
17
|
-
class
|
|
18
|
-
|
|
18
|
+
class AppBrowserWindow extends electron_1.BrowserWindow {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super(options);
|
|
21
|
+
this.appUrl = options.appUrl;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Loads the predefined app.
|
|
25
|
+
*
|
|
26
|
+
* @returns - A promise that is resolved as the app is loaded.
|
|
27
|
+
*/
|
|
28
|
+
loadApp() {
|
|
19
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
|
|
30
|
+
return yield this.loadURL(this.appUrl);
|
|
21
31
|
});
|
|
22
32
|
}
|
|
23
33
|
}
|
|
24
|
-
exports.
|
|
34
|
+
exports.AppBrowserWindow = AppBrowserWindow;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AppBrowserWindow, AppBrowserWindowConstructorOptions } from "./AppBrowserWindow";
|
|
2
|
+
export interface FullScreenBrowserWindowConstructorOptions extends AppBrowserWindowConstructorOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The screen the window should occupy. Use 'primary' for the primary display,
|
|
5
|
+
* 'secondary' for the first non-primary display, or a number for the display
|
|
6
|
+
* at that index in the list returned by screen.getAllDisplays(). Defaults to 'primary'.
|
|
7
|
+
*/
|
|
8
|
+
screen?: 'primary' | 'secondary' | number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Ensures the browser window will always be fullscreen. Generally, KioskBrowserWindow is preferred
|
|
12
|
+
* over this window. However in cases where there are multiple windows, or a window needs to span
|
|
13
|
+
* multiple screens, the FullScreenBrowserWindow can be a better fit.
|
|
14
|
+
*/
|
|
15
|
+
export declare class FullScreenBrowserWindow extends AppBrowserWindow {
|
|
16
|
+
constructor({ screen: target, ...options }: FullScreenBrowserWindowConstructorOptions, enabled?: boolean);
|
|
17
|
+
}
|