jxa-userland

repository·master·Indexed 19 days ago

https://github.com/jxa-userland/jxa

A collection of tools to bring modern developer experiences to JavaScript for Automation (JXA), including TypeScript integration, Node.js execution, and IDE autocomplete. Key packages include @jxa/run for executing JXA code from Node.js, @jxa/repl for an interactive terminal environment, @jxa/types and @jxa/global-type for TypeScript definitions, and @jxa/sdef-to-dts for converting Scripting definition files (.sdefs) to TypeScript definition files (.d.ts).

Tokens
25.4K
Snippets
79
Records
119
Agent score
66%

What's inside jxa-userland

  1. Overview of JXA-userland packages

    master

    The jxa-userland project provides tools to improve the developer experience for JavaScript for Automation (JXA). Key packages include:

    • @jxa/run: Allows running JXA code from Node.js.
    • @jxa/repl: Provides a REPL environment for JXA.
    • @jxa/types: Provides TypeScript types for JXA.
    • @jxa/global-type: Enables TypeScript autocomplete and typing for JXA in editors.
    • @jxa/sdef-to-dts: Converts SDEF (Scripting Definition) files to TypeScript definition files.
  2. Enable TypeScript autocomplete for JXA

    master

    To get TypeScript definitions and autocomplete for JXA APIs in your editor, import @jxa/global-type. This provides the necessary .d.ts definitions for the JXA global environment. Ensure your editor supports TypeScript.

    // Your .ts file require @jxa/global-type
    import "@jxa/global-type";
    
    // your JXA application
    const userName = Application("System Events").currentUser().name();
  3. Use the @jxa/repl REPL

    master

    You can start the JXA REPL using npx without a global installation, or use the jxa-repl command if you have installed it globally. Once started, you can execute JXA (JavaScript for Automation) commands directly in the terminal.

    # Using npx
    npx @jxa/repl
    
    # Or if installed globally
    jxa-repl
    
    # Example interaction
    > Application("System Events").currentUser().name();