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