Skip to content

Commit

Permalink
extension mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Apr 17, 2024
1 parent ef4de1c commit c547756
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 31 deletions.
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,28 @@
[![GitHub Actions status |pink-gorilla/goldly](https://github.com/pink-gorilla/goldly/workflows/CI/badge.svg)](https://github.com/pink-gorilla/goldly/actions?workflow=CI)
[![Clojars Project](https://img.shields.io/clojars/v/org.pinkgorilla/goldly.svg)](https://clojars.org/org.pinkgorilla/goldly)

- goldly uses the sci clojurescript interpreter to create a clojurescript kernel.
- goldly uses webly lazy shadow-cljs lazy modules.
- goldly uses the sci clojure(script) interpreter to create a clojurescript kernel.
- goldly uses webly to create lazy-loadable-js-modules via shadow-cljs.
- goldly has 3 sub-projects:
- goldly-sci: creates a sci-interpreter setup that works with shadow-cljs lazy modules.
- reval-sci: implements a reval kernel (for cljs)
- sci-configs: creates modules based on sci-configs namespace mappings.

## demo

The demo is mainly there for development of goldly.

Clone goldly git repo.


```
cd demo
clj -X:webly:npm-install
clj -X:webly:compile
clj -X:nbeval
clj -X:webly:run
```
## goldly - in your project **with custom ui-renderers**

You need to add the **goldly** artefact to build javascript bundle from scratch.
Expand All @@ -22,17 +41,3 @@ see how you can build a custom javascript js bundle with goldly.



## for goldly developers

Run inside cloned goldly git repo.

This option is mainly there for development of goldly.
For regular use, the long compile-times are not really sensible.

```
cd goldly-test
clj -X:goldly-build:npm-install
clj -X:goldly-build:compile
clj -X:goldly
```

4 changes: 2 additions & 2 deletions demo/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"resources"
"target/webly"]
:deps {org.pinkgorilla/goldly {:local/root ".." :deps/manifest :deps}
org.pinkgorilla/webly {:mvn/version "0.5.669"}
org.pinkgorilla/ui-repl {:mvn/version "0.1.102"}
org.pinkgorilla/webly {:mvn/version "0.5.673"}
org.pinkgorilla/ui-repl {:mvn/version "0.1.104"}
org.pinkgorilla/ui-site {:mvn/version "0.0.30"}
org.pinkgorilla/ui-binaryclock {:mvn/version "0.2.19"}
;org.pinkgorilla/ui-input {:mvn/version "0.2.44"} ; spaces
Expand Down
5 changes: 2 additions & 3 deletions demo/resources/demo/notebook/err_cljs.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns demo.notebook.err-cljs
(:require [bongistan]))
; bongistan ns does not exist

; no sci-code for ns: bongistan

(blubb 13 27)
;; blubb does not exist.
;; Could not resolve symbol: blubb
5 changes: 1 addition & 4 deletions demo/resources/test-config.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{:build {:disabled-extensions #{"goog.string"
"clojure.walk"
"clojure.string"
"goog.object"}}
{:build {:disabled-extensions #{"goog.string" "clojure.walk" "clojure.string" "goog.object"}}

:spa {:title "Goldly Demo"
:start-user-app [:goldly/init]}
Expand Down
5 changes: 2 additions & 3 deletions demo/src/demo/cljs_libs/helper.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

(defn test-header []
[site/header-menu
{:brand "goldly-test"
{:brand "goldly-demo"
:brand-link "/"
:items [{:text "service-test" :dispatch [:bidi/goto 'demo.page.service-test/service-page]}
{:text "sci-compile" :dispatch [:bidi/goto 'demo.page.sci-compile/sci-compile-page]}
:items [{:text "sci-compile" :dispatch [:bidi/goto 'demo.page.sci-compile/sci-compile-page]}
{:text "lazyload-test" :dispatch [:bidi/goto 'demo.page.lazy/lazy-page]}
{:text "kernel" :dispatch [:bidi/goto 'demo.page.kernel/kernel-page]}
{:text "error-test" :dispatch [:bidi/goto 'demo.page.error/error-page]}
Expand Down
3 changes: 1 addition & 2 deletions goldly-sci/src/goldly/sci/loader/shadow_add.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
(info "webly-shadow-ns load: " libname " type: " (type libname))
(load-namespace-raw libname))


(defn add-shadow-module [{:keys [ctx libname ns opts sci-mod]}]
(info "load-shadow-module: ns: " libname)
(let [r-p (p/deferred)
Expand All @@ -25,7 +24,7 @@
(info "ns " libname " is a simple namespace; adding ns..")
(sci/add-namespace! ctx libname x))
(do
(error "ns " libname " is a sci-configs-namespace ; adding ns ..")
(info "ns " libname " is a sci-configs-namespace ; adding ns ..")
(sci/add-namespace! ctx libname res)))
;; empty map return value, SCI will still process `:as` and `:refer`
(p/resolve! r-p {})))
Expand Down
8 changes: 8 additions & 0 deletions sci-configs/resources/demo/notebook/clojure_string.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns demo.notebook.clojure-string
(:require
[clojure.string :as str]))

(str/join ", " ["apple" "banana" "blueberry" "wine"])

(str/blank? " ")
(str/blank? " _")
13 changes: 13 additions & 0 deletions sci-configs/resources/demo/notebook/goog_string.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns demo.notebook.goog-string
(:require
[goog.string :refer [format]]))


(format "hello %s !" "mr X.")

(format "%.3f" 2.511)
(format "%.2f" 2.511)
(format "%.0f" 2.511)
(format "%d" 134.44)
(format "%s %s %s" 2021 11 13)

2 changes: 1 addition & 1 deletion sci-configs/resources/demo/notebook/javelin.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns demo.notebook.javelin
(:require
[javelin.core :refer [cell] :refer-macros [cell=]]))
[javelin.core :refer [cell cell=]]))

(defn start []
(let [a (cell 0) ;; input cell with initial value of 0.
Expand Down
9 changes: 9 additions & 0 deletions sci-configs/resources/ext/clojure.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{:name "clojure"
; build
:lazy false
:cljs-namespace [goldly.clojure-ns]
:cljs-ns-bindings {'clojure.string goldly.clojure-ns/clojure-string-namespace
;'clojure.edn goldly.clojure-ns/clojure-edn-namespace
'clojure.walk goldly.clojure-ns/clojure-walk-namespace
'goog.object goldly.clojure-ns/goog-object-namespace
'goog.string goldly.clojure-ns/goog-string-namespace}}
54 changes: 54 additions & 0 deletions sci-configs/src/goldly/clojure_ns.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(ns goldly.clojure-ns
(:require
[clojure.string]
[clojure.edn]
[clojure.walk]
[goog.object]
[goog.string]
[goog.string.format]
[sci.core :as sci]))



(def clojure-string-namespace
(sci/copy-ns clojure.string (sci/create-ns 'clojure.string nil)))

(def clojure-edn-namespace
(sci/copy-ns clojure.edn (sci/create-ns 'clojure.edn nil)))

(def clojure-walk-namespace
(sci/copy-ns clojure.walk (sci/create-ns 'clojure.walk nil)))

(def goog-object-namespace
(sci/copy-ns goog.object (sci/create-ns 'goog.object nil)))

(def goog-string-namespace
(sci/copy-ns goog.string (sci/create-ns 'goog.string nil)))






#_'clojure.string #_{'split clojure.string/split
'join clojure.string/join
'escape clojure.string/escape
'blank? clojure.string/blank?
'replace clojure.string/replace
'lower-case clojure.string/lower-case}

#_'clojure.edn #_{'read-string clojure.edn/read-string
'read clojure.edn/read}

#_'clojure.walk #_{'postwalk clojure.walk/postwalk
'prewalk clojure.walk/prewalk
'keywordize-keys clojure.walk/keywordize-keys
'walk clojure.walk/walk
'postwalk-replace clojure.walk/postwalk-replace
'prewalk-replace clojure.walk/prewalk-replace
'stringify-keys clojure.walk/stringify-keys}

#_ 'goog.object #_{'set goog.object/set
'get goog.object/get}

; 'goog.string {'format goog.string/format}

0 comments on commit c547756

Please sign in to comment.