claude-code-notify-lite 1.0.7 → 1.0.8
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 +1 -1
- package/src/notifier.js +20 -25
package/package.json
CHANGED
package/src/notifier.js
CHANGED
|
@@ -15,40 +15,35 @@ function notifyWindows(title, message) {
|
|
|
15
15
|
return new Promise((resolve) => {
|
|
16
16
|
logger.info('Sending Windows notification', { title, messageLength: message.length });
|
|
17
17
|
|
|
18
|
-
const escapedTitle = title.replace(/
|
|
19
|
-
const escapedMessage = message.replace(/
|
|
18
|
+
const escapedTitle = title.replace(/'/g, "''");
|
|
19
|
+
const escapedMessage = message.replace(/'/g, "''").replace(/\n/g, '`n');
|
|
20
20
|
|
|
21
21
|
const psScript = `
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Claude Code").Show($toast)
|
|
38
|
-
`.trim();
|
|
39
|
-
|
|
40
|
-
exec(`powershell -NoProfile -ExecutionPolicy Bypass -Command "${psScript.replace(/"/g, '\\"')}"`,
|
|
22
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
23
|
+
$balloon = New-Object System.Windows.Forms.NotifyIcon
|
|
24
|
+
$balloon.Icon = [System.Drawing.SystemIcons]::Information
|
|
25
|
+
$balloon.BalloonTipIcon = 'Info'
|
|
26
|
+
$balloon.BalloonTipTitle = '${escapedTitle}'
|
|
27
|
+
$balloon.BalloonTipText = '${escapedMessage}'
|
|
28
|
+
$balloon.Visible = $true
|
|
29
|
+
$balloon.ShowBalloonTip(5000)
|
|
30
|
+
Start-Sleep -Seconds 5
|
|
31
|
+
$balloon.Dispose()
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const base64Command = Buffer.from(psScript, 'utf16le').toString('base64');
|
|
35
|
+
|
|
36
|
+
exec(`powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand ${base64Command}`,
|
|
41
37
|
{ encoding: 'utf8', windowsHide: true },
|
|
42
38
|
(err) => {
|
|
43
39
|
if (err) {
|
|
44
|
-
logger.warn('Windows
|
|
40
|
+
logger.warn('Windows balloon notification failed, trying node-notifier', err);
|
|
45
41
|
notifier.notify({
|
|
46
42
|
title: title,
|
|
47
43
|
message: message,
|
|
48
44
|
sound: false,
|
|
49
45
|
wait: false,
|
|
50
|
-
timeout: 5
|
|
51
|
-
appID: 'Claude Code'
|
|
46
|
+
timeout: 5
|
|
52
47
|
}, (notifyErr) => {
|
|
53
48
|
if (notifyErr) {
|
|
54
49
|
logger.error('node-notifier also failed', notifyErr);
|
|
@@ -58,7 +53,7 @@ function notifyWindows(title, message) {
|
|
|
58
53
|
resolve();
|
|
59
54
|
});
|
|
60
55
|
} else {
|
|
61
|
-
logger.info('Windows
|
|
56
|
+
logger.info('Windows balloon notification sent successfully');
|
|
62
57
|
resolve();
|
|
63
58
|
}
|
|
64
59
|
}
|