mani-calc 1.2.0 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mani-calc",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Spotlight-style instant calculator for Windows Search | Math, natural language & unit conversions | Offline-first productivity tool",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -67,19 +67,24 @@ class FloatingSearchBox {
67
67
  setupIPC() {
68
68
  // Handle query from renderer
69
69
  ipcMain.on('process-query', async (event, query) => {
70
+ console.log('Processing query:', query);
70
71
  try {
71
72
  // Check for system commands first
72
73
  const systemResult = await this.handleSystemCommand(query);
73
74
  if (systemResult) {
75
+ console.log('System command executed:', systemResult);
74
76
  event.reply('query-result', systemResult);
75
77
  setTimeout(() => this.hide(), 1000);
76
78
  return;
77
79
  }
78
80
 
79
81
  // Process as calculation
82
+ console.log('Calculating...');
80
83
  const result = await this.maniCalc.processQuery(query);
84
+ console.log('Calculation result:', result);
81
85
  event.reply('query-result', result);
82
86
  } catch (error) {
87
+ console.error('Error processing query:', error);
83
88
  event.reply('query-result', {
84
89
  error: error.message,
85
90
  type: 'error'
@@ -93,160 +98,18 @@ class FloatingSearchBox {
93
98
  });
94
99
  }
95
100
 
96
- async handleSystemCommand(query) {
97
- const cmd = query.toLowerCase().trim();
98
- const { exec } = require('child_process');
99
- const { promisify } = require('util');
100
- const execAsync = promisify(exec);
101
-
102
- const commands = {
103
- 'help': {
104
- action: async () => {
105
- return 'Commands: sleep, lock, shutdown, restart, logout, mute, volume up/down, theme, quit';
106
- },
107
- description: 'Show available commands'
108
- },
109
- 'quit': {
110
- action: async () => {
111
- setTimeout(() => app.quit(), 500);
112
- return 'Quitting Mani-Calc...';
113
- },
114
- description: 'Quit application'
115
- },
116
- 'exit': {
117
- action: async () => {
118
- setTimeout(() => app.quit(), 500);
119
- return 'Quitting Mani-Calc...';
120
- },
121
- description: 'Quit application'
122
- },
123
- 'theme': {
124
- action: async () => {
125
- this.window.webContents.send('toggle-theme');
126
- return 'Toggled theme';
127
- },
128
- description: 'Toggle Light/Dark mode'
129
- },
130
- 'sleep': {
131
- action: async () => {
132
- await execAsync('rundll32.exe powrprof.dll,SetSuspendState 0,1,0');
133
- return 'System going to sleep...';
134
- },
135
- description: 'Put computer to sleep'
136
- },
137
- 'shutdown': {
138
- action: async () => {
139
- await execAsync('shutdown /s /t 0');
140
- return 'Shutting down...';
141
- },
142
- description: 'Shutdown computer'
143
- },
144
- 'restart': {
145
- action: async () => {
146
- await execAsync('shutdown /r /t 0');
147
- return 'Restarting...';
148
- },
149
- description: 'Restart computer'
150
- },
151
- 'lock': {
152
- action: async () => {
153
- await execAsync('rundll32.exe user32.dll,LockWorkStation');
154
- return 'Locking computer...';
155
- },
156
- description: 'Lock computer'
157
- },
158
- 'logout': {
159
- action: async () => {
160
- await execAsync('shutdown /l');
161
- return 'Logging out...';
162
- },
163
- description: 'Log out current user'
164
- },
165
- 'empty recycle bin': {
166
- action: async () => {
167
- await execAsync('rd /s /q %systemdrive%\\$Recycle.bin');
168
- return 'Recycle bin emptied';
169
- },
170
- description: 'Empty recycle bin'
171
- },
172
- 'volume up': {
173
- action: async () => {
174
- await execAsync('nircmd.exe changesysvolume 2000');
175
- return 'Volume increased';
176
- },
177
- description: 'Increase volume'
178
- },
179
- 'volume down': {
180
- action: async () => {
181
- await execAsync('nircmd.exe changesysvolume -2000');
182
- return 'Volume decreased';
183
- },
184
- description: 'Decrease volume'
185
- },
186
- 'mute': {
187
- action: async () => {
188
- await execAsync('nircmd.exe mutesysvolume 1');
189
- return 'Volume muted';
190
- },
191
- description: 'Mute volume'
192
- },
193
- 'unmute': {
194
- action: async () => {
195
- await execAsync('nircmd.exe mutesysvolume 0');
196
- return 'Volume unmuted';
197
- },
198
- description: 'Unmute volume'
199
- }
200
- };
201
-
202
- if (commands[cmd]) {
203
- try {
204
- const message = await commands[cmd].action();
205
- return {
206
- result: message,
207
- type: 'system_command',
208
- formatted: message
209
- };
210
- } catch (error) {
211
- return {
212
- error: `Failed to execute: ${error.message}`,
213
- type: 'error'
214
- };
215
- }
216
- }
217
-
218
- return null;
219
- }
220
-
221
- show() {
222
- if (this.window) {
223
- this.window.show();
224
- this.window.focus();
225
- this.isVisible = true;
226
- this.window.webContents.send('focus-input');
227
- }
228
- }
229
-
230
- hide() {
231
- if (this.window) {
232
- this.window.hide();
233
- this.isVisible = false;
234
- this.window.webContents.send('clear-input');
235
- }
236
- }
237
-
238
- toggle() {
239
- if (this.isVisible) {
240
- this.hide();
241
- } else {
242
- this.show();
243
- }
244
- }
101
+ // ... (rest of methods) ...
245
102
 
246
103
  destroy() {
247
104
  if (this.window) {
248
- globalShortcut.unregister(this.hotkey);
249
- this.window.close();
105
+ try {
106
+ globalShortcut.unregister(this.hotkey);
107
+ if (!this.window.isDestroyed()) {
108
+ this.window.close();
109
+ }
110
+ } catch (err) {
111
+ console.error('Error destroying window:', err);
112
+ }
250
113
  this.window = null;
251
114
  }
252
115
  }