Fork me on GitHub
#scittle
<
2024-03-28
>
chromalchemy16:03:14

A year and a half ago I got Scittle loading in Photoshop, via their plugin architecture which runs js. I stalled out trying to see if I could run nrepl connection so I could execute fns from outside (editor). Trying again: If I include this in html I get this error Uncaught UxpRuntimeError: Refusing to load inline script tag as executable code. Code generation is disabled in plugins. Is there another way to set the port for the nrepl include? Maybe my playground.cljs file that is sucessfully printing to console?

chromalchemy16:03:58

I can pursue some other kinds of RPC setups for this kind of outside-in scripting of (monolithic) app. An alternative means is to generatate .psjs files from Squint and execute those from command line. (or maybe even use obb applescript to execute squint js within the app) But I figured a proper repl would be the most pure connection if possible 🙏 The environment is node based and supports file and network access to some degree (with some security precautions/restrictions)

chromalchemy17:03:52

Tried these, but haven’t been able to successfully read the var from another js file (loaded after).

(def SCITTLE_NREPL_WEBSOCKET_PORT 1340 )

(set! 
  (.-SCITTLE_NREPL_WEBSOCKET_PORT js/window) 
  1340)

chromalchemy17:03:09

Also I’m fuzzy on all the pieces here. With the pure scittle repl example, I need to run bb dev to serve the page, plust the nrepl server? In this plugin case, the page is being served by the node instance embedded in the app. Would i still run the bb nrepl portion, outside the app, to interact with that embedded “page”? Is this supported? That a scittle web page could be served outside of a clojure process, but still be reached by nrepl?

borkdude19:03:00

yes, you need to run both

borkdude19:03:22

> Uncaught UxpRuntimeError: Refusing to load inline script tag as executable code. Code generation is disabled in plugins Perhaps you can just move that expression to a file then?

borkdude19:03:51

Setting that variable from scittle won't work since that would be too late

chromalchemy21:03:08

Thanks. Putting the var in a js file worked to set it. But when i included the nrepl script it failed with inscrutable error. So probably the envirnment may not support this. You suggested before making a custom Sci version. But I’m probably gonna table this scittle/nrepl testing for now and use some kind of rpc method.

borkdude21:03:54

the nrepl script expects a browser environment with websockets, does your environment support that?

borkdude21:03:26

it talks to the server process that bb runs via websockets

borkdude21:03:28

perhaps try this setup in a normal browser scittle project to see if you can get it working

chromalchemy14:03:23

I did successfully get running the nrepl setup for scittle/nrepl from scittle docs, with normal browser + bb + calva, as a reference build. I was trying to transfer that as simply as possible, essentially copying putting the index.html inside photoshop plugin (and setting the port var in js file). There is some api for websockets..? https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Global%20Members/Data%20Transfers/WebSocket/ Maybe I can just use that directly, without nrepl..

chromalchemy14:03:11

OMG I added a network permission in the plugin manifest.json and IT JUST WORKED!! sci 🙌🎉 Can hit Photoshop state from the repl!!

chromalchemy15:03:40

This screenshot shows defining a hello-world fn in scittle.cljs, running it in IDE repl (calva, connected to nrepl hosted by bb process). Results in calva repl window, js devtools from Photoshop node plugin (UXP) dev sdk, and in Photoshop ui (alert). Also executed same function from command line, using BB nrepl-client task. And getting output in terminal.

chromalchemy15:03:45

I will use the command line access to use Talon Voice TTS command to execute functions while in Photoshop. (Talon lives in a python env, so probably could talk to nrepl more directly from there, but will start with BB!)

chromalchemy16:03:49

This is a game changer for me. I’ve been using Photoshop forever, but have neglected to harness all it’s powers because I felt on outside it’s clunky ui inhibiting functional composition, and of ps scripting efforts (clouded by fragmented api and js uglyness). The squint/scittle proof of concept I got working a year ago was encouraging. But it didn’t know how to execute actions from outside app at the time, which was an important requirement for me due to the Talon part). It thought I might have to settle for some hacky RPC mechanism with limited feedback, and a bunch of convoluted code-gen. This is more pure and direct. I can introspect the environment with devtools, and build a scripting libary (+ ui) up dynamically. Feels likes a gloves off moment! Thank you for all your tooling!

chromalchemy16:03:53

I presume I could do this with shadow-cljs + esm also, but Scittle and Squint’s simplicity was very encouraging to even try it out.

staypufd21:03:53

@chromalchemy Please share a blog post, GitHub ir YouTube video showing how you did this. I’d love to use Clojure to script the Adobe apps.

👍 1
chromalchemy02:04:25

Ok will try to share something soon.