types-for-adobe

repository·master·Indexed 20 days ago

https://github.com/docsforadobe/types-for-adobe

TypeScript type definitions (typedefs) for various Adobe Creative Cloud products, enabling developers to write type-safe scripts for Adobe applications. The library provides version-specific typedefs to ensure API compatibility across different host application versions.

Tokens
920
Snippets
1
Records
3
Agent score
21%

What's inside types-for-adobe

  1. How to choose the correct Adobe version typedefs

    master

    The types-for-adobe repository maintains a history of typedefs for each specific version of each host application.

    Why version-specific types matter

    • Compatibility: If you are developing for an older version (e.g., After Effects v18.0), using those specific typedefs ensures you don't use APIs that were only introduced in later versions.
    • Commercial Tools: Targeting older versions allows for wider adoption among users who haven't updated their software.
    • Internal Tools: Companies often mandate specific software versions; versioned typedefs allow for precise targeting of those environments.

    Selection Strategy

    • If targeting a broad user base: Use the version that most of your users are likely to have, or the version that includes the features you need, and specify that as a minimum requirement.
    • If leveraging new features: Use the typedefs for the specific version where those features were introduced.

    Reference Syntax

    To use a specific version, use the triple-slash reference syntax in your .ts file: /// <reference types="types-for-adobe/[Product]/[Version]"/>

  2. Create an Adobe script using types-for-adobe

    master

    To develop scripts for Adobe products with TypeScript type safety, follow these steps to set up a project, install the types, and compile your code for use in the Adobe host application.

    1. Project Setup

    Create a new directory for your script and initialize a Node.js project:

    mkdir my-script
    cd my-script
    npm init -y
    npm i types-for-adobe

    2. Configure TypeScript

    Create a tsconfig.json file with specific settings to ensure compatibility with Adobe's ExtendScript environment. Use module: "none" and noLib: true:

    printf '{"compilerOptions":{"module":"none","noLib":true}}' > tsconfig.json

    3. Write your script

    Create an index.ts file. You must include a triple-slash directive at the top of the file to reference the specific Adobe product and version you are targeting.

    Example for Adobe Illustrator 2015.3:

    /// <reference types="types-for-adobe/Illustrator/2015.3"/>
    alert(String(app));

    4. Compile and Run

    Compile your TypeScript file into JavaScript using the TypeScript compiler (tsc):

    tsc

    To run the script in Adobe:

    1. Open your target Adobe application (e.g., Adobe Illustrator).
    2. Navigate to File -> Scripts -> Other Script...
    3. Select the generated index.js file.
    # create new folder
    mkdir my-script
    cd my-script
    
    # install types-for-adobe
    npm init -y
    npm i types-for-adobe
    
    # create tsconfig.json
    printf '{"compilerOptions":{"module":"none","noLib":true}}' > tsconfig.json
    
    # create index.ts and change reference types to Adobe product you're targeting
    printf '/// <reference types="types-for-adobe/Illustrator/2015.3"/>\nalert(String(app));\n' > index.ts
    
    # compile typescript files
    tsc
    
    # open Adobe Illustrator -> File -> Scripts -> Other Script -> and open index.js