Open kapooostin opened 4 days ago
I nailed the problem. It's on the Adobe side mostly, but I have a point to discuss on the Svelte side also.
After executing a Photoshop API call the top level function index
(from internal/client/dom/blocks/each
) is overwritten and becomes an integer because of a silly mistake in their codebase:
for (index = 0; index < varArgCount; ++index) { // let is missing
jsArgs.push(theArgs[index + fixedArgCount]);
}
I'll file the issue with them, though they are famous for being slow with the fixes (their API has been returning RGB color as { red, grain, blue }
for years). Meanwhile, the simplest solution seems to just globally declare index
variable at the top of the script and then the function in question is exported as index$1
and never gets overwritten.
As far as I understand, index
is exported from the each
module to keep implementation details within the module. Would it be possible to give it less generic name? Like get_index
, for example? We'd need to update the function name in the block, the exported name, and the call to it from EachBlock
visitor in the transformation phase of the compiler. I could prepare a pull request if this change would be acceptable.
Describe the bug
I have several sets of actions designed as tabs. Inside one of tabs there is a set of elements with
onclick
actions that call an inner async Photopshop API function. The set is rendered with{#each}
block. After the click the action is performed OK, the result is returned, but tab switching breaks. From that moment on the call toeach
inreconsile
cannot findget_key
function.Reproduction
It's rather an edge case, because I could only replicate it in Adobe UXP environment and only when an async action in question is a call to Adobe Photopshop host API, and not a regular JS async function. It all worked in Svelte 4.
Here is a playground with the basic setup of the script. A simple delayed Promise in
InnerTabs.svelte:make
works fine both in the browsers and in my Photoshop plugin. But if I add there a call to a Photoshop API function, and click a button, it fails to update UI from that moment onwards.In compiled code it's this:
Getting up the stack
get_key
refers to theindex
function ineach
:As it simply returns its second argument, when I replace it with
in compiled code, the plugin works without a hitch.
Idk, why it might behave like that. I have
queueMicrotask
shimmed with this package. Just in case it might matter somehow.Logs
System Info
Severity
blocking an upgrade