Fork me on GitHub
#scittle
<
2022-10-14
>
Richie17:10:31

Hey. I pasted the contents of https://cdn.jsdelivr.net/npm/[email protected]/dist/scittle.js into a https://script.google.com/home script file and the "Execution log" says ReferenceError: window is not defined. Do I need window if I just want eval_string? I'm not really sure how this would work but I wanted to be able to write a Google App Script in clojure (well sci really).

borkdude17:10:51

Scittle is specifically made for browsers

borkdude17:10:15

What is the runtime environment of Google Apps? Node?

borkdude17:10:37

You can maybe get rid of the warning by calling:

scittle.core.disable_auto_eval()

borkdude17:10:59

or defining a surrogate window object

borkdude17:10:58

The window object isn't referenced directly by scittle but this may be an artifact of how it's compiled by CLJS / shadow-cljs

borkdude17:10:31

Something like #C03U8L2NXNC might work better for something like Google Apps

Richie18:10:21

Ok, thanks.

borkdude18:10:26

but also not node right? so you can't run #C029PTWD3HR on there

borkdude18:10:36

are you able to run Google Apps locally for testing?

borkdude18:10:54

Else the squint method is a bit ugly too, by having to copy paste the output to test every time

Richie18:10:26

I hadn’t thought of nbb.

borkdude18:10:14

Creating a special SCI target for Google Apps may work too

borkdude18:10:27

nbb assumes Node specific stuff

Richie18:10:50

How would nbb work? I figured with scittle, I’d paste sci as js into an app script.

Richie18:10:19

Yea, I can just try clojurescript to compile to js…

Richie18:10:36

I was trying to find a shortcut or something. Idk.

borkdude18:10:52

nbb = SCI + Node.js, scittle = SCI + browser

borkdude18:10:55

just compiling a generic :target :esm script with SCI + eval_string should get you there, but if you end up copy pasting JS to a Google Apps console anyway, I'd go with squint since the output is much smaller

borkdude18:10:14

$ npx squint-cljs --show --no-run -e "(defn foo [x] (+ x 1 2 3))"
var foo = function (x) {
return (x + 1 + 2 + 3);
}
;

export { foo }

chromalchemy22:10:08

Photoshop scripting says it supports Node.js, NPM, and React with ES6. supports a limited version of chromium. They list these as usupported: • Drag and drop • iFrames • HTML5 Canvas • window.locationdata attributes and font-face • unsupported libs ◦ jQuery ◦ Vue.js ▪︎ (although some people have reported success) • window.event.cancelBubble = true ◦ Instead, use event.stopPropagation()getElementsByClassName(something) ◦ Instead, use document.querySelectorAll("something") Given this which SCI runtime might be most appropriate/powerful? #squint already seems to work for simple scripts. But I would like to be able to use cljs libs and and more idiomatic clj. I haven’t really tried the plugin/toolchain out yet. But do you see any dealbreakers for running #scittle or #nbb ? Or like you suggested in https://clojurians.slack.com/archives/C034FQN490E/p1665767911847449, maybe a custom SCI script with libs bundled?

borkdude08:10:19

I'm not familiar with Photoshop scripting but it sounds like scittle should work and else you could try making a custom SCI runtime

borkdude08:10:46

Btw there is also #C03QZH5PG6M which is like #C03U8L2NXNC with with the CLJS data structures