Is there a way (yet) in pure UXP scripts to resolve a raw specifier, i.e. an equivalent for the resolve(..)
function in ExtendScript? I’m trying to migrate some scripts that make use of this for performance/simplicity reasons… e.g. for looking up a particular Note by its ID, regardless of its owning container.
Hi,
as far as I know, there is no equivalent global function “resolve” in UXP (yet). My workaround so far:
const tfSpecifier = app.selection[0].toSpecifier();
const tf = resolve(tfSpecifier);
function resolve(specifier) {
if(!specifier || typeof specifier !== "string") {
return null;
}
const indesign = require('indesign');
const { app, ScriptLanguage } = indesign;
let item;
try {
item = app.doScript(
"resolve(\"" + specifier + "\");",
ScriptLanguage.JAVASCRIPT
);
} catch(err) {
console.error(err);
}
if(!item || !(item instanceof Object)|| !Reflect.has(item, "isValid") || !item.isValid) {
return null;
}
return item;
}
But this is probably not going to boost performance.
Roland
Thanks @Roland_Dreger for the… innovative workaround. I’d have to do so measurements but I suspect this indeed is not going to help much on the performance side (and most certainly not on in terms of complexity ;- )
Please Adobe let’s have a nice resolve function in the ‘indesign’ UXP module eh?