Git Product home page Git Product logo

jxa-infusion's Introduction

JXA

Libraries, both native and runtime injectable, for macOS’ JavasScript for Automation (JXA) system.

Contents

This repository contains two different kind of JXA libraries:

  1. Libraries: these are native OSA libraries used with Library(). They are managed as JXA source code but need to be compiled with osacompile before usage (see below).
  2. Injections: these are libraries extending the JXA object space. You will need the JXA native library to inject them into the JXA runtime. These are used as is.

Installing the libraries

OSA libraries need to go into a folder recognised by the Library() command on your system (basically here and, starting from macOS 10.11, here). The recommended location is the Script Libraries folder in you user Library.

Note the script files in the Libraries tree need to be compiled to binary OSA script files before usage. You can either download the releases from Github, which contain the native libraries in compiled format, or compile them yourself using osacompile as follows:

osacompile -l JavaScript -o ~/Library/Script Libraries/<name>.scpt <name>.jxa

Injections should be copied to a recognised location “as is”. The injection mechanism of the JXA library expects plain text files, so do not compile these!

Using the libraries

The libraries, once compiled and installed as described above, are directly available to the Library() command in your scripts, i.e.

const parser = Library('TextParser')
const addresses = parser.extractAddresses('Apple, One Apple Park Way, Cupertino, CA 95014.')

The injection libraries need a little two-step:

const jxa = Library('JXA')
var _p = new Function(jxa.source('Path')); _p(); _p = null

This will inject the Path extensions into the Path object.

API

For the API of the individual libraries (either native or injected), see the Wiki.

Compatibility

All scripts are written in ES6 conforming JavaScript. Because the JavaScript Core used in the first OS releases to support JXA, macOS 10.10 (Yosemite) and macOS 10.11 (El Capitan), did not fully support the ES6 feature set, macOS 10.12 (Sierra) or better is required to use the libraries.

jxa-infusion's People

Contributors

kopischke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ninjakttty

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.