mani-calc 1.1.0 ā 1.1.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/bin/overlay.js +16 -35
- package/package.json +1 -1
- package/src/ui/main-electron.js +44 -0
package/bin/overlay.js
CHANGED
|
@@ -1,46 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const chalk = require('chalk');
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const electron = require('electron');
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
let floatingSearch;
|
|
7
|
+
const mainScript = path.join(__dirname, '../src/ui/main-electron.js');
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// Initialize ManiCalc
|
|
15
|
-
maniCalc = new ManiCalc();
|
|
16
|
-
|
|
17
|
-
// Initialize Floating Search Box
|
|
18
|
-
floatingSearch = new FloatingSearchBox(maniCalc);
|
|
19
|
-
await floatingSearch.initialize();
|
|
20
|
-
|
|
21
|
-
console.log(chalk.green('ā Mani-Calc Overlay is running!'));
|
|
22
|
-
console.log(chalk.yellow('\nš Press Alt+Space to toggle the search box'));
|
|
23
|
-
console.log(chalk.gray(' Press Ctrl+C to exit\n'));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Handle app ready
|
|
27
|
-
app.on('ready', startOverlayMode);
|
|
28
|
-
|
|
29
|
-
// Prevent app from quitting when all windows are closed
|
|
30
|
-
app.on('window-all-closed', (e) => {
|
|
31
|
-
e.preventDefault();
|
|
9
|
+
const child = spawn(electron, [mainScript], {
|
|
10
|
+
stdio: 'inherit',
|
|
11
|
+
windowsHide: false
|
|
32
12
|
});
|
|
33
13
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (floatingSearch) {
|
|
37
|
-
floatingSearch.destroy();
|
|
38
|
-
}
|
|
14
|
+
child.on('close', (code) => {
|
|
15
|
+
process.exit(code);
|
|
39
16
|
});
|
|
40
17
|
|
|
41
|
-
// Handle
|
|
18
|
+
// Handle termination signals
|
|
42
19
|
process.on('SIGINT', () => {
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
child.kill('SIGINT');
|
|
21
|
+
process.exit(0);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
process.on('SIGTERM', () => {
|
|
25
|
+
child.kill('SIGTERM');
|
|
45
26
|
process.exit(0);
|
|
46
27
|
});
|
package/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const { app } = require('electron');
|
|
2
|
+
const ManiCalc = require('../index');
|
|
3
|
+
const FloatingSearchBox = require('./floating-search');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
|
|
6
|
+
let maniCalc;
|
|
7
|
+
let floatingSearch;
|
|
8
|
+
|
|
9
|
+
async function startOverlayMode() {
|
|
10
|
+
console.log(chalk.cyan('\nš Starting Mani-Calc Overlay Mode...\n'));
|
|
11
|
+
|
|
12
|
+
// Initialize ManiCalc
|
|
13
|
+
maniCalc = new ManiCalc();
|
|
14
|
+
|
|
15
|
+
// Initialize Floating Search Box
|
|
16
|
+
floatingSearch = new FloatingSearchBox(maniCalc);
|
|
17
|
+
await floatingSearch.initialize();
|
|
18
|
+
|
|
19
|
+
console.log(chalk.green('ā Mani-Calc Overlay is running!'));
|
|
20
|
+
console.log(chalk.yellow('\nš Press Alt+Space to toggle the search box'));
|
|
21
|
+
console.log(chalk.gray(' Press Ctrl+C to exit\n'));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Handle app ready
|
|
25
|
+
app.on('ready', startOverlayMode);
|
|
26
|
+
|
|
27
|
+
// Prevent app from quitting when all windows are closed
|
|
28
|
+
app.on('window-all-closed', (e) => {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Handle app quit
|
|
33
|
+
app.on('will-quit', () => {
|
|
34
|
+
if (floatingSearch) {
|
|
35
|
+
floatingSearch.destroy();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Handle Ctrl+C
|
|
40
|
+
process.on('SIGINT', () => {
|
|
41
|
+
console.log(chalk.cyan('\n\nš Shutting down Mani-Calc Overlay...\n'));
|
|
42
|
+
app.quit();
|
|
43
|
+
process.exit(0);
|
|
44
|
+
});
|