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

extend-script-loader

v1.0.6

Published

This package allows for easy execution of ExtendScript files directly from a CEP panel.

Downloads

7

Readme

extend-script-loader

This package allows for easy execution of ExtendScript (ES) files directly from a Adobe Common Extensibility Platform (CEP) panel.

Why

The process for setting up bi-directional communication between CEP and ES is a bit tedious to work with. This improves that process by allowing you to simply import your ES code and run it directly from the presentation layer. We also get free hot reloading on ES files when used with Hot Module Reloading (HMR).

Installation

npm install --save-dev extend-script-loader

Usage

Note: Examples use ES6 syntax on the CEP side. Use babel or similar to transpile.

You'll need to add extend-script-loader to the list of loaders within your webpack configuration like so:

module: {
  loaders: [
    {
      test: /\.es?$/, // js or jsx will also work if preferred.
      exclude: /(node_modules|bower_components)/,
      loader: 'extend-script', // 'extend-script-loader' is also a legal name to reference
    }
  ]
}

Make sure CSInterface is loaded in the CEP panel.

<html>
  <head>
    <script src="CSInterface.js"></script>
  </head>
</html>

Then write your ES inside of an Immediately-Invoked Function Expression (IIFE):

// hello-world.es
(function() {
  writeLn('Hello world!');
})();

Lastly, import and run the script inside your CEP panel:

// app.js
import helloWorld from './hello-world.es'

helloWorld();

If run with After Effects as the target, you'll see Hello world! inside of the Info panel.

Advanced Usage

It's also possible to send and receive data to scripts.

Receiving data from CEP

Return a function inside the script that will accept parameters passed from CEP:

// send-number.es
(function() {
  return function(number) {
    writeLn('Number from CEP: ' + number);
  };
})();
// app.js
import sendNumber from './send-number.es'

sendNumber(Math.random() * 100);

Receiving data from ES

Return a value inside the script that will be passed to CEP:

// receive-number.es
(function() {
  return function() {
    return Math.random() * 100
  };
})();
// app.js
import receiveNumber from './receive-number.es'

receiveNumber((err, result) => {
  console.log('Number from ES: ' + result);
});

Note: You can return any JSON parseable data (including objects and arrays).

// send-object.es
(function() {
  return function() {
    return {foo: 'bar'}
  };
})();
// app.js
import sendObj from './send-object.es'

sendObj((err, result) => {
  console.log('Object from ES: ', result);
});

Passing and receiving data inside CEP.

You can pass as many parameters as desired to the script. The callback will always be added as the last parameter.

// app.js
import scriptWithManyParameters from './my-script.es'

scriptWithManyParameters('foo', 'bar', (err, result) => {
  // this is still called no matter how many parameters are passed to scriptWithManyParameters
});

Exceptions

Currently, when any exception is thrown inside of an ES file it is caught and the error object is passed back to the CEP invocator's callback and also logged in the CEP console. This is because ExtendScript Toolkit is too slow and painful to work with and I've found it faster to just check the error's message and line number and then fix it in my text editor of choice. A configuration/query parameter to "unwrap" the try/catch to disable this could be added later if needed.

// throw-exception.es
(function() {
  throw Error('MyError: an error happened here.');
})();
// app.js
import throwException from './throw-exception.es'

throwException((err, result) => {
  if (err) {
    console.log(err.message); // MyError: an error happened here.
    console.log(err.line); // 2
    console.log(err.source); /* the entire script's source. this might be useful for some advanced
      CEP error displaying in the future.
    */
  }
});

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Todos

  • Auto include CSInterface.js in CEP panel.

  • Ability to import multiple functions from ES script:

    // app.js
    import { functionA, functionB } from './multiple-functions.es'

History

TODO: Write history

License

The MIT License (MIT)