Copy link to clipboard
Copied
Hello,
I was just curious what version of JS does ESTK support for Adobe Illustrator?
I am noticing that “const” works, but “let” does not.
Is there a list somewhere of supported language features?
Thanks!
ExtendScript based ECMA Edition 3 and not support "let" and "const" is better not to use it.
You can refer below.
Likely a copy/paste error on my part, apologies. Check here to reference
Copy link to clipboard
Copied
ExtendScript based ECMA Edition 3 and not support "let" and "const" is better not to use it.
You can refer below.
Copy link to clipboard
Copied
Awesome, thanks Ten, I really appreciate the help!
Also, thanks for the linkage ... That's very helpful.
Looks like I'll stick to es3 and be happy with it.
Thanks again!
Copy link to clipboard
Copied
Hey there! It's been a while, look who's back!
Also, ExtendScript has 'extras' such as - it supports triple quotes which act almost like template strings, except no normal syntax highlighter for javascript would recognize them, as well as xml inside of javascript!
Copy link to clipboard
Copied
Hi Silly-V,
I saw a photo in the Twitter timeline that your session in the Dev Events.
I wanted to see it in the front row but I couldn't go because of to far from here. (^-^;
Copy link to clipboard
Copied
They should help you out and bring you across vast oceans!
Copy link to clipboard
Copied
Fly me to the... (^-^;
Copy link to clipboard
Copied
Silly-V wrote
Hey there! It's been a while, look who's back!
Also, ExtendScript has 'extras' such as - it supports triple quotes which act almost like template strings, except no normal syntax highlighter for javascript would recognize them, as well as xml inside of javascript!
Hey Silly-V! It's great to hear from you!
Yah, I've been afk from doing Illustrator scripting for (I think) a few years now (how time flies!)
I've recently gotten back into Illustrator more again, and got inspired to write some jsx.
My last project was a Nodejs module (several of them) and it's spoiled me to the ways of ES2018+ ...
Anyway, I'm happy to be back in the game. I do love Illustrator the most out of all the Adobe products.
Thanks for the tips on the triple quotes! That's pretty interesting. Also, I will have to play with the XML syntax. I'm looking forward to dusting off my brain cells and creating some new plugins!
I'll see you around the forums!
Thanks to both of you Ten A and Silly-V, I really appreciate your help!!!
Copy link to clipboard
Copied
Well, nowadays you should be aware: future ExtendScript development after dropped support for ESTK will be done via a VSCode ExtendScript Debugger extension. (At 062019 version 1.1.1)
It's a little more cumbersome than the toolkit, and lack an OMV without some extra TypeScript stuff the pros (like you) use but when working on a Mac or a newer version of Windows that doesn't support old ESTK, it's alright.
There's also the issue of funky debugging - where the thing just aborts instead of stopping at a breakpoint - unless you step into.. etc - I've just been too busy and grateful for it working as well as it does.
Copy link to clipboard
Copied
Silly-V wrote
Well, nowadays you should be aware: future ExtendScript development after dropped support for ESTK will be done via a VSCode ExtendScript Debugger extension. (At 062019 version 1.1.1)
It's a little more cumbersome than the toolkit, and lack an OMV without some extra TypeScript stuff the pros (like you) use but when working on a Mac or a newer version of Windows that doesn't support old ESTK, it's alright.
There's also the issue of funky debugging - where the thing just aborts instead of stopping at a breakpoint - unless you step into.. etc - I've just been too busy and grateful for it working as well as it does.
Oh, wow! Ok, I am really out of the loop.
In a way, I'm kinda relieved that I can just use VSCode ... My current workflow involves having VSCode open and then jumping over to ESTK to hit compile and/or do breakpoints/view the OMV. I would much prefer to stay in an editor that's easier on my aging eyeballs.
Thanks so much for the heads up! I just installed the plugin and I am looking forward to playing with it this weekend.
Oh, Silly-V, did I read above that you presented at a conference? Googling ...
Looks cool!!! Did you get a recording of it?
Happy Friday!
Copy link to clipboard
Copied
Yea, I had my kids record it on an iPad, but it's a bumbling wreck of a presentation - like 100% of all my presentations - maybe in 5 years I'll get better at them
Copy link to clipboard
Copied
Awwww!
Well, if you do ever put it up, shoot me a link!
I feel you on bumbling. I've only had to do one thing like that, and i sucked! Hehe. Though, I'm sure your presentation went better than you are thinking ... Aren't we all our own worst critics.
Copy link to clipboard
Copied
Do you know about pravdomil's types? It's what Silly V is referring to, writing in Typescript can compile down to allow quite a bit of ES2018 (with exception to certain array functions like forEach/filter and template literals):
I have the correct tsconfig file here if you're interested! Just npm install @pravdomil/types-for-adobe (or types-for-adobe), then assuming you use VSCode hit Control+Shift+B and run the tsc:watch command on this tsconfig file. Write all your scripts in the .ts file, but point to the .jsx for use in CEP. It auto-compiles to .jsx every time you save and gives you DOM autocomplete! Pretty slick
Copy link to clipboard
Copied
Actually, come to think of it, you can add support for ES6 Array methods in .jsx! I've just confirmed with filter like below:
Array.prototype.filter = function(param) {
var filtered = [];
for (var i = 0; i < this.length; i++)
if (param(this, i, this)) filtered.push(this);
return filtered;
};
// Now in your .ts file you can use:
let filtered = ["a", "b", "c", "d"].filter(item => {
return /a|d/.test(item);
});
alert(filtered);
I'll make a utility library myself because I too am completely spoiled by ES6 Array methods nowadays. I'll share once it's done.
Copy link to clipboard
Copied
Inventsable wrote
Do you know about pravdomil's types? It's what Silly V is referring to, writing in Typescript can compile down to allow quite a bit of ES2018 (with exception to certain array functions like forEach/filter and template literals):
I have the correct tsconfig file here if you're interested! Just npm install @pravdomil/types-for-adobe (or types-for-adobe), then assuming you use VSCode hit Control+Shift+B and run the tsc:watch command on this tsconfig file. Write all your scripts in the .ts file, but point to the .jsx for use in CEP. It auto-compiles to .jsx every time you save and gives you DOM autocomplete! Pretty slick
Oh, shoot, that's cool!!!
Thanks for sharing!!!
I've been super busy this last week+ with some life BS ... Sorry to not have responded sooner.
This looks really cool though! THanks so much for sharing/elaborating. I can't wait to use it!
I'm sure I'll be back here, on in a new thread, with more questions.
Thanks @Inventsable! I really appreciate the help!
Copy link to clipboard
Copied
Hey,
as far as i know, pravdomil types are no longer maintained.
They are not updated to newset versions of adobe applications, and updating it by the pravdomils generator for types doesn't work out of box.
Even though it's pretty helpful. I'm just wondering if Adobe is on the road with creating some language server for ExtendScript, or we will need to stick to the pravdomil types.
If anyone have corrected file with types for illustrator i'd be happy to see it. I've found it few days ago and i'm thinking if should i use it even though there are some errors.
Copy link to clipboard
Copied
Some forks are still alive.
Copy link to clipboard
Copied
The link for "Use of 'const' in ExtendScript" seems to be broken. Here's the correct link (at the time of my posting):
https://community.adobe.com/t5/indesign-discussions/use-of-const-in-extendscript/m-p/5218549
Copy link to clipboard
Copied
Was told by Remco Janssen that this already exists somewhere, but regardless here's filter, map, find, and forEach:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
//
Array.prototype.filter = function(callback) {
var filtered = [];
for (var i = 0; i < this.length; i++)
if (callback(this, i, this)) filtered.push(this);
return filtered;
};
// Support for find()
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
//
Array.prototype.find = function(callback) {
var filtered = [];
for (var i = 0; i < this.length; i++)
if (callback(this, i, this)) return this;
};
// Support for map()
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
//
Array.prototype.map = function(callback) {
var mappedParam = [];
for (var i = 0; i < this.length; i++)
mappedParam.push(callback(this, i, this));
return mappedParam;
};
// Support for forEach()
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
//
Array.prototype.forEach = function(callback) {
for (var i = 0; i < this.length; i++) callback(this, i, this);
};
Copy link to clipboard
Copied
Wondering why these prototypes dont seem to work properly with cc 2018. I tried that Array prototype and it returns the complete list added 4 times with this example. Unless i dont change a small part in the function, it wont work correct
// Inventsable
// https://community.adobe.com/t5/illustrator-discussions/what-version-of-javascript-supported/m-p/10488213#M136748
Array.prototype.forEach = function(callback) {
for (var i = 0; i < this.length; i++) callback(this[i], i, this);
};
var sum = 0;
var numbers = [65, 44, 12, 4];
numbers.forEach(myFunction);
function myFunction(item) {
sum += item;
}
alert(sum)
Noticed that in the callback(this,i, this) i made a change to callback(this[i], i, this). Otherwise it return the complete array each time its called?!
Copy link to clipboard
Copied
Likely a copy/paste error on my part, apologies. Check here to reference
Copy link to clipboard
Copied
Thanks for the link!
PS i see many useful tools on your github, nice 🙂
Copy link to clipboard
Copied
Thanks !
Gonna check it out