Giter VIP home page Giter VIP logo

jsxbin's Introduction

jsxbin

Convert jsx ExtendScript files into jsxbin

Example

const jsxbin = require( 'jsxbin' )

jsxbin( 'path/to/script.js', 'output/script.jsxbin' )
	.then( outputfiles => {
		console.log( 'Finished!' )
	})
	.catch( err => {
		console.error( err )
	})

Methods

jsxbin( inputPaths, [outputPath] )

inputPaths can be:

  • String with path to jsx file. script.jsx
  • String with glob pattern that matches jsx/js files. *.jsx
  • Array of any of the above

outputPath, optional, can be:

  • String path to converted file. path/to/script.jsxbin
    • Should only be used when passing only one file as inputPaths
  • String path to converted file directory. path/to/output
  • Array of string paths of names for all converted files
    • Should only be used when passing an array to inputPaths. Input and output arrays must be the same length.
  • If not given, the files will be created in the same directory as the input file(s)

jsxbin returns a promise with an array of file paths to the converted files

Examples

// Just one file
jsxbin( 'script.jsx', 'script.jsxbin' )

// Is the same as
jsxbin( 'script.jsx' )

// Multiple files
jsxbin([ 'script1.jsx', 'script2.jsx' ], 'output/' )

// Using glob string for input, jsxbin files will be placed in 'output/' dir
jsxbin( 'src/*.jsx', 'output' )

// With no output path specified, jsxbin files will be placed in the 'src/' dir
jsxbin( 'src/*jsx' )

// As a gulp task
gulp.task( 'jsxbin', () => {
	return jsxbin( 'src/index.js', 'output/script.jsxbin' )
})

From the Command Line

This package also includes a jsxbin command than can be run from the command line.

jsxbin

  usage: jsxbin -i file1.jsx, file2.jsx.. -o outputdir
  usage: jsxbin -i file1.jsx -o outputname.jsxbin

  Converts Extendscript .jsx files into jsxbin

Options

  -i, --input   file(s)      The file or files to convert
  -o, --output  file|folder  The file or folder where the converted file will be placed
  -v, --verbose              Show more info while running
  --debug                    Show even more info while running
  -h, --help                 Show help

Install

with npm do:

npm install jsxbin

to get the function, or

npm install jsxbin -g

to get the command.

Contributing

Issues and pull requests are more than welcome! Please ensure you have tests for your pull requests, and that npm test passes.

License

This project is licensed under the MIT License - see the LICENSE.md file for details This project includes code from the Adobe Extendscript debugger extension for Visual Studio Code which uses the [Apache License, Version 2.0]*(http://www.apache.org/licenses/LICENSE-2.0)

Thanks

  • The implemention using VSCode ES debugger from Adobe was added by Sammarks
  • Thanks to RenderTom and Zlovatt for additional contributions

jsxbin's People

Contributors

fadri1 avatar rendertom avatar runegan avatar sammarks avatar thealexus avatar zlovatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsxbin's Issues

Fix "#include" preprocessor issue.

From ESTK's hidden file 80document.jsx you can see that app.compile() takes 3 arguments.
s = app.compile( this.getText(), ( f ? f.absoluteURI : undefined ), this.includePath );

Not sure what second argument is for, but third argument sets the includePath of the current script which resolves the relative import.

So in generateScriptFile.js file you could use this:
var t = app.compile(s, undefined, fileIn.parent.absoluteURI);

Boom!

#include with relative paths

Right now it only works when absolute paths are used in the #include statement.

The way to fix it is to place that script that is being run by ESTK in the same location as the script it is compiling.

I see two ways to do this:

  1. Create one script file for each of the files passed into jsxbin, and place the ESTK script in the same location as that passed file. ESTK has to close and reopen for each of the files, which may slow things down.
  2. Create a list of directories where the passed files are located and a list of which files are in those folders. Create a script for each of the directories and place them there. This is the most optimal, i believe.

Any help/pull request on this is welcome!

Add support for M1 Mac/arm64e

I'm not sure if this is possible, but on my M1 Mac I get this error when running a clone of the bolt-cep repo:

Error: dlopen(~/bolt-cep-test/node_modules/jsxbin/esdebugger-core/mac/esdcorelibinterface.node, 0x0001): tried: '~/bolt-cep-test/node_modules/jsxbin/esdebugger-core/mac/esdcorelibinterface.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/esdcorelibinterface.node' (no such file), '/usr/lib/esdcorelibinterface.node' (no such file)

One alternative that I would imagine working, but I haven't tried is to run/install node in Rosetta.

Install fails on Windows 10

Hello. I've installed this previously with no issue back when it was still using the ESTK, and recently came to revisit it but get an error when running npm install jsxbin:

> [email protected] postinstall C:\Users\TRSch\OneDrive\Documents\Dev\NPMpackages\bombino-commands\node_modules\jsxbin
> tar -xzf esdebugger-core.tar.gz

esdebugger-core/mac/Frameworks/esdcore.framework/Resources: Can't create '\\\\?\\C:\\Users\\TRSch\\OneDrive\\Documents\\Dev\\NPMpackages\\bombino-commands\\node_modules\\jsxbin\\esdebugger-core\\mac\\Frameworks\\esdcore.framework\\Resources'
esdebugger-core/mac/Frameworks/esdcore.framework/esdcore: Can't create '\\\\?\\C:\\Users\\TRSch\\OneDrive\\Documents\\Dev\\NPMpackages\\bombino-commands\\node_modules\\jsxbin\\esdebugger-core\\mac\\Frameworks\\esdcore.framework\\esdcore'
esdebugger-core/mac/Frameworks/esdcore.framework/Versions/Current: Can't create '\\\\?\\C:\\Users\\TRSch\\OneDrive\\Documents\\Dev\\NPMpackages\\bombino-commands\\node_modules\\jsxbin\\esdebugger-core\\mac\\Frameworks\\esdcore.framework\\Versions\\Current'
esdebugger-core/mac/Frameworks/esdcore.framework/Versions/A/Resources/adobe_caps.framework/Resources: Can't create '\\\\?\\C:\\Users\\TRSch\\OneDrive\\Documents\\Dev\\NPMpackages\\bombino-commands\\node_modules\\jsxbin\\esdebugger-core\\mac\\Frameworks\\esdcore.framework\\Versions\\A\\Resources\\adobe_caps.framework\\Resources'
esdebugger-core/mac/Frameworks/esdcore.framework/Versions/A/Resources/adobe_caps.framework/adobe_caps: Can't create '\\\\?\\C:\\Users\\TRSch\\OneDrive\\Documents\\Dev\\NPMpackages\\bombino-commands\\node_modules\\jsxbin\\esdebugger-core\\mac\\Frameworks\\esdcore.framework\\Versions\\A\\Resources\\adobe_caps.framework\\adobe_caps'
esdebugger-core/mac/Frameworks/esdcore.framework/Versions/A/Resources/adobe_caps.framework/Versions/Current: Can't create '\\\\?\\C:\\Users\\TRSch\\OneDrive\\Documents\\Dev\\NPMpackages\\bombino-commands\\node_modules\\jsxbin\\esdebugger-core\\mac\\Frameworks\\esdcore.framework\\Versions\\A\\Resources\\adobe_caps.framework\\Versions\\Current'
tar: Error exit delayed from previous errors.
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `tar -xzf esdebugger-core.tar.gz`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\TRSch\AppData\Roaming\npm-cache\_logs\2019-11-15T01_18_00_267Z-debug.log

Noticeably looks like it's trying to grab or do something with a Mac file structure and isn't reading my OS prior to know I'm using Windows. Any workaround to this?

Execution error from After Effects

Hi,
Thanks for this package. It's very useful.

I'm developing an AE Extension and it's working normally when I put the project in the extension folder without converting the .jsx files to .jsxbin.

When I convert to .jsxbin (and renaming the files to .jsx), I can execute the .jsxbin from the VSCode (with Adobe Script Runner), it is executed properly.
But when I try to execute the same .jsxbin scripts from within the After Effects 2021 - Version 18.2 (with CSInterface), they don't work.

For instance, in the code below I can execute via VSCode, but when I try to execute the jsxbin from After Effects, the alert("Hostscript.jsx"); is showed up, and I get an "null is not an object" error from the line var ROOT_DIR = File($.fileName).parent.parent.fsName; and the application breaks.

UPDATE: Seems that $.fileName is returning a number instead of a string path for File() and hence returning a null object. But I don't understand why this occurs only from AE and not from VS Code.

Any clues on what can be the problem?

alert("Hostscript.jsx");

function message(msg){
    var ROOT_DIR = File($.fileName).parent.parent.fsName;
    alert(msg + " - " + ROOT_DIR);
    // alert(msg);
}
message("message");

add linux support

hey @runegan and thnx for this tool!

  • can u add "linux" to the list of OSes in package.json? (in addition to 'darwin' and 'win32')

please forgive me if 'issues' is not the right place for this message

thnx in advance!

jsxbin Syntax Error

Running jsxbin script from command line results in "Syntax Error: Syntax Error", while saving as binary via ESTK works fine

Version 1.6.0 doesn't work

Version 1.6.0 doesn't work for me. It does not generate files. And I don't see any ESTK window. I didn't try to figure out what is going on I just downgraded to 1.5.1 which works good for me.

output file is empty

Hey, first of all thanks for the lib. Saved me a lot of hassle.

However, I have an issue regarding the following line:

jsxbin( 'path/to/script.js', 'output/script.jsxbin' )
	.then( outputfiles => {
		console.log( 'Finished!' )
	})
	.catch( err => {
		console.error( err )
	})

While the script succeeds, and creates the output folder, it remains empty. The only way I have had the script working is by using it as follows:

jsxbin( 'path/to/script.js')

Am I missing something?

Not sure if its installed at correct location

I havtn used NPM in quite a while. But i basically just ran the install code in Terminal, using osx 10.11.6 ( i know super old)

I got this "error" in return

[email protected] postinstall /Users/macpro1/node_modules/jsxbin
> node bin/postinstall.js

npm WARN saveError ENOENT: no such file or directory, open '/Users/macpro1/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/Users/macpro1/package.json'
npm WARN macpro1 No description
npm WARN macpro1 No repository field.
npm WARN macpro1 No README data
npm WARN macpro1 No license field.

+ [email protected]
added 61 packages from 33 contributors and audited 61 packages in 15.544s
found 0 vulnerabilities

Seem like its being installed in the wrong spot.

Error running jsxbin in gulp

I want to automate my workflow, but this is always giving me error in gulp 4.

My gulp code:
`const jsxbin = require('jsxbin');

function toJsxbin() {
return jsxbin('myScript.jsx');
}

exports.toJsxbin = toJsxbin;`

Then I type gulp toJsxbin in vscode terminal.

Everytime I got this error:
[22:58:46] Starting 'toJsxbin'...
[22:58:48] 'toJsxbin' errored after 2.26 s
[22:58:48] Error: Error with ESTK: 'unknown'
at getESDError (D:\Adobe_Scripting\ZXP_Packaging\node_modules\jsxbin\src\convertScripts.js:32:8)
at convertFileContents (D:\Adobe_Scripting\ZXP_Packaging\node_modules\jsxbin\src\convertScripts.js:56:3)
at convertScripts (D:\Adobe_Scripting\ZXP_Packaging\node_modules\jsxbin\src\convertScripts.js:79:27)
at D:\Adobe_Scripting\ZXP_Packaging\node_modules\jsxbin\index.js:61:16

What I am missing?
Thx in advance.

Preserve nested folders structure

Let's say that I have a tree structure of the folder and some scripts in each folder. Is there any chance to preserve that folder structure right now?

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.