Typings for JXA
This is a set of typings for AppleScript in JavaScript that works on macOS 10.10 and above.
This is a work in progress and is not yet stable.
Build
To run the examples, run webpack
in the root of the project. Then Execute dist/main.js
like so:
osascript -l JavaScript dist/main.js
A prompt window will appear for the Finder application.
Library
In the lib
directory, a helper library is available to make this easier to use in TypeScript (or ES6). It removes prefixes where possible to be more like Swift and removes long method names. Example:
; ;;try catch e // attr type is FileAttributes or undefined, which does not have prefixes removedif attr
Examples
See the examples directory.
Example with C functions
You do not have to use ObjC.import()
because all modules will do this on their own.
;; ;; // returns Ref<number>memsetbuf, 0, size;for ; i < size; i++, c++ ;; // memchr() returns Ref<number> or Ref to NULL;if result freeresult; // Do not print the result of the last expressionexit0;