npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsxk

v0.1.8

Published

Provides a two-way communication interface between NodeJS and Adobe ExtendScript (JSX) files

Downloads

6

Readme

jsxk (JSX Kit)

Provides a two-way communication interface between NodeJS and Adobe ExtendScript (JSX) files.

This library is built for command-line NodeJS scripts interfacing with Adobe Photoshop or Illustrator.

How it works

  1. NodeJS makes a temporary duplicate of a standalone JSX, overwrites the values of supplied variables and executes it
  2. The temporary JSX script runs, optionally calling jsxOnComplete after completion with any returned data
  3. This data is appended to the temporary script file itself, that is picked up by Node
  4. Node deletes the temporary JSX script and returns the data via promise or callback

Advantages

  • Injecting variables into an existing JSX script allows the JSX to be executed by itself without relying on NodeJS. This makes authoring and testing the JSX script much more convenient.
  • Executing a local JSX script file utilises the native ExtendScript environment on the host system so doesn't rely on complicated dependencies such as AppleScript to perform the script.
  • File based callback system ensures the JSX script has completed before moving on.
  • Supports queuing multiple JSX scripts at once that are each actioned before receiving individual callbacks.

Installation

npm install jsxk --save

Basic usage

// NodeJS script

const jsxk = require('jsxk');

jsxk.exec('alert.jsx', {MESSAGE:'Hola'}).then(console.log,console.error);
// alert.jsx

#target photoshop

app.bringToFront();

var MESSAGE = 'Default'; 

alert(MESSAGE);

The example JSX script will be executed with the MESSAGE variable overridden with the supplied value Hola. The result is returned to Node as a promise.

Returning data from JSX

// NodeJS script

const jsxk = require('jsxk');

jsxk.exec('example.jsx').then(function(data){
  console.log(data.msg)
}).catch(console.error);
// receive-message.jsx

#target photoshop

app.bringToFront();

jsxOnComplete({msg:'Hi from JSX'});

function jsxOnComplete(data){
// Will be overridden
}

Calling jsxOnComplete(data) from the JSX script will flag the script has finished and optionally return a data object. In the above example Hi from JSX will be returned to Node and written to the console.

Using a callback function instead of a promise

jsxk.exec('example.jsx', {foo:'bar'}, function(err, data){
  
  if (err){
    throw err;
  }
  
  console.log(data);
  
});

Targeting a process

The open library is used to execute the JSX script. It will use the default program associated with JSX files on the host machine, usually Illustrator or Photoshop.

To target a specific process set the targetProcess option before running the script.

jsx.options.targetProcess = 'Adobe Photoshop 2020';
jsxk.exec(...);

Release History

CHANGELOG.md