@pi-unipi/notify 0.1.1 → 0.1.4
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/events.ts +2 -17
- package/package.json +1 -1
package/events.ts
CHANGED
|
@@ -11,7 +11,6 @@ import type { NotifyConfig, NotifyPlatform, NotifyDispatchResult } from "./types
|
|
|
11
11
|
import { sendNativeNotification } from "./platforms/native.js";
|
|
12
12
|
import { sendGotifyNotification } from "./platforms/gotify.js";
|
|
13
13
|
import { sendTelegramNotification } from "./platforms/telegram.js";
|
|
14
|
-
import { loadConfig } from "./settings.js";
|
|
15
14
|
|
|
16
15
|
/** Built-in event definitions — maps event key to pi hook + display label */
|
|
17
16
|
export const BUILTIN_EVENTS: Record<
|
|
@@ -26,9 +25,6 @@ export const BUILTIN_EVENTS: Record<
|
|
|
26
25
|
session_shutdown: { hook: "session_shutdown", label: "Session End" },
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
/** Stores registered listener cleanup functions */
|
|
30
|
-
const cleanupFns: Array<() => void> = [];
|
|
31
|
-
|
|
32
28
|
/**
|
|
33
29
|
* Register event listeners for all enabled notification events.
|
|
34
30
|
* Attaches listeners to pi hooks and routes notifications to platforms.
|
|
@@ -49,9 +45,6 @@ export function registerEventListeners(
|
|
|
49
45
|
};
|
|
50
46
|
|
|
51
47
|
(pi as any).on(def.hook, handler);
|
|
52
|
-
cleanupFns.push(() => {
|
|
53
|
-
(pi as any).off(def.hook, handler);
|
|
54
|
-
});
|
|
55
48
|
}
|
|
56
49
|
|
|
57
50
|
// Listen for dynamic module events
|
|
@@ -63,18 +56,10 @@ export function registerEventListeners(
|
|
|
63
56
|
}
|
|
64
57
|
};
|
|
65
58
|
(pi as any).on(UNIPI_EVENTS.MODULE_READY, moduleHandler);
|
|
66
|
-
cleanupFns.push(() => {
|
|
67
|
-
(pi as any).off(UNIPI_EVENTS.MODULE_READY, moduleHandler);
|
|
68
|
-
});
|
|
69
59
|
}
|
|
70
60
|
|
|
71
|
-
/**
|
|
72
|
-
export function unregisterEventListeners(): void {
|
|
73
|
-
for (const cleanup of cleanupFns) {
|
|
74
|
-
cleanup();
|
|
75
|
-
}
|
|
76
|
-
cleanupFns.length = 0;
|
|
77
|
-
}
|
|
61
|
+
/** No-op — cleanup handled by session teardown */
|
|
62
|
+
export function unregisterEventListeners(): void {}
|
|
78
63
|
|
|
79
64
|
/**
|
|
80
65
|
* Dispatch a notification to the configured platforms.
|
package/package.json
CHANGED