cljs.pprint (#39)
This commit is contained in:
parent
7bf5bc087d
commit
cf65ffaf20
7 changed files with 43 additions and 11 deletions
3
bb.edn
3
bb.edn
|
|
@ -15,7 +15,8 @@
|
||||||
(fs/delete-tree ".shadow-cljs"))}
|
(fs/delete-tree ".shadow-cljs"))}
|
||||||
|
|
||||||
shadow:watch {:doc "Development build. Starts webserver and watches for changes."
|
shadow:watch {:doc "Development build. Starts webserver and watches for changes."
|
||||||
:task (clojure "-M:dev -m shadow.cljs.devtools.cli watch main")}
|
:task (clojure {:extra-env {"SCI_ELIDE_VARS" "true"}}
|
||||||
|
"-M:dev -m shadow.cljs.devtools.cli watch main")}
|
||||||
|
|
||||||
http-server {:doc "Starts http server for serving static files"
|
http-server {:doc "Starts http server for serving static files"
|
||||||
:requires ([babashka.http-server :as http])
|
:requires ([babashka.http-server :as http])
|
||||||
|
|
|
||||||
6
deps.edn
6
deps.edn
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
:deps
|
:deps
|
||||||
{org.clojure/clojure {:mvn/version "1.10.3"}
|
{org.clojure/clojure {:mvn/version "1.10.3"}
|
||||||
org.babashka/sci {:mvn/version "0.3.5"}
|
org.babashka/sci {:git/url "https://github.com/babashka/sci"
|
||||||
|
:git/sha "133a7565749ac6cd5a8308182f0b1c7fc47e8a3d"}
|
||||||
|
#_{:local/root "../babashka/sci"}
|
||||||
reagent/reagent {:mvn/version "1.1.0"}
|
reagent/reagent {:mvn/version "1.1.0"}
|
||||||
cljsjs/react {:mvn/version "17.0.2-0"}
|
cljsjs/react {:mvn/version "17.0.2-0"}
|
||||||
cljsjs/react-dom {:mvn/version "17.0.2-0"}
|
cljsjs/react-dom {:mvn/version "17.0.2-0"}
|
||||||
|
|
@ -14,7 +16,7 @@
|
||||||
#_{:local/root "../sci.nrepl"}
|
#_{:local/root "../sci.nrepl"}
|
||||||
{:git/sha "e83421ce9349c36df56a2eb936196dbb65b0de63"}
|
{:git/sha "e83421ce9349c36df56a2eb936196dbb65b0de63"}
|
||||||
io.github.babashka/sci.configs
|
io.github.babashka/sci.configs
|
||||||
{:git/sha "fcd367c6a6115c5c4e41f3a08ee5a8d5b3387a18"}}
|
{:git/sha "63225c8606d593c595d2f10a6fa5bf38103852df"}}
|
||||||
|
|
||||||
:aliases
|
:aliases
|
||||||
{:dev
|
{:dev
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>
|
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>
|
||||||
<script src="js/scittle.reagent.js" type="application/javascript"></script>
|
<script src="js/scittle.reagent.js" type="application/javascript"></script>
|
||||||
<script src="js/scittle.cljs-ajax.js" type="application/javascript"></script>
|
<script src="js/scittle.cljs-ajax.js" type="application/javascript"></script>
|
||||||
|
<script src="js/scittle.pprint.js" type="application/javascript"></script>
|
||||||
|
|
||||||
<script type="application/x-scittle">
|
<script type="application/x-scittle">
|
||||||
(defn my-alert []
|
(defn my-alert []
|
||||||
(js/alert "You clicked!"))
|
(js/alert "You clicked!"))
|
||||||
|
|
@ -118,6 +120,19 @@
|
||||||
Click me!
|
Click me!
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<a name="pprint"></a>
|
||||||
|
<h2><a href="#pprint">cljs.pprint plugin</a></h2>
|
||||||
|
|
||||||
|
To enable <a href="https://cljs.github.io/api/cljs.pprint/">cljs-ajax</a>,
|
||||||
|
in addition to <tt>scittle.js</tt>, you need to include <tt>scittle.pprint.js</tt>:
|
||||||
|
|
||||||
|
<pre><code data-type="scittle" data-src="html/cljs-ajax.html" class="html"></code></pre>
|
||||||
|
|
||||||
|
<button onclick="make_request()">
|
||||||
|
Click me!
|
||||||
|
</button>
|
||||||
|
|
||||||
|
|
||||||
<a name="repl"></a>
|
<a name="repl"></a>
|
||||||
<h2><a href="#nrepl">REPL</a></h2>
|
<h2><a href="#nrepl">REPL</a></h2>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
:depends-on #{:scittle}}
|
:depends-on #{:scittle}}
|
||||||
:scittle.promesa {:entries [scittle.promesa]
|
:scittle.promesa {:entries [scittle.promesa]
|
||||||
:depends-on #{:scittle}}
|
:depends-on #{:scittle}}
|
||||||
|
:scittle.pprint {:entries [scittle.pprint]
|
||||||
|
:depends-on #{:scittle}}
|
||||||
:scittle.reagent {:entries [scittle.reagent]
|
:scittle.reagent {:entries [scittle.reagent]
|
||||||
:depends-on #{:scittle}}
|
:depends-on #{:scittle}}
|
||||||
:scittle.cljs-ajax {:entries [scittle.cljs-ajax]
|
:scittle.cljs-ajax {:entries [scittle.cljs-ajax]
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,12 @@
|
||||||
[goog.object :as gobject]
|
[goog.object :as gobject]
|
||||||
[goog.string]
|
[goog.string]
|
||||||
[sci.core :as sci]
|
[sci.core :as sci]
|
||||||
|
[sci.impl.unrestrict]
|
||||||
[scittle.impl.common :refer [cljns]]
|
[scittle.impl.common :refer [cljns]]
|
||||||
[scittle.impl.error :as error]))
|
[scittle.impl.error :as error]))
|
||||||
|
|
||||||
|
(set! sci.impl.unrestrict/*unrestricted* true)
|
||||||
|
|
||||||
(clojure.core/defmacro time
|
(clojure.core/defmacro time
|
||||||
"Evaluates expr and prints the time it took. Returns the value of expr."
|
"Evaluates expr and prints the time it took. Returns the value of expr."
|
||||||
[expr]
|
[expr]
|
||||||
|
|
@ -29,11 +32,12 @@
|
||||||
'goog.object {'set gobject/set
|
'goog.object {'set gobject/set
|
||||||
'get gobject/get}})
|
'get gobject/get}})
|
||||||
|
|
||||||
(def !sci-ctx (atom (sci/init {:namespaces namespaces
|
(def !sci-ctx
|
||||||
:classes {'js js/window
|
(atom (sci/init {:namespaces namespaces
|
||||||
:allow :all}
|
:classes {'js js/window
|
||||||
:disable-arity-checks true})))
|
:allow :all
|
||||||
|
'Math js/Math}
|
||||||
|
:ns-aliases {'clojure.pprint 'cljs.pprint}})))
|
||||||
|
|
||||||
(def !last-ns (volatile! @sci/ns))
|
(def !last-ns (volatile! @sci/ns))
|
||||||
|
|
||||||
|
|
@ -103,4 +107,3 @@
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
(sci/alter-var-root sci/print-fn (constantly *print-fn*))
|
(sci/alter-var-root sci/print-fn (constantly *print-fn*))
|
||||||
|
|
||||||
|
|
|
||||||
8
src/scittle/pprint.cljs
Normal file
8
src/scittle/pprint.cljs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
(ns scittle.pprint
|
||||||
|
(:require
|
||||||
|
[sci.configs.cljs.pprint :refer [config]]
|
||||||
|
[scittle.core :as scittle]))
|
||||||
|
|
||||||
|
(scittle/register-plugin!
|
||||||
|
::promesa
|
||||||
|
config)
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
(ns scittle.promesa
|
(ns scittle.promesa
|
||||||
(:require [scittle.core :as scittle]
|
(:require
|
||||||
[sci.configs.funcool.promesa :as p]))
|
[sci.configs.funcool.promesa :as p]
|
||||||
|
[scittle.core :as scittle]))
|
||||||
|
|
||||||
(scittle/register-plugin!
|
(scittle/register-plugin!
|
||||||
::promesa
|
::promesa
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue