sindresorhus/run-applescript

Node.js bindings insead of child process

ORESoftware opened this issue · 5 comments

I see there are JavaScript libraries for displaying notifications, for example:
https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/DisplayNotifications.html

anyone know if there is a way to call the libs directly from JavaScript / Node.js, without launching a child process?

You could create a native Node.js addon that calls the NSAppleScript API. However, if performance is a concern, I'm not sure it will matter much as AppleScript is very slow already.

I'm personally avoiding native Node.js addons as they only create problems. Both with building and with crashing.

thanks, its possible that the electron api is based on bindings instead of applescript

https://www.electronjs.org/docs/api/notification

Yes, that's what Electron is doing.

yeah any idea if electron apis can be imported and used in a non-electron app, in some random nodejs code?

They cannot.