With sci-tag, is there a way to export a map of function to JS Land?
so that we have the ability to group our functions into namespace like object/data structure)
I got it, use js-obj 🙂
@neo2551 You can make a JavaScript object with functions using clj->js
and then use set!
to set it to the window object
Thanks!
Perfect! 🙂
haha, this is clearly some super power you provided us xD
@d.ian.b You need to add a <div id="app"></div>
@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.
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?
> most used libraries can be part of your repo through PRs yes, definitely
maintenance burden, I'm not too concerned about this
if the project grows bigger, then more maintainers can be added
the pod approach isn't so nice for CLJS since each part has to bring its own implementation of CLJS core, data structures etc
at least not if you implement those pods in CLJS as well
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
Yeah true
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
yeah I guess you could do a lot with caching and cdn’s, but it would be very unfriendly for first time visitors
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
And then only do a small part advanced?
I mean renamed via advanced. Maybe the plugins don’t need to repeat that much in that case
I discussed this in #clojurescript, best to read that
tl;dr: advanced doesn't only do renaming but also inlining etc
so it isn't that easy
Maybe wait indeed until we have enough motivation to explore this
also I want to rename the project so something nicer. perhaps scittle
or something
haha nice
I’ll ask you for naming suggestions when I create a new project 💪
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
Perhaps you can make a PR with a bookmarklet.html page (we already have a tictactoe.html page)
Yeah I’ll try to come up with something fun
a heads up, you now must provide your own React when using the reagent plugin:
<script crossorigin src="<https://unpkg.com/react@17/umd/react.production.min.js>"></script>
<script crossorigin src="<https://unpkg.com/react-dom@17/umd/react-dom.production.min.js>"></script>
<script src="<https://borkdude.github.io/sci-script-tag/js/sci-script-tag-plugin-reagent.js>" type="application/javascript"></script>
to make things even more modular
you can also provide a development React version, for better error messages this way
Is there are a way to evaluate Sci code after the dom has loaded? Maybe I need evalString for my bookmarklet
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
The project is now renamed to scittle: https://borkdude.github.io/scittle/
should we use application/x-scittle
too?
oh
this is now done implicitly when the dom content is done loading
but perhaps it's better to make it explicit
Same as the highlight JS plugin, it has
hljs.highlightAll();
Perhaps that's more flexible than doing it automaticallyI think the implicit way is fine for most users. The bookmarklet case is very specific. I just need a
way 😅
Why not?
maybe we can expose a function that evaluates a dom node
or a selection of dom nodes
maybe eval-string is actually cleaner for my use case. I don’t know about other use cases
in that case you don't even have to make a script node right?
yeah correct. Only for the plugins (scittle and scittle-reagent)
ok, let's expose it, commit coming
yeah, looks like fun right
this now works:
scittle.core.eval_string("(prn :hello)");
scittle.js:16 :hello
in the browser console
ok, pushing that change
duh, I was tired hahaha thx
@borkdude I have a basic bookmarklet example. What is a good place to put it?
perhaps you can put it in resources?
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
I'll take a look after I cut out 300kb from the build ;)
FYI, i added two small fixes for a better editting experience 🙂 https://github.com/borkdude/scittle/pull/2
I was missing the nice debugging experience of babashka. <----
stacktraces i mean. Maybe something to add later
@jeroenvandijk how is the bookmarklet working if you navigate away from the page?
I don't think it does
You drag the link to your bookmark page and you can use it on any page (that doesn’t set restrictions)
It will throw an error if the scittle js can’t be loaded due to restrictions (e.g. try http://github.com)
I was trying it in an empty browser page
oh it does work in CircleCI :)
wow :)
:))
amazing :)
If you google you will find some inspiration e.g. https://www.howtogeek.com/125846/the-most-useful-bookmarklets-to-enhance-your-browsing-experience/
I had some handy ones before in js, but stopped using it. Now with Scittle i’m motivated to write some myself