-
Notifications
You must be signed in to change notification settings - Fork 129
Photoshop: Move implementation to OpenPype #2510
Conversation
…ading it in global scope
var escapedPath = EscapeStringForJSX(data.path); | ||
return runEvalScript("importSmartObject('" + escapedPath +"', " + | ||
"'"+ data.name +"',"+ | ||
+ data.as_reference +")") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confusing plusses.
} | ||
} | ||
} | ||
return version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
const xmlDoc = parser.parseFromString(result.data.toString(), 'text/xml'); | ||
const children = xmlDoc.children; | ||
|
||
for (let i = 0; i <= children.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
if (window.DOMParser) { | ||
const parser = new DOMParser(); | ||
const xmlDoc = parser.parseFromString(result.data.toString(), 'text/xml'); | ||
const children = xmlDoc.children; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
if(result.err === 0){ | ||
if (window.DOMParser) { | ||
const parser = new DOMParser(); | ||
const xmlDoc = parser.parseFromString(result.data.toString(), 'text/xml'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
startUp("WEBSOCKET_URL"); | ||
|
||
// get websocket server url from environment value | ||
async function startUp(url){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
Missing semicolon.
@@ -0,0 +1,2 @@ | |||
/*! loglevel - v1.6.8 - https://github.com/pimterry/loglevel - (c) 2020 Tim Perry - licensed MIT */ | |||
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(b):"object"==typeof module&&module.exports?module.exports=b():a.log=b()}(this,function(){"use strict";function a(a,b){var c=a[b];if("function"==typeof c.bind)return c.bind(a);try{return Function.prototype.bind.call(c,a)}catch(b){return function(){return Function.prototype.apply.apply(c,[a,arguments])}}}function b(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(c){return"debug"===c&&(c="log"),typeof console!==i&&("trace"===c&&j?b:void 0!==console[c]?a(console,c):void 0!==console.log?a(console,"log"):h)}function d(a,b){for(var c=0;c<k.length;c++){var d=k[c];this[d]=c<a?h:this.methodFactory(d,a,b)}this.log=this.debug}function e(a,b,c){return function(){typeof console!==i&&(d.call(this,b,c),this[a].apply(this,arguments))}}function f(a,b,d){return c(a)||e.apply(this,arguments)}function g(a,b,c){function e(a){var b=(k[a]||"silent").toUpperCase();if(typeof window!==i){try{return void(window.localStorage[l]=b)}catch(a){}try{window.document.cookie=encodeURIComponent(l)+"="+b+";"}catch(a){}}}function g(){var a;if(typeof window!==i){try{a=window.localStorage[l]}catch(a){}if(typeof a===i)try{var b=window.document.cookie,c=b.indexOf(encodeURIComponent(l)+"=");-1!==c&&(a=/^([^;]+)/.exec(b.slice(c))[1])}catch(a){}return void 0===j.levels[a]&&(a=void 0),a}}var h,j=this,l="loglevel";a&&(l+=":"+a),j.name=a,j.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},j.methodFactory=c||f,j.getLevel=function(){return h},j.setLevel=function(b,c){if("string"==typeof b&&void 0!==j.levels[b.toUpperCase()]&&(b=j.levels[b.toUpperCase()]),!("number"==typeof b&&b>=0&&b<=j.levels.SILENT))throw"log.setLevel() called with invalid level: "+b;if(h=b,!1!==c&&e(b),d.call(j,b,a),typeof console===i&&b<j.levels.SILENT)return"No console available for logging"},j.setDefaultLevel=function(a){g()||j.setLevel(a,!1)},j.enableAll=function(a){j.setLevel(j.levels.TRACE,a)},j.disableAll=function(a){j.setLevel(j.levels.SILENT,a)};var m=g();null==m&&(m=null==b?"WARN":b),j.setLevel(m,!1)}var h=function(){},i="undefined",j=typeof window!==i&&typeof window.navigator!==i&&/Trident\/|MSIE /.test(window.navigator.userAgent),k=["trace","debug","info","warn","error"],l=new g,m={};l.getLogger=function(a){if("string"!=typeof a||""===a)throw new TypeError("You must supply a name when creating a logger.");var b=m[a];return b||(b=m[a]=new g(a,l.getLevel(),l.methodFactory)),b};var n=typeof window!==i?window.log:void 0;return l.noConflict=function(){return typeof window!==i&&window.log===l&&(window.log=n),l},l.getLoggers=function(){return m},l}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confusing use of '!'.
Expected an assignment or function call and instead saw an expression.
If a strict mode function is executed using function invocation, its 'this' value will be undefined.
Missing '()' invoking a constructor.
Missing semicolon.
Value of 'a' may be overwritten in IE 8 and earlier.
Value of 'b' may be overwritten in IE 8 and earlier.
} else { | ||
log('SOCKET IS', state); | ||
|
||
if (params && params['noWait']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
['noWait'] is better written in dot notation.
|
||
function logGroup(group, level, args) { | ||
console.group(group); | ||
console[level].apply(this, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a strict mode function is executed using function invocation, its 'this' value will be undefined.
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.WSRPC = factory()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
@@ -0,0 +1 @@ | |||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):(global=global||self).WSRPC=factory()}(this,function(){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function Deferred(){_classCallCheck(this,Deferred);var self=this;function wrapper(func){return function(){if(!self.done)return self.done=!0,func.apply(this,arguments);console.error(new Error("Promise already done"))}}return self.resolve=null,self.reject=null,self.done=!1,self.promise=new Promise(function(resolve,reject){self.resolve=wrapper(resolve),self.reject=wrapper(reject)}),self.promise.isPending=function(){return!self.done},self}function logGroup(group,level,args){console.group(group),console[level].apply(this,args),console.groupEnd()}function log(){WSRPC.DEBUG&&logGroup("WSRPC.DEBUG","trace",arguments)}function trace(msg){if(WSRPC.TRACE){var payload=msg;"data"in msg&&(payload=JSON.parse(msg.data)),logGroup("WSRPC.TRACE","trace",[payload])}}var readyState=Object.freeze({0:"CONNECTING",1:"OPEN",2:"CLOSING",3:"CLOSED"}),WSRPC=function WSRPC(URL){var reconnectTimeout=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e3;_classCallCheck(this,WSRPC);var self=this;function createSocket(){var ws=new WebSocket(URL),rejectQueue=function(){var deferred;for(self.connectionNumber++;0<self.callQueue.length;){var callObj=self.callQueue.shift();deferred=self.store[callObj.id],delete self.store[callObj.id],deferred&&deferred.promise.isPending()&&deferred.reject("WebSocket error occurred")}for(var key in self.store)self.store.hasOwnProperty(key)&&(deferred=self.store[key])&&deferred.promise.isPending()&&deferred.reject("WebSocket error occurred")};function tryCallEvent(func,event){try{return func(event)}catch(e){e.hasOwnProperty("stack")?log(e.stack):log("Event function",func,"raised unknown error:",e),console.error(e)}}function callEvents(evName,event){for(;0<self.oneTimeEventStore[evName].length;){var deferred=self.oneTimeEventStore[evName].shift();deferred.hasOwnProperty("resolve")&&deferred.promise.isPending()&&deferred.resolve()}for(var i in self.eventStore[evName]){if(self.eventStore[evName].hasOwnProperty(i))tryCallEvent(self.eventStore[evName][i],event)}}return ws.onclose=function(err){for(var serial in log("ONCLOSE CALLED","STATE",self.public.state()),trace(err),self.store)self.store.hasOwnProperty(serial)&&self.store[serial].hasOwnProperty("reject")&&self.store[serial].reject("Connection closed");rejectQueue(),callEvents("onclose",err),callEvents("onchange",err),function(callEvents){setTimeout(function(){try{self.socket=createSocket(),self.id=1}catch(exc){callEvents("onerror",exc),delete self.socket,console.error(exc)}},reconnectTimeout)}(callEvents)},ws.onerror=function(err){log("ONERROR CALLED","STATE",self.public.state()),trace(err),rejectQueue(),callEvents("onerror",err),callEvents("onchange",err),log("WebSocket has been closed by error: ",err)},ws.onopen=function(ev){for(log("ONOPEN CALLED","STATE",self.public.state()),trace(ev);0<self.callQueue.length;)self.socket.send(JSON.stringify(self.callQueue.shift(),0,1));callEvents("onconnect",ev),callEvents("onchange",ev)},ws.onmessage=function(message){var data;if(log("ONMESSAGE CALLED","STATE",self.public.state()),trace(message),"message"===message.type)try{if(log(data=JSON.parse(message.data)),data.hasOwnProperty("id"))return data.hasOwnProperty("method")?function(self,data){if(!self.routes.hasOwnProperty(data.method))throw new Error("Route not found");var connectionNumber=self.connectionNumber,deferred=new Deferred;deferred.promise.then(function(result){connectionNumber===self.connectionNumber&&self.socket.send(JSON.stringify({id:data.id,result:result||null}))},function(error){connectionNumber===self.connectionNumber&&self.socket.send(JSON.stringify({id:data.id,error:error||null}))});var func=self.routes[data.method];if(self.asyncRoutes[data.method])return func.apply(deferred,[data.params]);function badPromise(){throw new Error("You should register route with async flag.")}var promiseMock={resolve:badPromise,reject:badPromise};try{deferred.resolve(func.apply(promiseMock,[data.params]))}catch(e){deferred.reject(e),console.error(e)}}(self,data):data.hasOwnProperty("error")&&null===data.error?function(self,data){if(!self.store.hasOwnProperty(data.id))return log("Unknown callback");var deferred=self.store[data.id];if(void 0===deferred)return log("Confirmation without handler");delete self.store[data.id],log("REJECTING",data.error),deferred.reject(data.error)}(self,data):function(self,data){var deferred=self.store[data.id];return void 0===deferred?log("Confirmation without handler"):(delete self.store[data.id],data.hasOwnProperty("result")?deferred.resolve(data.result):deferred.reject(data.error))}(self,data);console.group("Event received");for(var i=0;i<self.socketEventsListeners.length;i++)try{self.socketEventsListeners[i].apply(self.public,[data])}catch(e){console.error(e)}console.groupEnd()}catch(exception){var err={error:exception.message,result:null,id:data?data.id:null};self.socket.send(JSON.stringify(err)),console.error(exception)}},ws}return URL=function(url){if(/^\w+:\/\//.test(url))return url;if("undefined"==typeof window&&window.location.host.length<1)throw new Error("Can not construct absolute URL from ".concat(window.location));var scheme="https:"===window.location.protocol?"wss:":"ws:",port=""===window.location.port?":".concat(window.location.port):"",host=window.location.host,path=url.replace(/^\/+/gm,"");return"".concat(scheme,"//").concat(host).concat(port,"/").concat(path)}(URL),self.id=1,self.eventId=0,self.socketStarted=!1,self.eventStore={onconnect:{},onerror:{},onclose:{},onchange:{}},self.connectionNumber=0,self.oneTimeEventStore={onconnect:[],onerror:[],onclose:[],onchange:[]},self.callQueue=[],self.socketEventsListeners=[function(event){console.log(event)}],self.asyncRoutes={},self.routes={},self.store={},self.public=Object.freeze({defer:function(){return new Deferred},call:function(func,args,params){return function(func,args,params){self.id+=2;var deferred=new Deferred,callObj=Object.freeze({id:self.id,method:func,params:args}),state=self.public.state();return"OPEN"===state?(self.store[self.id]=deferred,self.socket.send(JSON.stringify(callObj))):"CONNECTING"===state?(log("SOCKET IS",state),self.store[self.id]=deferred,self.callQueue.push(callObj)):(log("SOCKET IS",state),params&¶ms.noWait?deferred.reject("Socket is: ".concat(state)):(self.store[self.id]=deferred,self.callQueue.push(callObj))),deferred.promise}(func,args,params)},addRoute:function(route,callback,isAsync){self.asyncRoutes[route]=isAsync||!1,self.routes[route]=callback},deleteRoute:function(route){return delete self.asyncRoutes[route],delete self.routes[route]},addEventListener:function(event,func){var eventId=self.eventId++;return self.eventStore[event][eventId]=func,eventId},removeEventListener:function(event,index){return!!self.eventStore[event].hasOwnProperty(index)&&(delete self.eventStore[event][index],!0)},onEvent:function(event){var deferred=new Deferred;return self.oneTimeEventStore[event].push(deferred),deferred.promise},destroy:function(){return self.socket.close()},state:function(){return readyState[this.stateCode()]},stateCode:function(){return self.socketStarted&&self.socket?self.socket.readyState:3},connect:function(){self.socketStarted=!0,self.socket=createSocket()},addServerEventListener:function(callable){return self.socketEventsListeners.push(callable)-1},removeServerEventListener:function(index){return self.socketEventsListeners.splice(index,1).length},sendRaw:function(data){return self.socket.send(data)}}),self.public.addRoute("log",function(argsObj){console.info("Websocket sent: ".concat(argsObj))}),self.public.addRoute("ping",function(data){return data}),self.public};return WSRPC.DEBUG=!1,WSRPC.TRACE=!1,WSRPC}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected an assignment or function call and instead saw an expression.
If a strict mode function is executed using function invocation, its 'this' value will be undefined.
Missing '()' invoking a constructor.
Missing semicolon.
Too many errors. (100% scanned).
//////////////////////////////////////////////// | ||
var newErr; | ||
newErr = new Error(err); | ||
alert('Error Eek: ' + newErr.stack); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'alert' is not defined.
|
||
fileName = jsxScript.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); | ||
try { | ||
jsxScript = window.cep.fs.readFile(jsxScript).data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'window' is not defined.
if (forceEvalScript) { | ||
jsxScript = jsxScript.replace(/"/g, '\\"'); | ||
// Check that the path exist, should change this to asynchronous at some point | ||
if (!window.cep.fs.stat(jsxScript).err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'window' is not defined.
//////////////////////////////////////////////// | ||
var newErr; | ||
newErr = new Error(err); | ||
alert('Error Eek: ' + newErr.stack); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'alert' is not defined.
text = text.replace(rx_dangerous, function (a) { | ||
return ( | ||
"\\u" | ||
+ ("0000" + a.charCodeAt(0).toString(16)).slice(-4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '+'; readers may interpret this as an expression boundary.
rep = replacer; | ||
if (replacer && typeof replacer !== "function" && ( | ||
typeof replacer !== "object" | ||
|| typeof replacer.length !== "number" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '||'; readers may interpret this as an expression boundary.
v = partial.length === 0 | ||
? "{}" | ||
: gap | ||
? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '?'; readers may interpret this as an expression boundary.
// and wrap them in braces. | ||
|
||
v = partial.length === 0 | ||
? "{}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '?'; readers may interpret this as an expression boundary.
if (v) { | ||
partial.push(quote(k) + ( | ||
(gap) | ||
? ": " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '?'; readers may interpret this as an expression boundary.
|
||
from .launch_logic import stub | ||
|
||
from .pipeline import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'.pipeline.uninstall' imported but unused
if (v) { | ||
partial.push(quote(k) + ( | ||
(gap) | ||
? ": " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '?'; readers may interpret this as an expression boundary.
+ partial.join(",\n" + gap) | ||
+ "\n" | ||
+ mind | ||
+ "]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '+'; readers may interpret this as an expression boundary.
+ gap | ||
+ partial.join(",\n" + gap) | ||
+ "\n" | ||
+ mind |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '+'; readers may interpret this as an expression boundary.
"[\n" | ||
+ gap | ||
+ partial.join(",\n" + gap) | ||
+ "\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '+'; readers may interpret this as an expression boundary.
|
||
if ( | ||
value | ||
&& typeof value === "object" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '&&'; readers may interpret this as an expression boundary.
? "\"" + string.replace(rx_escapable, function (a) { | ||
var c = meta[a]; | ||
return typeof c === "string" | ||
? c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '?'; readers may interpret this as an expression boundary.
|
||
rx_escapable.lastIndex = 0; | ||
return rx_escapable.test(string) | ||
? "\"" + string.replace(rx_escapable, function (a) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '?'; readers may interpret this as an expression boundary.
+ f(this.getUTCMinutes()) | ||
+ ":" | ||
+ f(this.getUTCSeconds()) | ||
+ "Z" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '+'; readers may interpret this as an expression boundary.
+ ":" | ||
+ f(this.getUTCMinutes()) | ||
+ ":" | ||
+ f(this.getUTCSeconds()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading line break before '+'; readers may interpret this as an expression boundary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for standalone opening. (Didn't test Webpublisher, but I don't think there is an issue there.)
Brief description
Move Photoshop integration to OpenPype codebase.
Description
Photoshop was moved to OpenPype codebase and modified meanwhile a little bit.
Changes
MainThreadItem
which stores callback and args + kwargs for function call__init__.py
from empty hooks folder__init__.py
andlib.py
from plugins dirlib.py
toapi/plugin.py
PhotoshopLoader
was implement which hasget_stub
method to retrieve thatmain
in launching scriptNotes & TODOs (Next PR/s)
README.md
which seems to be outdated anywayCreator
class which was in~/avalon/photoshop/pipeline.py
is not used at all so should probably be removed?Testing notes:
Related PR ynput/avalon-core#410