Highlighted

Extensions $.fileName property yields '14'

Explorer ,
May 19, 2020

Copy link to clipboard

Copied

In my extension's manifest.xml file I have:

 

 

<ScriptPath>./jsx/init.jsx</ScriptPath>

 

 

This causes the JSX to load. Now I also want this JSX file to load other 'helper' JSX files. So I turned to $.evalFile to load a file in the same directory as init.jsx. Here are my attempts:

 

 

$.evalFile('polyfill.jsx');
$.evalFile('./polyfill.jsx');
$.evalFile('jsx/polyfill.jsx');
$.evalFile('/jsx/polyfill.jsx');
$.evalFile('./jsx/polyfill.jsx');​

 

 

All of these report file not found, even though it definitely exists.
 
So I went to look at what Folder.current reports and it is: /c/Program%20Files/Adobe/Adobe%20After%20Effects%20CC%202019/Support%20Files
This is not helpful. So I went to go look at $.fileName and it returns the string '14' (not a file name or anything, just the string '14'). Why? The only place I have found that can help me link my extension directory is $.includePath which contains the JSX path. But I am concerned $.includePath is not reliable and may not always be just a single path to the directory containing init.jsx.
 
I am confident I am not the first person who wanted to reference other files from their JSX script main. How do other people do this?
 
Thanks

I found a way! Inside of the main.jsx (the script referenced by <ScriptPath>), put either:

    #include './polyfill.jsx'

or

    //@include './polyfill.jsx'

And this seems to import the file correctly.

Topics

Error or problem, Expressions, Scripting

Views

353

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Extensions $.fileName property yields '14'

Explorer ,
May 19, 2020

Copy link to clipboard

Copied

In my extension's manifest.xml file I have:

 

 

<ScriptPath>./jsx/init.jsx</ScriptPath>

 

 

This causes the JSX to load. Now I also want this JSX file to load other 'helper' JSX files. So I turned to $.evalFile to load a file in the same directory as init.jsx. Here are my attempts:

 

 

$.evalFile('polyfill.jsx');
$.evalFile('./polyfill.jsx');
$.evalFile('jsx/polyfill.jsx');
$.evalFile('/jsx/polyfill.jsx');
$.evalFile('./jsx/polyfill.jsx');​

 

 

All of these report file not found, even though it definitely exists.
 
So I went to look at what Folder.current reports and it is: /c/Program%20Files/Adobe/Adobe%20After%20Effects%20CC%202019/Support%20Files
This is not helpful. So I went to go look at $.fileName and it returns the string '14' (not a file name or anything, just the string '14'). Why? The only place I have found that can help me link my extension directory is $.includePath which contains the JSX path. But I am concerned $.includePath is not reliable and may not always be just a single path to the directory containing init.jsx.
 
I am confident I am not the first person who wanted to reference other files from their JSX script main. How do other people do this?
 
Thanks

I found a way! Inside of the main.jsx (the script referenced by <ScriptPath>), put either:

    #include './polyfill.jsx'

or

    //@include './polyfill.jsx'

And this seems to import the file correctly.

Topics

Error or problem, Expressions, Scripting

Views

354

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
May 20, 2020

Copy link to clipboard

Copied

I have come to the conclusion that what I want to do is impossible. There is a whole section about this here:

https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_9.x/Documentation/CEP%209.0%20HTML%20Exte...

 

Basically it says:

 

"But if the $.fileName is referred in the FIRST LOADED JSX file, the value is not correct. That is to say, if the snippet above runs in example.jsx which is referred in the manifest.xml, the error will arise. So, PLEASE AVOID using $.fileName in the FIRST LOADED JSX file, maybe this is a limitation in ExtendScript. The workaround is to refer it in the second loaded and afterward JSX files."

 

So I cannot have any dependencies in my main.jsx file and CEP wants me to initialize from Chromium via evalFile. Now to figure out how to get the extension root directory from Chromium...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
May 20, 2020

Copy link to clipboard

Copied

I found a way! Inside of the main.jsx (the script referenced by <ScriptPath>), put either:

    #include './polyfill.jsx'

or

    //@include './polyfill.jsx'

And this seems to import the file correctly.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...