I need someone help clarify a things clear here. On manifest 4 I was using photoshop.app.open(file) and it was working correctly. I was getting the file from the server and opening it correctly. But on migrating to manifest 5 the file doesn’t open. yes the file gets downloaded successfully from my server to the disk but on trying to fetch it nothing happens. not even an error is thrown. What could be the reason since I’ve gone through the documentation and this change of things ain’t mentioned anywhere. Below is my code.
import photoshop from 'photoshop'
import uxp from 'uxp'
const fs = uxp.storage.localFileSystem
export const openMyFileAsDocument = (file: uxp.storage.File) => {
console.log('opening file as document ', file)
try {
return photoshop.app.open(file as unknown as File)
} catch (error) {
console.log('error openng file as document', error)
}
}
Besides, open the file as a layer also doesn’t seem to work on 5 as on 4. Am not sure where m getting it wrong since no exception is thrown
wrap all related code in a try/catch and share whatever is logged in the debugger.
if all fails:
I assume you’re using webpack since vanilla doesn’t support import
could you run a minimal vanilla test to make sure everything is good and go from there?
async function openFile() {
const fs = require("uxp").storage.localFileSystem;
const app = require("photoshop").app;
const f = await fs.getFileForOpening();
await app.open(f);
}
I changed the code to using executeModal and the problem migrated to the following. Error: Parameter must be a valid entry representing a file or a folder
below is the same code but with execute as modal and try catch
Where exactly do we make use of the execution context. I’ve seen it in the documentation and I’m unable to figure it out properly, with both the descriptor.
According to my understanding of the documentation, the target function refers to the function passed as an argument to execute as modal. so in my case above the OpenDocument function is the target function.
Then the documentation says that the target function again takes in the executionContext and the descriptor?
executionContext can be used to suspendHistory as follows:
let hostControl = executionContext.hostControl;
let suspensionID = await hostControl.suspendHistory({
"documentID": app.activeDocument.id,
"name": "My Plugin Command"
});
// your code here
await hostControl.resumeHistory(suspensionID);
this will create an entry in history called “My Plugin Command” that can be used for undo / redo.
we can also use executionContext to reportProgress
it will update the progress bar acoording to set value (0 to 1)