Fork me on GitHub
#squint
<
2022-10-01
>
chromalchemy00:10:55

Any way to compile this from squint?

require('photoshop').core.showAlert('Hello world') 
I tried this, but it doesn’t work.
(ns test
  (:require ["photoshop" :as app]))

(app/core.showAlert "Hello world")
This is to script https://developer.adobe.com/photoshop/uxp/2022/ps_reference/, which they say uses V8 JavaScript engine, which supports ES6 (..so maybe can use Cherry instead, or even NBB in a photoshop plugin…?) Unfortunately I think you need a Photoshop/CC install to run/test.

lilactown00:10:07

what does "it doesn't work" mean?

chromalchemy02:10:46

When i run the js code, I get an alert popup. When I run the squint js, nothing happens. The squint js uses import instead of require, not sure if thats an issue. I might just have the cljs . syntax wrong…

chromalchemy03:10:57

Here is the output

import { core.showAlert as app_core.showAlert } from 'photoshop'
app_core.showAlert("Hello world");

chromalchemy04:10:37

Here is my latest try

(ns test)

(def ps (require '"photoshop"))

(.. js/ps.core (showAlert "Hello"))
Compiles to:
var ps = require("photoshop")
ps;
ps.core.showAlert("Hello");

export { ps }
And it works!!!.. if I remove export { ps } at the end. Any way to omit that from output?

chromalchemy05:10:20

using (:require) doesn’t seem to work

(ns test
  (:require ["photoshop" :as ps]))

(. ps/core (showAlert "Hello"))
import { core as ps_core } from 'photoshop'
ps_core.showAlert("Hello");
Maybe Photoshop doesn’t like import

chromalchemy05:10:56

I think I am struggling with how to properly call functions from modules from this "photoshop" api root. like what is the equivalent of this?

var PhotoshopCore = require('photoshop').core;

borkdude06:10:25

@U09D96P9B

(def PhotoshopCore (.-core (js/require "photoshop)))

borkdude06:10:00

> Any way to omit that from output? Feel free to post an issue about that

chromalchemy06:10:45

Ok so require("photoshop")["core"] is equivalent to require('photoshop').core ?

borkdude11:10:44

@U09D96P9B I published a new version of squint where you can pass --elide-exports on the command line

borkdude12:10:11

$ ./node_cli.js compile --help
Usage: squint compile <files> <opts>

Options:

--elide-imports: do not include imports
--elide-exports: do not include exports

🚀 1
chromalchemy14:10:02

Awesome! Thanks for following up on that.