@viloris/vela-plugin-notify
v0.0.1
Published
Host TS capability plugin: system notifications (notify.show / notify.close)
Readme
@viloris/vela-plugin-notify
First-party T1 capability plugin: desktop user notifications.
| Surface | Value |
|---------|--------|
| Permission | notify:show (BuiltinPermissions.NotifyShow) |
| Methods | notify.show, notify.close |
| Events | notify.action (NotifyEventChannels.action) |
| Systems | HostAPI.sys.notify (injected; mock for tests) |
Host registration
import { createCapabilityHost, createHostEventBus } from "@viloris/vela-host-core";
import { BuiltinPermissions } from "@viloris/vela-api";
import { registerNotifyPlugin, createMockNotifySys } from "@viloris/vela-plugin-notify";
const events = createHostEventBus();
const mock = createMockNotifySys({ events });
const host = createCapabilityHost({
api: {
platform: "linux",
sys: { notify: mock.facade },
events,
},
capabilities: {
default: { permissions: [BuiltinPermissions.NotifyShow] },
},
});
registerNotifyPlugin(host);App (page)
await window.vela.call("notify.show", { title: "Hi", body: "…" });
// or thin wrapper:
import { showNotification } from "@viloris/vela-plugin-notify/client";
await showNotification({ title: "Hi" });
window.vela.events.subscribe("notify.action", (payload) => { /* … */ });Real OS delivery
Use @viloris/vela-sys-desktop on the Host:
import { createDesktopSystems } from "@viloris/vela-sys-desktop";
const desktop = createDesktopSystems({ platform: "auto", events });
// pass desktop.sys.notify into HostAPI.sys| Platform | Backend |
|----------|---------|
| Linux | notify-send |
| macOS | osascript |
| Windows | PowerShell toast / balloon |
For unit tests without OS tools, keep createMockNotifySys.
Verify
bun test plugins/notify
bun run --filter @viloris/vela-plugin-notify typecheck