Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
10

UXP plugin Promises are forever pending

New Here ,
Jan 29, 2024 Jan 29, 2024

I'm writing a plugin for indesign.
I want to read the name from the active document.
This is my code in a helper file:
```

const { ExportFormat, app } = require("indesign");
const {File} = require('fs');
class exportUtils {

async exportToEpub() {
try {
let doc = app.activeDocument;
let fullName = await doc.fullName;
 
console.log(fullName); // Directly log the fullName
 
let epubFileName = fullName.toString().replace(/\.[^\.]+$/, ".epub");
doc.exportFile(ExportFormat.FIXED_LAYOUT_EPUB, new File(epubFileName), false);
} catch (error) {
console.error(error);
}
};
}
```
The problem is fullName is a Promise and it never resolves.
I expected it to be a File object according to the api reference here: https://developer.adobe.com/indesign/dom/api/d/Document/
TOPICS
Scripting , UXP Scripting
628
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Mentor , Jan 29, 2024 Jan 29, 2024

UXP tries to mimic the full browser experience including all security circus.
See your promise details, maybe something about PromiseState "rejected" and PromiseResult Error: Could not find an entry … ?
This could be about missing permission requests in your manifest.
If your await works in an UXP Script, the difference is described here: https://developer.adobe.com/indesign/uxp/resources/fundamentals/manifest/
More details for plugins:
https://developer.adobe.com/indesign/uxp/plugins/concepts/manifest/

...
Translate
Mentor ,
Jan 29, 2024 Jan 29, 2024

UXP tries to mimic the full browser experience including all security circus.
See your promise details, maybe something about PromiseState "rejected" and PromiseResult Error: Could not find an entry … ?
This could be about missing permission requests in your manifest.
If your await works in an UXP Script, the difference is described here: https://developer.adobe.com/indesign/uxp/resources/fundamentals/manifest/
More details for plugins:
https://developer.adobe.com/indesign/uxp/plugins/concepts/manifest/
Basically you need:
"requiredPermissions": {
"localFileSystem": "fullAccess"
}
General info on Files the UXP way:
https://developer.adobe.com/indesign/uxp/reference/uxp-api/reference-js/Modules/uxp/Persistent%20Fil...

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 31, 2024 Jan 31, 2024
LATEST

Thank you, this helped me!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines