-
Notifications
You must be signed in to change notification settings - Fork 6
Add validator to check correct version of extension for PS and AE #397
Changes from 11 commits
34d4f42
9d9f527
829fee8
789772d
8c471fd
8221a72
753bb36
0a40d06
53c5b84
ab363f1
130a245
881a335
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,33 @@ async function startUp(url){ | |
main(res); | ||
} | ||
|
||
function get_extension_version(){ | ||
/** Returns version number from extension manifest.xml **/ | ||
log.debug("get_extension_version") | ||
var path = csInterface.getSystemPath(SystemPath.EXTENSION); | ||
log.debug("extension path " + path); | ||
|
||
var result = window.cep.fs.readFile(path + "/CSXS/manifest.xml"); | ||
var version = undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not necessary to initialize 'version' to 'undefined'. |
||
if(result.err === 0){ | ||
if (window.DOMParser) { | ||
const parser = new DOMParser(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
const xmlDoc = parser.parseFromString(result.data.toString(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
'text/xml'); | ||
const children = xmlDoc.children; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
|
||
for (let i = 0; i <= children.length; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 (children[i] && | ||
children[i].getAttribute('ExtensionBundleVersion')) { | ||
version = | ||
children[i].getAttribute('ExtensionBundleVersion'); | ||
} | ||
} | ||
} | ||
} | ||
return version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon. |
||
} | ||
|
||
function main(websocket_url){ | ||
// creates connection to 'websocket_url', registers routes | ||
var default_url = 'ws://localhost:8099/ws/'; | ||
|
@@ -268,6 +295,16 @@ function main(websocket_url){ | |
return result; | ||
}); | ||
}); | ||
|
||
RPC.addRoute('AfterEffects.get_extension_version', function (data) { | ||
log.warn('Server called client route "get_extension_version":', data); | ||
return get_extension_version(); | ||
}); | ||
|
||
RPC.addRoute('AfterEffects.close', function (data) { | ||
log.warn('Server called client route "close":', data); | ||
return runEvalScript("close()"); | ||
}); | ||
} | ||
|
||
/** main entry point **/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,30 @@ | |
// run rest only after resolved promise | ||
main(res); | ||
} | ||
|
||
function get_extension_version(){ | ||
/** Returns version number from extension manifest.xml **/ | ||
log.debug("get_extension_version") | ||
var path = csInterface.getSystemPath(SystemPath.EXTENSION); | ||
log.debug("extension path " + path); | ||
|
||
var result = window.cep.fs.readFile(path + "/CSXS/manifest.xml"); | ||
var version = undefined; | ||
if(result.err === 0){ | ||
if (window.DOMParser) { | ||
const parser = new DOMParser(); | ||
const xmlDoc = parser.parseFromString(result.data.toString(), 'text/xml'); | ||
const children = xmlDoc.children; | ||
|
||
for (let i = 0; i <= children.length; i++) { | ||
if (children[i] && children[i].getAttribute('ExtensionBundleVersion')) { | ||
version = children[i].getAttribute('ExtensionBundleVersion'); | ||
} | ||
} | ||
} | ||
} | ||
return version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing semicolon. |
||
} | ||
|
||
function main(websocket_url){ | ||
// creates connection to 'websocket_url', registers routes | ||
|
@@ -249,10 +273,15 @@ | |
}); | ||
}); | ||
|
||
RPC.addRoute('Photoshop.get_extension_version', function (data) { | ||
log.warn('Server called client route "get_extension_version":', data); | ||
return get_extension_version(); | ||
}); | ||
|
||
RPC.addRoute('Photoshop.close', function (data) { | ||
log.warn('Server called client route "close":', data); | ||
return runEvalScript("close()"); | ||
}); | ||
}); | ||
|
||
RPC.call('Photoshop.ping').then(function (data) { | ||
log.warn('Result for calling server route "ping": ', 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.
Missing semicolon.