2 ms·
macOS APIs have poor documentation overall, but JXA is on another level. It's not even like Carbon APIs which are still necessary to use today, but which docume
by lwouis 5y ago
macOS APIs have poor documentation overall, but JXA is on another level. It's not even like Carbon APIs which are still necessary to use today, but which documentation was removed from Apple's website. At least here, you can find an archive somewhere. No, JXA was simply never documented.
You basically have the AppleScript docs, which themselves are under-documented, and you have to guess what JXA APIs exist based off it. My recommendation is to use Safari and play with the debugger at runtime. That way you can test and see which APIs are available by trial and error. You can also hack around and display JS objects internal variables/prototypes to get an idea of what things may be available.
I've had to dig deep into this for my FOSS app recently, and I'll like to share these 2 gems of very-hard-to-find information:
- How AppleEvents (AppleScript or JXA triggered events) permission works (https://www.felix-schwarz.org/blog/2018/08/new-apple-event-apis-in-macos-mojave https://www.felix-schwarz.org/blog/2018/08/new-apple-event-a...)
- (Bitter) testimony from someone involved at JXA's inception (https://news.ycombinator.com/item?id=21803874 https://news.ycombinator.com/item?id=21803874)
Hopefully this message saves someone hours of research~