@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
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tiago Venceslau
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,381 @@
1
- # Temporary Holding Version
1
+ [![Banner](./workdocs/assets/Banner.png)](https://decaf-ts.github.io/for-os/)
2
+ ## for-os
3
+
4
+ Native operating-system bridges for Decaf.ts: a Rust system tray and desktop
5
+ notification addon exposed to TypeScript, with runtime icon switching,
6
+ notification timers, and JavaScript button mapping.
7
+
8
+
9
+ ![Licence](https://img.shields.io/github/license/decaf-ts/for-os.svg?style=plastic)
10
+ ![GitHub language count](https://img.shields.io/github/languages/count/decaf-ts/for-os?style=plastic)
11
+ ![GitHub top language](https://img.shields.io/github/languages/top/decaf-ts/for-os?style=plastic)
12
+
13
+ [![Build & Test](https://github.com/decaf-ts/for-os/actions/workflows/jest-coverage.yaml/badge.svg?event=pull_request)](https://github.com/decaf-ts/for-os/actions/workflows/jest-coverage.yaml)
14
+ [![CodeQL](https://github.com/decaf-ts/for-os/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/decaf-ts/for-os/actions/workflows/codeql-analysis.yml)[![Snyk Analysis](https://github.com/decaf-ts/for-os/actions/workflows/snyk-analysis.yaml/badge.svg)](https://github.com/decaf-ts/for-os/actions/workflows/snyk-analysis.yaml)
15
+ [![Release](https://github.com/decaf-ts/for-os/actions/workflows/release-on-merge-pr.yml/badge.svg?event=pull_request)](https://github.com/decaf-ts/for-os/actions/workflows/release-on-merge-pr.yml)
16
+
17
+ ![Open Issues](https://img.shields.io/github/issues/decaf-ts/for-os.svg)
18
+ ![Closed Issues](https://img.shields.io/github/issues-closed/decaf-ts/for-os.svg)
19
+ ![Pull Requests](https://img.shields.io/github/issues-pr-closed/decaf-ts/for-os.svg)
20
+ ![Maintained](https://img.shields.io/badge/Maintained%3F-yes-green.svg)
21
+
22
+ ![Forks](https://img.shields.io/github/forks/decaf-ts/for-os.svg)
23
+ ![Stars](https://img.shields.io/github/stars/decaf-ts/for-os.svg)
24
+ ![Watchers](https://img.shields.io/github/watchers/decaf-ts/for-os.svg)
25
+
26
+ ![Node Version](https://img.shields.io/badge/dynamic/json.svg?url=https%3A%2F%2Fraw.githubusercontent.com%2Fdecaf-ts%2Ffor-os%2Fmaster%2Fpackage.json&label=Node&query=$.engines.node&colorB=blue)
27
+ ![NPM Version](https://img.shields.io/badge/dynamic/json.svg?url=https%3A%2F%2Fraw.githubusercontent.com%2Fdecaf-ts%2Ffor-os%2Fmaster%2Fpackage.json&label=NPM&query=$.engines.npm&colorB=purple)
28
+
29
+ Documentation [here](https://decaf-ts.github.io/for-os/), Test results [here](https://decaf-ts.github.io/for-os/workdocs/reports/html/test-report.html) and Coverage [here](https://decaf-ts.github.io/for-os/workdocs/reports/coverage/lcov-report/index.html)
30
+
31
+
32
+
33
+ ### Description
34
+
35
+ `@decaf-ts/for-os` gives Node.js and TypeScript applications a small,
36
+ auditable bridge to the desktop:
37
+
38
+ - **System tray** — icon, tooltip, macOS title, and a menu whose entries call
39
+ JavaScript handlers. The icon can be replaced at runtime from a file path,
40
+ base64 string, byte buffer, or raw RGBA pixels.
41
+ - **Desktop notifications** — title/body, an auto-dismiss timer, and action
42
+ buttons mapped to JavaScript callbacks. Button delivery is native on Linux
43
+ (`notify-send --wait`); macOS and Windows render a plain notification.
44
+ - **Rust core** — the `native/tray-icon-node` crate is a vendored copy of
45
+ [`nglmercer/tray-icon-node`](https://github.com/nglmercer/tray-icon-node) at
46
+ commit `cb91e86184ed8612bcdee904277b4d5e78d966c3`, extended with the
47
+ notification-action bridge, notification timers, and configurable buttons.
48
+ It is built from the pinned source at install time; no prebuilt binary is
49
+ downloaded.
50
+
51
+ The TypeScript layer never shells out to `notify-send` or PowerShell itself:
52
+ all OS commands live in the Rust crate, and every failure is reported through
53
+ the Decaf error hierarchy.
54
+
55
+
56
+ ### How to Use
57
+
58
+ - [Native bridge reference](./workdocs/8-Native-Bridges.md)
59
+ - [Initial Setup](./workdocs/tutorials/For%20Developers.md#_initial_setup_)
60
+ - [Installation](./workdocs/tutorials/For%20Developers.md#installation)
61
+ - [Scripts](./workdocs/tutorials/For%20Developers.md#scripts)
62
+ - [Testing](./workdocs/tutorials/For%20Developers.md#testing)
63
+ - [Publishing](./workdocs/tutorials/For%20Developers.md#publishing)
64
+
65
+ Install the package and build the native addon:
66
+
67
+ ```bash
68
+ npm install @decaf-ts/for-os
69
+ npm run for-os:init # Rust toolchain + platform native build deps + addon
70
+ ```
71
+
72
+ Use a tray whose icon changes at runtime and whose menu calls JavaScript:
73
+
74
+ ```ts
75
+ import { TrayIcon, TRAY_ICON_BASE64 } from "@decaf-ts/for-os";
76
+
77
+ const tray = TrayIcon.create({
78
+ icon: { base64: TRAY_ICON_BASE64.idle },
79
+ tooltip: "My application",
80
+ menu: [
81
+ { id: "open", label: "Open" },
82
+ { id: "pause", label: "Pause", checkable: true },
83
+ { separator: true, id: "sep", label: "" },
84
+ { id: "quit", label: "Quit" },
85
+ ],
86
+ });
87
+
88
+ tray.on("open", () => (tray.setIcon({ base64: TRAY_ICON_BASE64.active }), openWindow()));
89
+ tray.on("pause", () => tray.toggleMenuItem("pause"));
90
+ tray.on("quit", () => tray.close());
91
+ ```
92
+
93
+ Send a notification that auto-dismisses and maps a button to JavaScript:
94
+
95
+ ```ts
96
+ import { NotificationCenter } from "@decaf-ts/for-os";
97
+
98
+ const notifications = new NotificationCenter();
99
+ notifications
100
+ .registerAction("accept", () => acceptAppointment())
101
+ .registerAction("see", () => openAppointment());
102
+
103
+ notifications.notify({
104
+ title: "New appointment",
105
+ body: "Accept or review the appointment?",
106
+ timeoutMs: 8_000,
107
+ buttons: [
108
+ { id: "accept", label: "Accept" },
109
+ { id: "see", label: "See" },
110
+ ],
111
+ });
112
+ ```
113
+
114
+
115
+ ### Native Bridges
116
+
117
+ Everything in this section is exported from `@decaf-ts/for-os`.
118
+
119
+ #### Source provenance
120
+
121
+ | Concern | Location |
122
+ | --- | --- |
123
+ | System-tray Rust crate | `native/tray-icon-node` (vendored from `nglmercer/tray-icon-node` at `cb91e86184ed8612bcdee904277b4d5e78d966c3`, package `0.1.2`) |
124
+ | OS-notification native bridge | `native/tray-icon-node/src/lib.rs` — ported from `with-ai/vendor/tray-icon-node/src/lib.rs` (`show_notification`, `show_appointment_notification`, `poll_notification_actions`) |
125
+ | with-ai JS fallback notification helper | `with-ai/src/cli/appointments/notify.ts` — **not ported**; it duplicated `osascript`/`notify-send`/PowerShell calls outside Rust, which this package deliberately centralizes in the crate |
126
+ | Source pin | `native/tray-icon-node/source-manifest.json` (SHA-512 of every source file and the canonical tree digest) |
127
+ | Build output pin | `native/tray-icon-node/build-manifest.json` (target triple, cargo/rustc versions, built binary SHA-512) |
128
+ | Build scripts | `scripts/for-os-{init,build,install,integration,integrity}.mjs`, shared in `scripts/lib/native.mjs` |
129
+ | Rust tests | `cargo test --locked --manifest-path native/tray-icon-node/Cargo.toml` (`npm run for-os:test:rust`) |
130
+
131
+ #### System tray
132
+
133
+ ```ts
134
+ import { TrayIcon } from "@decaf-ts/for-os";
135
+
136
+ const tray = TrayIcon.create({
137
+ icon: "/path/to/icon.png", // or { base64 }, { bytes }, { png }, { rgba, width, height }
138
+ tooltip: "My application",
139
+ title: "my-app", // macOS only
140
+ menu: [
141
+ { id: "open", label: "Open", onClick: () => openWindow() },
142
+ { id: "sync", label: "Sync", enabled: false },
143
+ { id: "auto", label: "Automatic", checkable: true, checked: true },
144
+ { separator: true, id: "sep", label: "" },
145
+ { id: "quit", label: "Quit" },
146
+ ],
147
+ onEvent: (event) => console.log(event.eventType, event.x, event.y),
148
+ });
149
+
150
+ tray.on("open", () => openWindow());
151
+ tray.setIcon({ base64: activePngBase64 }); // runtime icon switching
152
+ tray.setTooltip("Working…");
153
+ tray.updateMenuItem("sync", { enabled: true, label: "Sync now" });
154
+ tray.toggleMenuItem("auto");
155
+ tray.close();
156
+ ```
157
+
158
+ - `TrayIcon.create` throws `NativeModuleUnavailableError` (missing addon) or
159
+ `TrayError` (native failure). `TrayIcon.tryCreate` returns `undefined`
160
+ instead.
161
+ - The native event pump runs every 100 ms (`pollIntervalMs`) and is unref'd.
162
+ `tray.poll()` drains menu events synchronously, which is useful in tests.
163
+ - `close()` is idempotent and removes the temporary icon files.
164
+ - `TRAY_ICON_BASE64.idle` / `.active` are embedded 16×16 PNG examples for
165
+ dynamic-icon smoke checks.
166
+ - Icon decoding accepts PNG and JPEG input only; other formats are rejected as
167
+ unsupported. Icons are limited to 4096px per side — the limit is checked on
168
+ the encoded image header before decoding (with decoder limits as defense in
169
+ depth) and on raw `rgba` dimensions, so oversized or zero-dimension icons
170
+ fail with a dimension error instead of allocating memory for them.
171
+
172
+ #### Notifications
173
+
174
+ ```ts
175
+ import { NotificationCenter } from "@decaf-ts/for-os";
176
+
177
+ const center = new NotificationCenter();
178
+ center.registerAction("accept", () => acceptAppointment());
179
+
180
+ const notification = center.notify({
181
+ title: "New appointment",
182
+ body: "Accept or review the appointment?",
183
+ timeoutMs: 8_000, // 0 disables the timer
184
+ buttons: [
185
+ { id: "accept", label: "Accept" },
186
+ { id: "see", label: "See", onClick: () => openAppointment() },
187
+ ],
188
+ onDismiss: (reason) => console.log("dismissed", reason),
189
+ });
190
+
191
+ notification.onAction((id) => console.log("callback handled", id));
192
+ ```
193
+
194
+ - `timeoutMs` is passed to the native notification service. Linux
195
+ (`notify-send --expire-time`) and Windows (balloon-tip timeout) honour it;
196
+ macOS applies its system dismissal policy. The bridge also tracks the timer
197
+ locally so `onDismiss("timer")` always fires at the configured time.
198
+ - `dismiss()` marks the notification dismissed and reports `"manual"`. There is
199
+ no portable API to close an already-visible OS notification, so this is
200
+ bookkeeping, not a remote control.
201
+ - Action buttons are native on Linux. `notify-send --wait` blocks a Rust
202
+ worker thread and the activated button id is queued to
203
+ `pollNotificationActions()`. macOS and Windows show a plain notification;
204
+ put equivalent actions in the tray menu there.
205
+ - The action id returned by the service is matched against global
206
+ `registerAction` handlers, the notification's `onAction`, and each button's
207
+ `onClick`, in that order. An id that matches no live notification only reaches
208
+ global handlers; it never falls through to the most recent notification's
209
+ callbacks. The reserved `default` body-click id maps to the first button of the
210
+ notification that owns it.
211
+ - A notification is pruned from the centre's records when it is dismissed
212
+ (`timeoutMs` timer or `dismiss()`), so its handlers no longer resolve.
213
+ - `notifyAppointment` uses the native Accept/See action set and normalizes the
214
+ service's reserved `default` action to `see`.
215
+
216
+ #### Platform support
217
+
218
+ | Feature | Linux | macOS | Windows |
219
+ | --- | --- | --- | --- |
220
+ | Tray icon, tooltip, title, menu, events | yes | yes | yes |
221
+ | Runtime icon switching | yes | yes | yes |
222
+ | Notification title/body | yes (`notify-send`) | yes (`osascript`) | yes (PowerShell balloon) |
223
+ | Notification auto-dismiss timer | yes | system default | yes |
224
+ | Notification action buttons → JS | yes (`notify-send --wait`) | no | no |
225
+
226
+ The npm package bundles Linux x64/ARM64 (glibc), macOS x64/ARM64, and Windows
227
+ x64/x86 binaries. Linux musl and Windows ARM64 are not release targets.
228
+
229
+ #### Scripts
230
+
231
+ | Script | Purpose |
232
+ | --- | --- |
233
+ | `npm run for-os:init` | Install the pinned Rust toolchain (1.100.0, bootstrapped with a checksum-verified rustup-init) + Linux native build libraries (or report the exact manual commands where installation is not permitted), then build and materialize the addon |
234
+ | `npm run for-os:init:check` | Report host readiness without mutating anything |
235
+ | `npm run for-os:build` | `cargo build --release --locked` from the pinned source and write `build-manifest.json` |
236
+ | `npm run for-os:build:check` | Verify the source pin and report the existing build |
237
+ | `npm run for-os:install` | Materialize the bundled addon; build from source as a fallback |
238
+ | `npm run for-os:install:required` | Same, but fail when the native build cannot run |
239
+ | `npm run for-os:package:check` | Verify that all release target binaries are present |
240
+ | `npm run for-os:integrity:record` | Re-pin the native source tree (security-relevant; review the diff) |
241
+ | `npm run for-os:integrity:check` | Verify the source tree against the pin |
242
+ | `npm run for-os:test:rust` | Rust unit tests (notification argument/timer/action contract and tray conversions) |
243
+ | `npm run for-os:integration` | Interactive real-tray check: runtime icon switch, notification button, menu actions |
244
+ | `npm run for-os:smoke` | Non-interactive tray create → icon switch → timed notification → close |
245
+ | `npm run for-os:buttons` | Sends an actionable notification and waits for a JavaScript button callback |
246
+
247
+ `postinstall` runs `scripts/for-os-install.mjs` and materializes the matching
248
+ bundled addon under the package and, when npm reports an `INIT_CWD`, under that
249
+ project's `node_modules` as well. It attempts a local Rust build only if the
250
+ matching prebuilt binary is absent. The loader searches the current directory,
251
+ `INIT_CWD`, and the Node entrypoint's directory, and `FOR_OS_NATIVE_MODULE` can
252
+ pin an explicit path.
253
+
254
+ To exercise button mapping on a headless Linux host, run the integration check
255
+ with a notification daemon and trigger the notification body (the default
256
+ action is aliased to the first caller button):
257
+
258
+ ```bash
259
+ dbus-run-session -- xvfb-run -a bash -c '\
260
+ dunst & sleep 2; (sleep 2; dunstctl action 0) & \
261
+ npm run for-os:buttons'
262
+ ```
263
+
264
+ #### Continuous integration
265
+
266
+ This repository owns two workflows for its standalone CI:
267
+
268
+ - `for-os-native` builds and smoke-checks the Linux tray and notification
269
+ addon on relevant pushes and pull requests, plus manual dispatch.
270
+ - `rust-audit` scans `native/tray-icon-node/Cargo.lock` against the RustSec
271
+ advisory database on crate changes, weekly, and on demand. Vulnerabilities
272
+ at/above low severity fail the job; unmaintained/unsound/notice advisories
273
+ are report-only (`.github/rust-audit/audit.toml`).
274
+
275
+ These workflows run against this repository directly; they do not depend on a
276
+ copy in the umbrella repository.
277
+
278
+ #### Prerequisites
279
+
280
+ - Node.js >= 20 and npm >= 10.
281
+ - Pinned Rust toolchain 1.100.0 (`rustup`, `cargo`, `rustc`). A missing
282
+ toolchain is bootstrapped by `for-os:init` with rustup-init 1.29.3,
283
+ downloaded from the versioned rustup archive and verified against a
284
+ hard-coded SHA-256 before execution — the installer is never piped from the
285
+ network into a shell.
286
+ - Linux (Ubuntu/Debian): `build-essential pkg-config libgtk-3-dev
287
+ libayatana-appindicator3-dev libglib2.0-dev libxdo-dev libx11-dev
288
+ libnotify-bin`.
289
+ - macOS: Xcode command-line tools (`xcode-select --install`).
290
+ - Windows: Visual Studio Build Tools with **Desktop development with C++** and
291
+ the MSVC Rust host toolchain.
292
+ - A graphical desktop session with a system-tray host and notification service
293
+ for the real integration check. `--smoke` still needs a tray host and a
294
+ notification daemon (for example `xvfb-run` plus `dunst`).
295
+
296
+ #### Security and integrity
297
+
298
+ - Release binaries are built from the audited source tree on target-matched
299
+ runners; no third-party prebuilt addon is downloaded.
300
+ - `source-manifest.json` pins every source/wrapper file by SHA-512 and the
301
+ canonical source digest. Every build script verifies it before compiling.
302
+ - `build-manifest.json` records the source digest, target triple, toolchain
303
+ versions, and binary SHA-512; a build is reused only when all still match.
304
+ - The crate performs no network access, no environment reads, and no dynamic
305
+ code loading. `unsafe` is confined to the upstream Win32 message-loop pump
306
+ and the documented tray-icon handle `Send`/`Sync` impls.
307
+ - Notification text is passed to host commands as argument vectors, never
308
+ through a shell; AppleScript and PowerShell values are escaped in Rust.
309
+ `notify-send` arguments end option parsing with `--` before the title and body,
310
+ so leading-dash text is delivered literally.
311
+ - Caller-supplied icon extensions are sanitized to an alphanumeric/dot suffix
312
+ (capped at 16 characters) before the icon is materialized, and the resolved
313
+ path is checked to stay inside the private icon directory.
314
+
315
+ #### Published package layout
316
+
317
+ - `files` publishes the compiled output `lib` (ESM at
318
+ `lib/esm`, CommonJS at `lib/cjs`, declarations at `lib/types`), the
319
+ `native/tray-icon-node` Rust sources (Cargo manifest and lockfile plus the
320
+ NAPI-RS loader `index.js`/`index.d.ts`, all supported `.node` binaries, and
321
+ their SHA-512 manifest), and the `scripts/` folder that `postinstall` runs.
322
+ The release workflow builds each target on a matching runner, combines the
323
+ binaries, and blocks publication if any target is missing.
324
+ - `exports` maps `.` to both module systems: ESM at `./lib/esm/index.js`
325
+ with types `./lib/types/index.d.mts`, and CommonJS at `./lib/cjs/index.cjs`
326
+ with types `./lib/types/index.d.cts`. `main`, `module`, and `types` mirror
327
+ the same entry points.
328
+
329
+ #### Publishing and credential gates
330
+
331
+ - Publishing builds target binaries then publishes with npm trusted publishing.
332
+ - Release builds need the Rust toolchain and crates.io access; `Cargo.lock`
333
+ pins the full crate closure. Consumers receive the compiled addon and do not
334
+ need Rust or a native compiler. Linux runtime hosts still need GTK and
335
+ AppIndicator runtime libraries, plus `notify-send` for notifications.
336
+
337
+
338
+ ### Related
339
+
340
+ - [`@decaf-ts/core`](https://github.com/decaf-ts/core) — persistence, services, and adapters.
341
+ - [`@decaf-ts/logging`](https://github.com/decaf-ts/logging) — the Decaf logger and error hierarchy.
342
+ - [`@decaf-ts/db-decorators`](https://github.com/decaf-ts/db-decorators) — the concrete Decaf error classes used by this package.
343
+ - [`nglmercer/tray-icon-node`](https://github.com/nglmercer/tray-icon-node) — upstream source of the vendored Rust tray crate.
344
+
345
+
346
+ ### Social
347
+
348
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/TiagoVenceslau/)
349
+
350
+
351
+
352
+
353
+ #### Languages
354
+
355
+ ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
356
+ ![Rust](https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white)
357
+ ![JavaScript](https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black)
358
+ ![NodeJS](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)
359
+
360
+ ## Getting help
361
+
362
+ If you have bug reports, questions or suggestions, please [create a new issue](https://github.com/decaf-ts/for-os/issues/new/choose).
363
+
364
+ ## Contributing
365
+
366
+ I am grateful for any contributions made to this project. Please read [this](./workdocs/tutorials/Contributing.md) to get started.
367
+
368
+ ## Supporting
369
+
370
+ The first and easiest way you can support it is by [Contributing](./workdocs/tutorials/Contributing.md). Even just finding a typo in the documentation is important.
371
+
372
+ Financial support is always welcome and helps keep both me and the project alive and healthy.
373
+
374
+ So if you can, if this project in any way. either by learning something or simply by helping you save precious time, please consider donating.
375
+
376
+ ## License
377
+
378
+ This project is released under the [MIT License](./LICENSE.md).
379
+
380
+ By developers, for developers...
2
381
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IconError = exports.NotificationError = exports.TrayError = exports.NativeModuleUnavailableError = void 0;
4
+ /**
5
+ * @module for-os.errors
6
+ * @description Error hierarchy for the native operating-system bridges.
7
+ * @summary Every failure raised by `@decaf-ts/for-os` extends the Decaf
8
+ * `InternalError` hierarchy so callers get a stable `code` and `name`.
9
+ */
10
+ const db_decorators_1 = require("@decaf-ts/db-decorators");
11
+ /**
12
+ * @description Raised when the native tray/notification addon cannot be located or loaded.
13
+ * @summary Use this when the vendored `tray-icon-node` addon has not been built
14
+ * or the host platform is unsupported.
15
+ * @param {string|Error|unknown} msg error message or originating error
16
+ * @class NativeModuleUnavailableError
17
+ * @extends InternalError
18
+ * @category Errors
19
+ */
20
+ class NativeModuleUnavailableError extends db_decorators_1.InternalError {
21
+ constructor(msg) {
22
+ super(msg, NativeModuleUnavailableError.name, 500);
23
+ }
24
+ }
25
+ exports.NativeModuleUnavailableError = NativeModuleUnavailableError;
26
+ /**
27
+ * @description Raised when a system-tray host or menu operation fails.
28
+ * @summary Wraps native addon failures raised while creating or mutating a
29
+ * {@link TrayIcon} so callers can distinguish tray failures from other errors.
30
+ * @param {string|Error|unknown} msg error message or originating error
31
+ * @class TrayError
32
+ * @extends InternalError
33
+ * @category Errors
34
+ */
35
+ class TrayError extends db_decorators_1.InternalError {
36
+ constructor(msg) {
37
+ super(msg, TrayError.name, 500);
38
+ }
39
+ }
40
+ exports.TrayError = TrayError;
41
+ /**
42
+ * @description Raised when a desktop notification cannot be dispatched.
43
+ * @summary Reserved for notification-specific failures; validation and missing
44
+ * native backends report {@link ValidationError} and
45
+ * {@link NativeModuleUnavailableError} respectively.
46
+ * @param {string|Error|unknown} msg error message or originating error
47
+ * @class NotificationError
48
+ * @extends InternalError
49
+ * @category Errors
50
+ */
51
+ class NotificationError extends db_decorators_1.InternalError {
52
+ constructor(msg) {
53
+ super(msg, NotificationError.name, 500);
54
+ }
55
+ }
56
+ exports.NotificationError = NotificationError;
57
+ /**
58
+ * @description Raised when an icon source cannot be materialized or decoded.
59
+ * @summary Covers empty paths, missing files, malformed base64, and RGBA buffers
60
+ * whose length does not match `width x height x 4`.
61
+ * @param {string|Error|unknown} msg error message or originating error
62
+ * @class IconError
63
+ * @extends InternalError
64
+ * @category Errors
65
+ */
66
+ class IconError extends db_decorators_1.InternalError {
67
+ constructor(msg) {
68
+ super(msg, IconError.name, 500);
69
+ }
70
+ }
71
+ exports.IconError = IconError;
72
+ //# sourceMappingURL=errors.js.map
73
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.cjs","sourceRoot":"","sources":["errors.js"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,2DAAwD;AACxD;;;;;;;;GAQG;AACH,MAAa,4BAA6B,SAAQ,6BAAa;IAC3D,YAAY,GAAG;QACX,KAAK,CAAC,GAAG,EAAE,4BAA4B,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;CACJ;AAJD,oEAIC;AACD;;;;;;;;GAQG;AACH,MAAa,SAAU,SAAQ,6BAAa;IACxC,YAAY,GAAG;QACX,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;CACJ;AAJD,8BAIC;AACD;;;;;;;;;GASG;AACH,MAAa,iBAAkB,SAAQ,6BAAa;IAChD,YAAY,GAAG;QACX,KAAK,CAAC,GAAG,EAAE,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC;CACJ;AAJD,8CAIC;AACD;;;;;;;;GAQG;AACH,MAAa,SAAU,SAAQ,6BAAa;IACxC,YAAY,GAAG;QACX,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;CACJ;AAJD,8BAIC;AACD,kCAAkC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.VERSION = void 0;
18
+ /**
19
+ * @module for-os
20
+ * @description Native operating-system bridges for Decaf.ts: system tray and
21
+ * desktop notifications, built from Rust and exposed to TypeScript/JavaScript.
22
+ * @summary The package ships a vendored NAPI-RS crate
23
+ * (`native/tray-icon-node`) that is compiled at install time. The TypeScript
24
+ * layer adds runtime icon switching, menu callbacks, auto-dismiss notification
25
+ * timers, and JavaScript button mapping on top of the raw native API. The main
26
+ * entry points are {@link TrayIcon}, {@link NotificationCenter}, and the native
27
+ * loader helpers exposed by {@link loadNativeModule}.
28
+ */
29
+ __exportStar(require("./errors.cjs"), exports);
30
+ __exportStar(require("./native/types.cjs"), exports);
31
+ __exportStar(require("./native/icons.cjs"), exports);
32
+ __exportStar(require("./native/loader.cjs"), exports);
33
+ __exportStar(require("./tray/assets.cjs"), exports);
34
+ __exportStar(require("./tray/TrayIcon.cjs"), exports);
35
+ __exportStar(require("./notifications/NotificationCenter.cjs"), exports);
36
+ /**
37
+ * @description The package version, replaced by the build pipeline.
38
+ * @summary Reports the released semantic version of `@decaf-ts/for-os`; the
39
+ * placeholder literal is substituted during the release build.
40
+ * @type {string}
41
+ * @constant
42
+ * @memberOf module:for-os
43
+ */
44
+ exports.VERSION = "0.2.7";
45
+ //# sourceMappingURL=index.js.map
46
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,8CAA4B;AAC5B,oDAAkC;AAClC,oDAAkC;AAClC,qDAAmC;AACnC,mDAAiC;AACjC,qDAAmC;AACnC,wEAAsD;AACtD;;;;;;;GAOG;AACU,QAAA,OAAO,GAAG,aAAa,CAAC;AACrC,iCAAiC"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IconResolver = void 0;
4
+ exports.iconExtension = iconExtension;
5
+ /**
6
+ * @module for-os.native.icons
7
+ * @description Converts TypeScript icon sources into native tray icon handles.
8
+ * @summary The native addon loads icons from file paths (or raw RGBA), so
9
+ * base64 and byte-buffer sources are materialized into a private temporary
10
+ * directory that is removed when the owning tray closes.
11
+ */
12
+ const node_fs_1 = require("node:fs");
13
+ const node_os_1 = require("node:os");
14
+ const node_path_1 = require("node:path");
15
+ const errors_js_1 = require("./../errors.cjs");
16
+ const MAX_ICON_EXTENSION_LENGTH = 16;
17
+ function sanitizeExtension(extension) {
18
+ const cleaned = extension
19
+ .replace(/[^A-Za-z0-9.]/g, "")
20
+ .replace(/\.{2,}/g, ".")
21
+ .slice(0, MAX_ICON_EXTENSION_LENGTH)
22
+ .replace(/^\.+/, "");
23
+ return cleaned ? `.${cleaned}` : ".png";
24
+ }
25
+ function hasRgba(value) {
26
+ if (!value || typeof value !== "object")
27
+ return false;
28
+ const candidate = value;
29
+ return ((Buffer.isBuffer(candidate.rgba) || candidate.rgba instanceof Uint8Array) &&
30
+ typeof candidate.width === "number" &&
31
+ typeof candidate.height === "number");
32
+ }
33
+ /**
34
+ * @description Owns the temporary directory used to materialize file-backed icons.
35
+ * @summary One resolver is normally owned by a tray or notification host and
36
+ * disposed with it. Resolving an already-native handle is intentionally not
37
+ * supported; callers pass a source and the resolver keeps the native object.
38
+ * @param {NativeIconFactory} api native icon factory used to build handles
39
+ * @param {function(string): string} [createDirectory] creates the private
40
+ * temporary directory; defaults to `fs.mkdtempSync` under the OS temp dir
41
+ * @param {function(string): void} [removeDirectory] removes the private
42
+ * directory on {@link IconResolver.dispose}; defaults to a recursive `fs.rmSync`
43
+ * @class IconResolver
44
+ */
45
+ class IconResolver {
46
+ constructor(api, createDirectory = (prefix) => (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), prefix)), removeDirectory = (directory) => (0, node_fs_1.rmSync)(directory, { recursive: true, force: true })) {
47
+ this.api = api;
48
+ this.createDirectory = createDirectory;
49
+ this.removeDirectory = removeDirectory;
50
+ }
51
+ ensureDirectory() {
52
+ if (!this.directory)
53
+ this.directory = this.createDirectory("for-os-icons-");
54
+ return this.directory;
55
+ }
56
+ /**
57
+ * Materializes `source` into a native icon handle.
58
+ * @param {IconSource} source the icon path, bytes, base64, or RGBA data
59
+ * @return {unknown} the native icon handle expected by the addon
60
+ * @throws {IconError} when the source is invalid or points to a missing file
61
+ */
62
+ resolve(source) {
63
+ if (typeof source === "string")
64
+ return this.fromPath(source);
65
+ if (!source || typeof source !== "object") {
66
+ throw new errors_js_1.IconError("Icon source must be a path, bytes, base64 string, or RGBA data.");
67
+ }
68
+ if (hasRgba(source)) {
69
+ const expected = source.width * source.height * 4;
70
+ if (source.rgba.length !== expected) {
71
+ throw new errors_js_1.IconError(`RGBA icon length ${source.rgba.length} does not match ${source.width}x${source.height}x4 (${expected}).`);
72
+ }
73
+ return this.api.fromRgba(Buffer.from(source.rgba), source.width, source.height);
74
+ }
75
+ if ("path" in source)
76
+ return this.fromPath(source.path);
77
+ if ("base64" in source) {
78
+ const bytes = Buffer.from(source.base64, "base64");
79
+ if (!bytes.length)
80
+ throw new errors_js_1.IconError("Icon base64 payload is empty or invalid.");
81
+ return this.fromBytes(bytes, source.extension ?? ".png");
82
+ }
83
+ if ("png" in source)
84
+ return this.fromBytes(source.png, ".png");
85
+ if ("bytes" in source)
86
+ return this.fromBytes(source.bytes, source.extension ?? ".png");
87
+ throw new errors_js_1.IconError("Unsupported icon source shape.");
88
+ }
89
+ fromPath(path) {
90
+ if (!path)
91
+ throw new errors_js_1.IconError("Icon path is empty.");
92
+ if (!(0, node_fs_1.existsSync)(path))
93
+ throw new errors_js_1.IconError(`Icon file does not exist: ${path}`);
94
+ return this.api.fromPath(path);
95
+ }
96
+ fromBytes(bytes, extension) {
97
+ const directory = this.ensureDirectory();
98
+ const file = (0, node_path_1.join)(directory, `icon-${Date.now()}-${Math.random().toString(16).slice(2)}${sanitizeExtension(extension)}`);
99
+ if (!file.startsWith(directory + node_path_1.sep)) {
100
+ throw new errors_js_1.IconError("Icon extension resolved outside the icon directory.");
101
+ }
102
+ (0, node_fs_1.writeFileSync)(file, Buffer.from(bytes));
103
+ return this.api.fromPath(file);
104
+ }
105
+ /** Removes every materialized icon file; idempotent. */
106
+ dispose() {
107
+ if (!this.directory)
108
+ return;
109
+ this.removeDirectory(this.directory);
110
+ this.directory = undefined;
111
+ }
112
+ /** Directory holding materialized icons, when one has been created. */
113
+ get iconDirectory() {
114
+ return this.directory;
115
+ }
116
+ }
117
+ exports.IconResolver = IconResolver;
118
+ /** Returns a stable file extension for a path, defaulting to `.png`. */
119
+ function iconExtension(path) {
120
+ return (0, node_path_1.extname)(path) || ".png";
121
+ }
122
+ //# sourceMappingURL=icons.js.map
123
+ //# sourceMappingURL=icons.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native/icons.cjs","sourceRoot":"","sources":["native/icons.js"],"names":[],"mappings":";;;AAiHA,sCAEC;AAnHD;;;;;;GAMG;AACH,qCAAyE;AACzE,qCAAiC;AACjC,yCAA+C;AAC/C,8CAA2C;AAC3C,MAAM,yBAAyB,GAAG,EAAE,CAAC;AACrC,SAAS,iBAAiB,CAAC,SAAS;IAChC,MAAM,OAAO,GAAG,SAAS;SACpB,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC;SAC7B,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,KAAK,CAAC,CAAC,EAAE,yBAAyB,CAAC;SACnC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzB,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5C,CAAC;AACD,SAAS,OAAO,CAAC,KAAK;IAClB,IAAI,CA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