@decaf-ts/for-os 0.0.0-stage → 0.2.7
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/LICENSE.md +21 -0
- package/README.md +380 -2
- package/lib/cjs/errors.cjs +73 -0
- package/lib/cjs/errors.cjs.map +1 -0
- package/lib/cjs/index.cjs +46 -0
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/native/icons.cjs +123 -0
- package/lib/cjs/native/icons.cjs.map +1 -0
- package/lib/cjs/native/loader.cjs +123 -0
- package/lib/cjs/native/loader.cjs.map +1 -0
- package/lib/cjs/native/types.cjs +4 -0
- package/lib/cjs/native/types.cjs.map +1 -0
- package/lib/cjs/notifications/NotificationCenter.cjs +328 -0
- package/lib/cjs/notifications/NotificationCenter.cjs.map +1 -0
- package/lib/cjs/tray/TrayIcon.cjs +367 -0
- package/lib/cjs/tray/TrayIcon.cjs.map +1 -0
- package/lib/cjs/tray/assets.cjs +31 -0
- package/lib/cjs/tray/assets.cjs.map +1 -0
- package/lib/esm/errors.js +65 -0
- package/lib/esm/errors.js.map +1 -0
- package/lib/esm/index.js +28 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/native/icons.js +117 -0
- package/lib/esm/native/icons.js.map +1 -0
- package/lib/esm/native/loader.js +116 -0
- package/lib/esm/native/loader.js.map +1 -0
- package/lib/esm/native/types.js +8 -0
- package/lib/esm/native/types.js.map +1 -0
- package/lib/esm/notifications/NotificationCenter.js +322 -0
- package/lib/esm/notifications/NotificationCenter.js.map +1 -0
- package/lib/esm/tray/TrayIcon.js +362 -0
- package/lib/esm/tray/TrayIcon.js.map +1 -0
- package/lib/esm/tray/assets.js +26 -0
- package/lib/esm/tray/assets.js.map +1 -0
- package/lib/types/errors.d.cts +56 -0
- package/lib/types/errors.d.mts +56 -0
- package/lib/types/index.d.cts +27 -0
- package/lib/types/index.d.mts +27 -0
- package/lib/types/native/icons.d.cts +71 -0
- package/lib/types/native/icons.d.mts +71 -0
- package/lib/types/native/loader.d.cts +37 -0
- package/lib/types/native/loader.d.mts +37 -0
- package/lib/types/native/types.d.cts +104 -0
- package/lib/types/native/types.d.mts +104 -0
- package/lib/types/notifications/NotificationCenter.d.cts +163 -0
- package/lib/types/notifications/NotificationCenter.d.mts +163 -0
- package/lib/types/tray/TrayIcon.d.cts +174 -0
- package/lib/types/tray/TrayIcon.d.mts +174 -0
- package/lib/types/tray/assets.d.cts +25 -0
- package/lib/types/tray/assets.d.mts +25 -0
- package/native/tray-icon-node/Cargo.lock +1511 -0
- package/native/tray-icon-node/Cargo.toml +45 -0
- package/native/tray-icon-node/Cross.toml +10 -0
- package/native/tray-icon-node/LICENSE +21 -0
- package/native/tray-icon-node/UPSTREAM-README.md +281 -0
- package/native/tray-icon-node/UPSTREAM.md +213 -0
- package/native/tray-icon-node/build-manifest.json +16 -0
- package/native/tray-icon-node/build.rs +5 -0
- package/native/tray-icon-node/index.d.ts +368 -0
- package/native/tray-icon-node/index.js +609 -0
- package/native/tray-icon-node/package.json +55 -0
- package/native/tray-icon-node/rustfmt.toml +31 -0
- package/native/tray-icon-node/source-manifest.json +30 -0
- package/native/tray-icon-node/src/common.rs +101 -0
- package/native/tray-icon-node/src/icon.rs +255 -0
- package/native/tray-icon-node/src/lib.rs +449 -0
- package/native/tray-icon-node/src/menu.rs +849 -0
- package/native/tray-icon-node/src/tray.rs +251 -0
- package/native/tray-icon-node/tray-icon-node.linux-x64-gnu.node +0 -0
- package/package.json +131 -4
- package/scripts/for-os-build.mjs +60 -0
- package/scripts/for-os-init.mjs +327 -0
- package/scripts/for-os-install.mjs +47 -0
- package/scripts/for-os-integration.mjs +137 -0
- package/scripts/for-os-integrity.mjs +51 -0
- package/scripts/for-os-package.mjs +49 -0
- package/scripts/lib/native.mjs +591 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NATIVE_MODULE_PACKAGE = exports.NATIVE_MODULE_ENV = void 0;
|
|
4
|
+
exports.loadNativeModule = loadNativeModule;
|
|
5
|
+
exports.requireNativeModule = requireNativeModule;
|
|
6
|
+
exports.resetNativeModuleCache = resetNativeModuleCache;
|
|
7
|
+
/**
|
|
8
|
+
* @module for-os.native.loader
|
|
9
|
+
* @description Locates and loads the vendored `tray-icon-node` NAPI-RS addon.
|
|
10
|
+
* @summary The addon is built from `native/tray-icon-node` by
|
|
11
|
+
* `scripts/for-os-install.mjs` and materialized into `node_modules/tray-icon-node`.
|
|
12
|
+
* Resolution order is an explicit `FOR_OS_NATIVE_MODULE` path, normal Node
|
|
13
|
+
* package resolution from the current project, then the crate's checked-in
|
|
14
|
+
* `index.js` under the current project. Loading never throws: callers decide
|
|
15
|
+
* whether a missing addon is fatal.
|
|
16
|
+
*/
|
|
17
|
+
const node_fs_1 = require("node:fs");
|
|
18
|
+
const node_module_1 = require("node:module");
|
|
19
|
+
const node_path_1 = require("node:path");
|
|
20
|
+
const errors_js_1 = require("./../errors.cjs");
|
|
21
|
+
/** Environment variable that pins an explicit native addon module path. */
|
|
22
|
+
exports.NATIVE_MODULE_ENV = "FOR_OS_NATIVE_MODULE";
|
|
23
|
+
/** Package name of the vendored addon. */
|
|
24
|
+
exports.NATIVE_MODULE_PACKAGE = "tray-icon-node";
|
|
25
|
+
const REQUIRED_MEMBERS = [
|
|
26
|
+
"initialize",
|
|
27
|
+
"update",
|
|
28
|
+
"Icon",
|
|
29
|
+
"Menu",
|
|
30
|
+
"TrayIconBuilder",
|
|
31
|
+
"pollMenuEvents",
|
|
32
|
+
"showNotification",
|
|
33
|
+
];
|
|
34
|
+
let cached;
|
|
35
|
+
function requireFrom(directory) {
|
|
36
|
+
return (0, node_module_1.createRequire)((0, node_path_1.join)(directory, "package.json"));
|
|
37
|
+
}
|
|
38
|
+
function resolutionRoots() {
|
|
39
|
+
const roots = new Set([process.cwd()]);
|
|
40
|
+
const initCwd = process.env.INIT_CWD;
|
|
41
|
+
if (initCwd)
|
|
42
|
+
roots.add((0, node_path_1.resolve)(initCwd));
|
|
43
|
+
const entry = process.argv[1];
|
|
44
|
+
if (entry)
|
|
45
|
+
roots.add((0, node_path_1.dirname)((0, node_path_1.resolve)(entry)));
|
|
46
|
+
return [...roots];
|
|
47
|
+
}
|
|
48
|
+
function candidatePaths() {
|
|
49
|
+
const candidates = [];
|
|
50
|
+
const explicit = process.env[exports.NATIVE_MODULE_ENV];
|
|
51
|
+
if (explicit)
|
|
52
|
+
candidates.push((0, node_path_1.resolve)(explicit));
|
|
53
|
+
for (const root of resolutionRoots()) {
|
|
54
|
+
try {
|
|
55
|
+
candidates.push(requireFrom(root).resolve(exports.NATIVE_MODULE_PACKAGE));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// not installed under this resolution root: try the source tree below
|
|
59
|
+
}
|
|
60
|
+
candidates.push((0, node_path_1.join)(root, "native", exports.NATIVE_MODULE_PACKAGE, "index.js"));
|
|
61
|
+
candidates.push((0, node_path_1.join)(root, "node_modules", exports.NATIVE_MODULE_PACKAGE, "index.js"));
|
|
62
|
+
}
|
|
63
|
+
return [...new Set(candidates)];
|
|
64
|
+
}
|
|
65
|
+
function isNativeModule(candidate) {
|
|
66
|
+
if (!candidate || typeof candidate !== "object")
|
|
67
|
+
return false;
|
|
68
|
+
const record = candidate;
|
|
69
|
+
return REQUIRED_MEMBERS.every((member) => typeof record[member] === "function");
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Loads the native addon, reusing one process-wide result.
|
|
73
|
+
* @return {NativeLoadResult} the loaded module or the reason it is unavailable
|
|
74
|
+
*/
|
|
75
|
+
function loadNativeModule() {
|
|
76
|
+
if (cached)
|
|
77
|
+
return cached;
|
|
78
|
+
const tried = candidatePaths();
|
|
79
|
+
const failures = [];
|
|
80
|
+
for (const candidate of tried) {
|
|
81
|
+
if (!(0, node_fs_1.existsSync)(candidate)) {
|
|
82
|
+
failures.push(`${candidate} (missing)`);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const loaded = requireFrom((0, node_path_1.dirname)(candidate))(candidate);
|
|
87
|
+
const api = (loaded?.default ?? loaded);
|
|
88
|
+
if (!isNativeModule(api)) {
|
|
89
|
+
failures.push(`${candidate} (unexpected module shape)`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
cached = { available: true, api, modulePath: candidate };
|
|
93
|
+
return cached;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
failures.push(`${candidate} (${error instanceof Error ? error.message : String(error)})`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
cached = {
|
|
100
|
+
available: false,
|
|
101
|
+
error: new errors_js_1.NativeModuleUnavailableError(`The native for-os addon "${exports.NATIVE_MODULE_PACKAGE}" is not available. ` +
|
|
102
|
+
`Run "npm run for-os:install" to build it from native/${exports.NATIVE_MODULE_PACKAGE}. ` +
|
|
103
|
+
`Tried: ${failures.join("; ")}`),
|
|
104
|
+
};
|
|
105
|
+
return cached;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Loads the native addon or throws {@link NativeModuleUnavailableError}.
|
|
109
|
+
* @return {NativeModule} the loaded native module
|
|
110
|
+
* @throws {NativeModuleUnavailableError} when no usable addon was found
|
|
111
|
+
*/
|
|
112
|
+
function requireNativeModule() {
|
|
113
|
+
const result = loadNativeModule();
|
|
114
|
+
if (!result.available)
|
|
115
|
+
throw result.error;
|
|
116
|
+
return result.api;
|
|
117
|
+
}
|
|
118
|
+
/** Clears the process-wide load cache (used by tests and re-installs). */
|
|
119
|
+
function resetNativeModuleCache() {
|
|
120
|
+
cached = undefined;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=loader.js.map
|
|
123
|
+
//# sourceMappingURL=loader.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native/loader.cjs","sourceRoot":"","sources":["native/loader.js"],"names":[],"mappings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"mappings":";;AAOA,iCAAiC"}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationCenter = exports.DEFAULT_NOTIFICATION_TIMEOUT_MS = void 0;
|
|
4
|
+
exports.notify = notify;
|
|
5
|
+
/**
|
|
6
|
+
* @module for-os.notifications
|
|
7
|
+
* @description Desktop-notification bridge with timers and JavaScript action callbacks.
|
|
8
|
+
* @summary `NotificationCenter` sends notifications through the native addon,
|
|
9
|
+
* exposes action buttons as JavaScript callbacks, and owns the auto-dismiss
|
|
10
|
+
* timer contract. Button delivery is native on Linux (through
|
|
11
|
+
* `notify-send --wait`); macOS and Windows render a plain notification and
|
|
12
|
+
* report that no buttons are available.
|
|
13
|
+
*/
|
|
14
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
15
|
+
const errors_js_1 = require("./../errors.cjs");
|
|
16
|
+
const loader_js_1 = require("./../native/loader.cjs");
|
|
17
|
+
/** Default auto-dismiss delay for a notification, in milliseconds. */
|
|
18
|
+
exports.DEFAULT_NOTIFICATION_TIMEOUT_MS = 10_000;
|
|
19
|
+
/** Interval of the cooperative native action poll, in milliseconds. */
|
|
20
|
+
const DEFAULT_POLL_INTERVAL_MS = 100;
|
|
21
|
+
function defaultLog(message) {
|
|
22
|
+
console.warn(message);
|
|
23
|
+
}
|
|
24
|
+
function validate(options) {
|
|
25
|
+
if (!options || typeof options !== "object") {
|
|
26
|
+
throw new db_decorators_1.ValidationError("Notification options are required.");
|
|
27
|
+
}
|
|
28
|
+
if (typeof options.title !== "string" || !options.title.trim()) {
|
|
29
|
+
throw new db_decorators_1.ValidationError("Notification title is required.");
|
|
30
|
+
}
|
|
31
|
+
if (typeof options.body !== "string" || !options.body.trim()) {
|
|
32
|
+
throw new db_decorators_1.ValidationError("Notification body is required.");
|
|
33
|
+
}
|
|
34
|
+
if (options.timeoutMs !== undefined &&
|
|
35
|
+
(!Number.isFinite(options.timeoutMs) || options.timeoutMs < 0)) {
|
|
36
|
+
throw new db_decorators_1.ValidationError("Notification timeoutMs must be a finite number >= 0.");
|
|
37
|
+
}
|
|
38
|
+
const ids = new Set();
|
|
39
|
+
for (const button of options.buttons ?? []) {
|
|
40
|
+
if (!button?.id || !button?.label) {
|
|
41
|
+
throw new db_decorators_1.ValidationError("Every notification button requires an id and a label.");
|
|
42
|
+
}
|
|
43
|
+
if (ids.has(button.id)) {
|
|
44
|
+
throw new db_decorators_1.ValidationError(`Duplicate notification button id "${button.id}".`);
|
|
45
|
+
}
|
|
46
|
+
ids.add(button.id);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @description Sends native notifications and maps their buttons to JavaScript callbacks.
|
|
51
|
+
* @summary Use one centre per process. Action ids are matched against
|
|
52
|
+
* registered global handlers, the notification's own `onAction`, and each
|
|
53
|
+
* button's `onClick`. An id that matches no live notification reaches global
|
|
54
|
+
* handlers only, and dismissed notifications are pruned from the record set.
|
|
55
|
+
* The reserved `default` body-click id maps to the owning notification's first
|
|
56
|
+
* button. `close()` clears the timer and poll loop.
|
|
57
|
+
* @param {NotificationCenterOptions} [options] native module override, poll
|
|
58
|
+
* interval, and diagnostics sink
|
|
59
|
+
* @class NotificationCenter
|
|
60
|
+
* @example
|
|
61
|
+
* import { NotificationCenter } from "@decaf-ts/for-os";
|
|
62
|
+
* const center = new NotificationCenter();
|
|
63
|
+
* const notification = center.notify({
|
|
64
|
+
* title: "Build finished",
|
|
65
|
+
* body: "The native addon is ready.",
|
|
66
|
+
* timeoutMs: 5000,
|
|
67
|
+
* buttons: [{ id: "open", label: "Open" }],
|
|
68
|
+
* });
|
|
69
|
+
* notification.onAction((actionId) => console.log(actionId));
|
|
70
|
+
* center.close();
|
|
71
|
+
*/
|
|
72
|
+
class NotificationCenter {
|
|
73
|
+
constructor(options = {}) {
|
|
74
|
+
this.globalHandlers = new Map();
|
|
75
|
+
this.records = [];
|
|
76
|
+
this.counter = 0;
|
|
77
|
+
this.closed = false;
|
|
78
|
+
this.api = options.api;
|
|
79
|
+
this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
80
|
+
this.log = options.log ?? defaultLog;
|
|
81
|
+
}
|
|
82
|
+
/** Whether a native notification backend is available. */
|
|
83
|
+
get available() {
|
|
84
|
+
if (this.api)
|
|
85
|
+
return true;
|
|
86
|
+
return (0, loader_js_1.loadNativeModule)().available;
|
|
87
|
+
}
|
|
88
|
+
native() {
|
|
89
|
+
if (this.closed) {
|
|
90
|
+
throw new errors_js_1.NativeModuleUnavailableError("The notification centre is closed.");
|
|
91
|
+
}
|
|
92
|
+
if (this.api)
|
|
93
|
+
return this.api;
|
|
94
|
+
return (0, loader_js_1.requireNativeModule)();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Registers a global handler for an action id.
|
|
98
|
+
* @param {string} id action id
|
|
99
|
+
* @param {NotificationActionHandler} handler callback
|
|
100
|
+
* @return {NotificationCenter} this instance
|
|
101
|
+
*/
|
|
102
|
+
registerAction(id, handler) {
|
|
103
|
+
const handlers = this.globalHandlers.get(id) ?? new Set();
|
|
104
|
+
handlers.add(handler);
|
|
105
|
+
this.globalHandlers.set(id, handlers);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Removes a global action handler.
|
|
110
|
+
* @param {string} id action id
|
|
111
|
+
* @param {NotificationActionHandler} handler callback
|
|
112
|
+
* @return {NotificationCenter} this instance
|
|
113
|
+
*/
|
|
114
|
+
unregisterAction(id, handler) {
|
|
115
|
+
this.globalHandlers.get(id)?.delete(handler);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Sends a notification and returns its handle.
|
|
120
|
+
* @param {NotifyOptions} options title, body, timer, and buttons
|
|
121
|
+
* @return {NotificationRecord} the dispatched notification
|
|
122
|
+
* @throws {ValidationError} for missing title/body or invalid options
|
|
123
|
+
* @throws {NativeModuleUnavailableError} when no native backend is available
|
|
124
|
+
*/
|
|
125
|
+
notify(options) {
|
|
126
|
+
validate(options);
|
|
127
|
+
const api = this.native();
|
|
128
|
+
const timeoutMs = options.timeoutMs ?? exports.DEFAULT_NOTIFICATION_TIMEOUT_MS;
|
|
129
|
+
const buttons = [...(options.buttons ?? [])];
|
|
130
|
+
const record = this.createRecord(options, timeoutMs, buttons, true);
|
|
131
|
+
try {
|
|
132
|
+
const actions = buttons.map((button) => ({
|
|
133
|
+
id: button.id,
|
|
134
|
+
label: button.label,
|
|
135
|
+
}));
|
|
136
|
+
if (actions.length && api.showNotificationWithActions) {
|
|
137
|
+
api.showNotificationWithActions(options.title, options.body, actions, timeoutMs > 0 ? timeoutMs : undefined);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
api.showNotification(options.title, options.body, timeoutMs > 0 ? timeoutMs : undefined);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
this.removeRecord(record);
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
this.startPoll();
|
|
148
|
+
return record;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Sends an appointment-style notification with Accept and See buttons.
|
|
152
|
+
* @param {Omit<NotifyOptions, "buttons">} options notification content
|
|
153
|
+
* @return {NotificationRecord} the dispatched notification
|
|
154
|
+
*/
|
|
155
|
+
notifyAppointment(options) {
|
|
156
|
+
const api = this.native();
|
|
157
|
+
if (!api.showAppointmentNotification) {
|
|
158
|
+
return this.notify({
|
|
159
|
+
...options,
|
|
160
|
+
buttons: [
|
|
161
|
+
{ id: "accept", label: "Accept appointment" },
|
|
162
|
+
{ id: "see", label: "See appointment" },
|
|
163
|
+
],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
validate(options);
|
|
167
|
+
const timeoutMs = options.timeoutMs ?? exports.DEFAULT_NOTIFICATION_TIMEOUT_MS;
|
|
168
|
+
const buttons = [
|
|
169
|
+
{ id: "accept", label: "Accept appointment" },
|
|
170
|
+
{ id: "see", label: "See appointment" },
|
|
171
|
+
];
|
|
172
|
+
const record = this.createRecord(options, timeoutMs, buttons, true);
|
|
173
|
+
try {
|
|
174
|
+
api.showAppointmentNotification(options.title, options.body, timeoutMs > 0 ? timeoutMs : undefined);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
this.removeRecord(record);
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
this.startPoll();
|
|
181
|
+
return record;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Drains pending native actions immediately.
|
|
185
|
+
* @return {string[]} action ids dispatched in this drain
|
|
186
|
+
*/
|
|
187
|
+
pollActions() {
|
|
188
|
+
const api = this.api ?? ((0, loader_js_1.loadNativeModule)().available ? (0, loader_js_1.requireNativeModule)() : undefined);
|
|
189
|
+
if (!api?.pollNotificationActions)
|
|
190
|
+
return [];
|
|
191
|
+
const dispatched = [];
|
|
192
|
+
try {
|
|
193
|
+
for (let action = api.pollNotificationActions(); action; action = api.pollNotificationActions()) {
|
|
194
|
+
this.dispatch(action);
|
|
195
|
+
dispatched.push(action);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
this.log(`for-os: notification action poll failed (${error instanceof Error ? error.message : String(error)}).`);
|
|
200
|
+
}
|
|
201
|
+
return dispatched;
|
|
202
|
+
}
|
|
203
|
+
/** Clears timers, the poll loop, and retained notification records. */
|
|
204
|
+
close() {
|
|
205
|
+
if (this.closed)
|
|
206
|
+
return;
|
|
207
|
+
this.closed = true;
|
|
208
|
+
if (this.poll)
|
|
209
|
+
clearInterval(this.poll);
|
|
210
|
+
this.poll = undefined;
|
|
211
|
+
for (const record of [...this.records]) {
|
|
212
|
+
if (record.timer)
|
|
213
|
+
clearTimeout(record.timer);
|
|
214
|
+
this.records.splice(this.records.indexOf(record), 1);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
createRecord(options, timeoutMs, buttons, delivered) {
|
|
218
|
+
const id = `for-os-notification-${++this.counter}`;
|
|
219
|
+
const record = {
|
|
220
|
+
id,
|
|
221
|
+
title: options.title,
|
|
222
|
+
body: options.body,
|
|
223
|
+
timeoutMs,
|
|
224
|
+
buttons,
|
|
225
|
+
delivered,
|
|
226
|
+
dismissed: false,
|
|
227
|
+
actionHandlers: new Set(),
|
|
228
|
+
dismissHandlers: [],
|
|
229
|
+
dismiss: () => undefined,
|
|
230
|
+
onAction: () => record,
|
|
231
|
+
};
|
|
232
|
+
record.dismiss = (reason = "manual") => this.dismiss(record, reason);
|
|
233
|
+
record.onAction = (handler) => {
|
|
234
|
+
record.actionHandlers.add(handler);
|
|
235
|
+
return record;
|
|
236
|
+
};
|
|
237
|
+
if (options.onAction)
|
|
238
|
+
record.actionHandlers.add(options.onAction);
|
|
239
|
+
if (options.onDismiss)
|
|
240
|
+
record.dismissHandlers.push(options.onDismiss);
|
|
241
|
+
if (timeoutMs > 0) {
|
|
242
|
+
record.timer = setTimeout(() => this.dismiss(record, "timer"), timeoutMs);
|
|
243
|
+
record.timer.unref?.();
|
|
244
|
+
}
|
|
245
|
+
this.records.push(record);
|
|
246
|
+
return record;
|
|
247
|
+
}
|
|
248
|
+
dismiss(record, reason) {
|
|
249
|
+
if (record.dismissed)
|
|
250
|
+
return;
|
|
251
|
+
record.dismissed = true;
|
|
252
|
+
if (record.timer)
|
|
253
|
+
clearTimeout(record.timer);
|
|
254
|
+
for (const handler of record.dismissHandlers) {
|
|
255
|
+
try {
|
|
256
|
+
handler(reason, record);
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
this.log(`for-os: notification dismiss handler failed (${error instanceof Error ? error.message : String(error)}).`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
this.removeRecord(record);
|
|
263
|
+
}
|
|
264
|
+
removeRecord(record) {
|
|
265
|
+
if (record.timer)
|
|
266
|
+
clearTimeout(record.timer);
|
|
267
|
+
const index = this.records.indexOf(record);
|
|
268
|
+
if (index >= 0)
|
|
269
|
+
this.records.splice(index, 1);
|
|
270
|
+
}
|
|
271
|
+
dispatch(actionId) {
|
|
272
|
+
const record = this.findRecord(actionId);
|
|
273
|
+
const handlers = this.globalHandlers.get(actionId);
|
|
274
|
+
if (handlers) {
|
|
275
|
+
for (const handler of handlers)
|
|
276
|
+
this.invoke(actionId, record, handler);
|
|
277
|
+
}
|
|
278
|
+
if (!record)
|
|
279
|
+
return;
|
|
280
|
+
const recordAction = actionId === "default" && !record.buttons.some((button) => button.id === "default")
|
|
281
|
+
? (record.buttons[0]?.id ?? actionId)
|
|
282
|
+
: actionId;
|
|
283
|
+
for (const handler of record.actionHandlers)
|
|
284
|
+
this.invoke(recordAction, record, handler);
|
|
285
|
+
const button = record.buttons.find((candidate) => candidate.id === recordAction);
|
|
286
|
+
if (button?.onClick)
|
|
287
|
+
this.invoke(recordAction, record, button.onClick);
|
|
288
|
+
}
|
|
289
|
+
findRecord(actionId) {
|
|
290
|
+
for (let index = this.records.length - 1; index >= 0; index--) {
|
|
291
|
+
const record = this.records[index];
|
|
292
|
+
if (record.buttons.some((button) => button.id === actionId))
|
|
293
|
+
return record;
|
|
294
|
+
}
|
|
295
|
+
if (actionId === "default") {
|
|
296
|
+
for (let index = this.records.length - 1; index >= 0; index--) {
|
|
297
|
+
if (this.records[index].buttons.length)
|
|
298
|
+
return this.records[index];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return undefined;
|
|
302
|
+
}
|
|
303
|
+
invoke(actionId, record, handler) {
|
|
304
|
+
try {
|
|
305
|
+
handler(actionId, record);
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
this.log(`for-os: notification action "${actionId}" handler failed (${error instanceof Error ? error.message : String(error)}).`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
startPoll() {
|
|
312
|
+
if (this.poll || this.closed)
|
|
313
|
+
return;
|
|
314
|
+
this.poll = setInterval(() => this.pollActions(), this.pollIntervalMs);
|
|
315
|
+
this.poll.unref?.();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
exports.NotificationCenter = NotificationCenter;
|
|
319
|
+
/**
|
|
320
|
+
* Sends one notification through a short-lived default centre.
|
|
321
|
+
* @param {NotifyOptions} options notification content
|
|
322
|
+
* @return {NotificationRecord} the dispatched notification
|
|
323
|
+
*/
|
|
324
|
+
function notify(options) {
|
|
325
|
+
return new NotificationCenter().notify(options);
|
|
326
|
+
}
|
|
327
|
+
//# sourceMappingURL=NotificationCenter.js.map
|
|
328
|
+
//# sourceMappingURL=NotificationCenter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifications/NotificationCenter.cjs","sourceRoot":"","sources":["notifications/NotificationCenter.js"],"names":[],"mappings":";;;AA8TA,wBAEC;AAhUD;;;;;;;;GAQG;AACH,2DAA0D;AAC1D,8CAA8D;AAC9D,qDAA8E;AAC9E,sEAAsE;AACzD,QAAA,+BAA+B,GAAG,MAAM,CAAC;AACtD,uEAAuE;AACvE,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,SAAS,UAAU,CAAC,OAAO;IACvB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AACD,SAAS,QAAQ,CAAC,OAAO;IACrB,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,+BAAe,CAAC,oCAAoC,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7D,MAAM,IAAI,+BAAe,CAAC,iCAAiC,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CA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