@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,368 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export declare class AboutMetadataBuilder {
4
+ name?: string
5
+ version?: string
6
+ copyright?: string
7
+ authors?: Array<string>
8
+ website?: string
9
+ websiteLabel?: string
10
+ comments?: string
11
+ constructor()
12
+ withName(name: string): AboutMetadataBuilder
13
+ withVersion(version: string): AboutMetadataBuilder
14
+ withCopyright(copyright: string): AboutMetadataBuilder
15
+ withAuthors(authors: Array<string>): AboutMetadataBuilder
16
+ withWebsite(website: string): AboutMetadataBuilder
17
+ withWebsiteLabel(websiteLabel: string): AboutMetadataBuilder
18
+ withComments(comments: string): AboutMetadataBuilder
19
+ build(): AboutMetadata
20
+ }
21
+
22
+ export declare class CheckMenuItem {
23
+ isChecked(): boolean
24
+ setChecked(checked: boolean): void
25
+ }
26
+
27
+ export declare class CheckMenuItemBuilder {
28
+ constructor()
29
+ withText(text: string): CheckMenuItemBuilder
30
+ withEnabled(enabled: boolean): CheckMenuItemBuilder
31
+ withChecked(checked: boolean): CheckMenuItemBuilder
32
+ withId(id: string): CheckMenuItemBuilder
33
+ /**
34
+ * Builds the check menu item.
35
+ *
36
+ * # Errors
37
+ *
38
+ * Returns an error if the underlying OS fails to create the menu item.
39
+ */
40
+ build(): CheckMenuItem
41
+ }
42
+
43
+ export declare class Icon {
44
+ /**
45
+ * Creates an icon from an image file at the given path.
46
+ *
47
+ * # Errors
48
+ *
49
+ * Returns an error if the file cannot be opened or decoded as an image.
50
+ */
51
+ static fromPath(path: string): Icon
52
+ /**
53
+ * Creates an icon from raw RGBA pixel data.
54
+ *
55
+ * # Errors
56
+ *
57
+ * Returns an error if the RGBA data length does not match `width * height * 4`
58
+ * or the OS fails to create the icon.
59
+ */
60
+ static fromRgba(rgba: Buffer, width: number, height: number): Icon
61
+ }
62
+
63
+ export declare class IconMenuItem {
64
+ setText(text: string): void
65
+ setEnabled(enabled: boolean): void
66
+ }
67
+
68
+ export declare class IconMenuItemBuilder {
69
+ constructor()
70
+ withText(text: string): IconMenuItemBuilder
71
+ withEnabled(enabled: boolean): IconMenuItemBuilder
72
+ /**
73
+ * Sets the icon for this menu item.
74
+ *
75
+ * # Errors
76
+ *
77
+ * Returns an error if the icon data is invalid or the OS fails to create the icon.
78
+ */
79
+ withIcon(icon: Icon): IconMenuItemBuilder
80
+ withId(id: string): IconMenuItemBuilder
81
+ /**
82
+ * Builds the icon menu item.
83
+ *
84
+ * # Errors
85
+ *
86
+ * Returns an error if no icon was set or the OS fails to create the menu item.
87
+ */
88
+ build(): IconMenuItem
89
+ }
90
+
91
+ export declare class Menu {
92
+ constructor()
93
+ /**
94
+ * Appends a checkable menu item to this menu.
95
+ *
96
+ * # Errors
97
+ *
98
+ * Returns an error if the underlying OS menu operation fails.
99
+ */
100
+ appendCheckMenuItem(item: CheckMenuItem, id: string): void
101
+ /**
102
+ * Appends a standard menu item to this menu.
103
+ *
104
+ * # Errors
105
+ *
106
+ * Returns an error if the underlying OS menu operation fails.
107
+ */
108
+ appendMenuItem(item: MenuItem, id?: string | undefined | null): void
109
+ /**
110
+ * Appends a submenu to this menu.
111
+ *
112
+ * # Errors
113
+ *
114
+ * Returns an error if the underlying OS menu operation fails.
115
+ */
116
+ appendSubmenu(item: Submenu, id?: string | undefined | null): void
117
+ /**
118
+ * Appends an icon menu item to this menu.
119
+ *
120
+ * # Errors
121
+ *
122
+ * Returns an error if the underlying OS menu operation fails.
123
+ */
124
+ appendIconMenuItem(item: IconMenuItem, id: string): void
125
+ /**
126
+ * Appends a predefined menu item (e.g., separator) to this menu.
127
+ *
128
+ * # Errors
129
+ *
130
+ * Returns an error if the underlying OS menu operation fails.
131
+ */
132
+ appendPredefinedMenuItem(item: PredefinedMenuItem): void
133
+ isChecked(id: string): boolean
134
+ toggleCheck(id: string): boolean
135
+ setText(id: string, text: string): void
136
+ }
137
+
138
+ export declare class MenuItem {
139
+ setText(text: string): void
140
+ setEnabled(enabled: boolean): void
141
+ }
142
+
143
+ export declare class MenuItemBuilder {
144
+ constructor()
145
+ withText(text: string): MenuItemBuilder
146
+ withEnabled(enabled: boolean): MenuItemBuilder
147
+ withId(id: string): MenuItemBuilder
148
+ /**
149
+ * Builds the menu item.
150
+ *
151
+ * # Errors
152
+ *
153
+ * Returns an error if the underlying OS fails to create the menu item.
154
+ */
155
+ build(): MenuItem
156
+ }
157
+
158
+ export declare class PredefinedMenuItem {
159
+ static separator(): PredefinedMenuItem
160
+ }
161
+
162
+ export declare class Submenu {
163
+ /**
164
+ * Appends a standard menu item to this submenu.
165
+ *
166
+ * # Errors
167
+ *
168
+ * Returns an error if the underlying OS menu operation fails.
169
+ */
170
+ appendMenuItem(item: MenuItem, id?: string | undefined | null): void
171
+ /**
172
+ * Appends a nested submenu to this submenu.
173
+ *
174
+ * # Errors
175
+ *
176
+ * Returns an error if the underlying OS menu operation fails.
177
+ */
178
+ appendSubmenu(item: Submenu, id?: string | undefined | null): void
179
+ /**
180
+ * Appends a checkable menu item to this submenu.
181
+ *
182
+ * # Errors
183
+ *
184
+ * Returns an error if the underlying OS menu operation fails.
185
+ */
186
+ appendCheckMenuItem(item: CheckMenuItem, id: string): void
187
+ /**
188
+ * Appends an icon menu item to this submenu.
189
+ *
190
+ * # Errors
191
+ *
192
+ * Returns an error if the underlying OS menu operation fails.
193
+ */
194
+ appendIconMenuItem(item: IconMenuItem, id?: string | undefined | null): void
195
+ /**
196
+ * Appends a predefined menu item (e.g., separator) to this submenu.
197
+ *
198
+ * # Errors
199
+ *
200
+ * Returns an error if the underlying OS menu operation fails.
201
+ */
202
+ appendPredefinedMenuItem(item: PredefinedMenuItem): void
203
+ isChecked(id: string): boolean
204
+ toggleCheck(id: string): boolean
205
+ }
206
+
207
+ export declare class SubmenuBuilder {
208
+ constructor()
209
+ withText(text: string): SubmenuBuilder
210
+ withEnabled(enabled: boolean): SubmenuBuilder
211
+ /**
212
+ * Builds the submenu.
213
+ *
214
+ * # Errors
215
+ *
216
+ * Returns an error if the underlying OS fails to create the submenu.
217
+ */
218
+ build(): Submenu
219
+ }
220
+
221
+ export declare class TrayIcon {
222
+ /**
223
+ * Sets the tray icon image.
224
+ *
225
+ * # Errors
226
+ *
227
+ * Returns an error if the OS fails to update the icon.
228
+ */
229
+ setIcon(icon?: Icon | undefined | null): void
230
+ /**
231
+ * Sets the tooltip text shown on hover.
232
+ *
233
+ * # Errors
234
+ *
235
+ * Returns an error if the OS fails to update the tooltip.
236
+ */
237
+ setTooltip(tooltip?: string | undefined | null): void
238
+ /**
239
+ * Sets the title text shown next to the tray icon (macOS only).
240
+ *
241
+ * # Errors
242
+ *
243
+ * This method currently never returns an error but the `Result` type
244
+ * is provided for future-proofing and API consistency.
245
+ */
246
+ setTitle(title?: string | undefined | null): void
247
+ /**
248
+ * Sets the visibility of the tray icon.
249
+ *
250
+ * # Errors
251
+ *
252
+ * Returns an error if the OS fails to change visibility.
253
+ */
254
+ setVisible(visible: boolean): void
255
+ }
256
+
257
+ export declare class TrayIconBuilder {
258
+ constructor()
259
+ withIcon(icon: Icon): TrayIconBuilder
260
+ withTooltip(tooltip: string): TrayIconBuilder
261
+ withTitle(title: string): TrayIconBuilder
262
+ withMenu(menu: Menu): TrayIconBuilder
263
+ /**
264
+ * Builds the tray icon.
265
+ *
266
+ * # Errors
267
+ *
268
+ * Returns an error if the underlying OS fails to create the tray icon
269
+ * (e.g., no system tray available, invalid icon data).
270
+ */
271
+ build(): TrayIcon
272
+ }
273
+
274
+ export interface AboutMetadata {
275
+ name?: string
276
+ version?: string
277
+ copyright?: string
278
+ authors?: Array<string>
279
+ website?: string
280
+ websiteLabel?: string
281
+ comments?: string
282
+ }
283
+
284
+ /**
285
+ * Initializes the native tray subsystem.
286
+ *
287
+ * On Linux, this initializes GTK. On macOS and Windows, this is a no-op
288
+ * as those platforms handle initialization automatically.
289
+ *
290
+ * # Errors
291
+ *
292
+ * Returns an error if GTK initialization fails (Linux only).
293
+ */
294
+ export declare function initialize(): void
295
+
296
+ export interface MenuEvent {
297
+ id: string
298
+ }
299
+
300
+ export declare const enum MouseButton {
301
+ Left = 0,
302
+ Right = 1,
303
+ Middle = 2
304
+ }
305
+
306
+ export declare const enum MouseButtonState {
307
+ Up = 0,
308
+ Down = 1
309
+ }
310
+
311
+ export declare function pollMenuEvents(): MenuEvent | null
312
+
313
+ export declare function pollTrayEvents(): TrayIconEvent | null
314
+
315
+ export interface Rect {
316
+ x: number
317
+ y: number
318
+ width: number
319
+ height: number
320
+ }
321
+
322
+ export interface TrayIconEvent {
323
+ eventType: string
324
+ id: string
325
+ x: number
326
+ y: number
327
+ iconRect: Rect
328
+ button: MouseButton
329
+ buttonState: MouseButtonState
330
+ }
331
+
332
+ /**
333
+ * Processes pending UI events for the tray subsystem.
334
+ *
335
+ * On Linux, this iterates pending GTK events.
336
+ * On Windows, this processes the thread's message queue via `PeekMessageW`.
337
+ * On macOS, this is a no-op as `NSApplication` handles its own event loop.
338
+ *
339
+ * Call this in your event loop to ensure tray interactions are processed.
340
+ */
341
+ export declare function update(): void
342
+
343
+ export interface NotificationAction {
344
+ id: string
345
+ label: string
346
+ }
347
+
348
+ /**
349
+ * Sends a best-effort native desktop notification through the host OS.
350
+ *
351
+ * `timeoutMs` asks the notification service to dismiss the notification after
352
+ * that many milliseconds where the platform supports it.
353
+ */
354
+ export declare function showNotification(title: string, body: string, timeoutMs?: number | undefined | null): void
355
+
356
+ /**
357
+ * Sends a desktop notification with caller-defined action buttons.
358
+ *
359
+ * Action buttons are delivered on Linux; macOS and Windows show a normal
360
+ * notification without buttons.
361
+ */
362
+ export declare function showNotificationWithActions(title: string, body: string, actions: Array<NotificationAction>, timeoutMs?: number | undefined | null): void
363
+
364
+ /** Sends an appointment notification with Accept/See actions when supported. */
365
+ export declare function showAppointmentNotification(title: string, body: string, timeoutMs?: number | undefined | null): void
366
+
367
+ /** Polls for a selected notification action id, or returns null. */
368
+ export declare function pollNotificationActions(): string | null