sci

https://github.com/babashka/SCI - also see #babashka and #nbb
2021-05-26T07:31:03.031700Z

With sci-tag, is there a way to export a map of function to JS Land?

2021-05-26T07:31:43.032500Z

so that we have the ability to group our functions into namespace like object/data structure)

2021-05-26T07:55:05.033100Z

I got it, use js-obj 🙂

borkdude 2021-05-26T07:55:15.033400Z

@neo2551 You can make a JavaScript object with functions using clj->js and then use set! to set it to the window object

2021-05-26T07:55:28.033600Z

Thanks!

2021-05-26T07:56:12.034200Z

Perfect! 🙂

2021-05-26T07:56:25.034500Z

haha, this is clearly some super power you provided us xD

borkdude 2021-05-26T07:58:37.034800Z

@d.ian.b You need to add a <div id="app"></div>

1
borkdude 2021-05-26T09:02:09.035900Z

@jeroenvandijk a thought: I guess we could distribute both advanced and simple builds, then people can choose. If they only need sci + maybe reagent, they can use the advanced ones. If they want plugins from third parties they can use the simple ones.

2021-05-26T09:13:37.036Z

Yeah I think the advanced is necessary to keep it light weight. And like with Babashka, the most used libraries can be part of your repo through PRs? Not sure about this maintenance burden. If it grows too big for one repo, maybe a similar approach a with the pods could work?

borkdude 2021-05-26T09:14:19.036200Z

> most used libraries can be part of your repo through PRs yes, definitely

borkdude 2021-05-26T09:14:46.036400Z

maintenance burden, I'm not too concerned about this

borkdude 2021-05-26T09:15:05.036600Z

if the project grows bigger, then more maintainers can be added

borkdude 2021-05-26T09:15:34.036800Z

the pod approach isn't so nice for CLJS since each part has to bring its own implementation of CLJS core, data structures etc

borkdude 2021-05-26T09:15:54.037100Z

at least not if you implement those pods in CLJS as well

borkdude 2021-05-26T09:16:37.037300Z

with bb pods this is also the case, but less of a problem since you can cache the downloads pretty well and on servers downloads are less problematic than on web pages

2021-05-26T09:16:49.037500Z

Yeah true

borkdude 2021-05-26T09:17:23.037700Z

and the minimum pod size with clojure is about 10mb which is not so big for a binary you have to download, but for a JS file it is

2021-05-26T09:19:01.037900Z

yeah I guess you could do a lot with caching and cdn’s, but it would be very unfriendly for first time visitors

2021-05-26T09:19:21.038100Z

Do you think we could create a core that exports all vars from namespaces? https://github.com/borkdude/sci/blob/master/src/sci/impl/namespaces.cljc#L730

2021-05-26T09:19:35.038400Z

And then only do a small part advanced?

2021-05-26T09:20:01.038600Z

I mean renamed via advanced. Maybe the plugins don’t need to repeat that much in that case

borkdude 2021-05-26T09:21:12.038800Z

I discussed this in #clojurescript, best to read that

1👍
borkdude 2021-05-26T09:21:25.039100Z

tl;dr: advanced doesn't only do renaming but also inlining etc

borkdude 2021-05-26T09:21:29.039300Z

so it isn't that easy

2021-05-26T09:23:10.039500Z

Maybe wait indeed until we have enough motivation to explore this

borkdude 2021-05-26T09:25:26.039700Z

also I want to rename the project so something nicer. perhaps scittle or something

2021-05-26T09:25:50.039900Z

haha nice

2021-05-26T09:26:12.040100Z

I’ll ask you for naming suggestions when I create a new project 💪

2021-05-26T09:26:58.040300Z

Btw, not sure if you think it’s useful but I think some bookmarklet examples are also cool. I played with it last year https://gist.github.com/jeroenvandijk/2c54cfcfacd61a97962c0504a77cacc3

borkdude 2021-05-26T09:28:26.040500Z

Perhaps you can make a PR with a bookmarklet.html page (we already have a tictactoe.html page)

2021-05-26T09:29:29.040700Z

Yeah I’ll try to come up with something fun

borkdude 2021-05-26T10:23:45.041200Z

a heads up, you now must provide your own React when using the reagent plugin:

&lt;script crossorigin src="<https://unpkg.com/react@17/umd/react.production.min.js>"&gt;&lt;/script&gt;
&lt;script crossorigin src="<https://unpkg.com/react-dom@17/umd/react-dom.production.min.js>"&gt;&lt;/script&gt;
&lt;script src="<https://borkdude.github.io/sci-script-tag/js/sci-script-tag-plugin-reagent.js>" type="application/javascript"&gt;&lt;/script&gt;

borkdude 2021-05-26T10:24:03.041500Z

to make things even more modular

borkdude 2021-05-26T10:25:38.041900Z

you can also provide a development React version, for better error messages this way

2021-05-26T10:39:16.043100Z

Is there are a way to evaluate Sci code after the dom has loaded? Maybe I need evalString for my bookmarklet

2021-05-26T10:45:16.043300Z

I.e. this triggers an alert

s=document.createElement("script");s.innerText="alert('js')";document.body.appendChild(s)
but this doesn’t
s=document.createElement("script");s.setAttribute('type', 'application/x-sci');s.innerText="(js/alert \"cljs\")";document.body.appendChild(s)
I’m not sure if you can add dom events for loading custom application types. Otherwise I need something like sci.evalString

borkdude 2021-05-26T10:50:48.043800Z

The project is now renamed to scittle: https://borkdude.github.io/scittle/

borkdude 2021-05-26T10:51:01.044100Z

should we use application/x-scittle too?

borkdude 2021-05-26T10:51:12.044200Z

oh

borkdude 2021-05-26T10:51:27.044400Z

this is now done implicitly when the dom content is done loading

borkdude 2021-05-26T10:51:36.044600Z

but perhaps it's better to make it explicit

borkdude 2021-05-26T10:52:24.044800Z

Same as the highlight JS plugin, it has

hljs.highlightAll();
Perhaps that's more flexible than doing it automatically

2021-05-26T10:53:51.045Z

I think the implicit way is fine for most users. The bookmarklet case is very specific. I just need a way 😅

2021-05-26T10:54:25.045400Z

Why not?

borkdude 2021-05-26T10:54:34.045500Z

maybe we can expose a function that evaluates a dom node

borkdude 2021-05-26T10:54:54.045700Z

or a selection of dom nodes

2021-05-26T10:55:35.045900Z

maybe eval-string is actually cleaner for my use case. I don’t know about other use cases

borkdude 2021-05-26T10:56:07.046100Z

in that case you don't even have to make a script node right?

2021-05-26T10:56:15.046300Z

yeah correct. Only for the plugins (scittle and scittle-reagent)

borkdude 2021-05-26T10:56:32.046700Z

ok, let's expose it, commit coming

1🤘
borkdude 2021-05-26T10:58:45.047100Z

yeah, looks like fun right

borkdude 2021-05-26T10:59:27.047200Z

this now works:

scittle.core.eval_string("(prn :hello)");
scittle.js:16 :hello

1👌
borkdude 2021-05-26T10:59:30.047400Z

in the browser console

borkdude 2021-05-26T11:01:56.047800Z

ok, pushing that change

2021-05-26T13:30:26.047900Z

duh, I was tired hahaha thx

2021-05-26T13:45:23.048700Z

@borkdude I have a basic bookmarklet example. What is a good place to put it?

2021-05-26T13:47:33.049100Z

borkdude 2021-05-26T14:04:55.049500Z

perhaps you can put it in resources?

2021-05-26T14:27:27.049700Z

Yep done https://github.com/borkdude/scittle/pull/1

2021-05-26T14:27:55.050Z

works locally. I used absolute urls though https://github.com/borkdude/scittle/pull/1/files#diff-25c3650694da19d8dce442cc761a939f823b5bbba41bd7ac90eba3a93083b841R5 as /js is not in resources/public locally

borkdude 2021-05-26T14:32:11.050300Z

I'll take a look after I cut out 300kb from the build ;)

1😎
2021-05-26T15:04:57.050600Z

FYI, i added two small fixes for a better editting experience 🙂 https://github.com/borkdude/scittle/pull/2

2021-05-26T15:06:35.050900Z

I was missing the nice debugging experience of babashka. &lt;---- stacktraces i mean. Maybe something to add later

borkdude 2021-05-26T15:44:23.051100Z

@jeroenvandijk how is the bookmarklet working if you navigate away from the page?

borkdude 2021-05-26T15:44:56.051300Z

I don't think it does

2021-05-26T15:45:01.051500Z

You drag the link to your bookmark page and you can use it on any page (that doesn’t set restrictions)

2021-05-26T15:45:25.051700Z

It will throw an error if the scittle js can’t be loaded due to restrictions (e.g. try http://github.com)

borkdude 2021-05-26T15:46:11.051900Z

I was trying it in an empty browser page

borkdude 2021-05-26T15:46:30.052100Z

oh it does work in CircleCI :)

borkdude 2021-05-26T15:46:41.052300Z

wow :)

2021-05-26T15:46:44.052500Z

:))

borkdude 2021-05-26T15:47:31.052700Z

amazing :)

2021-05-26T15:47:50.052900Z

If you google you will find some inspiration e.g. https://www.howtogeek.com/125846/the-most-useful-bookmarklets-to-enhance-your-browsing-experience/

2021-05-26T15:48:11.053200Z

I had some handy ones before in js, but stopped using it. Now with Scittle i’m motivated to write some myself