scittle

Richie 2022-10-14T17:18:31.847449Z

Hey. I pasted the contents of https://cdn.jsdelivr.net/npm/scittle@0.3.10/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).

borkdude 2022-10-14T17:48:51.095409Z

Scittle is specifically made for browsers

borkdude 2022-10-14T17:49:15.184839Z

What is the runtime environment of Google Apps? Node?

borkdude 2022-10-14T17:52:37.379709Z

You can maybe get rid of the warning by calling:

scittle.core.disable_auto_eval()

borkdude 2022-10-14T17:53:59.193879Z

or defining a surrogate window object

borkdude 2022-10-14T17:54:58.930829Z

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

borkdude 2022-10-14T17:55:31.049829Z

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

Richie 2022-10-14T18:02:21.167759Z

Ok, thanks.

borkdude 2022-10-14T18:04:26.875039Z

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

borkdude 2022-10-14T18:04:36.521919Z

are you able to run Google Apps locally for testing?

borkdude 2022-10-14T18:04:54.533329Z

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

Richie 2022-10-14T18:05:26.792149Z

I hadn’t thought of nbb.

borkdude 2022-10-14T18:06:14.702709Z

Creating a special SCI target for Google Apps may work too

borkdude 2022-10-14T18:06:27.625329Z

nbb assumes Node specific stuff

Richie 2022-10-14T18:06:50.399619Z

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

Richie 2022-10-14T18:07:19.437579Z

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

Richie 2022-10-14T18:07:36.154259Z

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

borkdude 2022-10-14T18:07:52.900989Z

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

borkdude 2022-10-14T18:08:55.256189Z

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

borkdude 2022-10-14T18:11:14.374519Z

$ 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 }

chromalchemy 2022-10-14T22:38:08.690009Z

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?

borkdude 2022-10-15T08:15:19.705449Z

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

borkdude 2022-10-15T08:15:46.556139Z

Btw there is also #cherry which is like #squint with with the CLJS data structures