I have been able to use Node js and Adobe's extendscript debugger VSCode extension code to automate some JSXBIN creation (there's at least one package out there that does the same as I hand-made to do this, from the looks of it, pretty much almost the exact same way: you use a path to Adobe's code you find inside the VSCode extension and feed your parameters to it). That is just great, except now that I've tried this out on something that I've worked on for years with no JSXBIN and saw there are some issues which are kind-of problematic, but only in some advanced cases. First, the good news is that a JSXBIN file can be invoked with regular scripting triggers (File > Scripts > other scripts) just fine. That's a given, but furthermore it also works by using eval on a JSXBIN string. Interestingly, I was not able to actually make it eval like this: eval("#inlclude 'path/to/jsxbin.jsx'"). Note: Matter of fact, although there's some convention of a 'jsxbin' file extension, the UI doesn't let you pick anything other than js or jsx Instead, I was able to read the string and eval the string like this:
var f = File(pathToScript); f.open('r'); var c = f.read(); f.close(); eval(c); If anyone used the "Script Panel 2" - the SUI-based script-panel, it takes a minor edit to run bin files from the buttons, it has to read the script file to see if it begins with the string "@JSXBIN" (or something). But, it works: the script panel reads the jsxbin gibberish text and evals it using the above line successfully. What does not work for me though is the special case where the target script is actually also a BridgeTalk-enabled script too. I make mine in a specific way where the entire script function is sent to another app via BT, and accompanying arguments make this script behave differently when in that other app. When I do this, it goes like so: function TheScript (args) {
function hexDecode (inStr) {
var r = ""; for (var i = 0; i < inStr.length; i += 2) { r += unescape("%" + inStr.substr(i, 2)); } return r;
};
function hexEncode (inStr) {
var r = ""; var i = 0; var h; while (i < inStr.length) { h = inStr.charCodeAt(i++).toString(16); while (h.length < 2) { h = h; } r += h; } return r;
};
"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(t){return 10>t?"0"+t:t}function quote(t){
return escapable.lastIndex=0,escapable.test(t)?'"'+t.replace(escapable,function(t){var e=meta[t];
return"string"==typeof e?e:"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}
function str(t,e){var n,r,o,f,u,i=gap,p=e[t];switch(p&&"object"==typeof p&&"function"==typeof p.toJSON&&(p=p.toJSON(t)),
"function"==typeof rep&&(p=rep.call(e,t,p)),typeof p){case"string":return quote(p);case"number":return isFinite(p)?String(p):"null";
case"boolean":case"null":return String(p);case"object":if(!p)return"null";if(gap+=indent,u=[],"[object Array]"===Object.prototype.toString.apply(p)){
for(f=p.length,n=0;f>n;n+=1)u[n]=str(n,p)||"null";return o=0===u.length?"[]":gap?"[\n"+gap+u.join(",\n"+gap)+"\n"+i+"]":"["+u.join(",")+"]",gap=i,o}
if(rep&&"object"==typeof rep)for(f=rep.length,n=0;f>n;n+=1)"string"==typeof rep[n]&&(r=rep[n],o=str(r,p),o&&u.push(quote(r)+(gap?": ":":")+o));
else for(r in p)Object.prototype.hasOwnProperty.call(p,r)&&(o=str(r,p),o&&u.push(quote(r)+(gap?": ":":")+o));return o=0===u.length?"{}":gap?"{\n"+gap+
u.join(",\n"+gap)+"\n"+i+"}":"{"+u.join(",")+"}",gap=i,o}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){
return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+
f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){
return this.valueOf()});var cx,escapable,gap,indent,meta,rep;"function"!=typeof JSON.stringify&&
(escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(t,e,n){var r;
if(gap="",indent="","number"==typeof n)for(r=0;n>r;r+=1)indent+=" ";else"string"==typeof n&&(indent=n);if(rep=e,
e&&"function"!=typeof e&&("object"!=typeof e||"number"!=typeof e.length))throw new Error("JSON.stringify");return str("",{"":t})}),
"function"!=typeof JSON.parse&&(cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
JSON.parse=function(text,reviver){function walk(t,e){var n,r,o=t[e];if(o&&"object"==typeof o)for(n in o)Object.prototype.hasOwnProperty.call(o,n)&&
(r=walk(o,n),void 0!==r?o[n]=r:delete o[n]);return reviver.call(t,e,o)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&
(text=text.replace(cx,function(t){return"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})),
/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@")
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]")
.replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;
throw new SyntaxError("JSON.parse")})}();
function sendABridgeTalkMessage (scriptText, args) {
var bt = new BridgeTalk();
bt.target = args.appName;
// send the message containing the combined script and arguments.
var btMessage = scriptText + "\nTheScript('" + JSON.stringify(args) + "');";
btMessage = hexDecode.toString().replace(/[\r\n]+/g, " ") + "; eval(decodeURI(hexDecode('" + hexEncode(encodeURI(btMessage)) + "')))";
bt.body = btMessage;
bt.onError = function (messageObj) {
alert(messageObj.body);
}
bt.send(); // No onResult is being tested for this simple script.
};
function someSharedCode () {
// some code can be shared between apps, it will travel with the container script, same as the JSON object above.
return "This app is: " + app.name;
};
args = JSON.parse(args);
var method = args.method;
var foo = someSharedCode();
alert(foo);
if (method == "aiMethod") {
// do stuff in Illustrator and get it ready for Photoshop.
sendABridgeTalkMessage(TheScript, { method : "psMethod", appName : "photoshop" });
} else if (method == "psMethod") {
// now do stuff in Photoshop.
alert("The Photoshop part.");
}
}
TheScript('{ "method" : "aiMethod" }'); The reason it works is that our function text of "TheScript" is the source text and it is in plain-text format. However, if this script was in JSXBIN..
@JSXB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hRjGicjYhXjGhNicjYhZjGicjVhQhQjBj
EicjVhQhWhQhQhNicjVhQhWhQhUicjVhQhXhQjGicjVhRhXjChUicjVhRhXjChVicjVhShQhQjDhNic
jVhShQhQjGicjVhShQhShYhNicjVhShQhSjGicjVhShQhWhQhNicjVhShQhWjGicjVjGjFjGjGicjVj
GjGjGhQhNicjVjGjGjGjGidBjHnffShOEWhGHzBIiRFeCicjCzChAhAiSFeCicjUzBKiTFeCicjOzBM
iUFeCicjGzBNiVFeCicjSzBhCiWFeCichCzBiciXFeCicicnffBXVfjWfNyBnAMYbyBn0ADOZKZJZnA
BjiBfCCnnneBhAntASBAndAffChHVhbfDVBfAnnSBACCnnndBntfARDBjhSfneAfBjiBfneAfChPnih
FVhbfDeGjOjVjNjCjFjSntJyZnAUhDChPnihFVhbfDeGjTjUjSjJjOjHnBjiBfVhbfDnfnnOyZfganA
EjzFiFjSjSjPjSiYfRBFeOiKiTiPiOhOjTjUjSjJjOjHjJjGjZftARCBjhVfVhNfCnfUhDUhDVhNfCC
hEnihFVhNfCeIjGjVjOjDjUjJjPjOnnnUhcChEnihFVhNfCeGjPjCjKjFjDjUnChEnihFXHfVhNfCeG
jOjVjNjCjFjSnnnnntnZganAEjhdfRCFeAWhGBgdVhIfBffAEB40BiAhI40BhAhN4B0AhAhb4C0AhAD
BAgdCganftnnJgbnAUhDChEnihFXzFjQjBjSjTjFiZfjWfeIjGjVjOjDjUjJjPjOnRCSzCjDjYiaAYj
HibicjVhQhQhQhQicjVhQhQjBjEicjVhQhWhQhQhNicjVhQhWhQhUicjVhQhXhQjGicjVhRhXjChUic
jVhRhXjChVicjVhShQhQjDhNicjVhShQhQjGicjVhShQhShYhNicjVhShQhSjGicjVhShQhWhQhNicj
VhShQhWjGicjVjGjFjGjGicjVjGjGjGhQhNicjVjGjGjGjGidBjHnffBXiZfjWfNyBnAMgcbyBnABMg
cbyBn0ADJgcnASheCQgdfVhIfDVhNfEnftOygcLygcJygcnAUhDEXhWfXiFfXiDfjhGfRCVhefCVhbf
AffRCSBBEjzEjXjBjMjLibfRCVhefCVhbfAffnffdCzDhBhdhdichzEjWjPjJjEidFdAVBfBnnBQgdf
VhefCVhbfAVBfBnfizGjEjFjMjFjUjFieQgdfVhefCVhbfAtnnAVhbfAVhefCyBgdfAUhDVhefCChPn
ihFVhefCeGjPjCjKjFjDjUnnnnZgdnAEXhWfjzHjSjFjWjJjWjFjSiffRDVhIfDVhNfEVhefCffAFB4
B0AiAhI40BhAhN4B0AhAhb40BiAhe4C0AiACDAibAgdCOgdZhBnARCSzBjKjAAEjzEjFjWjBjMjBfRB
CCCCnVzEjUjFjYjUjCfBeBhInnneBhJffnffdChPnihFViffCeIjGjVjOjDjUjJjPjOnEjibfRCWhGB
gdVjAfAFeAffVjAfAtARESjCBEjhYfRBVjCfBffnffBXhKfjiafndAfUhDEXhMfjiafRBVjCfBffSjC
BEXXfVjCfBRCjiafNyBnAMgebyBn0ABZgenACCnEXhQfCCnEXLfEXMfVhIfARBFdAffRBFdQffeEhQh
QhQhQnRBFdyEffeCicjVnABhI40BhAB0AgdCgeffnffnnEXhMfYNieibicidhMhajbjdicjTidhKhEA
RBEXXfEXXfEXXfVjCfBRCYhCicichIhfhaibhCicicichPjCjGjOjSjUidjcjVibhQhNhZjBhNjGiBh
NiGidjbhUjdhJBjHFeBiAffRCYhfhCibiehCicicicjOicjSidhKhCjcjUjSjVjFjcjGjBjMjTjFjcj
OjVjMjMjchNhficjEhLhIhfhaichOicjEhKhJhfhIhfhaibjFiFidibhLichNidhficjEhLhJhfBjHF
eBidffRCYThIhfhaiejchajchMhJhIhfhaicjThKicibhJhLBjHFeAfffftnfhCnAEjzLiTjZjOjUjB
jYiFjSjSjPjSjDfRBFeKiKiTiPiOhOjQjBjSjTjFftADjC40BhAif4B0AhAjA40BiACBAgdChCnftnn
AGhV4F0AiAiB4D0AiAia40BiAhL4B0AiAhO4E0AiAhS4C0AiAAGAgdChCnfJhWnASSCEXiZfjWfRBVS
fCffnffJhYnASzGjNjFjUjIjPjEjEAXjEfVSfCnftJhZnASzDjGjPjPjFBEjhCfnfnftJhanAEjgbfR
BVjFfBffOhcbyhen0ABJhenAEjgffRCjzJiUjIjFiTjDjSjJjQjUjGfWhGCjEFeIjQjTiNjFjUjIjPj
ERFeJjQjIjPjUjPjTjIjPjQffAChPVjEfAnneIjBjJiNjFjUjIjPjEOhfbyiBn0ABJiBnAEjgbfRBFe
TiUjIjFhAiQjIjPjUjPjTjIjPjQhAjQjBjSjUhOffAChPVjEfAnneIjQjTiNjFjUjIjPjEnADS40BhA
jE40BiAjF4B0AiABCAjGAiDBJiEnAEjjGfRBFeZjbhAhCjNjFjUjIjPjEhChAhahAhCjBjJiNjFjUjI
jPjEhChAjdff0DgdByB
It actually fails, and if I got the error alert working it would be saying that it's a syntax error. In this case the source text is the jsxbin characters. Alerting something like alert(TheScript.toString()) will say "function TheScript { [compiled code] }". As the source is now this encoded string, I am wondering if there's any way to work around this and still get the function text for use in code for the purposes of sending a method to another application via BT and also pack in some arguments. This is the bridgetalk message which results when this technique is executed with JSXBINs:
function hexDecode() { [compiled code] } ; eval(decodeURI(hexDecode('25304166756e6374696f6e2532305468655363726970742829253230253742253041253230253230253230253230253542636f6d70696c6564253230636f646525354425304125374425304125304154686553637269707428272537422532326d6574686f642532323a25323270734d6574686f642532322c2532326170704e616d652532323a25323270686f746f73686f7025323225374427293b')))
As you see, the method contents are ruined. The encoded script string is actually:
function TheScript { [compiled code] }
Maybe a work-around could be to develop a normal script, then make a process which stringifies a script by turning it into something that theoretically can be passed into eval() as a concrete string. Afterwards maybe when this part gets converted to jsxbin, it may be able to get the real code text. Or it may also just keep on with the [compiled code]. 🤔
... View more