{"id":15021214,"url":"https://github.com/xan105/node-powertoast","last_synced_at":"2025-08-12T01:15:14.296Z","repository":{"id":46138269,"uuid":"173887247","full_name":"xan105/node-powertoast","owner":"xan105","description":"Windows toast notification and toastXml string builder","archived":false,"fork":false,"pushed_at":"2024-02-18T08:10:46.000Z","size":23635,"stargazers_count":25,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T20:40:42.440Z","etag":null,"topics":["actioncenter","nodejs","notification","notificationcenter","powershell","toast","toast-notification","toastxml","windows","winrt"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xan105.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"xan105","custom":"https://www.paypal.me/xan105","patreon":"xan105"}},"created_at":"2019-03-05T06:22:07.000Z","updated_at":"2024-12-10T11:31:26.000Z","dependencies_parsed_at":"2024-06-19T11:23:20.639Z","dependency_job_id":"e2933a1d-00ba-4d59-80a2-132268643c8e","html_url":"https://github.com/xan105/node-powertoast","commit_stats":{"total_commits":133,"total_committers":2,"mean_commits":66.5,"dds":0.007518796992481258,"last_synced_commit":"9c303e4f1eecd8ecd93d724fc3e2071c099bdabd"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xan105/node-powertoast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-powertoast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-powertoast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-powertoast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-powertoast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xan105","download_url":"https://codeload.github.com/xan105/node-powertoast/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-powertoast/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269982681,"owners_count":24507438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actioncenter","nodejs","notification","notificationcenter","powershell","toast","toast-notification","toastxml","windows","winrt"],"created_at":"2024-09-24T19:56:18.148Z","updated_at":"2025-08-12T01:15:14.270Z","avatar_url":"https://github.com/xan105.png","language":"JavaScript","funding_links":["https://github.com/sponsors/xan105","https://www.paypal.me/xan105","https://patreon.com/xan105"],"categories":[],"sub_categories":[],"readme":"About\n=====\n\nWindows toast notification and toastXml string builder.\u003cbr /\u003e\n\nDoesn't use any native module. Everything is done through PowerShell but you can use native WinRT API bindings instead by **optionally** installing [NodeRT](https://github.com/NodeRT/NodeRT) relative packages (see [installation](#Installation) for more details).\n\nPlease note that when using PowerShell some features such as click events and user input requires Powershell ≥ 7.1 (pwsh) also known as PowerShell Core.\u003cbr /\u003e\nUsing WinRT (NodeRT) is a bit faster as you don't have to wait for the PowerShell VM to start.\n\n**Electron**\n\nPowertoast was made for Node.js first but it also works in Electron with either PowerShell or WinRT (NodeRT).\u003cbr /\u003e\nIf you prefer to use the new [Electron native API](https://www.electronjs.org/fr/docs/latest/api/notification#new-notificationoptions) directly. \nYou can easily build a [toastXml string](https://docs.microsoft.com/en-us/uwp/schemas/tiles/toastschema/schema-root) for it.\n\nExample\n=======\n\n### A simple toast\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/xan105/node-powertoast/raw/master/screenshot/example.png\"\u003e\n\u003c/p\u003e\n\n```js \nimport { Toast } from \"powertoast\";\n\n//Create a toast\nconst toast = new Toast({\n  title: \"NPM\",\n  message: \"Installed.\",\n  icon: \"https://static.npmjs.com/7a7ffabbd910fc60161bc04f2cee4160.png\"\n})\n\n//Events (optional)\ntoast.on(\"activated\", (event, input) =\u003e { \n  // Where event and input are the data from an interactive toast\n  console.log(\"click\");\n});\ntoast.on(\"dismissed\", (reason) =\u003e { console.log(reason) });\n\ntoast.show() //Promise\n.then(()=\u003e{\n  console.log(\"Sent\");\n})\n.catch((err) =\u003e { \n  console.error(err);\n});\n```\n\n### Build a toastXml string for [Electron native API](https://www.electronjs.org/fr/docs/latest/api/notification#new-notificationoptions):\n\n```js\n//Main process\nimport { Notification } from \"electron\";\nimport { toXmlString } from \"powertoast\";\n  \nconst options = {\n  title: \"First partner\",\n  message: \"Every journey begins with a choice\",\n  button: [\n    { text: \"Bulbasaur\", activation: \"myapp:green\" },\n    { text: \"Charmander\", activation: \"myapp:red\" },\n    { text: \"Squirtle\", activation: \"myapp:blue\" }\n  ]\n};\n\nconst xmlString = toXmlString(options);\nconst toast = new Notification({ toastXml: xmlString });\ntoast.show();\n```\n\nInstallation\n============\n\n```\nnpm install powertoast\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eOptional NodeRT packages\u003c/summary\u003e\n\n  \u003cbr /\u003e\n  \n  All NodeRT scopes up to the latest official [@nodert-win10-rs4](https://github.com/NodeRT/NodeRT) and unofficial made by the community up to [@nodert-win11-22h2](https://github.com/demosjarco/NodeRT) are supported. The Windows SDK version they target is implied in their name.\n\n  💡 Mixing NodeRT modules from different scopes is supported (priority to the most recent SDK) but should be treated with caution.\n\n  NodeRT modules required for toast notification:\n\n  - `windows.data.xml.dom`\n  - `windows.ui.notifications`\n\n  For user input (text box and dropdown selection list) you will also need:\n\n  - `windows.ui.notifications` (\u003e nodert-win10-rs4 (1803) since it's available on win10 ≥ 1903)\n  - `windows.foundation`\n  - `windows.foundation.collections`\n\n  💡 If you have trouble compiling NodeRT native addons.\u003cbr /\u003e\n  They are available precompiled through the [@xan105/nodert](https://github.com/xan105/node-nodeRT) package.\n\n  ```\n  npm i @xan105/nodert --modules=\"windows.ui.notifications, windows.data.xml.dom, windows.foundation, windows.foundation.collections\"\n  ```\n\n  Note that you can also add a list of modules in your package.json file under the `_nodert/modules` path:\n\n  ```json\n  \"_nodert\" : {\n    \"modules\" : [\n      \"windows.data.xml.dom\",\n      \"windows.ui.notifications\"\n    ]\n  },\n  ```\n\n  Please see [@xan105/nodert](https://github.com/xan105/node-nodeRT#install) for more details.\n\n  **Electron**\n\n  For Electron add the `--electron` flag to target Electron's ABI\n\n  ```\n  npm i @xan105/nodert --electron --modules=\"windows.ui.notifications, windows.data.xml.dom\"\n  ```\n\n  ⚠️ Electron ≥ 14 : NodeRT should be loaded in the main process [NodeRT#158](https://github.com/NodeRT/NodeRT/issues/158)\n\n\u003c/details\u003e\n\nAPI\n===\n\n⚠️ This module is only available as an ECMAScript module (ESM) starting with version `2.0.0`.\u003cbr /\u003e\nPrevious version(s) are CommonJS (CJS) with an ESM wrapper.\n\nℹ️ Windows 8/8.1 support was removed in `3.x`\n\n## Named export\n\n### `Toast(option?: object): Class`\n\nCreate a toast notification.\n\n_extends 📖 [EventEmitter](https://nodejs.org/docs/latest-v20.x/api/events.html#class-eventemitter)_\n\n#### Constructor\n\n`(option?: object)`\n\nℹ️ Because there is a ton of options for toast notification, they are in [TOAST.md](./TOAST.md).\n\n#### Events\n\n- `activated (event: string, input: { key: value, ... })`\n\n  When user activates a toast notification through a click.\n  \n  Event is the argument passed by the notification or button.\n  \n  Input (textbox and/or selection) is the user input represented as key/value pair(s).\n\n- `dismissed (reason: string)`\n\n  When a toast notification leaves the screen, either by expiring or being explicitly dismissed by the user.\n\n  |Name|Description|\n  |----|-----------|\n  |UserCanceled|User dismissed the toast|\n  |ApplicationHidden|Application explicitly hid the toast|\n  |TimedOut|Toast had been shown for the maximum allowed time and was faded out|\n  \n#### Methods\n\n- `clear(): Promise\u003cvoid\u003e`\n\n  Remove the notification from the notification center and all event listeners.\n\n- `show(option?: object): Promise\u003cvoid\u003e`\n\n  Show toast notification.\n\n  **⚙️ Options**\n\n  + `disableWinRT?: boolean` (false)\n\n    If you have installed the optional NodeRT native module(s) but for whatever reason(s) you want to use PowerShell instead set this to `true`.\n\n  + `disablePowershellCore?: boolean` (false)\n\n    By default when using PowerShell this module will first try to use `pwsh` (PowerShell Core), then `powershell` (PowerShell Desktop / Windows Embedded).\n    Set this to `true` to skip `pwsh` and only use `powershell` which is included with Windows.\n\n    ℹ️ PowerShell Core has some caveats hence the option to disable/skip it:\n\n      - It's painfully slow to start.\n      - It needs to be installed and its path added to your env var.\n      - In order for PowerShell Core to use WinRT it will have to download WinRT assemblies \n        through its package manager (done on first run).\n\n    ⚠️ Please note that some features such as click events and user input requires Powershell ≥ 7.1 (pwsh).\u003cbr /\u003e\n\n  + `keepalive?: number` (6) seconds\n\n    ⚠️ This option is only for when listening for events !\n\n    The maximum amount of time PowerShell will wait for events before exiting or how long to keep the event loop alive for NodeRT.\n\n    PowerShell needs to be running to subscribe to the events and NodeRT registered event listener does not keep the event loop alive.\n    The default value is `6` seconds as 5 seconds is the default notification duration but keep in mind some users might have change this value in their Windows settings.\n\n    ℹ️ NB: When using NodeRT If you have something else maintaining the event loop then you can ignore this.\n\n  **Returns**\n    \n    ✔️ Resolves as soon as the notification has been dispatched. Except when PowerShell needs to be running to subscribe to events in which case the promise will resolve only afterwards.\n    \n    ❌ Rejects on error.\n  \n### `toXmlString(option?: object): string`\n\nExpose the toastXML string builder used by the Toast class for debugging purposes or for example if you want to use it with [Electron native API](https://www.electronjs.org/fr/docs/latest/api/notification#new-notificationoptions).\n\nPlease see the `Toast` class constructor for the relevant options.\n\nℹ️ The following options have no effect when just building a Toast XmlString:\n\n- aumid\n- uniqueID\n- hide\n- sequenceNumber\n- expiration\n\n### `const isWinRTAvailable: boolean`\n\nTrue if the peerDependencies for WinRT were successfully loaded; false otherwise.\n\n### `remove(aumid: string, uniqueID?: string | string[]): Promise\u003cvoid\u003e`\n\nRemove programmatically notification(s) from the notification center.\n\nIf using only `aumid` then it removes every notification for said aumid in the notification center.\u003cbr/\u003e\nIf you provide an optional `uniqueID` (string) then it removes that specific notification for the given aumid.\n\nℹ️ This library `uniqueID` option actually sets both tag and groupLabel to the same value for convenience.\u003cbr /\u003e\nIf you want to use the tag and groupLabel properties of a toast to target a notification then use\u003cbr /\u003e\n`uniqueID` (array) as `[ groupLabel: string, tag?: string ]`.\n\n### `getHistory(aumid: string, verbose?: boolean): Promise\u003cobject[]\u003e`\n\nList the current notification(s) for the given `aumid` in the notification center.\n\n\u003cdetails\u003e\n\u003csummary\u003eReturn an array of object with the following properties:\u003c/summary\u003e\n\n\u003cbr /\u003e\n\n|name|type|description|\n|----|----|-----------|\n|expirationTime|string|time after which a toast should not be displayed (eg: \"01/08/2021 20:53:23 +07:00\")|\n|tag|string|unique identifier (tag)|\n|group|string|unique identifier (group label)|\n\nIf `verbose` (false) is set to `true` then the following properties are added:\n\n|name|type|description|\n|----|----|-----------|\n|remoteID|string or null|id to correlate this notification with another one generated on another device|\n|suppressPopup|boolean|whether toast's pop-up UI is displayed on the user's screen|\n|mirroringAllowed|boolean|whether notification is allowed to be displayed on multiple devices|\n|expiresOnReboot|boolean|whether toast will remain in the notification center after a reboot|\n|highPriority|boolean|whether the notification is displayed in high priority (wake up the screen, etc)|\n|status|string or null|additional information about the status of the toast|\n\n\u003c/details\u003e\n\n📖 Microsoft doc\n=================\n\n📖 [Microsoft Toast API](https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts).\u003cbr /\u003e\n📖 [Toast content XML schema](https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-xml-schema).\u003cbr /\u003e\n📖 [ToastNotificationHistory class](https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Notifications.ToastNotificationHistory).\u003cbr /\u003e\n📖 [ToastNotification properties](https://docs.microsoft.com/en-us/uwp/api/windows.ui.notifications.toastnotification#properties).\u003cbr /\u003e\n📖 [send-local-toast-other-apps](https://github.com/MicrosoftDocs/windows-dev-docs/blob/docs/hub/apps/design/shell/tiles-and-notifications/send-local-toast-other-apps.md).\u003cbr /\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxan105%2Fnode-powertoast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxan105%2Fnode-powertoast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxan105%2Fnode-powertoast/lists"}