Skip to content

Commit

Permalink
Merge pull request #17 from smucclaw/cleanup-imports
Browse files Browse the repository at this point in the history
cleanup imports
  • Loading branch information
joewatt95 authored Apr 10, 2024
2 parents ca569a7 + 6aad4e6 commit 3f6c760
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
8 changes: 2 additions & 6 deletions src/l4_lp/swipl/js/wasm_query.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
[l4-lp.swipl.js.common.swipl-js-to-clj :as swipl-js->clj]
[promesa.core :as prom]
["https://SWI-Prolog.github.io/npm-swipl-wasm/3/7/5/dynamic-import.js"
:as swipl-mod]))

(def ^:private swipl-constructor
(jsi/get swipl-mod :SWIPL))
:rename {SWIPL Swipl}]))

(def ^:private prelude-qlf-url
"resources/swipl/prelude.qlf")
Expand All @@ -18,8 +15,7 @@
;; TODO: Document and clean up this function.
(defn query-and-trace! [program goal]
(prom/let
[Swipl swipl-constructor
swipl (Swipl. #js {:arguments #js ["-q"]})
[swipl (Swipl. #js {:arguments #js ["-q"]})

stack-trace (transient [])

Expand Down
17 changes: 7 additions & 10 deletions src/l4_lp/web_editor/guifier.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
[l4-lp.swipl.js.wasm-query :as swipl-wasm-query]
[l4-lp.syntax.l4-to-prolog :as l4->prolog]
[promesa.core :as prom]
["https://cdn.jsdelivr.net/npm/guifier@1.0.24/dist/Guifier.js"
:as guifier-mod]))
["https://cdn.jsdelivr.net/npm/guifier@1.0.24/dist/Guifier.js$default"
:as Guifier]))

(def ^:private guifier
{:element-id "guifier"
:constructor (jsi/get guifier-mod :default)})
(def ^:private guifier-element-id
"guifier")

(def ^:private query
(-> "query" l4->prolog/l4->prolog-str))

(defn query-and-trace-and-guifier! [l4-program]
(-> js/document
(jsi/call :getElementById (:element-id guifier))
(jsi/call :getElementById guifier-element-id)
(jsi/assoc! :innerHTML ""))

(prom/let
Expand All @@ -24,11 +23,9 @@
_ (jsi/call js/console :log "Transpiled program: " program)
_ (jsi/call js/console :log "Transpiled query: " query)

stack-trace (swipl-wasm-query/query-and-trace-js! program query)

Guifier (:constructor guifier)]
stack-trace (swipl-wasm-query/query-and-trace-js! program query)]
(Guifier. #js {:data stack-trace
:dataType "js"
:elementSelector (str "#" (:element-id guifier))
:elementSelector (str "#" guifier-element-id)
:withoutContainer true
:readOnlyMode true})))

0 comments on commit 3f6c760

Please sign in to comment.