diff --git a/src/samak/api.cljc b/src/samak/api.cljc
index a7542cd..260f1b9 100644
--- a/src/samak/api.cljc
+++ b/src/samak/api.cljc
@@ -20,6 +20,10 @@
#:samak.nodes{:type :samak.nodes/fn-ref
:fn [:samak.nodes/name identifier]})
+(defn id-ref [identifier]
+ #:samak.nodes{:type :samak.nodes/fn-ref
+ :fn {:db/id identifier}})
+
(defn pipe
([from to]
#:samak.nodes {:type :samak.nodes/pipe
diff --git a/src/samak/code_db.cljc b/src/samak/code_db.cljc
index 7a5319e..4f5158a 100644
--- a/src/samak/code_db.cljc
+++ b/src/samak/code_db.cljc
@@ -147,8 +147,6 @@
"loads a network given a source entity id from the database"
[db id loaded]
(if (contains? loaded id)
- ;; (println "!!!!!!!!!!!!!!!!!!!!!")
- ;; FIXME
{}
(let [ast (load-by-id db id)
subs (mapv :db/id (find-links-from db id))
diff --git a/src/samak/helpers.cljc b/src/samak/helpers.cljc
index fb913ea..1833ee2 100644
--- a/src/samak/helpers.cljc
+++ b/src/samak/helpers.cljc
@@ -3,6 +3,8 @@
(:clj
[(:refer-clojure :exclude [uuid])
(:require
+ [promesa.core :as p]
+ [clojure.walk :as w]
[clojure.data.json :as json]
[clj-time.core :as time]
[clj-time.format :as time-format]
@@ -10,6 +12,9 @@
:cljs
[(:refer-clojure :exclude [uuid])
(:require
+ [goog.async.nextTick]
+ [promesa.core :as p]
+ [clojure.walk :as w]
[cljs-time.core :as time]
[cljs-time.format :as time-format]
[cljs-time.coerce :as time-coerce])]))
@@ -106,3 +111,28 @@
(defn to-json [x]
#?(:cljs (clj->js x)
:clj (json/write-str x)))
+
+(defn debounce
+ ""
+ [f]
+ #?(:cljs (goog.async.nextTick f)
+ :clj (f)))
+
+(defn str-to-int [s]
+ #?(:clj (try (Integer/parseInt s) (catch Exception e nil))
+ :cljs (js/parseInt s)))
+
+(defn pwalk
+ ""
+ [inner outer form]
+ (cond
+ (p/promise? form) (p/then form #(w/walk inner outer form))
+ (list? form) (outer (apply list (p/all (map inner form))))
+ (seq? form) (outer (p/all (map inner form)))
+ (coll? form) (outer (into (empty form) (p/all (map inner form))))
+ :else (w/walk inner outer form)))
+
+(defn ppostwalk
+ ""
+ [f form]
+ (pwalk (partial ppostwalk f) f form))
diff --git a/src/samak/nodes.cljc b/src/samak/nodes.cljc
index a116312..b1a1152 100644
--- a/src/samak/nodes.cljc
+++ b/src/samak/nodes.cljc
@@ -39,21 +39,10 @@
(ref? value) (let [id (:db/id value)]
(or ((:resolve *manager*) id)
(compile-error "Referenced id " id " was undefined")))
- :default (compile-error "unknown token during evaluation: " (str value))))
+ :default (compile-error "unknown token during evaluation: " (str "type: " (or (type value) "nil") " with value: " (str value)))))
-(defmethod eval-node ::module [{:keys [::definition] :as module}]
- ;; (println "evaling module: " module)
- ;; FIXME: also needs to make this stuff available for resolve?
-
- (fn []
- ;; FIXME
- ;; needs to prep resolve magic when instanciating pipes, to select same runtime
- ;; maybe simply do so explicitly
-
- (println (str "about to eval module: " module))
- (let [evaled (eval-node definition)]
- (println (str "used module: " module "->" evaled))
- evaled)))
+(defmethod eval-node ::module [module]
+ ((:module *manager*) module *manager*))
(defmethod eval-node ::map [{:keys [::mapkv-pairs]}]
(reduce (fn [a {:keys [::mapkey ::mapvalue]}]
@@ -71,29 +60,40 @@
(defmethod eval-node ::float [{:keys [::value]}] value)
(defmethod eval-node ::builtin [{:keys [::value]}] (get *builtins* value))
-(defmethod eval-node ::def [{:keys [::rhs]}] (eval-node rhs))
+(defmethod eval-node ::def [{:keys [::rhs] :as fn}]
+ (let [res (eval-node rhs)
+ id (:db/id fn)]
+ ((:register *manager*) id res)
+ res))
(defmethod eval-node ::pipe [{:keys [::from ::to ::xf] :as p}]
(let [a (eval-node from)
+ c (eval-node to)
b (when xf
(let [db-id (:db/id xf)]
(binding [*db-id* db-id]
(-> xf
eval-node
((partial pipes/instrument db-id (:cancel? *manager*)))
- pipes/transduction-pipe))))
- c (eval-node to)]
+ (#(pipes/transduction-pipe % (str (pipes/uuid a) "-" db-id "-" (pipes/uuid c))))))))]
((:link *manager*) a c b)))
(defmethod eval-node ::fn-ref [{:keys [::fn] :as f}]
- (or (when (api/is-def? fn) (eval-node fn))
- ((:resolve *manager*) (:db/id fn))
- (compile-error "Undefined reference " fn " in " *manager*)))
+ (or ((:resolve *manager*) (:db/id fn))
+ (when (api/is-def? fn)
+ (let [res (eval-node fn)]
+ ;; (println "evaling" (:db/id fn) "->" res "def" fn)
+ res))
+ ;; (when (api/is-module? fn)
+ ;; (let [res (eval-node fn)]
+ ;; (println "evaling" (:db/id fn) "->" res "mod" fn) res))
+ (println "type:" (::type fn) (:db/id fn))
+ (compile-error "Undefined reference for evaling " *db-id* " fn " fn)))
(defmethod eval-node ::fn-call [{:keys [::fn-expression ::arguments]}]
(let [func (eval-node fn-expression)]
(try (apply (p/eval-as-fn func) (eval-reordered arguments))
- (catch clojure.lang.ArityException ex
+ (catch #?(:clj clojure.lang.ArityException :cljs js/Error) ex
(compile-error "wrong args: " (eval-reordered arguments) " for fn " func " -> " ex)))))
(defmethod eval-node ::link [{:keys [::from ::to]}]
diff --git a/src/samak/pipes.cljc b/src/samak/pipes.cljc
index e616801..aec0068 100644
--- a/src/samak/pipes.cljc
+++ b/src/samak/pipes.cljc
@@ -1,29 +1,53 @@
(ns samak.pipes
- #?
+ (:refer-clojure :exclude [uuid])
+ #?@
(:clj
- (:require
- [clojure.core.async :as a :refer [chan put!]]
+ [(:require
+ [clojure.core.async :as a :refer [chan put! ! chan go go-loop close! put!]]
+ [promesa.core :as prom]
[samak.lisparser :as p]
[samak.oasis :as oasis]
[samak.pipes :as pipes]
@@ -23,6 +24,7 @@
[cljs.reader :as edn]
[clojure.string :as str]
[clojure.core.async :as a :refer [! chan close! put!]]
+ [promesa.core :as prom]
[samak.lisparser :as p]
[samak.oasis :as oasis]
[samak.pipes :as pipes]
@@ -41,7 +43,7 @@
(def ^:dynamic *default-timeout* 0)
(def config {:tracer {:backend :none}})
-(def rt (atom (run/make-runtime core/samak-symbols nil)))
+(def rt (atom (run/make-runtime core/samak-symbols)))
(def trace (atom (trace/init-tracer rt (:tracer config))))
(caravan/init @rt)
@@ -65,8 +67,8 @@
(defn fire-event-into-named-pipe
[pipe-name event]
- (let [arg (edn/read-string event)
- res (run/fire-into-named-pipe @rt (symbol pipe-name) arg *default-timeout*)]
+ (prom/let [arg (edn/read-string event)
+ res (run/fire-into-named-pipe @rt (symbol pipe-name) arg *default-timeout*)]
(if (:error res)
(println (:error res)))))
@@ -95,18 +97,12 @@
(defn start-oasis
[cb]
- (let [c (chan)
- exps (oasis/start)
+ (let [exps (oasis/start)
numbered (map-indexed vector exps)
- cnt (count numbered)]
- (go-loop [state @rt]
- (let [part (> lines
@@ -143,5 +138,4 @@
[(str/join " " lines)])))))
(defn eval-lines [lines]
- (doseq [line (group-repl-cmds lines)]
- (eval-line line)))
+ (prom/all (map eval-line (group-repl-cmds lines))))
diff --git a/src/samak/runtime.cljc b/src/samak/runtime.cljc
index 029319b..281dab8 100644
--- a/src/samak/runtime.cljc
+++ b/src/samak/runtime.cljc
@@ -3,6 +3,7 @@
(:clj
[(:require
[clojure.core.async :as a :refer [! chan go go-loop close! put!]]
+ [promesa.core :as p]
[samak.runtime.stores :as stores]
[samak.runtime.servers :as servers]
[samak.helpers :as helpers]
@@ -16,6 +17,7 @@
:cljs
[(:require
[clojure.core.async :as a :refer [! chan close! put!]]
+ [promesa.core :as p]
[samak.runtime.stores :as stores]
[samak.runtime.servers :as servers]
[samak.helpers :as helpers]
@@ -29,8 +31,32 @@
(:require-macros [cljs.core.async.macros :refer [go go-loop]])]))
-(def resolver (atom {}))
(def cancel-conditions (atom {}))
+(def pipe-links (atom {}))
+
+(defn eval-all [server forms]
+ (reduce (fn [server form]
+ ;; (println "form" (:db/id form) "->" form)
+ (servers/eval-ast server form))
+ server forms))
+
+(defn resolve-name [runtime sym]
+ (-> runtime :store (stores/resolve-name sym)))
+
+(defn load-by-id
+ ""
+ [{store :store} id]
+ (stores/load-by-id store id))
+
+(defn load-ast
+ "loads an ast given by its entity id from the database"
+ [rt id]
+ (helpers/ppostwalk (fn [form]
+ (if-let [sub-id (when (and (map? form) (= (keys form) [:db/id]))
+ (:db/id form))]
+ (load-by-id rt sub-id)
+ form))
+ (load-by-id rt id)))
(defn cancel?
""
@@ -46,96 +72,121 @@
[id condition]
(swap! cancel-conditions update id merge condition))
-(defn eval-all [server forms]
- (reduce (fn [server form]
- (swap! resolver #(assoc % :server server))
- (servers/eval-ast server form))
- server forms))
(defn resolve-fn
- ([id]
- (resolve-fn @resolver id))
([rt id]
- (let [defs (servers/get-defined (:server rt))
- fn (get defs id)]
- ;; (println "found: " id fn)
- (if fn
- fn
- (println "not found: " id)))))
+ (println "resolve" (:uuid rt) id)
+ (get (servers/get-defined (:server rt)) id)))
(defn wrap-out
""
- [target]
+ [target id]
(fn [paket]
+ ;; (println id "wrap-out paket" target paket)
{::type ::paket ::target (:named target) ::content paket}))
(defn wrap-in
""
- [wrapped]
+ [wrapped id]
(fn [paket]
+ ;; (println id "wrap-in paket" wrapped paket)
(let [type (::type paket)
- target (subs (name (::target paket)) 3)]
- (if (and (= type ::paket) (= target (name (:named wrapped))))
+ target (::target paket)]
+ (if (and (= type ::paket) (= target (:name (:named wrapped))))
(do
- ;; (println "wrap-in" wrapped target)
+ ;; (println "wrap-in target" target (::content paket))
(::content paket))
::ignore)))) ;;FIXME
(defn replace-piped
""
- [{target :target :as pipe} dir]
+ [{target :target :as pipe} id broadcast inbound]
(if (not= target :pipe)
pipe
(do
- (println "replacing " pipe)
- (let [from-scheduler (:scheduler @resolver)
- trans-in (pipes/transduction-pipe (comp (map (wrap-in pipe)) (remove #(= % ::ignore))))
- to-world (:broadcast @resolver)
- trans-out (pipes/transduction-pipe (map (wrap-out pipe)))
- in-mapped (pipes/link! from-scheduler trans-in)
- out-mapped (pipes/link! trans-out to-world)]
+ (println "### replacing " pipe)
+ (let [trans-in (pipes/transduction-pipe (comp (map (wrap-in pipe id)) (remove #(= % ::ignore))) (str "trans-in-" pipe))
+ trans-out (pipes/transduction-pipe (map (wrap-out pipe id)) (str "trans-out-" pipe))
+ in-mapped (pipes/link! inbound trans-in)
+ out-mapped (pipes/link! trans-out broadcast)]
(pipes/composite-pipe out-mapped in-mapped)))))
-
(defn link-fn
""
- [from to xf]
- (let [a (replace-piped from "from")
- c (replace-piped to "to")]
- (when (not a)
- (fail "cant link from " from))
- (when (not c)
- (fail "cant link to " to))
- (if xf
- (pipes/link! (pipes/link! a xf) c)
- (pipes/link! a c))))
+ [id broadcast inbound]
+ (fn [from to xf]
+ (println "### linking" (:uuid from) (:uuid to))
+ (let [a (replace-piped from id broadcast inbound)
+ c (replace-piped to id broadcast inbound)
+ _ (when (not (pipes/pipe? a))
+ (fail "cant link from " from))
+ _ (when (not (pipes/pipe? c))
+ (fail "cant link to " to))
+ l (if xf
+ (pipes/link! (pipes/link! a xf) c)
+ (pipes/link! a c))]
+ (swap! pipe-links assoc (str (pipes/uuid from) "-" (pipes/uuid to)) id)
+ l)))
+
+(defn instanciate-module
+ ""
+ [{:keys [:samak.nodes/definition] :as module} man]
+ (let [n (str (:samak.nodes/name module))
+ c (get (:config man) n)]
+ (if c
+ (fn []
+ ;; (println "return stub for" n "[" (:db/id module) "] -> " c)
+ c)
+ (fn []
+ ;; FIXME
+ ;; needs to prep resolve magic when instanciating pipes, to select same runtime
+ ;; maybe simply do so explicitly
+ ;; (if (:config man))
+ (println (str "### about to eval module: " module))
+ (let [evaled (n/eval-env man nil definition (:db/id module))]
+ (println (str "### used module: " module "->" evaled))
+ evaled)))))
+
+(defn make-store-internal
+ ""
+ [conf inbound broadcast builtins]
+ (if conf
+ (stores/make-piped-store inbound broadcast)
+ (let [store (stores/make-local-store)]
+ (stores/load-builtins! store (keys builtins))
+ (stores/serve-store store inbound broadcast))))
+
(defn make-runtime-internal
""
- [scheduler]
- (let [c (pipes/pipe (chan))]
- {:id (str "rt-" (helpers/uuid))
- :store (stores/make-local-store)
- :server (servers/make-local-server {:resolve resolve-fn :link link-fn :cancel? cancel?})
- :broadcast c
- :scheduler (when scheduler (scheduler c))}))
+ [scheduler conf builtins]
+ (let [[inbound broadcast] (scheduler)
+ id (or (:id conf) (str "rt-" (helpers/uuid)))
+ manager {:config (:modules conf)
+ :link (link-fn id broadcast inbound)
+ :cancel? cancel?
+ :module instanciate-module}]
+ {:id id
+ :store (make-store-internal (:store conf) inbound broadcast builtins)
+ :manager manager
+ :server (servers/make-local-server manager)
+ :broadcast broadcast
+ :scheduler inbound}))
(defn make-runtime
([]
- (make-runtime nil nil))
+ (make-runtime nil))
([builtins]
- (make-runtime builtins nil))
+ (make-runtime builtins (fn [] [(pipes/pipe (chan) ::broken) (pipes/pipe (chan) ::broken)])))
([builtins scheduler]
- (let [runtime (-> (make-runtime-internal scheduler)
- (update :store stores/load-builtins! (keys builtins))
- (update :server servers/load-builtins! builtins))
- rt2 (->> (keys builtins)
- (map (partial stores/resolve-name (:store runtime)))
- (map (partial stores/load-by-id (:store runtime)))
- (update runtime :server eval-all))]
- (reset! resolver rt2)
- rt2)))
+ (make-runtime builtins scheduler {}))
+ ([builtins scheduler conf]
+ (p/let [prep (make-runtime-internal scheduler conf builtins)
+ runtime (update prep :server servers/load-builtins! builtins)
+ build-in-names (p/all (map (partial resolve-name runtime) (keys builtins)))
+ asts (p/all (map (partial load-by-id runtime) build-in-names))]
+ (update runtime :server eval-all asts))))
(defn link-storage
""
@@ -161,35 +212,28 @@
;; Evaluation - Dumb and without dependency resolution for now
-(defn persist-to-ids! [store tx-records]
- (-> (stores/persist-tree! store tx-records)
- :tempids
- (dissoc :db/current-tx)
- vals))
+(defn persist-to-ids!
+ ""
+ [store tx-records]
+ (stores/persist-tree! store tx-records))
+
(defn store!
[store tx-records]
- (->> tx-records
- (persist-to-ids! store)
- (map (partial stores/load-by-id store))))
+ (p/let [ids (persist-to-ids! store tx-records)]
+ (p/all (map (partial stores/load-by-id store) ids))))
(defn store-and-eval!
[{store :store server :server :as rt} tx-records]
- (reset! resolver rt)
- (->> tx-records
- (store! store)
- (eval-all server)))
-
-(defn load-by-id
- ""
- [{store :store} id]
- (stores/load-by-id store id))
+ (p/let [asts (store! store tx-records)]
+ (eval-all server asts)))
(defn load-by-sym
""
- [{store :store} sym]
- (when-let [ref (stores/resolve-name store sym)]
- (stores/load-by-id store ref)))
+ [rt sym]
+ (p/let [ref (resolve-name rt sym)]
+ (when ref
+ (load-by-id rt ref))))
(defn load-network
"loads the given network from storage"
@@ -203,45 +247,75 @@
(get-in fn [:samak.nodes/fn :db/id])))
-(defn load-sources-from-bundle
+(defn get-ids-from-source-def
+ [def type-set]
+ (let [deps (filter #(type-set (:samak.nodes/value (:samak.nodes/mapkey %))) def)
+ ;; _ (println "deps" deps)
+ sources (mapcat #(:samak.nodes/mapkv-pairs (:samak.nodes/mapvalue %)) deps)] ;; FIXME, move to db?
+ ;; (println "sources" sources)
+ sources))
+
+
+(defn load-def-from-bundle
""
- [defns]
- (let [kv (:samak.nodes/mapkv-pairs defns)
- sources (:samak.nodes/mapkv-pairs (:samak.nodes/mapvalue (first kv))) ;; FIXME, move to db?
- value (map get-id-from-source-val sources)]
- value))
+ [rt id defns]
+ (p/let [defs (if (= (:samak.nodes/type defns) :samak.nodes/def)
+ (:samak.nodes/rhs defns)
+ (:samak.nodes/definition defns))
+ kvs (:samak.nodes/mapkv-pairs defs)
+ sources (get-ids-from-source-def kvs #{:sources})
+ source-ids (apply sorted-set (map get-id-from-source-val sources))
+ _ (println "### source-ids:" source-ids)
+ sinks (get-ids-from-source-def kvs #{:sinks})
+ sink-ids (apply sorted-set (map get-id-from-source-val sinks))
+ _ (println "### sink-ids:" sink-ids)
+ deps (get-ids-from-source-def kvs #{:depends})
+ dep-ids (mapv get-id-from-source-val deps)
+ _ (println "### dep-ids" dep-ids)
+ deps-source-ids (p/all (map (fn [dep]
+ (println "### dep" dep)
+ (p/let [ast (load-by-id rt dep)]
+ (load-def-from-bundle rt dep ast)))
+ dep-ids))
+ _ (println "### dep-s-id" deps-source-ids)
+ def {id {:depends dep-ids
+ :dependencies deps-source-ids
+ :sinks sink-ids
+ :roots source-ids}}]
+ (println "### def: " def)
+ def))
(defn load-bundle
- "loads the definition of a bundle"
- [{store :store :as rt} sym]
- (let [defns (load-by-sym rt sym)
- value (load-sources-from-bundle (if (= (:samak.nodes/type defns) :samak.nodes/def)
- (:samak.nodes/rhs defns)
- (:samak.nodes/definition defns)))]
- value))
+ "loads the definition of a bundle by the given id"
+ [rt id]
+ (p/let [defns (load-by-id rt id)]
+ (load-def-from-bundle rt id defns)))
(defn eval-expression! [{:keys [store server] :as rt} form]
- (let [new-server (store-and-eval! rt (rewrite-expression "user" form))]
+ (p/let [new-server (store-and-eval! rt (rewrite-expression "user" form))]
(assoc rt :server new-server)))
-(defn resolve-name [runtime sym]
- (-> runtime :store (stores/resolve-name sym)))
+(defn get-definition-by-id [runtime id]
+ (when id
+ (-> runtime :server servers/get-defined (get id))))
(defn get-definition-by-name [runtime sym]
- (let [id (-> runtime :store (stores/resolve-name sym))]
- (-> runtime :server servers/get-defined (get id))))
+ (p/let [id (resolve-name runtime sym)]
+ (get-definition-by-id runtime id)))
+
(defn fire-into-named-pipe
""
[rt pipe-name data timeout]
- (let [pipe (get-definition-by-name rt pipe-name)]
- (if (pipes/pipe? pipe)
- (let [paket (pipes/make-paket data ::fire)
- cancel-id (:samak.pipes/cancel (:samak.pipes/meta paket))]
- (when (> timeout 0)
- (set-cancellation-condition cancel-id {:timeout (helpers/future-ms timeout)}))
- (trace/trace ::fire 0 paket)
- (pipes/fire-raw! pipe paket))
- {:error (str "could not find pipe " pipe-name)})))
+ (println "firing" pipe-name)
+ (p/let [pipe (get-definition-by-name rt pipe-name)]
+ (do (println (:id rt) "pipeis" pipe) (if (pipes/pipe? pipe)
+ (let [paket (pipes/make-paket data ::fire)
+ cancel-id (:samak.pipes/cancel (:samak.pipes/meta paket))]
+ (when (> timeout 0)
+ (set-cancellation-condition cancel-id {:timeout (helpers/future-ms timeout)}))
+ (trace/trace ::fire 0 paket)
+ (pipes/fire-raw! pipe paket))
+ (ex-info "could not find pipe" {:pipe-name pipe-name})))))
diff --git a/src/samak/runtime/servers.cljc b/src/samak/runtime/servers.cljc
index 5879e53..46e26a1 100644
--- a/src/samak/runtime/servers.cljc
+++ b/src/samak/runtime/servers.cljc
@@ -8,23 +8,30 @@
:cljs
[(:require [clojure.core.async :as a]
[cljs.reader :as edn]
- [samak.protocols :as p]
[samak.pipes :as pipes]
[samak.nodes :as n])]))
(defprotocol SamakServer
- (add-manager [this man])
(eval-ast [this ast])
(get-defined [this])
(load-builtins [this builtins])
(unload [this ids]))
+
(defrecord LocalSamakServer [defined-ids builtins manager]
SamakServer
(eval-ast [this {:keys [db/id] :as ast}]
- (update this :defined-ids assoc id (n/eval-env (get this :manager) builtins ast id)))
- (get-defined [_]
- defined-ids)
+ ;; (println "eval <-" id ast)
+ (let [defs (atom (get-defined this))
+ man (merge (get this :manager)
+ {:resolve (fn [x] (get @defs x))
+ :register (fn [did def] (swap! defs assoc did def))})
+ def (n/eval-env man builtins ast id)]
+ (swap! defs assoc id def)
+ ;; (println "eval ->" id def)
+ (assoc this :defined-ids @defs)))
+ (get-defined [this]
+ (get this :defined-ids))
(load-builtins [this builtins]
(update this :builtins merge builtins))
(unload [this ids]
diff --git a/src/samak/runtime/stores.cljc b/src/samak/runtime/stores.cljc
index 73ba03a..368ccfa 100644
--- a/src/samak/runtime/stores.cljc
+++ b/src/samak/runtime/stores.cljc
@@ -1,6 +1,21 @@
(ns samak.runtime.stores
- (:require [samak.code-db :as db]
- [samak.api :as api]))
+ #?@
+ (:clj
+ [(:require [promesa.core :as p]
+ [clojure.core.async :as a :refer [! put! chan go go-loop close!]]
+ [clojure.edn :as edn]
+ [samak.code-db :as db]
+ [samak.api :as api]
+ [samak.pipes :as pipes]
+ [clojure.core.async :as a])]
+ :cljs
+ [(:require [promesa.core :as p]
+ [clojure.core.async :as a :refer [! put! chan close!]]
+ [cljs.reader :as edn]
+ [samak.code-db :as db]
+ [samak.api :as api]
+ [samak.pipes :as pipes])
+ (:require-macros [cljs.core.async.macros :refer [go go-loop]])]))
(defprotocol SamakStore
(persist-tree! [this tree])
@@ -11,17 +26,128 @@
(defrecord LocalSamakStore [db]
SamakStore
(persist-tree! [_ tree]
- (db/parse-tree->db! db tree))
+ (p/resolved
+ (-> (db/parse-tree->db! db tree)
+ :tempids
+ (dissoc :db/current-tx)
+ vals)))
(load-by-id [_ id]
- (db/load-by-id db id))
+ (p/resolved (db/load-recurse db id)))
(load-network [_ id]
- (db/load-network db id))
+ (p/resolved (db/load-network db id)))
(resolve-name [_ db-name]
- (db/resolve-name db db-name)))
+ (p/resolved (db/resolve-name db db-name))))
+
+(def resolve-cache (atom {}))
+
+(defrecord RemoteSamakStore [db in out counter]
+ SamakStore
+
+ (persist-tree! [_ tree]
+ (let [prom (p/deferred)
+ id (swap! counter inc)
+ c (chan)]
+ (a/tap (pipes/out-port in) c)
+ ;; (println "req persist" id "-" tree)
+ (put! (pipes/in-port out) {:samak.runtime/type :samak.runtime/store :cmd :persist-tree :args {:id id :tree tree}})
+ (go-loop [] ;;FIXME timeouts leak
+ (when-let [i (! chan go go-loop close! put! pipe]]
+ [promesa.core :as p]
+ [samak.api :as api]
+ [samak.helpers :as helpers]
+ [samak.builtins :as builtins]
+ [samak.stdlib :as std]
+ [samak.pipes :as pipes]
+ [samak.runtime :as run])]
+ :cljs
+ [(:require
+ [clojure.string :as str]
+ [clojure.core.async :as a :refer [! chan close! put! pipe]]
+ [promesa.core :as p]
+ [samak.api :as api]
+ [samak.helpers :as helpers]
+ [samak.pipes :as pipes]
+ [samak.runtime :as run])
+ (:require-macros [cljs.core.async.macros :refer [go go-loop]])]))
+
+(defn make-pipe-id
+ ""
+ [name]
+ {:target :pipe :named name})
+
+(defn module-id
+ ""
+ [sym]
+ (keyword (str "dynamic-" (name sym))))
+
+(defn load-module
+ ""
+ [rt mod]
+ (p/let [sources (p/all (map #(run/load-network rt %) (:roots mod)))
+ net (reduce (fn [a, v]
+ (let [val (vals v)]
+ {:nodes (into (:nodes a) (flatten [(map :xf val) (map :ends val)]))
+ :pipes (into (:pipes a) (map :db/id (flatten (map :pipes val))))
+ }))
+ {:nodes (into [] (:roots mod))
+ :pipes []}
+ sources)]
+ {:nodes (distinct (:nodes net))
+ :pipes (distinct (:pipes net))}))
+
+(defn load-deps
+ ""
+ [rt [id mod]]
+ (println "### load-deps" id mod)
+ (p/let [deps (p/all (mapv (fn [m] (load-deps rt (first m))) (:dependencies mod)))
+ roots (load-module rt mod)]
+ {:id id
+ :deps deps
+ :sinks (:sinks mod)
+ :sources (:roots mod)
+ :roots roots}))
+
+
+(defn load-bundle-by-id
+ ""
+ [rt bundle-id]
+ (p/let [_ (println " V" "Bundle id:" bundle-id)
+ ast (run/load-bundle rt bundle-id)
+ bundle (get ast bundle-id)
+ _ (println "### bundle: " bundle)
+ deps (load-deps rt [bundle-id bundle])]
+ deps))
+
+(defn load-bundle
+ ""
+ [rt sym]
+ (p/let [_ (println " V" "Fetching bundle from DB:" sym)
+ bundle-id (run/resolve-name rt sym)
+ deps (load-bundle-by-id rt bundle-id)]
+ deps))
+
+(defn eval-module
+ ""
+ [rt conf module root]
+ (if (contains? conf (:id module))
+ (println "### skipping" (:id module))
+ (p/do!
+ ;; (println "eval" (:id module) "->" module)
+ (p/all (map #(eval-module rt conf % (:id %)) (:deps module)))
+ (println "### loading" (:id module))
+ (p/let [roots (:roots module)
+ base (if root [root] [])
+ root-ids (into (into base (:nodes roots)) (:pipes roots))
+ _ (println "[" (:id module) "] roots" root-ids)
+ asts (p/all (map #(run/load-ast @rt %) root-ids))]
+ (println "### evaling" (:id module))
+ (reset! rt (update @rt :server run/eval-all asts))
+ (println "### done" (:id module))))))
+
+(defn run-module
+ ""
+ [rt id sym]
+ (let [mod (run/get-definition-by-id @rt id)
+ exp [(assoc (api/fn-call {:db/id id} []) :db/id sym)]]
+ (reset! rt (update @rt :server run/eval-all exp))))
+
+(defn setup-out
+ ""
+ [rt [key pipe]]
+ (println (:id @rt) "### setup out" key)
+ (let [wrap (pipes/transduction-pipe (map (run/wrap-out {:named key} :setup)) (str "scheduler-out-" key))]
+ (pipes/link! pipe wrap)
+ (pipes/link! wrap (:broadcast @rt))))
+
+
+(defn setup-outs
+ ""
+ [rt mod]
+ (doall (map (partial setup-out rt) (:sinks mod))))
+
+
+(defn eval-run-module
+ ""
+ [rt conf net sym]
+ (p/let [mod-name (module-id 'lone)]
+ (eval-module rt conf net (:id net))
+ (println (:id @rt) "### module" sym "done \\o/")
+ (run-module rt (:id net) mod-name)
+ (let [mod (run/resolve-fn @rt mod-name)]
+ (println (:id @rt) "mod" mod-name mod)
+ (setup-outs rt mod))))
+
+
+(defn start-module
+ [rt conf sym]
+ (p/let [net (load-bundle @rt sym)]
+ (eval-run-module rt conf net sym)))
diff --git a/src/samak/stdlib.cljc b/src/samak/stdlib.cljc
index 29e2dcf..d89e50d 100644
--- a/src/samak/stdlib.cljc
+++ b/src/samak/stdlib.cljc
@@ -31,11 +31,17 @@
(:require-macros [cljs.core.async.macros :refer [go go-loop]])]))
+
+
;; Utility helper
(defn debug
- ([] (pipes/pipe (chan)))
- ([spec] (pipes/checked-pipe (debug) spec spec)))
+ ([] (debug (helpers/uuid)))
+ ([id] (debug id nil))
+ ([id spec]
+ (if spec
+ (pipes/checked-pipe (debug) spec spec id)
+ (pipes/pipe (pipes/pipe-chan id nil) id))))
(defn log-through
([]
@@ -44,20 +50,21 @@
(pipes/transduction-pipe
(map (if prefix
(fn [x] (tools/log prefix x) x)
- (fn [x] (tools/log x) x))))))
+ (fn [x] (tools/log x) x)))
+ (str "logthrough-" prefix))))
(defn log
([] (log (rand-int 100000)))
([prefix]
- (let [log-chan (chan)]
+ (let [log-chan (pipes/pipe-chan prefix nil)]
(go-loop []
(when-let [x (db! db args))
-
-;; (defn db-query [db query]
-;; (pipes/async-pipe (query-call db query) nil nil))
-
-
-;; Runtime
-
-(def notify-chan (chan 1))
-
-(defn notify-source
- ([ast]
- (notify-source ast nil))
- ([ast cb]
- (if cb
- (put! notify-chan (pipes/make-paket ast ::notify) cb)
- (put! notify-chan (pipes/make-paket ast ::notify)))))
-
-(defn eval-notify
- ""
- []
- (let [source (chan 1)]
- (a/pipeline 1 source (map (fn [x] (println "ast in: " x) x)) notify-chan)
- (pipes/source source)))
-
-
-;; TODO: don't think this belongs here
-
-#_(defn eval-line-call
- ""
- [input]
- (doseq [expression (lp/parse input)]
- (notify-source expression)))
-
-#_(defn eval-line
- ""
- []
- (let [log-chan (chan)]
- (go-loop []
- (when-let [x ( f p/eval-as-fn wrap-samak-reducer)
(tt/re-wrap (pipes/make-meta {:samak.pipes/source ::reductions})
- init))))
+ init))
+ (str "reductions-" (helpers/uuid))))
(def pipe-symbols
@@ -163,8 +114,4 @@
'pipes/log-through log-through
'pipes/debug debug
'pipes/http http
- 'pipes/eval-notify eval-notify
-
- ;; 'pipes/eval-line eval-line
-
'pipes/reductions reductions*})
diff --git a/src/samak/test_programs.cljc b/src/samak/test_programs.cljc
index 3c38b5b..4dc5e1b 100644
--- a/src/samak/test_programs.cljc
+++ b/src/samak/test_programs.cljc
@@ -72,15 +72,15 @@
"(def out (pipes/log))"
"(def out2 (pipes/log))"
"(def incinc (-> (inc _) (inc _)))"
- "(| in incinc out2)"
"(| in incinc out)"
- "(def tl {:source {:main in}
- :tests {:test {:when {\"in\" [1]}
- :then {\"out\" [(-> (incase (= 3 _) :success))]
- \"out2\" [(-> (incase (= 3 _) :success))]}}
- :test2 {:when {\"in\" [3]}
- :then {\"out\" [(-> (incase (= 5 _) :success))]}}
+ "(| in incinc out2)"
+ "(defmodule tl {:sources {:main in :out out :out2 out2} :sinks {:out out :out2 out2}
+ :tests {:test {:when {\"in\" [1]}
+ :then {\"out\" [(-> (incase (= 3 _) :success))]
+ \"out2\" [(-> (incase (= 3 _) :success))]}}
}})"])
+ ;; :test2 {:when {\"in\" [3]}
+ ;; :then {\"out\" [(-> (incase (= 5 _) :success))]}}
(def test-local-modules
[
@@ -93,25 +93,56 @@
(def test-builtin-modules
["(def in (pipes/debug))"
- "(def mod (modules/caravan))"
- "(def a (-> mod :-sinks :-actions))"
- "(| in (a 42))"
- "!f in \"!!!\""
+ "(def out (pipes/log))"
+ "(def mod ((modules/caravan)))"
+ "(def a ((-> mod :-sinks :-actions) 42))"
+ "(def b ((-> mod :-sources :-commands) 42))"
+ "(| in a)"
+ "(| b out)"
+ "!f in {:ping 1}"
])
(def test-local-modules-test
- [
- "(def in (pipes/debug))"
+ ["(def in (pipes/debug))"
"(def out (pipes/debug))"
"(| in (inc _) out)"
"(defmodule bar {:sources {:in in}
:sinks {:out out}
:tests {:t1 {:when {\"in\" [1]}
- :then {\"out\" [(incase 2 :success)]}}}
+ :then {\"out\" [(incase (= 2 _) :success)]}}}
})"
])
+
(def test-builtin-modules-test
+ ["(def in (pipes/debug))"
+ "(def out (pipes/debug))"
+ "(def mod ((modules/caravan)))"
+ "(def act (-> mod :-sinks :-actions))"
+ "(def cmd (-> mod :-sources :-commands))"
+ "(def a (act 42))"
+ "(def b (cmd 42))"
+ "(| in a)"
+ "(| b out)"
+ "(defmodule bar {:sources {:in in :b b}
+ :sinks {:out out}
+ :tests {:t1 {:when {\"in\" [:ping]}
+ :then {\"out\" [(-> (spy \"pong\") (incase (= :pong :-event) :success))]}}}
+ })"
+ ])
+
+(def test-local-modules-multi-test
+ ["(def in (pipes/debug))"
+ "(def out (pipes/debug))"
+ "(| in (inc _) out)"
+ "(defmodule bar {:sources {:in in}
+ :sinks {:out out}
+ :tests {:t1 {:when {\"in\" [1]}
+ :then {\"out\" [(incase (= 2 _) :success)]}}}
+ })"
+ ])
+
+(def test-nested-modules-test
["(def in (pipes/debug))"
"(def out (pipes/debug))"
"(def mod ((modules/caravan) 42))"
@@ -119,9 +150,57 @@
"(def b ((-> mod :-sources :-commands) 42))"
"(| in a)"
"(| b out)"
- "(def bar {:sources {:in in :fake b}
- :tests {:test {:when {\"in\" [{:ping :me}]}
- :then {\"out\" [(incase (:-pong _) :success)]}}}})"
+ "(defmodule bar {:depends {:caravan modules/caravan}
+ :sources {:in in :b b :mod mod}
+ :sinks {:out out}
+ :tests {:t1 {:when {\"in\" [1]}
+ :then {\"out\" [(incase (= 2 _) :success)]}}}})"
+ "(def s (pipes/debug))"
+ "(def t (pipes/debug))"
+ "(| s t)"
+ "(defmodule quux {:sources {:s s}
+ :sinks {:t t}
+ :tests {:t1 {:when {\"s\" [1]}
+ :then {\"t\" [(incase 1 :success)]}}}})"
+ "(def barmod (bar))"
+ "(def quuxmod (quux))"
+ "(def x (pipes/debug))"
+ "(def quuxin ((-> barmod :-sources :-in) 42))"
+ "(def quuxout ((-> barmod :-sources :-in) 42))"
+ "(def barin ((-> barmod :-sources :-in) 42))"
+ "(def barout ((-> barmod :-sinks :-out) 42))"
+ "(| x quuxin)"
+ "(| x barin)"
+ "(defmodule baz {:depends {:bar bar :quux quux}
+ :sources {:x x :barmod barmod}
+ :tests {:t1 {:when {\"in\" [1]}
+ :then {\"out\" [(incase 2 :success)]}}}})"
+ ;; "!f in \"!!!\""
+ ])
+
+(def test-nested-modules-multi-test
+ ["(def in (pipes/debug))"
+ "(def out (pipes/debug))"
+ "(def red (pipes/reductions (+ :-next :-state) 0))"
+ "(| in red)"
+ "(| red out)"
+ "(defmodule bar {:sources {:in in :b b :mod mod}
+ :sinks {:out out}
+ :tests {:t1 {:when {\"in\" [1]}
+ :then {\"out\" [(incase (= 2 _) :success)]}}}})"
+ "(def x (pipes/debug))"
+ "(def barmod (bar))"
+ "(def barin ((-> barmod :-sources :-in) 42))"
+ "(def barout ((-> barmod :-sinks :-out) 42))"
+ "(def barmod2 (bar))"
+ "(def barin2 ((-> barmod2 :-sources :-in) 42))"
+ "(def barout2 ((-> barmod2 :-sinks :-out) 42))"
+ "(| x barin)"
+ "(| x barin2)"
+ "(defmodule baz {:depends {:bar bar}
+ :sources {:x x :barmod barmod :barmod2 barmod2}
+ :tests {:t1 {:when {\"x\" [1]}
+ :then {\"barin\" [(incase false :success)]}}}})"
;; "!f in \"!!!\""
])
@@ -163,7 +242,7 @@
(| in joke-list)
(| joke-list render-ui ui-out)
- (def chuck {:sources {:main in
+ (defmodule chuck {:sources {:main in
:ui-in ui-in
:http-in http-in}
:tests {
diff --git a/src/samak/trace.cljc b/src/samak/trace.cljc
index 9fdb215..9062308 100644
--- a/src/samak/trace.cljc
+++ b/src/samak/trace.cljc
@@ -2,19 +2,22 @@
#?(:clj
(:require [clojure.spec.alpha :as s]
[clojure.walk :as w]
+ [promesa.core :as prom]
[samak.zipkin :as tracing]
[samak.trace-db :as db]
[samak.helpers :as helper]
[samak.tools :as tools]
[samak.api :as api]
- [samak.runtime.stores :as store])
+ ;; [samak.runtime.stores :as store]
+ )
:cljs
(:require [cljs.spec.alpha :as s]
[clojure.walk :as w]
+ [promesa.core :as prom]
[samak.zipkin :as tracing]
[samak.trace-db :as db]
[samak.helpers :as helper]
- [samak.runtime.stores :as store]
+ ;; [samak.runtime.stores :as store]
[samak.api :as api]
[samak.tools :as tools])))
@@ -39,25 +42,19 @@
(reset! tracer {:trace-fn (fn [t x] (println pre x) t)}))))
-(defn load-ast
- "loads an ast given by its entity id from the database"
- [rt id]
- (w/postwalk (fn [form]
- (if-let [sub-id (when (and (map? form) (= (keys form) [:db/id]))
- (:db/id form))]
- (store/load-by-id rt sub-id)
- form))
- (store/load-by-id rt id)))
-
(defn node-as-str
""
[node]
- (if (number? node)
- (let [ast (load-ast (:store @rt) node)]
- (if (api/is-def? ast)
- (str "(" node ") " (:samak.nodes/name ast))
- (str ast)))
- node))
+ ;; (if (number? node) ;; split into own ns
+ ;; (prom/let [ast (store/load-by-id (:store @rt) node)]
+ ;; (if (api/is-def? ast)
+ ;; (str "(" node ") " (:samak.nodes/name ast))
+ ;; (if (api/is-def? (:samak.nodes/fn ast))
+ ;; (str "(" node ") " (:samak.nodes/name (:samak.nodes/fn ast)))
+ ;; (str ast))))
+ ;; node)
+ node
+ )
(defn make-trace
""
@@ -81,7 +78,8 @@
""
[db-id duration event]
(if-not (:samak.pipes/uuid (:samak.pipes/meta event))
- (println "assert failed:" event))
+ (when event
+ (println "no traceable event:" event)))
(when @tracer
(let [data (make-trace db-id duration event)]
(reset! tracer ((:trace-fn @tracer) @tracer (to-tracer data)))))
diff --git a/test/samak/caravan_test.cljc b/test/samak/caravan_test.cljc
index e84bc56..d4c12b2 100644
--- a/test/samak/caravan_test.cljc
+++ b/test/samak/caravan_test.cljc
@@ -5,10 +5,12 @@
[samak.oasis :as oasis]
[samak.core :as core]
[samak.runtime :as rt]
- [samak.test-programs :as test-programs]
+ [samak.test-programs :as test-programs]
[samak.code-db :as db]
[samak.utils :as utils]
[samak.trace :as trace]
+ [samak.scheduler :as sched]
+ [promesa.core :as p]
#?(:clj [clojure.core.async :as a :refer [ r
- (sut/eval-expression! def-node)
- :store
- (stores/resolve-name 'quux))]
+ (p/let [init (sut/make-runtime)
+ rt (sut/eval-expression! init def-node)
+ k (stores/resolve-name (:store rt) 'quux)]
(is (number? k))))
@@ -40,10 +42,10 @@
:arguments []}})
(deftest should-eval-pipe-node
- (let [r (sut/make-runtime {'pipes/debug std/debug
- 'pipes/log std/log})
- new-state (sut/eval-expression! r pipe-node)
- defined-things (-> new-state :server servers/get-defined vals)]
+ (p/let [r (sut/make-runtime {'pipes/debug std/debug
+ 'pipes/log std/log})
+ new-state (sut/eval-expression! r pipe-node)
+ defined-things (-> new-state :server servers/get-defined vals)]
(is (some samak.pipes/pipe? defined-things))))
(def other-def-node
@@ -53,10 +55,10 @@
:value "foo"}})
(deftest should-keep-existing-symbols
- (let [r (-> (sut/make-runtime)
- (sut/eval-expression! def-node)
- (sut/eval-expression! other-def-node))
- vs (-> r :server servers/get-defined vals)]
+ (p/let [r (-> (sut/make-runtime)
+ (p/then #(sut/eval-expression! % def-node))
+ (p/then #(sut/eval-expression! % other-def-node)))
+ vs (-> r :server servers/get-defined vals)]
(is (= (set vs) #{"quux" "foo"}))))
(def referring-node
@@ -65,23 +67,38 @@
:rhs [:samak.nodes/name 'quux]})
(deftest should-resolve-symbols
- (let [vs (-> (sut/make-runtime)
- (sut/eval-expression! def-node)
- (sut/eval-expression! referring-node)
- :server
- servers/get-defined
- vals)]
+ (p/let [rt (-> (sut/make-runtime)
+ (sut/eval-expression! def-node)
+ (sut/eval-expression! referring-node))
+ vs (-> rt
+ :server
+ servers/get-defined
+ vals)]
(is (= 2 (count vs)))
(is (apply = vs))))
(deftest should-retrieve-definitions-by-name
- (let [r (-> (sut/make-runtime)
- (sut/eval-expression! other-def-node))]
- (is (= 1 (stores/resolve-name (:store r) 'foo)))))
+ (p/let [init (sut/make-runtime)
+ rt (sut/eval-expression! init other-def-node)
+ n (stores/resolve-name (:store rt) 'foo)]
+ (is (= 1 n))))
(deftest should-persist-builtins
- (is (= inc (-> (sut/make-runtime {'inc inc 'dec dec})
- :server
- servers/get-defined
- (get 1)))))
+ (utils/test-promise (p/then (sut/make-runtime {'inc inc 'dec dec})
+ #(is (=
+ inc
+ (-> %
+ :server
+ servers/get-defined
+ (get 1)))))))
+
+
+(deftest should-load-def-from-bundle
+ (utils/test-promise
+ (p/let [code [(api/defmodule 'test (api/map {(api/keyword :sources) (api/map {(api/keyword :test1) (api/symbol 'inc)})}))]
+ rt (sut/make-runtime core/samak-symbols)
+ _ (sut/persist-to-ids! (:store rt) code)
+ defns (sut/load-by-sym rt 'test)
+ def (sut/load-def-from-bundle rt 'test defns)]
+ (is (= {'test {:depends [], :dependencies [], :sinks #{}, :roots #{151}}} def)))))
diff --git a/test/samak/scheduler_test.cljc b/test/samak/scheduler_test.cljc
new file mode 100644
index 0000000..c794727
--- /dev/null
+++ b/test/samak/scheduler_test.cljc
@@ -0,0 +1,25 @@
+(ns samak.scheduler-test
+ (:require [samak.scheduler :as sut]
+ #?(:clj [clojure.test :as t]
+ :cljs [cljs.test :as t :include-macros true])
+ [clojure.string :as s]
+ [promesa.core :as prom]
+ [samak.core :as core]
+ [samak.lisparser :as p]
+ [samak.runtime :as rt]
+ [samak.test-programs :as test-programs]
+ [samak.utils :as utils]))
+
+(t/deftest should-load-module
+ (utils/test-promise
+ (prom/then (prom/let [rt (rt/make-runtime core/samak-symbols)
+ parsed (p/parse-all (s/join " " test-programs/tl6))
+ _ (rt/persist-to-ids! (:store rt) (:value parsed))
+ bundle-id (rt/resolve-name rt 'tl)]
+ (sut/load-bundle-by-id rt bundle-id))
+ #(t/is (= {:id 227,
+ :deps [],
+ :sinks #{200 203},
+ :sources #{197 200 203},
+ :roots {:nodes '(197 200 203 206), :pipes '(219 223)}}
+ %)))))
diff --git a/test/samak/utils.cljc b/test/samak/utils.cljc
index b971d74..31559a7 100644
--- a/test/samak/utils.cljc
+++ b/test/samak/utils.cljc
@@ -2,7 +2,8 @@
(:require #?(:clj [clojure.core.async :as a :refer [! chan go go-loop close!]]
+ [clojure.core.async :as a :refer [! put! chan go go-loop close!]]
+ [promesa.core :as prom]
[samak.test-programs :as test-programs]
[samak.api :as api]
+ [samak.helpers :as helpers]
[samak.lisparser :as p]
+ [samak.scheduler :as sched]
[samak.runtime :as rt]
[samak.runtime.servers :as servers]
[samak.pipes :as pipes]
@@ -22,10 +25,13 @@
:cljs
[(:require [clojure.string :as s]
[clojure.walk :as w]
- [clojure.core.async :as a :refer [! chan close!]]
+ [clojure.core.async :as a :refer [! put! chan close!]]
+ [promesa.core :as prom]
[samak.test-programs :as test-programs]
[samak.api :as api]
+ [samak.helpers :as helpers]
[samak.lisparser :as p]
+ [samak.scheduler :as sched]
[samak.runtime :as rt]
[samak.runtime.servers :as servers]
[samak.pipes :as pipes]
@@ -37,8 +43,10 @@
[samak.tools :as tools])
(:require-macros [cljs.core.async.macros :refer [go go-loop]])]))
-(def rt-conn (atom {}))
-(def rt-preview (atom {}))
+(def rt-conn (atom {:state :uninited}))
+
+(def rt-link-fn (atom nil))
+
(def fns (atom {}))
(def net (atom {}))
@@ -174,8 +182,13 @@
(defn notify-source
""
- [src]
- (doall (map (fn [[key val]] (std/notify-source {(str key) val})) src)))
+ ([c src]
+ (notify-source c src nil))
+ ([c src cb]
+ (doall (map (fn [[key val]] (if cb
+ (put! c (pipes/make-paket {(str key) val} ::notify) cb)
+ (put! c (pipes/make-paket {(str key) val} ::notify))))
+ src))))
(defn is-sink?
@@ -191,16 +204,16 @@
is-stdlib
(not is-reductions))))
-(defn reset-rt
- ""
- [rt]
- (reset! rt (rt/make-runtime (merge builtins/samak-symbols
- symbols
- std/pipe-symbols)))
- (reset! rt (reduce rt/eval-expression! @rt (vals @net)))
- (let [p (rt/get-definition-by-name @rt (symbol "start"))
- r (when p (pipes/fire! p 1 ::init))]
- (println (str "fire2! " p " - " r))))
+;; (defn reset-rt
+;; ""
+;; [rt]
+;; (reset! rt (rt/make-runtime (merge builtins/samak-symbols
+;; symbols
+;; std/pipe-symbols)))
+;; (reset! rt (reduce rt/eval-expression! @rt (vals @net)))
+;; (let [p (rt/get-definition-by-name @rt (symbol "start"))
+;; r (when p (pipes/fire! p 1 ::init))]
+;; (println (str "fire2! " p " - " r))))
(defn format-node
""
@@ -209,17 +222,17 @@
ast (make-cell-list fn)]
(if (empty? ast)
(println (str "ERROR: no ast for: " sym " - " fn))
- {(str sym) {:caravan/type type
- :caravan/name (str sym)
- :caravan/ast ast}})))
+ {sym {:caravan/type type
+ :caravan/id sym
+ :caravan/name (:samak.nodes/name fn)
+ :caravan/ast ast}})))
+
(defn add-node
""
[sym fn]
;; (println (str "function cache: " (keys @fns)))
(swap! fns assoc sym fn)
(swap! rt-conn #(update % :server rt/eval-all [fn]))
- ;; (swap! rt-preview rt/link-storage (:store @rt-conn))
- ;; (reset-rt rt-preview)
(format-node sym fn))
(defn name-of-node
@@ -245,12 +258,18 @@
xf (:samak.nodes/xf pipe)
func (if xf (name-of-node xf) nil)
sink (name-of-node (:samak.nodes/to pipe))
- pipe-name (str source "-" func "-" sink)]
- {pipe-name {:caravan/type :caravan/pipe
- :caravan/name pipe-name
- :caravan/source source
- :caravan/func func
- :caravan/sink sink}}))
+ pipe-name (str source "-" func "-" sink)
+ id (:db/id pipe)]
+ {id {:caravan/type :caravan/pipe
+ :caravan/id id
+ :caravan/name pipe-name
+ :caravan/source (:db/id (:samak.nodes/fn (:samak.nodes/from pipe)))
+ :caravan/source-name source
+ :caravan/func (:db/id (:samak.nodes/fn xf)) ;;This might be wrong?
+ :caravan/func-name func
+ :caravan/sink (:db/id (:samak.nodes/fn (:samak.nodes/to pipe)))
+ :caravan/sink-name sink
+ }}))
(defn add-pipe
@@ -263,21 +282,21 @@
(println (str "adding pipe from " source " with " func " to " sink))
(when (and source func sink)
;; (swap! net assoc key pipe)
- ;; (swap! rt-preview rt/link-storage (:store @rt-conn))
- (swap! rt-conn rt/eval-expression! pipe)
- ;; (reset-rt rt-preview)
+ (swap! rt-conn #(update % :server rt/eval-all [pipe]))
(format-pipe pipe))))
(defn load-ast
"loads an ast given by its entity id from the database"
[rt id]
- (w/postwalk (fn [form]
- (if-let [sub-id (when (and (map? form) (= (keys form) [:db/id]))
- (:db/id form))]
- (rt/load-by-id rt sub-id)
- form))
- (rt/load-by-id rt id)))
+ (rt/load-by-id rt id)
+ ;; (w/postwalk (fn [form]
+ ;; (if-let [sub-id (when (and (map? form) (= (keys form) [:db/id]))
+ ;; (:db/id form))]
+ ;; (rt/load-by-id rt sub-id)
+ ;; form))
+ ;; (rt/load-by-id rt id))
+ )
(defn persist!
@@ -289,16 +308,19 @@
(defn single!
""
[exp]
- (let [loaded (persist! @rt-conn [(assoc exp :db/id -1)])
- ast (load-ast @rt-conn (:db/id (first loaded)))]
+ (prom/let [loaded (persist! @rt-conn [(assoc exp :db/id -1)])
+ _ (println "### single" loaded)
+ ast (load-ast @rt-conn (:db/id (first loaded)))]
ast))
(defn repl-eval
[exp]
- (if (api/is-pipe? exp)
- (notify-source (add-pipe exp))
- (let [loaded (single! exp)]
- (notify-source (add-node (symbol (str (:samak.nodes/name exp))) loaded)))))
+ (throw (str "broken: " exp))
+ ;; (if (api/is-pipe? exp)
+ ;; (notify-source (add-pipe exp))
+ ;; (let [loaded (single! exp)]
+ ;; (notify-source (add-node (symbol (str (:samak.nodes/name exp))) loaded))))
+ )
(defn find-cell-internal
@@ -382,8 +404,8 @@
(defn add-cell
""
- [{:keys [sym cell type] :as x}]
- (println (str "adding: " x))
+ [ev {:keys [sym cell type] :as x}]
+ (println (str "### adding: " x))
(let [src (get @fns (symbol sym))
idx (dec cell)]
(when (and sym src idx type)
@@ -395,10 +417,10 @@
updated (if (is-mapish cell)
(add-map (if (is-map-node cell) cell par) (- idx 1 par-idx) content)
(add-list (if (is-listy-node cell) cell par) content))]
- (let [write (persist! @rt-conn [updated])
- exp (load-ast @rt-conn root-id)]
+ (prom/let [write (persist! @rt-conn [updated])
+ exp (load-ast @rt-conn root-id)]
(println (str "res: " exp))
- (notify-source (add-node (symbol sym) exp))
+ (notify-source ev (add-node (symbol sym) exp))
:done)))))
(defn value-from-type
@@ -413,7 +435,7 @@
(defn edit-cell
""
- [{:keys [sym cell value] :as x}]
+ [ev {:keys [sym cell value] :as x}]
(println (str "editing: " x))
(let [src (get @fns (symbol sym))
idx (dec cell)]
@@ -421,10 +443,10 @@
(let [[cell par] (add-cell-internal src idx)
root-id (:db/id src)
updated (value-from-type cell value)]
- (let [write (persist! @rt-conn [updated])
- exp (load-ast @rt-conn root-id)]
+ (prom/let [write (persist! @rt-conn [updated])
+ exp (load-ast @rt-conn root-id)]
(println (str "res: " exp))
- (notify-source (add-node (symbol sym) exp)))))))
+ (notify-source ev (add-node (symbol sym) exp)))))))
(defn change-order
@@ -437,7 +459,7 @@
(defn swap-cell
""
- [{:keys [:sym :cell-idx :target] :as x}]
+ [ev {:keys [:sym :cell-idx :target] :as x}]
(println (str "swap: " x))
(let [src (get @fns (symbol sym))
idx (dec cell-idx)]
@@ -449,10 +471,10 @@
sorted-args (vec (sort-by :order (get par (get-child-key par)))) ;; need to make a copy because sort-by is inplace sometimes
changed (change-order sorted-args arg-source-idx arg-target-idx)
node (assoc par (get-child-key par) changed)]
- (let [write (persist! @rt-conn [node])
- exp (load-ast @rt-conn root-id)]
+ (prom/let [write (persist! @rt-conn [node])
+ exp (load-ast @rt-conn root-id)]
(println (str "res: " exp))
- (notify-source (add-node (symbol sym) exp)))
+ (notify-source ev (add-node (symbol sym) exp)))
))))
(defn remove-arg
@@ -467,7 +489,7 @@
(defn cut-cell
""
- [{:keys [sym cell-idx] :as x}]
+ [ev {:keys [sym cell-idx] :as x}]
(println (str "cut: " x))
(let [src (get @fns (symbol sym))
idx (dec cell-idx)]
@@ -479,15 +501,15 @@
updated (assoc par (get-child-key par) removed-args)
target-node (some #(when (= (:order %) arg-idx) %) (get par (get-child-key par)))
retract [:db/retract (:db/id par) (get-child-key par) (:db/id target-node)]]
- (let [write (persist! @rt-conn [updated retract])
- exp (load-ast @rt-conn root-id)]
+ (prom/let [write (persist! @rt-conn [updated retract])
+ exp (load-ast @rt-conn root-id)]
(println (str "res: " exp))
- (notify-source (add-node (symbol sym) exp))
+ (notify-source ev (add-node (symbol sym) exp))
:done)))))
(defn indent-cell
""
- [{:keys [sym cell-idx] :as x}]
+ [ev {:keys [sym cell-idx] :as x}]
(println (str "indent: " x))
(let [src (get @fns (symbol sym))
idx (dec cell-idx)]
@@ -512,91 +534,51 @@
retract [:db/retract (:db/id par) (get-child-key par) (:db/id own-arg)]
;; _ (println (str "retract: " retract))
]
- (let [write (persist! @rt-conn [insertion fixup retract])
- exp (load-ast @rt-conn root-id)]
+ (prom/let [write (persist! @rt-conn [insertion fixup retract])
+ exp (load-ast @rt-conn root-id)]
(println (str "res: " exp))
- (notify-source (add-node (symbol sym) exp))
+ (notify-source ev (add-node (symbol sym) exp))
:done)))))))
-(defn create-sink
- ""
- []
- (fn [x]
- (println "create sink: " x)
- (let [pipe-name (:name x)
- sym (str pipe-name "-" (rand-int 1000000000))
- exp (api/defexp (symbol sym) (api/fn-call (api/symbol (symbol (str "pipes/" pipe-name))) nil))
- ast (single! exp)]
- (println (str "res: " ast))
- (notify-source (add-node (symbol sym) ast))
- :okay)))
-
-(defn disconnect
- ""
- []
- (println "disconnect"))
-
-(defn connect
- ""
- [source connector sink]
- ;; (println (str "connect " source " with " connector " to " sink))
- (let [fn (api/defexp (symbol connector) (api/symbol '_))
- fn-ast (single! fn)
- pipe (api/pipe (api/symbol (symbol source))
- (api/symbol (symbol connector))
- (api/symbol (symbol sink)))]
- (notify-source (add-node (symbol connector) fn-ast))
- (notify-source (add-pipe pipe))))
-
-
-(defn link
- ""
- []
- (fn [{:keys [:source :sink] :as x}]
- (println "connect: " x)
- (let [connector (str "c-" source "-" sink)
- pipe-key (make-pipe-key source connector sink)
- existing (contains? @net pipe-key)]
- (when (and sink source (not= sink source) )
- (if existing
- (disconnect)
- (connect source connector sink))))))
-
(defn link-pipes
""
[from to xf]
- (rt/link-fn from
- to
- (when xf (pipes/transduction-pipe (pipes/instrument :caravan/adhoc nil xf)))))
+ ((:link (:manager @rt-conn))
+ from
+ to
+ (when xf (pipes/transduction-pipe (pipes/instrument :caravan/adhoc nil xf) (str (pipes/uuid from) "-" (pipes/uuid to))))))
(defn find-tests
""
[conf]
- (println "conf " conf)
+ (println "### conf " conf)
(when conf
- (let [is-module (= (:samak.nodes/type conf) :samak.nodes/module)
- sym (if is-module (symbol (str "test-" (:samak.nodes/name conf))) (symbol (:samak.nodes/name conf)))
- conf (if is-module
- (api/defexp sym (api/fn-call conf []))
- conf)
- rt2 (update @rt-conn :server #(rt/eval-all % [conf]))
- evaled (rt/get-definition-by-name rt2 sym)]
- (println "evaled " evaled)
+ (prom/let [is-module (= (:samak.nodes/type conf) :samak.nodes/module)
+ sym (if is-module (symbol (str "test-" (:samak.nodes/name conf))) (symbol (:samak.nodes/name conf)))
+ conf (if is-module
+ (assoc (api/defexp sym (api/fn-call conf [])) :db/id sym)
+ conf)
+ rt2 (update @rt-conn :server #(rt/eval-all % [conf]))
+ evaled (if is-module
+ (rt/get-definition-by-id rt2 sym)
+ (rt/get-definition-by-name rt2 sym))]
;; (println "evaled " (:samak.nodes/definition evaled))
(:tests evaled))))
(defn attach-assert
""
[verify source-pipe xf-fn test-fn]
- (let [assert-name (str "assert-" (rand-int 1000000))
- assert-exp (api/defexp (symbol assert-name) (api/fn-call (api/symbol 'pipes/debug) []))
- assert-ast (single! assert-exp)]
- (add-node (symbol assert-name) assert-ast)
- (let [assert-pipe (rt/get-definition-by-name @rt-conn (symbol assert-name))
- verify-pipe (rt/get-definition-by-name @rt-conn (symbol verify))]
- (link-pipes source-pipe assert-pipe xf-fn)
- (link-pipes assert-pipe verify-pipe test-fn))))
+ (prom/let [assert-name (symbol (str "assert-" (rand-int 1000000)))
+ assert-exp (api/defexp assert-name (api/fn-call (api/symbol 'pipes/debug) []))
+ assert-ast (single! assert-exp)]
+ (prom/do!
+ (add-node assert-name assert-ast)
+ (prom/let [assert-pipe (rt/get-definition-by-id @rt-conn (:db/id assert-ast))
+ verify-pipe (rt/get-definition-by-id @rt-conn verify)]
+ (prom/do!
+ (link-pipes source-pipe assert-pipe xf-fn)
+ (link-pipes assert-pipe verify-pipe test-fn))))))
(defn resolve-sym-or-fn
""
@@ -605,12 +587,12 @@
(rt/get-definition-by-name @rt-conn (get-in exp [:samak.nodes/fn :samak.nodes/name]))
(do
(println exp)
- (let [ast (load-ast @rt-conn (:db/id exp))]
- (println "loaded" ast)
+ (prom/let [ast (load-ast @rt-conn (:db/id exp))]
+ (println "### loaded" ast)
(swap! rt-conn #(update % :server rt/eval-all [ast])))
- (println "evaled" exp)
+ (println "### evaled" exp)
(let [r (rt/resolve-fn @rt-conn (:db/id exp))]
- (println "resolved " r)
+ (println "### resolved " r)
r)
)))
@@ -618,96 +600,119 @@
(defn add-pipe-net
""
[verify config ast]
- (let [source (resolve-sym-or-fn (:samak.nodes/from ast))
- source-name (get-in ast [:samak.nodes/from :samak.nodes/fn :samak.nodes/name])
- xf (get-in ast [:samak.nodes/xf :samak.nodes/fn])
- sink (resolve-sym-or-fn (:samak.nodes/to ast))
- sink-name (get-in ast [:samak.nodes/to :samak.nodes/fn :samak.nodes/name])
- test-ref (get config (str sink-name))]
+ (prom/let [source (resolve-sym-or-fn (:samak.nodes/from ast))
+ source-name (get-in ast [:samak.nodes/from :samak.nodes/fn :samak.nodes/name])
+ xf (get-in ast [:samak.nodes/xf :samak.nodes/fn])
+ sink (resolve-sym-or-fn (:samak.nodes/to ast))
+ sink-name (get-in ast [:samak.nodes/to :samak.nodes/fn :samak.nodes/name])
+ test-ref (get config (str sink-name))]
(println " V" "Adding pipe:" source-name
"with" (if xf
- (str "[" (:db/id xf) "] " (:samak.nodes/name xf))
- "~none~")
+ (str "[" (:db/id xf) "] " (:samak.nodes/name xf))
+ "~none~")
"to" sink-name)
- (let [xf-pipe (get (servers/get-defined (:server @rt-conn)) (:db/id xf))]
- (when test-ref
- (println " V" "Verifying pipe:" sink-name "with" test-ref)
- (attach-assert verify source xf-pipe (first test-ref)))
- (link-pipes source sink xf-pipe))))
+ (prom/let [xf-pipe (get (servers/get-defined (:server @rt-conn)) (:db/id xf))]
+ (prom/do!
+ (when test-ref
+ (println " V" "Verifying pipe:" sink-name "with" test-ref)
+ (attach-assert verify source xf-pipe (first test-ref)))
+ (link-pipes source sink xf-pipe)))))
(defn setup-verify
""
[]
(println " V" "Set up result collection")
- (let [verify-name (symbol (str "verify-" (rand-int 1000000)))
- verify-exp (api/defexp verify-name (api/fn-call (api/symbol 'pipes/debug) []))
- verify-ast (single! verify-exp)]
+ (prom/let [verify-name (symbol (str "verify-" (rand-int 1000000)))
+ verify-exp (api/defexp verify-name (api/fn-call (api/symbol 'pipes/debug) []))
+ verify-ast (single! verify-exp)]
(add-node verify-name verify-ast)
- verify-name))
+ (:db/id verify-ast)))
(defn handle-source
""
[source eval?]
- (let [nodes (:nodes source)
- _ (println " V" "Loading asts: " (s/join ", " nodes))
- asts (map #(load-ast @rt-conn %1) nodes)
- _ (println " V" "Adding nodes: " (s/join ", " (map :samak.nodes/name asts)))
- adder (if eval? add-node format-node)
- node-notify (doall (map #(adder (symbol (name-of-node %)) %) asts))
- pipes (:pipes source)
- _ (println " V" "Adding pipes: " (s/join ", " pipes))
- pipe-asts (doall (map #(load-ast @rt-conn %1) pipes))]
+ (prom/let [nodes (:nodes source)
+ _ (println " V" "Loading asts: " (s/join ", " nodes))
+ asts (prom/all (map #(load-ast @rt-conn %1) nodes))
+ _ (println " V" "Adding nodes: " (s/join ", " (map #(str (:samak.nodes/name %) "(" (:db/id %) ")") asts)))
+ adder (if eval? add-node format-node)
+ node-notify (doall (map #(adder (:db/id %) %) asts))
+ pipes (:pipes source)
+ _ (println " V" "Adding pipes: " (s/join ", " pipes))
+ pipe-asts (prom/all (map #(load-ast @rt-conn %1) pipes))]
[node-notify pipe-asts]))
+(defn handle-mod
+ ""
+ [module]
+ (println "### mod" module)
+ (let [id (:id module)
+ root (:roots module)]
+ {id {:caravan/type :caravan/module
+ :caravan/name (str id)
+ :caravan/ports (into [] (concat (:sources module) (:sinks module)))
+ :caravan/nodes (into [] (:nodes root))
+ :caravan/pipes (into [] (:pipes root))}}))
+
(defn runtime-net
""
[net config verify]
;; (println "Loading source: " (str sym))
- (let [[_ pipe-asts] (handle-source net true)]
- (doall (map #(add-pipe-net verify (:then config) %) pipe-asts))))
+ (prom/let [[_ pipe-asts] (handle-source net true)]
+ (prom/all (map #(add-pipe-net verify (:then config) %) pipe-asts))))
+
(defn database-net
""
[net]
- (let [[node-notify pipe-asts] (handle-source net false)
- pipe-notify (map format-pipe pipe-asts)]
+ (prom/let [[node-notify pipe-asts] (handle-source net false)
+ pipe-notify (map format-pipe pipe-asts)]
{:nodes node-notify :pipes pipe-notify}))
-(defn load-bundle
- ""
- [sym]
- (let [_ (print " V" "Fetching bundle from DB: ")
- bundle (rt/load-bundle @rt-conn sym)
- _ (println (s/join "," bundle))
- sources (map #(rt/load-network @rt-conn %) bundle)
- net (reduce (fn [a, v]
- (let [val (vals v)]
- {:nodes (into (:nodes a) (flatten [(map :xf val) (map :ends val)]))
- :pipes (into (:pipes a) (map :db/id (flatten (map :pipes val))))
- }))
- {:nodes (set bundle)
- :pipes #{}}
- sources)]
- net
-))
-
+(defn handle-deps
+ ""
+ [deps]
+ (prom/let [init (prom/resolved {:nodes []
+ :pipes []
+ :modules []})]
+ (reduce (fn [promise x] (prom/handle promise
+ (fn [acc _]
+ (prom/let [roots (database-net (:roots x))]
+ {:nodes (into [] (concat (:nodes acc) (:nodes roots)))
+ :pipes (into [] (concat (:pipes acc) (:pipes roots)))
+ :modules (conj (:modules acc) (handle-mod x))}))))
+ init
+ deps)))
(defn eval-bundle
""
- [sym]
- (database-net (load-bundle sym)))
+ [bundle]
+ (prom/let [_ (println "### ev b" bundle)
+ roots (:roots bundle)
+ deps (handle-deps (:deps bundle))
+ _ (println "### deps" deps)
+ net (database-net roots)
+ rootnotify (assoc net :modules [(handle-mod bundle)])
+ ;; rootnotify (database-net roots)
+ _ (println "### root" rootnotify)
+ a1 (merge-with into rootnotify deps)
+ _ (println "### ev n" a1)]
+ (assoc a1 :id (:id bundle))
+ ))
+
(defn test-bundle
""
[sym test]
- (let [verify (setup-verify)
- bundle (load-bundle sym)]
- (runtime-net bundle test verify)
- verify))
+ (prom/let [verify (setup-verify)
+ bundle (sched/load-bundle @rt-conn sym)]
+ (prom/do!
+ (runtime-net (:roots bundle) test verify)
+ verify)))
(defn trace-dump
""
@@ -719,9 +724,8 @@
(defn persist-net
""
[code]
- (let [parsed (p/parse-all (s/join " " code))
- _ (rt/persist-to-ids! (:store @rt-conn) (:value parsed))
- ]
+ (prom/let [parsed (p/parse-all (s/join " " code))
+ _ (rt/persist-to-ids! (:store @rt-conn) (:value parsed))]
:done))
@@ -741,21 +745,20 @@
[c sym [name tst]]
(println (str "test " name " - " tst))
- (let [verify (test-bundle sym tst)]
- (go (let [pipe (rt/get-definition-by-name @rt-conn verify)
- listener (chan 1)]
- (a/tap (.-out pipe) listener) ;; TODO: FIX protocol?
- (loop [results []]
- (let [msg (! c (or (some #(when (not= :success (:samak.pipes/content %)) %) results) :success))
- (recur results))))))
+ (prom/let [verify (test-bundle sym tst)
+ pipe (rt/get-definition-by-id @rt-conn verify)
+ listener (pipes/pipe-chan ::listener 100)]
+ (go-loop [results []]
+ (let [msg (! c (or (some #(when (not= :success (:samak.pipes/content %)) %) results) :success))
+ (recur results))))
+ (a/tap (.-out pipe) listener)
(doall (map (fn [[pipe-name values]]
- (println (str "pipe " (str pipe-name) " values: " values))
- (let [pipe (rt/get-definition-by-name @rt-conn (symbol pipe-name))]
+ (prom/let [pipe (rt/get-definition-by-name @rt-conn (symbol pipe-name))]
+ (println (str "### pipe [" (str pipe-name) "] " pipe " values: " values))
(if (nil? pipe)
(println "no such pipe: " pipe-name)
(doall (map #(run-event pipe pipe-name %) values)))))
@@ -766,13 +769,13 @@
""
([c sym] (run-testsuite c sym {}))
([c sym {timeout :timeout :or {timeout 3000}}]
- (let [net (rt/load-by-sym @rt-conn sym)
- _ (println "Preloading network")
- _ (test-bundle sym :noop)
- _ (println "Loading test definitions")
- tests (find-tests net)
- test-num (count tests)
- test-results-chan (chan 1)]
+ (prom/let [net (rt/load-by-sym @rt-conn sym)
+ _ (println "Preloading network")
+ _ (test-bundle sym :noop)
+ _ (println "Loading test definitions")
+ tests (find-tests net)
+ test-num (count tests)
+ test-results-chan (pipes/pipe-chan ::result 100)]
(if (zero? test-num)
(a/put! c :no-tests)
(go-loop [results []
@@ -788,37 +791,67 @@
(defn load-lib
""
- [c sym]
- (let [bundle (doall (eval-bundle sym))
- ;; merged (merge-with concat bundle)
- ;; _ (println (str "bundle: " merged))
- ;; dist (into {} (for [[k v] merged] [k (distinct v)]))
- ;; _ (println (str "bundle2: " dist))
- ;; cnt (apply + (map #(map count (vals %)) merged))
- ]
+ [cmd ev bundle-id]
+ (prom/let [bundle-code (sched/load-bundle-by-id @rt-conn bundle-id)
+ bundle (eval-bundle bundle-code)]
;; (println (str "count: " cnt))
- (doall (map notify-source (:nodes bundle)))
- (doall (map notify-source (:pipes bundle)))
- (std/notify-source
+ (doall (map #(notify-source ev %) (:modules bundle)))
+ (doall (map #(notify-source ev %) (:nodes bundle)))
+ (doall (map #(notify-source ev %) (:pipes bundle)))
+ (notify-source
+ ev
{::state ::done}
- #(a/put! c (pipes/make-paket {::event ::load ::status ::done ::percent 100} ::caravan)))))
+ #(a/put! cmd (pipes/make-paket {::event ::load ::status ::done ::percent 100 ::id (:id bundle)} ::caravan)))))
+
+(defn load-bundle
+ ""
+ [cmd ev sym]
+ (prom/let [bundle-id (rt/resolve-name @rt-conn sym)]
+ (load-lib cmd ev bundle-id)))
+
(defn load-net
""
- [c prog sym]
+ [cmd ev prog sym]
(persist-net prog)
- (load-lib c sym))
+ (helpers/debounce #(load-bundle cmd ev sym)))
(defn test-net
""
[c prog sym]
- (persist-net prog)
- (run-testsuite c sym {:timeout 3000}))
+ (prom/do! (persist-net prog)
+ (run-testsuite c sym {:timeout 10000})))
(defn load-chuck
""
- [c]
- (load-net c test-programs/chuck 'chuck))
+ [cmd ev]
+ (load-net cmd ev test-programs/chuck 'chuck)
+ )
+
+(defn load-test
+ ""
+ [cmd ev]
+ (load-net cmd ev test-programs/test-nested-modules-test 'baz)
+ )
+
+
+(def base-module
+ [
+ "(def in (pipes/debug))"
+ "(def out (pipes/debug))"
+ "(def foo (pipes/debug))"
+ "(defmodule base {:sinks {:in in}
+ :sources {:in in :out out :foo foo}})"
+ "(| in out)"
+ "(def base-mod (base))"
+ ])
+
+
+(defn load-base
+ ""
+ [cmd ev]
+ (load-net cmd ev base-module 'base)
+ )
(defn test-chuck
""
@@ -827,14 +860,99 @@
(defn load-oasis
""
- [c]
- (load-lib c 'oasis))
+ [cmd ev]
+ (helpers/debounce #(load-bundle cmd ev 'oasis)))
(defn test-oasis
""
[c]
(run-testsuite c 'oasis {:timeout 3000}))
+(defn test-example
+ ""
+ [cmd ev arg]
+ (case arg
+ :test (load-test cmd ev)
+ :base (load-base cmd ev)
+ :self (load-oasis cmd ev)
+ (tools/log "load unknown: " arg)))
+
+(defn disconnect
+ ""
+ []
+ (println "disconnect"))
+
+(defn connect
+ ""
+ [ev source connector sink]
+ ;; (println (str "connect " source " with " connector " to " sink))
+ (prom/let [fn (api/defexp (symbol connector) (api/symbol '_))
+ fn-ast (single! fn)
+ pipe (api/pipe (api/id-ref (helpers/str-to-int source))
+ (api/symbol (symbol connector))
+ (api/id-ref (helpers/str-to-int sink)))
+ pipe-ast (single! pipe) ]
+ (notify-source ev (add-node (symbol connector) fn-ast))
+ (notify-source ev (add-pipe pipe-ast))))
+
+(defn get-smap-key
+ ""
+ [key e]
+ (= key (:samak.nodes/value (:samak.nodes/mapkey e))))
+
+
+(defn get-in-smap
+ ""
+ [smap key]
+ (let [mv (:samak.nodes/mapkv-pairs smap)]
+ (first (filter #(get-smap-key key %) mv))))
+
+
+(defn smap-find
+ ""
+ [smap keys]
+ (let [val (get-in-smap smap (first keys))
+ more (next keys)]
+ (if more
+ (smap-find val more)
+ val)))
+
+
+(defn create-sink
+ ""
+ [cmd ev {scope :scope {pipe-name :name} :args :as x}]
+ (println "create sink: " x)
+ (prom/let [sym (str pipe-name "-" (rand-int 1000000000))
+ exp (api/defexp (symbol sym) (api/fn-call (api/symbol (symbol (str "pipes/" pipe-name))) nil))
+ ast (single! exp)
+ mod (load-ast @rt-conn scope)
+ _ (println (str "mod: " mod))
+ bucket (:samak.nodes/mapvalue (smap-find (:samak.nodes/definition mod) [:sources]))
+ _ (println (str "bucket: " bucket))
+ modded (update bucket :samak.nodes/mapkv-pairs conj {:samak.nodes/mapkey (api/keyword (keyword pipe-name))
+ :samak.nodes/mapvalue (api/symbol (symbol sym))})
+ _ (println (str "modded: " modded))
+ mod-alt (persist! @rt-conn [modded])]
+ (println (str "res: " ast))
+ (notify-source ev (add-node (:db/id ast) ast)) ;; FIXME
+ (println (str "res: " ast))
+ (load-lib cmd ev (helpers/str-to-int scope))))
+
+
+(defn link
+ ""
+ [cmd ev {scope :scope {:keys [:source :sink]} :args :as x}]
+ (println "connect: " x)
+ (let [connector (str "c-" source "-" sink)
+ pipe-key (make-pipe-key source connector sink)
+ existing (contains? @net pipe-key)]
+ (when (and sink source (not= sink source) )
+ (if existing
+ (disconnect)
+ (connect ev source connector sink))
+ (load-lib cmd ev (helpers/str-to-int scope)))))
+
+
(defn oasis-hook
""
[]
@@ -850,52 +968,56 @@
(defn init
[rt]
- (reset! rt-conn rt)
- ;; (reset! rt-preview (rt/make-runtime (merge builtins/samak-symbols
- ;; symbols
- ;; std/pipe-symbols)))
- )
+ (reset! rt-conn rt))
(defn pong
""
[caravan-out x]
- (tools/log "ponging: " x caravan-out)
- (a/put! caravan-out (pipes/make-paket {::event ::pong} ::caravan)))
+ (a/put! caravan-out (pipes/make-paket {:event :pong} ::caravan)))
(defn caravan-module
""
[]
- (let [caravan-in (chan)
- caravan-out (chan)]
- (tools/log "pipe: " caravan-out)
- (go-loop []
- (when-let [x (" foo)
+ foo))))
(def symbols
(merge
- {'create-sink create-sink
- 'connect link
- 'modules/caravan caravan-module}))
+ {'modules/caravan caravan-module}))
diff --git a/ui_src/samak/layout.cljs b/ui_src/samak/layout.cljs
index 4f06926..0134afe 100644
--- a/ui_src/samak/layout.cljs
+++ b/ui_src/samak/layout.cljs
@@ -20,7 +20,7 @@
(defn make-worker
""
[url]
- (println "returning workder")
+ (println "returning worker")
(js/Worker. url))
(def elk (js/ELK. (clj->js {"workerFactory" make-worker
@@ -51,6 +51,7 @@
before (helpers/now)
handler (fn [token]
(fn [return]
+ (println "layout ret: " return)
(let [result (assoc {} token return)
re-wrap (tt/re-wrap meta result)]
(trace/trace ::layout (helpers/duration before (helpers/now)) re-wrap)
@@ -68,7 +69,7 @@
(let [in-chan (chan (a/sliding-buffer 1))
out-chan (chan)]
(a/pipeline-async 1 out-chan layout-call in-chan)
- (pipes/Pipethrough. in-chan (a/mult out-chan) nil nil)))
+ (pipes/Pipethrough. in-chan (a/mult out-chan) nil nil (helpers/uuid))))
(def layout-symbols
{'pipes/layout layout})
diff --git a/ui_src/samak/oasis.cljc b/ui_src/samak/oasis.cljc
index 9d51dd0..b50a3d2 100644
--- a/ui_src/samak/oasis.cljc
+++ b/ui_src/samak/oasis.cljc
@@ -1,23 +1,25 @@
(ns ^:figwheel-no-load samak.oasis
#?@
- (:clj
- [(:require
- [clojure.spec.alpha :as s]
- [samak.api :as api]
- [samak.code-db :as db]
- [samak.nodes :as n]
- [samak.pipes :as pipes]
- samak.spec
- [samak.stdlib :as std])]
- :cljs
- [(:require
- [cljs.spec.alpha :as s]
- [samak.api :as api]
- [samak.code-db :as db]
- [samak.nodes :as n]
- [samak.pipes :as pipes]
- samak.spec
- [samak.stdlib :as std])]))
+ (:clj
+ [(:require
+ [clojure.spec.alpha :as s]
+ [samak.api :as api]
+ [samak.code-db :as db]
+ [samak.nodes :as n]
+ [samak.pipes :as pipes]
+ [samak.runtime.stores :as stores]
+ samak.spec
+ [samak.stdlib :as std])]
+ :cljs
+ [(:require
+ [cljs.spec.alpha :as s]
+ [samak.api :as api]
+ [samak.code-db :as db]
+ [samak.nodes :as n]
+ [samak.pipes :as pipes]
+ [samak.runtime.stores :as stores]
+ samak.spec
+ [samak.stdlib :as std])]))
(defn defncall
([sym fn-name]
@@ -63,17 +65,23 @@
(s/def :oasis.spec/mouse-state (s/keys :req-un [:samak.mouse/type]))
(def oasis1 [(defncall 'oasis-layout 'pipes/layout)
- (defncall 'oasis-eval 'pipes/eval-notify)
- (defncall 'm-caravan 'modules/caravan)
+ (api/defexp 'carv-mod (api/fn-call (api/symbol 'modules/caravan) []))
+ (api/defexp 'm-caravan (api/fn-call (api/symbol 'carv-mod) []))
(defncall 'caravan-actions '->
(api/symbol 'm-caravan)
(api/key-fn :sinks)
(api/key-fn :actions))
- (defncall 'caravan-commands '->
+ (defncall 'm-caravan-commands '->
(api/symbol 'm-caravan)
(api/key-fn :sources)
(api/key-fn :commands))
+ (defncall 'caravan-commands 'm-caravan-commands)
+ (defncall 'm-caravan-eval '->
+ (api/symbol 'm-caravan)
+ (api/key-fn :sources)
+ (api/key-fn :eval))
+ (defncall 'caravan-eval 'm-caravan-eval)
(defncall 'log 'pipes/log)
@@ -81,69 +89,9 @@
(defncall 'log-layout 'pipes/log (api/string "layout: "))
(defncall 'log-events 'pipes/log (api/string "events: "))
(defncall 'log-editor 'pipes/log (api/string "editor: "))
- (defncall 'log-mouse 'pipes/log (api/string "mouse: "))
- (defncall 'log-hover 'pipes/log (api/string "hover: "))
(defncall 'log-keyboard 'pipes/log (api/string "keyboard: "))
- (defncall 'log-caravan 'pipes/log (api/string "caravan: "))
-
- ;; dark theme based on base16-atelierdune-dark
- ;; (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune)
- (defmap 'get-color
- {(api/keyword :cell-active) (api/string "#4d4a41")
- (api/keyword :cell-edit) (api/string "#6684e1")
- (api/keyword :cell-seclight) (api/string "#999580")
- (api/keyword :cell-background) (api/string "#292824")
- (api/keyword :cell-content) (api/string "#e8e4cf")
- (api/keyword :cell-active-content) (api/string "#fefbec")
- (api/keyword :cell-dividers) (api/string "#6e6b5e")
- (api/keyword :cell-type-fill) (api/string "#6e6b5e")
- (api/keyword :cell-type-stroke) (api/string "#20201d")
- (api/keyword :cell-counter-stroke) (api/string "#6e6b5e")
- (api/keyword :node-selected) (api/string "#6684e1")
- (api/keyword :node-bg) (api/string "#292824")
- (api/keyword :node-name-stroke) (api/string "#e8e4cf")
- (api/keyword :node-gutter) (api/string "#292824")
- (api/keyword :element-highlight-stroke) (api/string "#6684e1")
- (api/keyword :pipe-fill) (api/string "#292824")
- (api/keyword :pipe-glow) (api/string "#6684e1")
- (api/keyword :pipe-stroke) (api/string "#a6a28c")
- (api/keyword :pipe-drag) (api/string "#b65611")
- (api/keyword :edge-in) (api/string "#6684e1")
- (api/keyword :edge-out) (api/string "#b65611")
- (api/keyword :edge-neutral) (api/string "#a6a28c")
- (api/keyword :graph-background) (api/string "#20201d")
- (api/keyword :shadow-flood) (api/string "#292824")
- (api/keyword :menu-entry-bg) (api/string "#999580")
- (api/keyword :menu-entry-active-bg) (api/string "#a6a28c")
- (api/keyword :menu-entry-text) (api/string "#fefbec")
- (api/keyword :menu-bar-bg) (api/string "#6e6b5e")
- (api/keyword :menu-bar-text) (api/string "#a6a28c")
- })
-
- (defmap 'get-font
- {(api/string "str") (api/string "serif")})
-
- (defmap 'get-syntax-color
- {(api/keyword :caravan/str) (api/map {(api/keyword :cell-content) (api/string "#60ac39")
- (api/keyword :cell-active-content) (api/string "#60ac39")})
- (api/keyword :caravan/kw) (api/map {(api/keyword :cell-content) (api/string "#b65611")
- (api/keyword :cell-active-content) (api/string "#b65611")})
- (api/keyword :caravan/int) (api/map {(api/keyword :cell-content) (api/string "#1fad83")
- (api/keyword :cell-active-content) (api/string "#1fad83")})
- (api/keyword :caravan/float) (api/map {(api/keyword :cell-content) (api/string "#1fad83")
- (api/keyword :cell-active-content) (api/string "#1fad83")})
- (api/keyword :caravan/acc) (api/map {(api/keyword :cell-content) (api/string "#ae9513")
- (api/keyword :cell-active-content) (api/string "#ae9513")})
- (api/keyword :caravan/func) (api/map {(api/keyword :cell-content) (api/string "#6684e1")
- (api/keyword :cell-active-content) (api/string "#6684e1")})
- (api/keyword :caravan/table) (api/map {(api/keyword :cell-content) (api/string "#d43552")
- (api/keyword :cell-active-content) (api/string "#d43552")})
- (api/keyword :caravan/list) (api/map {(api/keyword :cell-content) (api/string "#b854d4")
- (api/keyword :cell-active-content) (api/string "#b854d4")})})
-
- (defncall 'config-color '->
- (api/symbol 'get-color))
-
+ (defncall 'log-caravan 'pipes/log (api/string "caravan-cmd: "))
+ (defncall 'log-caravan-ev 'pipes/log (api/string "caravan-eval: "))
(defncall 'get-event-val '->
(api/key-fn :event)
@@ -201,9 +149,9 @@
(api/key-fn :button)
(api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :primary)])])]))
- (defncall 'raw-events 'pipes/debug)
- (defncall 'reduced-events 'pipes/debug)
- (defncall 'events 'pipes/debug)
+ (defncall 'raw-events 'pipes/debug (api/string "raw-events"))
+ (defncall 'reduced-events 'pipes/debug (api/string "reduced-events"))
+ (defncall 'events 'pipes/debug (api/string "events"))
(defncall 'merge-state '->
(api/vector [(api/key-fn :state) (api/key-fn :next)])
@@ -257,95 +205,6 @@
;; helpers
- (defncall 'translate-str 'str
- (api/string "translate(")
- (api/fn-call (api/symbol 'or) [(api/key-fn :x) (api/integer 0)])
- (api/string ",")
- (api/fn-call (api/symbol 'or) [(api/key-fn :y) (api/integer 0)])
- (api/string ")"))
-
- (defncall 'translate-graph-str 'str
- (api/string "matrix(")
- (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol 'nth) [(api/key-fn :matrix) (api/integer 0)])
- (api/key-fn :zoom)])
- (api/string ",")
- (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol 'nth) [(api/key-fn :matrix) (api/integer 1)])
- (api/key-fn :zoom)])
- (api/string ",")
- (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol 'nth) [(api/key-fn :matrix) (api/integer 2)])
- (api/key-fn :zoom)])
- (api/string ",")
- (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol 'nth) [(api/key-fn :matrix) (api/integer 3)])
- (api/key-fn :zoom)])
- (api/string ",")
- (api/key-fn :x)
- (api/string ",")
- (api/key-fn :y)
- (api/string ")"))
-
- (defncall 'translate-dialog '->
- (api/map {(api/keyword :x)
- (api/integer 150)
- (api/keyword :y)
- (api/integer 50)
- (api/keyword :zoom)
- (api/float 1.5)
- (api/keyword :matrix)
- (api/vector [(api/float 1.0)
- (api/float 0.0)
- (api/float 0.0)
- (api/float 1.0)])})
- (api/symbol 'translate-graph-str))
-
- (defncall 'translate-func '->
- (api/fn-call (api/symbol 'into) [(api/symbol '_)
- (api/map {(api/keyword :zoom)
- (api/float 1.5)
- ;; (api/keyword :x)
- ;; (api/integer 150)
- ;; (api/keyword :y)
- ;; (api/integer -60)
- (api/keyword :matrix)
- (api/vector [(api/float 1.0)
- (api/float 0.0)
- (api/float 0.0)
- (api/float 1.0)])})])
- (api/symbol 'translate-graph-str))
-
- (defncall 'translate-blur '->
- (api/fn-call (api/symbol 'into) [(api/symbol '_)
- (api/map {(api/keyword :zoom)
- (api/float 2.0)
- (api/keyword :x)
- (api/fn-call (api/symbol '-) [(api/key-fn :x) (api/integer 100)])
- ;; (api/keyword :y)
- ;; (api/integer -50)
- (api/keyword :matrix)
- (api/vector [(api/float 1.0)
- (api/float 0.0)
- (api/float 0.0)
- (api/float 1.0)])})])
- (api/symbol 'translate-graph-str))
-
- (defncall 'translate-graph '->
- (api/fn-call (api/symbol 'assoc) [(api/symbol '_) (api/keyword :matrix)
- (api/vector [(api/float 1.0)
- (api/float -0.5)
- (api/float 1.0)
- (api/float 0.5)])])
- (api/symbol 'translate-graph-str))
-
- (defncall 'translate-ident '->
- (api/fn-call (api/symbol 'into) [(api/symbol '_)
- (api/map {(api/keyword :zoom)
- (api/float 1.0)
- (api/keyword :matrix)
- (api/vector [(api/float 1.0)
- (api/float 0.0)
- (api/float 0.0)
- (api/float 1.0)])})])
- (api/symbol 'translate-graph-str))
-
(defncall 'fn-name-from-select '->
(api/fn-call (api/symbol 'str-split) [(api/symbol '_) (api/string "/")]) ;; func/
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-valid-target)
@@ -364,344 +223,6 @@
(api/keyword :id) (api/string "input/repl")
(api/keyword :style) (api/map {(api/keyword :pointer-events) (api/string "auto")})})])])})})
- (defncall 'header '->
- (api/map {(api/keyword :header)
- (api/map {(api/keyword :oasis.gui/order)
- (api/integer 1)
- (api/keyword :oasis.gui/element)
- (api/vector [(api/keyword :h1)
- (api/string "사막 Oasis")])})}))
-
- (defncall 'calculate-y '->
- (api/fn-call (api/symbol '*) [(api/integer 100) (api/key-fn :position)])
- (api/fn-call (api/symbol '+) [(api/integer 10) (api/symbol '_)]))
-
- (defncall 'menu-transform '->
- (api/key-fn :item)
- (api/map {(api/keyword :x) (api/integer 50)
- (api/keyword :y) (api/symbol 'calculate-y)})
- (api/symbol 'translate-str))
-
- (defncall 'animate-sink '->
- (api/vector [(api/vector [(api/keyword :animate)
- (api/map {(api/keyword :attributeName) (api/string "stroke")
- (api/keyword :values) (api/string "#999580;#6684e1;#6684e1;#6684e1;#999580")
- (api/keyword :dur) (api/string "3s")
- (api/keyword :repeatCount) (api/string "indefinite")})])
- (api/vector [(api/keyword :animate)
- (api/map {(api/keyword :attributeName) (api/string "r")
- (api/keyword :values) (api/string "43;37;37;37;35")
- (api/keyword :dur) (api/string "3s")
- (api/keyword :repeatCount) (api/string "indefinite")})])]))
-
- (defncall 'animate-source '->
- (api/vector [(api/vector [(api/keyword :animate)
- (api/map {(api/keyword :attributeName) (api/string "stroke")
- (api/keyword :values) (api/string "#999580;#6684e1;#6684e1;#6684e1;#999580")
- (api/keyword :dur) (api/string "3s")
- (api/keyword :repeatCount) (api/string "indefinite")})])
- (api/vector [(api/keyword :animate)
- (api/map {(api/keyword :attributeName) (api/string "r")
- (api/keyword :values) (api/string "35;37;37;37;43")
- (api/keyword :dur) (api/string "3s")
- (api/keyword :repeatCount) (api/string "indefinite")})])]))
-
- (defncall 'is-hovered-entry '->
- (api/vector [(api/fn-call (api/symbol '->) [(api/key-fn :item)
- (api/vector [(api/key-fn :type) (api/key-fn :name)])])
- (api/fn-call (api/symbol '->) [(api/key-fn :context)
- (api/key-fn :hover)
- (api/key-fn :current)
- (api/vector [(api/key-fn :type) (api/key-fn :name)])])])
- (api/fn-call (api/symbol '->) [(api/fn-call (api/symbol 'distinct) [(api/symbol '_)])
- (api/fn-call (api/symbol 'count) [(api/symbol '_)])
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/integer 1)])]))
-
- (defncall 'is-entry-sink '->
- (api/key-fn :item)
- (api/key-fn :type)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "sink")]))
-
- (defncall 'get-animation-style '->
- (api/fn-call (api/symbol 'if) [(api/symbol 'is-hovered-entry)
- (api/fn-call (api/symbol 'if) [(api/symbol 'is-entry-sink)
- (api/symbol 'animate-sink)
- (api/symbol 'animate-source)])
- (api/string "")]))
-
- (defncall 'get-entry-bg '->
- (api/fn-call (api/symbol 'if) [(api/symbol 'is-hovered-entry)
- (api/keyword :menu-entry-active-bg)
- (api/keyword :menu-entry-bg)]))
-
- (defncall 'render-menu-entry '->
- (api/vector [(api/keyword :g)
- (api/map {(api/keyword :transform) (api/symbol 'menu-transform)})
- (api/vector [(api/keyword :circle)
- (api/map {(api/keyword :cx) (api/integer 0)
- (api/keyword :cy) (api/integer 45)
- (api/keyword :r) (api/integer 40)
- (api/keyword :style) (api/map {(api/keyword :filter) (api/string "url(#shadow)")
- (api/keyword :pointer-events) (api/string "all")})
- (api/keyword :fill) (api/fn-call (api/symbol '->) [(api/keyword :menu-entry-bg)
- (api/symbol 'get-color)])
- (api/keyword :stroke) (api/fn-call (api/symbol '->) [(api/keyword :menu-entry-text)
- (api/symbol 'get-color)])})])
- (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :circle)
- (api/map {(api/keyword :cx) (api/integer 0)
- (api/keyword :cy) (api/integer 45)
- (api/keyword :r) (api/integer 35)
- (api/keyword :stroke-width) (api/integer 2)
- (api/keyword :stroke) (api/fn-call (api/symbol '->) [(api/keyword :element-highlight-stroke)
- (api/symbol 'get-color)])
- (api/keyword :fill) (api/fn-call (api/symbol '->) [(api/symbol 'get-entry-bg)
- (api/symbol 'get-color)])})])
- (api/symbol 'get-animation-style)])
- (api/vector [(api/keyword :text)
- (api/map {(api/keyword :height) (api/integer 20)
- (api/keyword :width) (api/string "100%")
- (api/keyword :fill) (api/fn-call (api/symbol '->) [(api/keyword :menu-entry-text) (api/symbol 'get-color)])
- (api/keyword :text-anchor) (api/keyword :middle)
- (api/keyword :x) (api/integer 0)
- (api/keyword :y) (api/integer 35)
- (api/keyword :dy) (api/integer 14)})
- (api/fn-call (api/symbol '->) [(api/key-fn :item)
- (api/key-fn :name)])])
- (api/vector [(api/keyword :circle)
- (api/map {(api/keyword :id) (api/fn-call (api/symbol '->) [(api/key-fn :item)
- (api/key-fn :id)])
- (api/keyword :style) (api/map {(api/keyword :pointer-events) (api/string "all")})
- (api/keyword :cx) (api/integer 0)
- (api/keyword :cy) (api/integer 45)
- (api/keyword :r) (api/integer 40)
- (api/keyword :fill-opacity) (api/integer 0)})])]))
-
- (defncall 'get-menu-fill '->
- (api/keyword :menu-bar-bg)
- (api/symbol 'config-color))
-
- (defncall 'get-menu-fg '->
- (api/keyword :menu-bar-text)
- (api/symbol 'config-color))
-
-
- (defncall 'tag-item-context '->
- (api/map {(api/keyword :item) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
- (api/keyword :context) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])}))
-
- (defncall 'get-menu-items '->
- (api/key-fn :items)
- (api/fn-call (api/symbol 'map) [(api/symbol 'tag-item-context) (api/symbol '_)])
- (api/fn-call (api/symbol 'map) [(api/symbol 'render-menu-entry) (api/symbol '_)])
- (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :g)]) (api/symbol '_)])
- )
-
-
- (defncall 'render-source-menu '->
- (api/key-fn :source-menu)
- (api/map {(api/keyword :items) (api/key-fn :items)
- (api/keyword :context) (api/map {(api/keyword :hover) (api/key-fn :hover)
- (api/keyword :resize) (api/key-fn :resize)})})
- (api/map {(api/keyword :items) (api/fn-call (api/symbol 'myzip) [(api/key-fn :items)
- (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol 'count) [(api/key-fn :items)])
- (api/key-fn :context)])])
- (api/keyword :context) (api/key-fn :context)})
- (api/vector [(api/keyword :g)
- (api/vector [(api/keyword :rect)
- (api/map {(api/keyword :id) (api/string "menu/source")
- (api/keyword :height) (api/string "100%")
- (api/keyword :width) (api/integer 100)
- (api/keyword :stroke) (api/symbol 'get-menu-fg)
- (api/keyword :style) (api/map {(api/keyword :filter) (api/string "url(#shadow)")
- (api/keyword :pointer-events) (api/string "all")})
- (api/keyword :fill-opacity) (api/float 0.8)
- (api/keyword :fill) (api/symbol 'get-menu-fill)})])
- (api/symbol 'get-menu-items)])
- (api/map {(api/keyword :source-menu) (api/symbol '_)}))
-
- (defncall 'get-sink-position '->
- (api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :resize) (api/key-fn :width)])
- (api/fn-call (api/symbol '-) [(api/symbol '_) (api/integer 100)])
- (api/map {(api/keyword :x) (api/symbol '_)})
- (api/symbol 'translate-str))
-
- (defncall 'render-sink-menu '->
- (api/key-fn :sink-menu)
- (api/map {(api/keyword :items) (api/key-fn :items)
- (api/keyword :context) (api/map {(api/keyword :hover) (api/key-fn :hover)
- (api/keyword :resize) (api/key-fn :resize)})})
- (api/map {(api/keyword :items) (api/fn-call (api/symbol 'myzip) [(api/key-fn :items)
- (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol 'count) [(api/key-fn :items)])
- (api/key-fn :context)])])
- (api/keyword :context) (api/key-fn :context)})
- (api/vector [(api/keyword :g)
- (api/map {(api/keyword :transform) (api/symbol 'get-sink-position)})
- (api/vector [(api/keyword :rect)
- (api/map {(api/keyword :id) (api/string "menu/sink")
- (api/keyword :height) (api/string "100%")
- (api/keyword :width) (api/integer 100)
- (api/keyword :stroke) (api/symbol 'get-menu-fg)
- (api/keyword :style) (api/map {(api/keyword :filter) (api/string "url(#leftshadow)")
- (api/keyword :pointer-events) (api/string "all")})
- (api/keyword :fill-opacity) (api/float 0.8)
- (api/keyword :fill) (api/symbol 'get-menu-fill)})])
- (api/symbol 'get-menu-items)])
- (api/map {(api/keyword :sink-menu) (api/symbol '_)}))
-
- (defncall 'get-menu-state '->
- (api/vector [(api/string "mode: ")
- (api/fn-call (api/symbol '->) [(api/key-fn :editor)
- (api/key-fn :mode)])
- (api/string "/")
- (api/fn-call (api/symbol '->) [(api/key-fn :editor)
- (api/key-fn :activity)])])
- (api/fn-call (api/symbol 'str-join) [(api/string " ") (api/symbol '_)]))
-
- (defncall 'render-menu-action '->
- ;; (api/fn-call (api/symbol 'spy) [(api/string "render action")])
- (api/symbol '_))
-
- (defncall 'get-menu-actions '->
- (api/fn-call (api/symbol '->) [(api/key-fn :mode)
- (api/key-fn :actions)
- (api/fn-call (api/symbol 'map) [(api/symbol 'render-menu-action) (api/symbol '_)])])
- (api/fn-call (api/symbol 'str-join) [(api/string ", ") (api/symbol '_)])
- (api/vector [(api/string "type: ") (api/symbol '_)])
- (api/fn-call (api/symbol 'str-join) [(api/string "") (api/symbol '_)]))
-
- (defncall 'get-action-position '->
- (api/fn-call (api/symbol '->) [(api/key-fn :resize) (api/key-fn :height)])
- (api/fn-call (api/symbol '-) [(api/symbol '_) (api/integer 50)])
- (api/map {(api/keyword :y) (api/symbol '_)})
- (api/symbol 'translate-str))
-
- (defncall 'render-action-menu '->
- (api/map {(api/keyword :action-menu)
- (api/vector [(api/keyword :g)
- (api/map {(api/keyword :transform) (api/symbol 'get-action-position)})
- (api/vector [(api/keyword :rect)
- (api/map {(api/keyword :id) (api/string "menu/action")
- (api/keyword :height) (api/integer 50)
- (api/keyword :width) (api/string "100%")
- (api/keyword :stroke) (api/symbol 'get-menu-fg)
- (api/keyword :style) (api/map {(api/keyword :filter) (api/string "url(#upshadow)")
- (api/keyword :pointer-events) (api/string "all")})
- (api/keyword :fill-opacity) (api/float 0.8)
- (api/keyword :fill) (api/symbol 'get-menu-fill)})])
- (api/vector [(api/keyword :text)
- (api/map {(api/keyword :height) (api/integer 20)
- (api/keyword :width) (api/string "100%")
- (api/keyword :text-anchor) (api/keyword :middle)
- (api/keyword :x) (api/integer 600)
- (api/keyword :y) (api/integer 5)
- (api/keyword :dy) (api/integer 14)})
- (api/fn-call (api/symbol '->)
- [(api/vector [(api/string "state: ")
- (api/symbol 'get-menu-state)])
- (api/fn-call (api/symbol 'str-join) [(api/string "") (api/symbol '_)])])])
- (api/vector [(api/keyword :text)
- (api/map {(api/keyword :height) (api/integer 20)
- (api/keyword :width) (api/string "100%")
- (api/keyword :text-anchor) (api/keyword :middle)
- (api/keyword :x) (api/integer 600)
- (api/keyword :y) (api/integer 25)
- (api/keyword :dy) (api/integer 14)})
- (api/fn-call (api/symbol '->)
- [(api/vector [(api/string "actions: ")
- (api/symbol 'get-menu-actions)])
- (api/fn-call (api/symbol 'str-join) [(api/string "") (api/symbol '_)])])])])}))
-
- (defncall 'source-menu 'pipes/debug)
- (defncall 'source-menu-items 'pipes/debug)
- (defncall 'source-menu-events 'pipes/debug)
- (defncall 'source-menu-state 'pipes/debug)
-
-
- (defncall 'source-menu-const '->
- (api/vector [(api/string "debug")
- (api/string "ui")
- (api/string "http")])
- (api/symbol 'many))
-
- (defncall 'sink-menu 'pipes/debug)
- (defncall 'sink-menu-items 'pipes/debug)
- (defncall 'sink-menu-events 'pipes/debug)
- (defncall 'sink-menu-state 'pipes/debug)
-
- (defncall 'sink-menu-const '->
- (api/vector [(api/string "debug")
- (api/string "log")
- (api/string "ui")
- (api/string "http")])
- (api/symbol 'many))
-
- (defncall 'map-menu-item '->
- (api/map {(api/keyword :position)
- (api/key-fn :count)
- (api/keyword :name)
- (api/key-fn :name)
- (api/keyword :type)
- (api/key-fn :type)
- (api/keyword :id)
- (api/fn-call (api/symbol 'str) [(api/key-fn :type)
- (api/string "/")
- (api/key-fn :name)])}))
-
- (defncall 'source-menu-map 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/vector [(api/key-fn :state)
- (api/fn-call (api/symbol '->) [(api/map {(api/keyword :count)
- (api/fn-call (api/symbol 'count) [(api/key-fn :state)])
- (api/keyword :type)
- (api/string "source")
- (api/keyword :name)
- (api/key-fn :next)})
- (api/symbol 'map-menu-item)])])
- (api/fn-call (api/symbol 'flatten) [(api/symbol '_)])])
- (api/vector []))
-
- (defncall 'sink-menu-map 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/vector [(api/key-fn :state)
- (api/fn-call (api/symbol '->) [(api/map {(api/keyword :count)
- (api/fn-call (api/symbol 'count) [(api/key-fn :state)])
- (api/keyword :type)
- (api/string "sink")
- (api/keyword :name)
- (api/key-fn :next)})
- (api/symbol 'map-menu-item)])])
- (api/fn-call (api/symbol 'flatten) [(api/symbol '_)])])
- (api/vector []))
-
- (defncall 'tag-items '->
- (api/map {(api/keyword :items) (api/symbol '_)}))
-
- (defncall 'tag-menu-source '->
- (api/map {(api/keyword :source-menu) (api/symbol '_)}))
-
- (defncall 'reduce-menu-source 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/vector [(api/key-fn :state) (api/key-fn :next)])
- (api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)])])
- (api/map {(api/keyword :items) (api/vector [])
- (api/keyword :hover) (api/map {})}))
-
- (defncall 'tag-sink-menu '->
- (api/map {(api/keyword :sink-menu) (api/symbol '_)}))
-
- (defncall 'reduce-menu-sink 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/vector [(api/key-fn :state) (api/key-fn :next)])
- (api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)])])
- (api/map {(api/keyword :items) (api/vector [])
- (api/keyword :hover) (api/map {})
- (api/keyword :resize) (api/map {})}))
-
- (defncall 'is-mouse-move '->
- (api/key-fn :next)
- (api/key-fn :samak.mouse/type)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :move)]))
-
(defncall 'calculate-mouse-delta-x '->
(api/fn-call (api/symbol '+) [(api/fn-call (api/symbol '->) [(api/key-fn :next)
(api/key-fn :samak.mouse/page-x)])
@@ -724,132 +245,6 @@
(api/key-fn :y)
])])]))
- (defncall 'handle-mouse-move '->
- (api/map {(api/keyword :state) (api/key-fn :state)
- (api/keyword :next) (api/map {(api/keyword :position)
- (api/map {(api/keyword :x) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :samak.mouse/page-x)])
- (api/keyword :y) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/symbol 'get-mouse-y)])})
- (api/keyword :delta)
- (api/map {(api/keyword :x)
- (api/symbol 'calculate-mouse-delta-x)
- (api/keyword :y)
- (api/symbol 'calculate-mouse-delta-y)})
- (api/keyword :drag)
- (api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :mouse) (api/key-fn :drag)
- (api/map {(api/keyword :active) (api/key-fn :active)
- (api/keyword :source) (api/key-fn :source)
- (api/keyword :begin) (api/keyword :false)
- (api/keyword :button) (api/key-fn :button)})])})}))
-
- (defncall 'is-mouse-down '->
- (api/key-fn :next)
- (api/key-fn :samak.mouse/type)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :down)]))
-
- (defncall 'handle-mouse-down '->
- (api/map {(api/keyword :state) (api/key-fn :state)
- (api/keyword :next) (api/fn-call (api/symbol '->)
- [(api/key-fn :next)
- (api/map {(api/keyword :drag) (api/map {(api/keyword :begin) (api/keyword :true)
- (api/keyword :active) (api/keyword :true)
- (api/keyword :button) (api/key-fn :samak.mouse/button)
- (api/keyword :source) (api/key-fn :samak.mouse/target)})
-
- (api/keyword :position) (api/map {(api/keyword :x) (api/key-fn :samak.mouse/page-x)
- (api/keyword :y) (api/symbol 'get-mouse-y)})
- (api/keyword :start) (api/map {(api/keyword :x) (api/key-fn :samak.mouse/page-x)
- (api/keyword :y) (api/symbol 'get-mouse-y)})})])}))
-
- (defncall 'is-mouse-up '->
- (api/key-fn :next)
- (api/key-fn :samak.mouse/type)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :up)]))
-
- (defncall 'handle-mouse-up '->
- (api/map {(api/keyword :state) (api/key-fn :state)
- (api/keyword :next) (api/map {(api/keyword :drag)
- (api/map {(api/keyword :active) (api/keyword :false)
- (api/keyword :end) (api/keyword :end)
- (api/keyword :button) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :samak.mouse/button)])
- (api/keyword :target) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :samak.mouse/target)])
- (api/keyword :source) (api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :mouse) (api/key-fn :drag) (api/key-fn :source)])})})}))
-
- (defncall 'mouse-reduce 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/fn-call (api/symbol 'incase) [(api/symbol 'is-mouse-move)
- (api/symbol 'handle-mouse-move)])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-mouse-down)
- (api/symbol 'handle-mouse-down)])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-mouse-up)
- (api/symbol 'handle-mouse-up)])
- (api/vector [(api/fn-call (api/symbol '->) [(api/key-fn :state)
- (api/key-fn :mouse)])
- (api/key-fn :next)])
- (api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)])
- (api/map {(api/keyword :mouse) (api/symbol '_)})])
- (api/map {(api/keyword :mouse) (api/map {})}))
-
- (defncall 'mouse-state 'pipes/debug ;; (api/keyword :oasis.spec/mouse-state)
- )
-
- (defncall 'target-reduce 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/map {(api/keyword :prev) (api/fn-call (api/symbol '->) [(api/key-fn :state)
- (api/key-fn :current)])
- (api/keyword :current) (api/fn-call (api/symbol '->) [(api/key-fn :next)
- (api/key-fn :samak.mouse/target)
- (api/symbol 'make-target)])})])
- (api/map {(api/keyword :current) (api/map {(api/keyword :type) (api/string "none")
- (api/keyword :name) (api/string "none")})
- (api/keyword :prev) (api/map {(api/keyword :type) (api/string "none")
- (api/keyword :name) (api/string "none")})}))
-
- (defncall 'only-different '->
- (api/fn-call (api/symbol 'except) [(api/fn-call (api/symbol '->) [(api/vector [(api/key-fn :prev) (api/key-fn :current)])
- (api/fn-call (api/symbol 'distinct) [(api/symbol '_)])
- (api/fn-call (api/symbol 'count) [(api/symbol '_)])
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/integer 1)])])]))
-
- (defncall 'tag-hover '->
- (api/map {(api/keyword :hover) (api/symbol '_)}))
-
- (defncall 'target-events 'pipes/debug ;; (api/keyword :oasis.spec/mouse-state)
- )
- (defncall 'hover-events 'pipes/debug ;; (api/keyword :oasis.spec/mouse-state)
- )
- (defncall 'hover-state 'pipes/debug ;; (api/keyword :oasis.spec/mouse-state)
- )
-
- (defncall 'is-drag '->
- (api/key-fn :mouse)
- (api/key-fn :drag)
- (api/key-fn :active)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :true)]))
-
- (defncall 'is-drag-end '->
- (api/key-fn :drag)
- (api/key-fn :end)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :end)]))
-
- (defncall 'is-drag-start '->
- (api/key-fn :drag)
- (api/key-fn :begin)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :true)]))
-
- (defncall 'is-drag-or-end 'or
- (api/symbol 'is-drag)
- (api/fn-call (api/symbol '->) [(api/key-fn :mouse) (api/symbol 'is-drag-end)]))
-
- (defncall 'is-drag-end-or-start 'or
- (api/fn-call (api/symbol '->) [(api/key-fn :mouse) (api/symbol 'is-drag-start)])
- (api/fn-call (api/symbol '->) [(api/key-fn :mouse) (api/symbol 'is-drag-end)]))
-
- (defncall 'filter-drag-end-or-start 'only (api/symbol 'is-drag-end-or-start))
-
- (defncall 'filter-drag 'only (api/symbol 'is-drag-or-end))
-
- (defncall 'drag-events 'pipes/debug)
- (defncall 'drag-state 'pipes/debug)
;; (defncall 'drag-reduce 'pipes/reductions
;; (api/fn-call (api/symbol '->)
@@ -872,7 +267,7 @@
(api/key-fn :which)
(api/fn-call (api/symbol '>) [(api/integer 31) (api/symbol '_)]))
- (defncall 'keyboard-filtered 'pipes/debug)
+ (defncall 'keyboard-filtered 'pipes/debug (api/string "keyboard-filtered"))
(defncall 'filter-key-input 'except (api/fn-call (api/symbol 'and) [(api/symbol 'is-target-input)
(api/symbol 'is-key-common)]))
@@ -1091,6 +486,10 @@
(api/keyword :fall)
(api/symbol 'construct-action))
+ (defncall 'construct-scope '->
+ (api/map {(api/keyword :command) (api/keyword :scope)
+ (api/keyword :data) (api/symbol '_)}))
+
(defncall 'filter-edit '->
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-phase-up)
(api/fn-call (api/symbol '->) [(api/map {(api/keyword :key) (api/keyword :ignore)})])])
@@ -1155,7 +554,18 @@
(defncall 'construct-load '->
(api/map {(api/keyword :command) (api/keyword :load)
(api/keyword :type) (api/keyword :immediate)
- (api/keyword :data) (api/keyword :load)}))
+ (api/keyword :data) (api/keyword :load)
+ (api/keyword :load) (api/keyword :base)}))
+
+ (defncall 'is-kb-self '->
+ (api/key-fn :key)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "p")]))
+
+ (defncall 'construct-self '->
+ (api/map {(api/keyword :command) (api/keyword :load)
+ (api/keyword :type) (api/keyword :immediate)
+ (api/keyword :data) (api/keyword :load)
+ (api/keyword :load) (api/keyword :self)}))
(defncall 'is-kb-test '->
(api/key-fn :key)
@@ -1182,6 +592,8 @@
(api/symbol 'construct-menu)])
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-load)
(api/symbol 'construct-load)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-self)
+ (api/symbol 'construct-self)])
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-test)
(api/symbol 'construct-test)])
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-trace)
@@ -1190,88 +602,6 @@
(api/symbol 'ignore)]))
- (defncall 'is-kb-move-left '->
- (api/key-fn :key)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "ArrowLeft")]))
-
- (defncall 'is-kb-move-right '->
- (api/key-fn :key)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "ArrowRight")]))
-
- (defncall 'is-kb-move-up '->
- (api/key-fn :key)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "ArrowUp")]))
-
- (defncall 'is-kb-move-down '->
- (api/key-fn :key)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "ArrowDown")]))
-
- (defncall 'construct-move-left '->
- (api/map {(api/keyword :command) (api/keyword :move)
- (api/keyword :x) (api/integer 50)
- (api/keyword :y) (api/integer 0)
- (api/keyword :zoom) (api/integer 1)}))
-
- (defncall 'construct-move-right '->
- (api/map {(api/keyword :command) (api/keyword :move)
- (api/keyword :x) (api/integer -50)
- (api/keyword :y) (api/integer 0)
- (api/keyword :zoom) (api/integer 1)}))
-
- (defncall 'construct-move-up '->
- (api/map {(api/keyword :command) (api/keyword :move)
- (api/keyword :x) (api/integer 0)
- (api/keyword :y) (api/integer 50)
- (api/keyword :zoom) (api/integer 1)}))
-
- (defncall 'construct-move-down '->
- (api/map {(api/keyword :command) (api/keyword :move)
- (api/keyword :x) (api/integer 0)
- (api/keyword :y) (api/integer -50)
- (api/keyword :zoom) (api/integer 1)}))
-
- (defncall 'is-kb-zoom-in '->
- (api/key-fn :key)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "+")]))
-
- (defncall 'is-kb-zoom-out '->
- (api/key-fn :key)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "-")]))
-
- (defncall 'construct-zoom-out '->
- (api/map {(api/keyword :command) (api/keyword :zoom)
- (api/keyword :zoom) (api/float 0.9)}))
-
- (defncall 'construct-zoom-in '->
- (api/map {(api/keyword :command) (api/keyword :zoom)
- (api/keyword :zoom) (api/float 1.1)}))
-
-
-
- (defncall 'filter-view '->
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-move-left)
- (api/symbol 'construct-move-left)])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-move-right)
- (api/symbol 'construct-move-right)])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-move-up)
- (api/symbol 'construct-move-up)])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-move-down)
- (api/symbol 'construct-move-down)])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-phase-up)
- (api/fn-call (api/symbol '->) [(api/map {(api/keyword :key) (api/keyword :ignore)})])])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-zoom-in)
- (api/symbol 'construct-zoom-in)])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-zoom-out)
- (api/symbol 'construct-zoom-out)])
- (api/fn-call (api/symbol 'unless) [(api/key-fn :command)
- (api/symbol 'ignore)]))
-
- (defncall 'make-zoom 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/map {(api/keyword :zoom) (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :zoom)])
- (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :zoom)])])})])
- (api/map {(api/keyword :zoom) (api/integer 1)}))
-
(defncall 'make-view-move 'pipes/reductions
(api/fn-call (api/symbol '->)
[(api/key-fn :next)
@@ -1292,6 +622,7 @@
(defncall 'handle-sink '->
(api/key-fn :name)
(api/map {(api/keyword :command) (api/keyword :create-sink)
+ (api/keyword :type) (api/keyword :immediate)
(api/keyword :data) (api/map {(api/keyword :name) (api/symbol '_)})}))
(defncall 'is-source '->
@@ -1305,7 +636,7 @@
(defncall 'is-func '->
(api/key-fn :type)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "func")]))
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "d")])) ;;FIXME?
(defncall 'handle-func '->
(api/key-fn :name)
@@ -1313,6 +644,7 @@
(api/keyword :data) (api/fn-call (api/symbol 'str) [(api/string "func/")(api/symbol '_)])}))
(defncall 'handle-mouse-click '->
+ (api/fn-call (api/symbol 'spy) [(api/string "lmb")])
(api/key-fn :source)
(api/symbol 'make-target)
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-source)
@@ -1345,11 +677,12 @@
(defncall 'handle-mouse-connect '->
(api/map {(api/keyword :command) (api/keyword :connect)
+ (api/keyword :type) (api/keyword :immediate)
(api/keyword :data) (api/map {(api/keyword :source) (api/fn-call (api/symbol '->) [(api/key-fn :source) (api/symbol 'get-pipe-name)])
(api/keyword :sink) (api/fn-call (api/symbol '->) [(api/key-fn :target) (api/symbol 'get-pipe-name)])})}))
(defncall 'is-pipe '->
- (api/fn-call (api/symbol 'str-index) [(api/string "pipe/") (api/symbol '_)])
+ (api/fn-call (api/symbol 'str-index) [(api/string "d/") (api/symbol '_)]) ;;d/pipe?
(api/fn-call (api/symbol '=) [(api/symbol '_) (api/integer 0)]))
(defncall 'is-source-source '->
@@ -1371,6 +704,7 @@
(api/symbol 'is-target-sink)]))
(defncall 'is-start '->
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "fmod2")])
(api/fn-call (api/symbol 'and) [(api/symbol 'is-lmb-event)
(api/symbol 'is-source-source)
(api/fn-call (api/symbol '=) [(api/key-fn :begin) (api/keyword :true)])]))
@@ -1393,75 +727,9 @@
(api/keyword :data) (api/keyword :scouting)})]))
(defncall 'handle-caravan-command '->
- (api/symbol 'construct-back))
-
- (defncall 'is-scroll '->
- (api/key-fn :mouse)
- (api/key-fn :drag)
- (api/key-fn :button)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :secondary)]))
-
- (defncall 'filter-scroll 'only (api/fn-call (api/symbol 'and) [(api/symbol 'is-scroll)
- (api/symbol 'is-drag-or-end)]))
-
- (defncall 'scroll-state 'pipes/debug ;; (api/keyword :oasis.spec/mouse-state)
- )
-
- (defncall 'construct-view '->
- (api/key-fn :mouse)
- (api/map {(api/keyword :x) (api/fn-call (api/symbol '->) [(api/key-fn :delta)
- (api/key-fn :x)])
- (api/keyword :y) (api/fn-call (api/symbol '->) [(api/key-fn :delta)
- (api/key-fn :y)])}))
-
- (defncall 'center-view 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/map {(api/keyword :x) (api/integer 150)
- (api/keyword :y) (api/integer 50)})])
- (api/map {}))
-
- (defncall 'view-reduce 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/fn-call (api/symbol 'into) [(api/key-fn :state) (api/key-fn :next)])])
- (api/map {(api/keyword :zoom) (api/integer 1)
- (api/keyword :x) (api/integer 150)
- (api/keyword :y) (api/integer 50)}))
-
- (defncall 'tag-view '->
- (api/map {(api/keyword :view) (api/symbol '_)}))
-
-
- (defncall 'view-commands 'pipes/debug)
- (defncall 'view-events 'pipes/debug)
- (defncall 'zoom-events 'pipes/debug)
-
- (defncall 'view-delta 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/map {(api/keyword :x)
- (api/fn-call (api/symbol '+) [(api/fn-call (api/symbol '->)
- [(api/key-fn :next)
- (api/key-fn :x)])
- (api/fn-call (api/symbol '->)
- [(api/key-fn :state)
- (api/key-fn :x)])])
- (api/keyword :y)
- (api/fn-call (api/symbol '+) [(api/fn-call (api/symbol '->)
- [(api/key-fn :next)
- (api/key-fn :y)])
- (api/fn-call (api/symbol '->)
- [(api/key-fn :state)
- (api/key-fn :y)])])}
- )])
- (api/map {(api/keyword :x) (api/integer 150)
- (api/keyword :y) (api/integer 50)}))
-
-
- (defncall 'view-raw 'pipes/debug ;; (api/keyword :oasis.spec/mouse-state)
- )
- (defncall 'view-state 'pipes/debug ;; (api/keyword :oasis.spec/mouse-state)
- )
- (defncall 'view-deltas 'pipes/debug ;; (api/keyword :oasis.spec/mouse-state)
- )
+ (api/fn-call (api/symbol 'spy) [(api/string "car cmd")])
+ (api/key-fn :samak.caravan/id)
+ (api/symbol 'construct-scope))
;; keep evaluations in state reduction
@@ -1486,9 +754,12 @@
(api/vector [(api/vector [(api/symbol 'eval-id) (api/symbol '_)])])
(api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)]))
- (defncall 'eval-events 'pipes/debug ;; (api/keyword :oasis.spec/eval-state)
+ (defncall 'eval-events 'pipes/debug (api/string "eval-events") ;; (api/keyword :oasis.spec/eval-state)
)
+ ;; (defncall 'extract-eval '->
+ ;; (api/key-fn :samak.pipes/content))
+
(defncall 'eval-reduce 'pipes/reductions
(api/fn-call (api/symbol '->)
[(api/map {(api/keyword :org) (api/symbol '_)
@@ -1499,32 +770,32 @@
(api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)])])
(api/map {}))
- (defncall 'eval-raw 'pipes/debug ;; (api/keyword :oasis.spec/eval-state)
+ (defncall 'eval-raw 'pipes/debug (api/string "eval-raw") ;; (api/keyword :oasis.spec/eval-state)
)
(defncall 'tag-eval '->
;; (api/fn-call (api/symbol 'spy) [(api/string "evaled")])
(api/map {(api/keyword :eval) (api/symbol '_)}))
- (defncall 'eval-state 'pipes/debug ;; (api/keyword :oasis.spec/eval-state)
+ (defncall 'eval-state 'pipes/debug (api/string "eval-state") ;; (api/keyword :oasis.spec/eval-state)
)])
(def oasis2 [
;; commands
- (defncall 'editor-commands 'pipes/debug)
- (defncall 'editor-events 'pipes/debug)
- (defncall 'editor-cooked 'pipes/debug)
- (defncall 'editor-immediate 'pipes/debug)
- (defncall 'editor-actions 'pipes/debug)
- (defncall 'editor-state 'pipes/debug)
- (defncall 'select-events 'pipes/debug)
+ (defncall 'editor-commands 'pipes/debug (api/string "editor-commands"))
+ (defncall 'editor-events 'pipes/debug (api/string "editor-events"))
+ (defncall 'editor-cooked 'pipes/debug (api/string "editor-cooked"))
+ (defncall 'editor-immediate 'pipes/debug (api/string "editor-immediate"))
+ (defncall 'editor-actions 'pipes/debug (api/string "editor-actions"))
+ (defncall 'editor-state 'pipes/debug (api/string "editor-state"))
+ (defncall 'select-events 'pipes/debug (api/string "select-events"))
- (defncall 'be-commands 'pipes/debug)
+ (defncall 'be-commands 'pipes/debug (api/string "be-commands"))
(defncall 'filter-call 'only (api/key-fn :call))
- (defncall 'mode-state 'pipes/debug)
- (defncall 'mode-raw 'pipes/debug)
+ (defncall 'mode-state 'pipes/debug (api/string "mode-state"))
+ (defncall 'mode-raw 'pipes/debug (api/string "mode-raw"))
(defncall 'is-immediate-command '->
(api/key-fn :type)
@@ -1542,8 +813,7 @@
(defncall 'handle-create-sink '->
(api/key-fn :data)
- (api/fn-call (api/symbol 'create-sink) [])
- (api/map {(api/keyword :result) (api/symbol '_)}))
+ (api/map {(api/keyword :create-sink) (api/symbol '_)}))
(defncall 'is-connect '->
(api/key-fn :command)
@@ -1551,8 +821,8 @@
(defncall 'handle-connect '->
(api/key-fn :data)
- (api/fn-call (api/symbol 'connect) [])
- (api/map {(api/keyword :result) (api/symbol '_)
+ (api/map {(api/keyword :connect) (api/symbol '_)
+ (api/keyword :type) (api/keyword :immediate)
(api/keyword :mode) (api/keyword :back)}))
(defncall 'is-select '->
@@ -1595,7 +865,7 @@
(defncall 'handle-load '->
(api/key-fn :data)
(api/map {(api/keyword :mode) (api/keyword :load)
- (api/keyword :load) (api/keyword :none)}))
+ (api/keyword :load) (api/keyword :test2)}))
(defncall 'is-test '->
(api/key-fn :command)
@@ -1604,7 +874,7 @@
(defncall 'handle-test '->
(api/key-fn :data)
(api/map {(api/keyword :mode) (api/keyword :test)
- (api/keyword :test) (api/keyword :none)}))
+ (api/keyword :test) (api/keyword :self)}))
(defncall 'is-trace '->
(api/key-fn :command)
@@ -1631,6 +901,13 @@
(api/key-fn :data)
(api/map {(api/keyword :activity) (api/symbol '_)}))
+ (defncall 'is-scope-change '->
+ (api/key-fn :command)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :scope)]))
+
+ (defncall 'handle-scope '->
+ (api/key-fn :data)
+ (api/map {(api/keyword :scope) (api/symbol '_)}))
(defncall 'handle-commands '->
(api/fn-call (api/symbol 'spy) [(api/string "comm")])
@@ -1652,6 +929,8 @@
(api/symbol 'handle-trace)])
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-mode-change)
(api/symbol 'handle-mode)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-scope-change)
+ (api/symbol 'handle-scope)])
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-activity-change)
(api/symbol 'handle-activity)])
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-command)
@@ -1720,9 +999,10 @@
(defncall 'def-name 'str
(api/string "d/")
- (api/key-fn :caravan/name))
+ (api/key-fn :caravan/id))
(defncall 'detect-pipe-node '->
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "detect")])
(api/key-fn :caravan/type)
(api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :caravan/sink)]))
@@ -1787,6 +1067,17 @@
(api/keyword :formatted) (api/fn-call (api/symbol '->) [(api/map {(api/keyword :def) (api/symbol 'selected-source-change)})
(api/symbol 'format-def)])})}))
+ (defncall 'is-next-scope '->
+ (api/key-fn :next)
+ (api/key-fn :scope))
+
+ (defncall 'process-scope '->
+ (api/map {(api/keyword :state) (api/key-fn :state)
+ (api/keyword :next) (api/map {(api/keyword :mode) (api/keyword :navigate)
+ (api/keyword :scope) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :scope)])})})
+ (api/fn-call (api/symbol 'spy) [(api/string "scope")])
+ )
+
(defncall 'is-next-mode '->
(api/key-fn :next)
(api/key-fn :mode))
@@ -1882,6 +1173,8 @@
(api/symbol 'process-activity)])
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-next-cursor)
(api/symbol 'process-cursor)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-next-scope)
+ (api/symbol 'process-scope)])
(api/fn-call (api/symbol 'incase) [(api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :selected)])
(api/symbol 'process-select)])
(api/fn-call (api/symbol 'incase) [(api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :eval)])
@@ -1900,11 +1193,113 @@
(api/keyword :hovered) (api/map {})
(api/keyword :hover) (api/vector [])}))
+ (defncall 'source-menu 'pipes/debug (api/string "source-menu"))
+ (defncall 'source-menu-items 'pipes/debug (api/string "source-menu-items"))
+ (defncall 'source-menu-events 'pipes/debug (api/string "source-menu-events"))
+ (defncall 'source-menu-state 'pipes/debug (api/string "source-menu-state"))
+
+
+ (defncall 'source-menu-const '->
+ (api/vector [(api/string "debug")
+ (api/string "ui")
+ (api/string "http")])
+ (api/symbol 'many))
+
+ (defncall 'sink-menu 'pipes/debug (api/string "sink-menu"))
+ (defncall 'sink-menu-items 'pipes/debug (api/string "sink-menu-items"))
+ (defncall 'sink-menu-events 'pipes/debug (api/string "sink-menu-events"))
+ (defncall 'sink-menu-state 'pipes/debug (api/string "sink-menu-state"))
+
+ (defncall 'sink-menu-const '->
+ (api/vector [(api/string "debug")
+ (api/string "log")
+ (api/string "ui")
+ (api/string "http")])
+ (api/symbol 'many))
+
+ (defncall 'map-menu-item '->
+ (api/map {(api/keyword :position)
+ (api/key-fn :count)
+ (api/keyword :name)
+ (api/key-fn :name)
+ (api/keyword :type)
+ (api/key-fn :type)
+ (api/keyword :id)
+ (api/fn-call (api/symbol 'str) [(api/key-fn :type)
+ (api/string "/")
+ (api/key-fn :name)])}))
+
+ (defncall 'source-menu-map 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/vector [(api/key-fn :state)
+ (api/fn-call (api/symbol '->) [(api/map {(api/keyword :count)
+ (api/fn-call (api/symbol 'count) [(api/key-fn :state)])
+ (api/keyword :type)
+ (api/string "source")
+ (api/keyword :name)
+ (api/key-fn :next)})
+ (api/symbol 'map-menu-item)])])
+ (api/fn-call (api/symbol 'flatten) [(api/symbol '_)])])
+ (api/vector []))
+
+ (defncall 'sink-menu-map 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/vector [(api/key-fn :state)
+ (api/fn-call (api/symbol '->) [(api/map {(api/keyword :count)
+ (api/fn-call (api/symbol 'count) [(api/key-fn :state)])
+ (api/keyword :type)
+ (api/string "sink")
+ (api/keyword :name)
+ (api/key-fn :next)})
+ (api/symbol 'map-menu-item)])])
+ (api/fn-call (api/symbol 'flatten) [(api/symbol '_)])])
+ (api/vector []))
+
+ (defncall 'tag-items '->
+ (api/map {(api/keyword :items) (api/symbol '_)}))
+
+ (defncall 'tag-menu-source '->
+ (api/map {(api/keyword :source-menu) (api/symbol '_)}))
+
+ (defncall 'reduce-menu-source 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/vector [(api/key-fn :state) (api/key-fn :next)])
+ (api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)])])
+ (api/map {(api/keyword :items) (api/vector [])
+ (api/keyword :hover) (api/map {})}))
+
+ (defncall 'tag-sink-menu '->
+ (api/map {(api/keyword :sink-menu) (api/symbol '_)}))
+
+ (defncall 'reduce-menu-sink 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/vector [(api/key-fn :state) (api/key-fn :next)])
+ (api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)])])
+ (api/map {(api/keyword :items) (api/vector [])
+ (api/keyword :hover) (api/map {})
+ (api/keyword :resize) (api/map {})}))
+
+
+ (defncall 'state-dedupe 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/map {(api/keyword :next) (api/key-fn :next)
+ (api/keyword :state) (api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :state)])
+ (api/keyword :key) (api/fn-call (api/symbol 'first) [(api/fn-call (api/symbol 'keys) [(api/key-fn :next)])])})
+ (api/map {(api/keyword :next) (api/key-fn :next)
+ (api/keyword :state) (api/key-fn :state)
+ (api/keyword :existing) (api/fn-call (api/symbol 'lookup) [(api/key-fn :state) (api/key-fn :key) (api/keyword :not-found)])})
+ (api/map {(api/keyword :dupe) (api/fn-call (api/symbol 'if) [(api/fn-call (api/symbol '=) [(api/key-fn :existing) (api/key-fn :next)])
+ (api/keyword :dupe)
+ (api/keyword :unique)])
+ (api/keyword :state) (api/fn-call (api/symbol 'into) [(api/map {}) (api/vector [(api/key-fn :state) (api/key-fn :next)])])})])
+ (api/map {(api/keyword :state) (api/map {})}))
+
+
;; global state
- (defncall 'load-state 'pipes/debug ;; (api/keyword :oasis.spec/state)
+ (defncall 'load-state 'pipes/debug (api/string "load-state") ;; (api/keyword :oasis.spec/state)
)
- (defncall 'loaded-state 'pipes/debug ;; (api/keyword :oasis.spec/state)
+ (defncall 'loaded-state 'pipes/debug (api/string "loaded-state") ;; (api/keyword :oasis.spec/state)
)
(defncall 'load-reduce 'pipes/reductions
@@ -1922,123 +1317,10 @@
(defncall 'tag-layout '->
(api/map {(api/keyword :layout) (api/key-fn :success)}))
- (defncall 'layout-state 'pipes/debug ;; (api/keyword :oasis.spec/state)
+ (defncall 'layout-state 'pipes/debug (api/string "layout-state") ;; (api/keyword :oasis.spec/state)
)
- ;; cell handling
-
- (defncall 'func-id 'str
- (api/string "func/")
- (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :name)]))
-
-
- (defncall 'is-same '->
- (api/fn-call (api/symbol 'distinct) [(api/symbol '_)])
- (api/fn-call (api/symbol 'count) [(api/symbol '_)])
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/integer 1)]))
-
-
- (defncall 'is-selected '->
- (api/vector [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :selected)])
- (api/symbol 'func-id)])
- (api/symbol 'is-same))
-
- (defncall 'is-hovered '->
- (api/vector [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :hovered) (api/key-fn :name)])
- (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :name)])])
- (api/symbol 'is-same))
-
-
- (defncall 'cell-y '->
- (api/fn-call (api/symbol '*) [(api/integer 20)
- (api/key-fn :counter)])
- (api/fn-call (api/symbol '+) [(api/integer 10)
- (api/symbol '_)]))
-
- (defncall 'cell-x '->
- (api/fn-call (api/symbol '*) [(api/integer 15)
- (api/key-fn :level)]))
-
- (defncall 'cell-pos '->
- (api/map {(api/keyword :x)
- (api/integer 0)
- (api/keyword :y)
- (api/symbol 'cell-y)})
- (api/symbol 'translate-str))
-
- (defncall 'line-pos '->
- (api/map {(api/keyword :x)
- (api/integer 0)
- (api/keyword :y)
- (api/integer -15)})
- (api/symbol 'translate-str))
-
-
- (defncall 'text-pos '->
- (api/map {(api/keyword :x)
- (api/symbol 'cell-x)
- (api/keyword :y)
- (api/integer 0)})
- (api/symbol 'translate-str))
-
- (defncall 'counter-pos '->
- (api/map {(api/keyword :x)
- (api/integer 10)
- (api/keyword :y)
- (api/integer 0)})
- (api/symbol 'translate-str))
-
- (defncall 'type-pos '->
- (api/map {(api/keyword :x)
- (api/fn-call (api/symbol '+) [(api/integer 190)
- ;; (api/symbol 'cell-x)
- (api/integer 10)])
- (api/keyword :y)
- (api/integer 0)})
- (api/symbol 'translate-str))
-
- (defncall 'is-marked-cell '->
- (api/fn-call (api/symbol '-) [(api/fn-call (api/symbol '->) [(api/key-fn :context)
- (api/key-fn :mark)])
- (api/fn-call (api/symbol '->) [(api/key-fn :exp)
- (api/key-fn :counter)])])
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/integer 0)]))
-
- (defncall 'is-active-cell '->
- (api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '->) [(api/key-fn :context)
- (api/key-fn :selected)])
- (api/symbol 'is-marked-cell)]))
-
- (defncall 'is-edited-cell '->
- ;; (api/fn-call (api/symbol 'spy) [(api/string "edited")])
- (api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '->) [(api/key-fn :context)
- (api/key-fn :activity)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :edit)])])
- (api/fn-call (api/symbol '->) [(api/key-fn :context)
- (api/key-fn :selected)])
- (api/symbol 'is-marked-cell)]))
-
- (defncall 'is-active-branch '->
- (api/key-fn :exp)
- (api/key-fn :counter)
- (api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '>) [(api/symbol '_) (api/integer 100)])
- (api/fn-call (api/symbol '<) [(api/symbol '_) (api/integer 101)])]))
-
- (defncall 'get-fill '->
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-edited-cell)
- (api/fn-call (api/symbol '->) [(api/keyword :cell-edit)
- (api/symbol 'get-color)])])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-active-cell)
- (api/fn-call (api/symbol '->) [(api/keyword :cell-active)
- (api/symbol 'get-color)])])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-active-branch)
- (api/fn-call (api/symbol '->) [(api/keyword :cell-seclight)
- (api/symbol 'get-color)])])
- (api/fn-call (api/symbol 'incase) [(api/key-fn :exp)
- (api/fn-call (api/symbol '->) [(api/keyword :cell-background)
- (api/symbol 'get-color)])]))
-
(defncall 'make-cell '->
(api/symbol '_))
@@ -2064,9 +1346,18 @@
- (defncall 'is-pipe-eval '->
- (api/key-fn :caravan/type)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :caravan/pipe)]))
+ (defncall 'is-pipe-eval '->
+ (api/key-fn :caravan/type)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :caravan/pipe)]))
+
+ (defncall 'is-module-eval '->
+ (api/key-fn :caravan/type)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :caravan/module)]))
+
+ (defncall 'filter-modules '->
+ (api/key-fn :eval)
+ (api/fn-call (api/symbol 'filter) [(api/symbol 'is-module-eval)
+ (api/symbol '_)]))
(defncall 'filter-nodes '->
(api/key-fn :eval)
@@ -2078,16 +1369,55 @@
(api/fn-call (api/symbol 'filter) [(api/symbol 'is-pipe-eval)
(api/symbol '_)]))
- (defncall 'merge-defs '->
- (api/map {(api/keyword :def) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
- (api/keyword :context) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])}))
- (defncall 'format-defs '->
- (api/fn-call (api/symbol 'myzip) [(api/key-fn :defs)
- (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol 'count) [(api/key-fn :defs)])
- (api/key-fn :context)])])
- (api/fn-call (api/symbol 'map) [(api/symbol 'merge-defs) (api/symbol '_)])
- (api/fn-call (api/symbol 'map) [(api/symbol 'format-def) (api/symbol '_)]))
+ (defncall 'format-child-fn '->
+ (api/map {(api/keyword :def) (api/fn-call (api/symbol 'lookup) [(api/key-fn :evalorig) (api/fn-call (api/symbol 'str) [(api/key-fn :node)]) (api/map {(api/keyword :unknown) (api/fn-call (api/symbol 'str) [(api/key-fn :node)])})])
+ (api/keyword :context) (api/map {(api/keyword :zoom) (api/integer 2)})})
+ (api/symbol 'format-def)
+ )
+
+ (defncall 'merge-child-fn '->
+ (api/map {(api/keyword :node) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
+ (api/keyword :evalorig) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])}))
+
+ (defncall 'format-child-fns '->
+ (api/fn-call (api/symbol 'myzip) [(api/fn-call (api/symbol '->) [(api/key-fn :mod)
+ (api/key-fn :caravan/nodes)])
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol '->) [(api/key-fn :mod)
+ (api/key-fn :caravan/nodes)
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])])
+ (api/key-fn :evalorig)])])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'merge-child-fn) (api/symbol '_)])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'format-child-fn) (api/symbol '_)]))
+
+ (defncall 'port-name 'str
+ (api/string "d/")
+ (api/key-fn :caravan/id))
+
+ (defncall 'format-port-def '->
+ (api/map {(api/keyword :id) (api/fn-call (api/symbol '->) [(api/key-fn :def) (api/symbol 'port-name)])
+ (api/keyword :name) (api/fn-call (api/symbol '->) [(api/key-fn :def) (api/key-fn :caravan/name)])
+ (api/keyword :width) (api/integer 30)
+ (api/keyword :height) (api/integer 30)}))
+
+ (defncall 'format-port '->
+ (api/map {(api/keyword :def) (api/fn-call (api/symbol 'lookup) [(api/key-fn :evalorig) (api/fn-call (api/symbol 'str) [(api/key-fn :port)]) (api/map {(api/keyword :unknown) (api/fn-call (api/symbol 'str) [(api/key-fn :port)])})])})
+ (api/symbol 'format-port-def)
+ )
+
+ (defncall 'merge-port '->
+ (api/map {(api/keyword :port) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
+ (api/keyword :evalorig) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])}))
+
+ (defncall 'format-ports '->
+ (api/fn-call (api/symbol 'myzip) [(api/fn-call (api/symbol '->) [(api/key-fn :mod)
+ (api/key-fn :caravan/ports)])
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol '->) [(api/key-fn :mod)
+ (api/key-fn :caravan/ports)
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])])
+ (api/key-fn :evalorig)])])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'merge-port) (api/symbol '_)])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'format-port) (api/symbol '_)]))
(defncall 'extract-connection '->
(api/fn-call (api/symbol 'if) [(api/key-fn :caravan/func)
@@ -2100,24 +1430,91 @@
(api/keyword :to) (api/key-fn :caravan/sink)})])]))
- (defncall 'format-pipes '->
- (api/fn-call (api/symbol 'mapcat) [(api/symbol 'extract-connection) (api/key-fn :pipes)])
+ (defncall 'merge-child-pipe '->
+ (api/map {(api/keyword :pipe) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
+ (api/keyword :evalorig) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])}))
+
+ (defncall 'extract-child-pipe '->
+ (api/fn-call (api/symbol 'lookup) [(api/key-fn :evalorig) (api/fn-call (api/symbol 'str) [(api/key-fn :pipe)]) (api/map {(api/keyword :unknown) (api/fn-call (api/symbol 'str) [(api/key-fn :pipe)])})])
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "fconn")])
+ (api/symbol 'extract-connection))
+
+ (defncall 'format-child-pipes '->
+ (api/fn-call (api/symbol 'myzip) [(api/fn-call (api/symbol '->) [(api/key-fn :mod)
+ (api/key-fn :caravan/pipes)])
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol '->) [(api/key-fn :mod)
+ (api/key-fn :caravan/pipes)
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])])
+ (api/key-fn :evalorig)])])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'merge-child-pipe) (api/symbol '_)])
+ (api/fn-call (api/symbol 'mapcat) [(api/symbol 'extract-child-pipe) (api/symbol '_)])
(api/fn-call (api/symbol 'map) [(api/symbol 'format-pipe) (api/symbol '_)]))
+ (defncall 'format-mod '->
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "fmod2")])
+ (api/map {(api/keyword :id) (api/fn-call (api/symbol '->) [(api/key-fn :mod) (api/key-fn :caravan/name)])
+ (api/keyword :name) (api/fn-call (api/symbol '->) [(api/key-fn :mod) (api/key-fn :caravan/name)])
+ (api/keyword :type) (api/keyword :module)
+ (api/keyword :ports) (api/symbol 'format-ports)
+ (api/keyword :children) (api/symbol 'format-child-fns)
+ (api/keyword :edges) (api/symbol 'format-child-pipes)
+ })
+ )
+
+
+ (defncall 'merge-mod '->
+ (api/map {(api/keyword :mod) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
+ (api/keyword :evalorig) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])}))
+
+ (defncall 'format-modules '->
+ (api/fn-call (api/symbol 'myzip) [(api/fn-call (api/symbol '->) [(api/key-fn :modules)])
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol '->) [(api/key-fn :modules)
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])])
+ (api/key-fn :evalorig)])])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'merge-mod) (api/symbol '_)])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'format-mod) (api/symbol '_)]))
+
+ (defncall 'format-scope '->
+ (api/map {(api/keyword :scope) (api/fn-call (api/keyword '->) [(api/key-fn :context)])})
+ (api/fn-call (api/symbol 'spy) [(api/string "fscope")])
+ )
+
+ (defncall 'merge-defs '->
+ (api/map {(api/keyword :def) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
+ (api/keyword :context) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])}))
+
+ (defncall 'format-defs '->
+ (api/fn-call (api/symbol 'myzip) [(api/key-fn :defs)
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol 'count) [(api/key-fn :defs)])
+ (api/key-fn :context)])])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'merge-defs) (api/symbol '_)])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'format-def) (api/symbol '_)]))
+
+ ;; (defncall 'format-pipes '->
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "freepipe")])
+ ;; (api/fn-call (api/symbol 'mapcat) [(api/symbol 'extract-connection) (api/key-fn :pipes)])
+ ;; (api/fn-call (api/symbol 'map) [(api/symbol 'format-pipe) (api/symbol '_)]))
+
(defncall 'format-state '->
- (api/map {(api/keyword :eval) (api/fn-call (api/symbol '->) [(api/key-fn :eval)
+ (api/map {(api/keyword :evalorig) (api/key-fn :eval)
+ (api/keyword :eval) (api/fn-call (api/symbol '->) [(api/key-fn :eval)
(api/fn-call (api/symbol 'vals) [(api/symbol '_)])])
(api/keyword :context) (api/symbol '_)})
- (api/map {(api/keyword :defs) (api/symbol 'filter-nodes)
- (api/keyword :pipes) (api/symbol 'filter-connections)
- (api/keyword :context) (api/key-fn :context)})
+ (api/map {(api/keyword :evalorig) (api/key-fn :evalorig)
+ (api/keyword :defs) (api/symbol 'filter-nodes)
+ (api/keyword :pipes) (api/symbol 'filter-connections)
+ (api/keyword :modules) (api/symbol 'filter-modules)
+ (api/keyword :context) (api/key-fn :context)})
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "fmod")])
(api/map {(api/keyword :id) (api/string "root")
(api/keyword :layoutOptions) (api/map {(api/string "elk.algorithm") (api/string "layered")})
- (api/keyword :children) (api/symbol 'format-defs)
- (api/keyword :edges) (api/symbol 'format-pipes)}))
+ (api/keyword :children) (api/fn-call (api/symbol 'into) [(api/symbol 'format-modules) ;; (api/symbol 'format-defs)
+ ])
+ ;; (api/keyword :edges) (api/symbol 'format-pipes)
+ }))
- (defncall 'lay-in 'pipes/debug)
+ (defncall 'lay-in 'pipes/debug (api/string "lay-in"))
(defncall 'edit-information '->
@@ -2135,9 +1532,6 @@
(api/key-fn :state)
(api/key-fn :editor)
(api/key-fn :mark))
- ])
-
-(def oasis3 [
(defncall 'map-choice-to-type '->
(api/fn-call (api/symbol 'incase) [(api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :first)])
@@ -2263,7 +1657,39 @@
(api/map {(api/keyword :state) (api/key-fn :state)
(api/keyword :next) (api/map {(api/keyword :call)
(api/map {(api/keyword :action)
- (api/keyword :load)})})}))
+ (api/keyword :load)
+ (api/keyword :arguments)
+ (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :load)])})})}))
+
+ (defncall 'should-create '->
+ (api/key-fn :next)
+ (api/key-fn :command)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :create-sink)]))
+
+ (defncall 'create '->
+ (api/map {(api/keyword :state) (api/key-fn :state)
+ (api/keyword :next) (api/map {(api/keyword :call)
+ (api/map {(api/keyword :action)
+ (api/keyword :create-sink)
+ (api/keyword :arguments)
+ (api/map {(api/keyword :scope) (api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :mode) (api/key-fn :scope)])
+ (api/keyword :args) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :data)])})})})}))
+
+ (defncall 'should-connect '->
+ (api/key-fn :next)
+ (api/key-fn :command)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :connect)]))
+
+ (defncall 'link '->
+ (api/fn-call (api/symbol 'spy) [(api/string "link")])
+ (api/map {(api/keyword :state) (api/key-fn :state)
+ (api/keyword :next) (api/map {(api/keyword :call)
+ (api/map {(api/keyword :action)
+ (api/keyword :link)
+ (api/keyword :arguments) (api/map {(api/keyword :scope)
+ (api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :mode) (api/key-fn :scope)])
+ (api/keyword :args)
+ (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :data)])})})})}))
(defncall 'should-test '->
(api/key-fn :next)
@@ -2356,6 +1782,12 @@
(api/fn-call (api/symbol 'incase) [(api/symbol 'should-load)
(api/symbol 'load)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'should-create)
+ (api/symbol 'create)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'should-connect)
+ (api/symbol 'link)])
+ ;; (api/fn-call (api/symbol 'incase) [(api/symbol 'should-load)
+ ;; (api/symbol 'load)])
(api/fn-call (api/symbol 'incase) [(api/symbol 'should-test)
(api/symbol 'test)])
(api/fn-call (api/symbol 'incase) [(api/symbol 'should-trace)
@@ -2495,182 +1927,886 @@
(api/vector [(api/keyword :next)
(api/keyword :mode)])
(api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :editor) (api/key-fn :mode)])])
+ (api/fn-call (api/symbol 'assoc-in) [(api/symbol '_)
+ (api/vector [(api/keyword :next)
+ (api/keyword :scope)])
+ (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :editor) (api/key-fn :scope)])])
(api/fn-call (api/symbol 'update-in) [(api/symbol '_) (api/vector [(api/keyword :next) (api/keyword :editor)]) (api/keyword :removed)])
(api/vector [(api/key-fn :state)
(api/key-fn :next)])
(api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)]) ])
(api/map {(api/keyword :mode) (api/keyword :unknown)
+ (api/keyword :scope) (api/keyword :none)
(api/keyword :actions) (api/vector [])}))
(defncall 'tag-mode '->
(api/map {(api/keyword :mode) (api/symbol '_)}))
- (defncall 'init-view '->
- (api/map {(api/keyword :zoom) (api/integer 1)
- (api/keyword :x) (api/integer 150)
- (api/keyword :y) (api/integer 50)}))
-
- (defncall 'm-caravan-actions 'caravan-actions (api/integer 42))
+ (defncall 'm-caravan-actions 'caravan-actions)
])
(def oasis-core-defs
- [(defncall 'oasis-core-init 'pipes/debug)
- (defncall 'oasis-core-out 'pipes/debug)
- (api/defmodule 'oasis-core (api/map {(api/keyword :sources) (api/map {(api/keyword :init) (api/symbol 'oasis-core-init)})
- (api/keyword :sinks) (api/map {(api/keyword :state) (api/symbol 'oasis-core-out)})}))])
+ [(defncall 'oasis-core-init 'pipes/debug (api/string "oasis-core-init"))
+ (defncall 'oasis-kb 'pipes/debug (api/string "oasis-kb"))
+ (defncall 'oasis-hover-state 'pipes/debug (api/string "oasis-hover-state"))
+ (defncall 'oasis-hover-in 'pipes/debug (api/string "oasis-hover-in"))
+ (defncall 'oasis-scroll-state 'pipes/debug (api/string "oasis-scroll-state"))
+ (defncall 'oasis-drag-state 'pipes/debug (api/string "oasis-drag-state"))
+ (defncall 'oasis-core-events 'pipes/debug (api/string "oasis-core-events"))
+ (defncall 'oasis-core-out 'pipes/debug (api/string "oasis-core-out"))
+
+ (defncall 'log-drag 'pipes/log (api/string "drag: "))
+ (defncall 'log-hover 'pipes/log (api/string "hover: "))
+ (defncall 'log-scroll 'pipes/log (api/string "scroll: "))
+ (defncall 'log-state2 'pipes/log (api/string "state: "))
+
+ (api/defmodule 'oasis-core (api/map {(api/keyword :depends) (api/map {(api/keyword :caravan) (api/symbol 'modules/caravan)})
+ (api/keyword :sources) (api/map {(api/keyword :module-caravan-inst) (api/symbol 'carv-mod)
+ (api/keyword :module-caravan) (api/symbol 'm-caravan)
+ (api/keyword :caravan-commands) (api/symbol 'm-caravan-commands)
+ (api/keyword :caravan-commands-inst) (api/symbol 'caravan-commands)
+ (api/keyword :caravan-eval) (api/symbol 'm-caravan-eval)
+ (api/keyword :caravan-eval-inst) (api/symbol 'caravan-eval)
+ ;(api/keyword :layout) (api/symbol 'oasis-layout)
+ (api/keyword :init) (api/symbol 'oasis-core-init)
+ (api/keyword :kb) (api/symbol 'oasis-kb)
+ (api/keyword :drag) (api/symbol 'oasis-drag-state)
+ (api/keyword :hover) (api/symbol 'oasis-hover-in)
+ (api/keyword :events) (api/symbol 'oasis-core-events)
+ (api/keyword :state) (api/symbol 'oasis-core-out)
+ })
+ (api/keyword :sinks) (api/map {(api/keyword :state) (api/symbol 'oasis-core-out)
+ })}))])
(def oasis-core-net
- [ ;; networks
-
- (pipe 'oasis-mouse 'mouse-reduce)
- (pipe 'mouse-reduce 'mouse-state)
- (pipe 'oasis-mouse 'target-reduce)
- (pipe 'target-reduce 'target-events)
-
- (pipe 'target-events 'only-different 'hover-events)
- (pipe 'hover-events 'tag-hover 'hover-state)
-
- (pipe 'oasis-kb 'filter-key-input 'keyboard-filtered)
- (pipe 'keyboard-filtered 'filter-edit 'editor-commands)
- (pipe 'keyboard-filtered 'filter-menu 'editor-commands)
- ;; (pipe 'keyboard-filtered 'log-keyboard)
- ;; (pipe 'oasis-kb 'log-keyboard)
-
- (pipe 'keyboard-filtered 'filter-view 'view-commands)
- (pipe 'view-commands 'make-zoom)
- (pipe 'make-zoom 'zoom-events)
- (pipe 'zoom-events 'view-events)
- (pipe 'view-commands 'view-deltas)
-
- (pipe 'raw-events 'input-reduce)
- (pipe 'input-reduce 'reduced-events)
- (pipe 'raw-events 'tag-events 'events)
-
- ;; (pipe 'oasis-ev 'filter-input 'raw-events)
- ;; (pipe 'oasis-ev 'filter-submit 'raw-events)
-
- (pipe 'oasis-ui-out 'filter-resize 'events)
-
- ;; (pipe 'select-events 'editor-commands)
-
- (pipe 'oasis-eval 'eval-events)
-
- ;; (pipe 'eval-events 'log-events)
- (pipe 'eval-events 'eval-reduce)
- (pipe 'eval-reduce 'eval-raw)
- (pipe 'eval-raw 'tag-eval 'eval-state)
-
- (pipe 'mouse-state 'filter-drag 'drag-events)
-
- (pipe 'drag-events 'filter-drag-end-or-start 'drag-state) ;; FIXME reduce
- ;; (pipe 'drag-state 'log-mouse)
- (pipe 'drag-state 'interpret-drag 'editor-commands)
- ;; (pipe 'drag-events 'log-mouse)
-
- (api/pipe (api/fn-call (api/symbol 'caravan-commands) [(api/integer 42)])
- (api/symbol 'handle-caravan-command)
- (api/symbol 'editor-commands))
- ;; (pipe 'caravan 'handle-caravan-command 'editor-commands)
- (pipe 'editor-commands 'handle-commands 'editor-events)
- (pipe 'hover-state 'editor-events)
- (pipe 'scroll-state 'editor-events)
- (pipe 'editor-events 'editor-state-reduce)
- (pipe 'editor-state-reduce 'editor-cooked)
- (pipe 'editor-cooked 'tag-editor 'editor-state)
- ;; (pipe 'editor-state 'log-editor)
-
- (pipe 'editor-commands 'filter-immediate 'editor-immediate)
- ;; (pipe 'editor-immediate 'log-command)
-
- (pipe 'mouse-state 'filter-scroll 'scroll-state)
- (pipe 'scroll-state 'construct-view 'view-deltas)
- (pipe 'view-deltas 'view-delta)
- (pipe 'view-delta 'view-events)
- (pipe 'view-events 'view-reduce)
- (pipe 'view-reduce 'view-raw)
- (pipe 'view-raw 'tag-view 'view-state)
-
-
- (pipe 'editor-state 'state-dedupe)
- (pipe 'loaded-state 'state-dedupe)
- (pipe 'view-state 'state-dedupe)
- (pipe 'drag-events 'state-dedupe)
- (pipe 'hover-state 'state-dedupe)
- (pipe 'mode-state 'state-dedupe)
- (pipe 'events 'state-dedupe)
- (pipe 'state-dedupe 'filter-state 'oasis-core-out)
-
- (pipe 'mode-state 'load-reduce)
- (pipe 'hover-state 'load-reduce)
- (pipe 'eval-state 'load-reduce)
- (pipe 'zoom-events 'load-reduce)
- (pipe 'load-reduce 'load-state)
- (pipe 'load-state 'filter-load 'loaded-state)
-
- (pipe 'loaded-state 'format-state 'oasis-layout)
- ;; (pipe 'eval-state 'format-state 'log-layout)
-
- (pipe 'eval-state 'edit-information 'editor-events)
-
- (pipe 'oasis-layout 'tag-layout 'layout-state)
- ;; (pipe 'layout-state 'log-layout)
- (pipe 'layout-state 'state-dedupe)
-
- ;; (pipe 'select-events 'center-view)
- ;; (pipe 'layout-state 'center-view)
- ;; (pipe 'center-view 'view-events)
-
- (pipe 'editor-state 'mode-data)
- (pipe 'mode-data 'mode-raw)
- (pipe 'mode-raw 'tag-mode 'mode-state)
-
- (pipe 'editor-state 'editor-actions)
- (pipe 'editor-immediate 'editor-actions)
- (pipe 'mode-state 'editor-actions)
- (pipe 'events 'editor-actions)
-
- (pipe 'editor-actions 'handle-state)
- (pipe 'handle-state 'be-commands)
- ;; (pipe 'be-commands 'log-command)
- (api/pipe (api/symbol 'be-commands)
- (api/symbol 'filter-call)
- (api/symbol 'm-caravan-actions))
-
- (pipe 'oasis-core-init 'source-menu-const 'source-menu-items)
- (pipe 'source-menu-items 'source-menu-map)
- (pipe 'source-menu-map 'source-menu)
- (pipe 'source-menu 'tag-items 'source-menu-events)
- (pipe 'hover-state 'source-menu-events)
- (pipe 'source-menu-events 'reduce-menu-source)
- (pipe 'reduce-menu-source 'source-menu-state)
- (pipe 'source-menu-state 'tag-menu-source 'state-reduce)
-
- (pipe 'oasis-core-init 'sink-menu-const 'sink-menu-items)
- (pipe 'sink-menu-items 'sink-menu-map)
- (pipe 'sink-menu-map 'sink-menu)
- (pipe 'sink-menu 'tag-items 'sink-menu-events)
- (pipe 'hover-state 'sink-menu-events)
- (pipe 'events 'sink-menu-events)
- (pipe 'sink-menu-events 'reduce-menu-sink)
- (pipe 'reduce-menu-sink 'sink-menu-state)
- (pipe 'sink-menu-state 'tag-sink-menu 'state-reduce)
-
-
- ;; (pipe 'init 'header 'render)
- ;; (pipe 'init 'repl 'render)
- (pipe 'oasis-core-init 'init-view 'view-events)
-
- (api/pipe (api/fn-call (api/symbol 'caravan-commands) [(api/integer 42)])
- (api/symbol 'log-caravan))
-
+ [;; networks
+
+ (pipe 'oasis-drag-state 'log-drag)
+ (pipe 'oasis-hover-in 'oasis-hover-state)
+
+ (pipe 'oasis-kb 'filter-key-input 'keyboard-filtered)
+ (pipe 'keyboard-filtered 'filter-edit 'editor-commands)
+ (pipe 'keyboard-filtered 'filter-menu 'editor-commands)
+ (pipe 'keyboard-filtered 'log-keyboard)
+
+ (pipe 'raw-events 'input-reduce)
+ (pipe 'input-reduce 'reduced-events)
+ (pipe 'raw-events 'tag-events 'events)
+
+ ;; (pipe 'oasis-ev 'filter-input 'raw-events)
+ ;; (pipe 'oasis-ev 'filter-submit 'raw-events)
+
+ (pipe 'oasis-core-events 'filter-resize 'events)
+
+ ;; (pipe 'select-events 'editor-commands)
+
+ (pipe 'caravan-eval 'log-caravan-ev)
+ (pipe 'caravan-eval 'eval-events)
+
+ ;; (pipe 'eval-events 'log-events)
+ (pipe 'eval-events 'eval-reduce)
+ (pipe 'eval-reduce 'eval-raw)
+ (pipe 'eval-raw 'tag-eval 'eval-state)
+
+ (pipe 'oasis-drag-state 'interpret-drag 'editor-commands)
+
+ (pipe 'caravan-commands 'handle-caravan-command 'editor-commands)
+ (pipe 'editor-commands 'handle-commands 'editor-events)
+ (pipe 'oasis-hover-state 'editor-events)
+ ;; (pipe 'oasis-scroll-state 'editor-events)
+ (pipe 'editor-events 'editor-state-reduce)
+ (pipe 'editor-state-reduce 'editor-cooked)
+ (pipe 'editor-cooked 'tag-editor 'editor-state)
+ ;; (pipe 'editor-state 'log-editor)
+
+ (pipe 'editor-commands 'filter-immediate 'editor-immediate)
+ ;; (pipe 'editor-immediate 'log-command)
+
+
+ (pipe 'oasis-core-init 'source-menu-const 'source-menu-items)
+ (pipe 'source-menu-items 'source-menu-map)
+ (pipe 'source-menu-map 'source-menu)
+ (pipe 'source-menu 'tag-items 'source-menu-events)
+ (pipe 'oasis-hover-state 'source-menu-events)
+ (pipe 'source-menu-events 'reduce-menu-source)
+ (pipe 'reduce-menu-source 'source-menu-state)
+ (pipe 'source-menu-state 'tag-menu-source 'state-dedupe)
+
+ (pipe 'oasis-core-init 'sink-menu-const 'sink-menu-items)
+ (pipe 'sink-menu-items 'sink-menu-map)
+ (pipe 'sink-menu-map 'sink-menu)
+ (pipe 'sink-menu 'tag-items 'sink-menu-events)
+ (pipe 'oasis-hover-state 'sink-menu-events)
+ (pipe 'events 'sink-menu-events)
+ (pipe 'sink-menu-events 'reduce-menu-sink)
+ (pipe 'reduce-menu-sink 'sink-menu-state)
+ (pipe 'sink-menu-state 'tag-sink-menu 'state-dedupe)
+
+ (pipe 'editor-state 'state-dedupe)
+ (pipe 'loaded-state 'state-dedupe)
+ (pipe 'oasis-hover-state 'state-dedupe)
+ (pipe 'mode-state 'state-dedupe)
+ (pipe 'events 'state-dedupe)
+ (pipe 'state-dedupe 'filter-state 'oasis-core-out)
+ ;; (pipe 'state-dedupe 'oasis-core-out)
+
+ (pipe 'mode-state 'load-reduce)
+ ;; (pipe 'scope-state 'load-reduce)
+ (pipe 'oasis-hover-state 'load-reduce)
+ (pipe 'eval-state 'load-reduce)
+ (pipe 'load-reduce 'load-state)
+ (pipe 'load-state 'filter-load 'loaded-state)
+
+ (pipe 'loaded-state 'format-state 'oasis-layout)
+ ;; (pipe 'loaded-state 'format-state 'log-layout)
+
+ (pipe 'eval-state 'edit-information 'editor-events)
+
+ (pipe 'oasis-layout 'tag-layout 'layout-state)
+ (pipe 'layout-state 'state-dedupe)
+
+ ;; (pipe 'select-events 'center-view)
+ ;; (pipe 'layout-state 'center-view)
+ ;; (pipe 'center-view 'view-events)
+
+ (pipe 'editor-state 'mode-data)
+ (pipe 'mode-data 'mode-raw)
+ (pipe 'mode-raw 'tag-mode 'mode-state)
+
+ (pipe 'editor-state 'editor-actions)
+ (pipe 'editor-immediate 'editor-actions)
+ (pipe 'mode-state 'editor-actions)
+ (pipe 'events 'editor-actions)
+
+ (pipe 'editor-actions 'handle-state)
+ (pipe 'handle-state 'be-commands)
+ (pipe 'be-commands 'filter-call 'log-command)
+ (api/pipe (api/symbol 'be-commands)
+ (api/symbol 'filter-call)
+ (api/symbol 'm-caravan-actions))
+
+
+ (pipe 'oasis-core-init 'm-caravan-actions)
+
+ (pipe 'caravan-commands 'log-caravan)
])
(def oasis-render-defs
[
- (defncall 'oasis-render-in 'pipes/debug)
- (defncall 'oasis-render-out 'pipes/debug)
+ (defncall 'oasis-render-in 'pipes/debug (api/string "oasis-render-in"))
+ (defncall 'oasis-render-init 'pipes/debug (api/string "oasis-render-init"))
+ (defncall 'oasis-render-mouse-in 'pipes/debug (api/string "oasis-render-mouse-in"))
+ (defncall 'oasis-render-kb-in 'pipes/debug (api/string "oasis-render-kb-in"))
+ (defncall 'oasis-render-kb-out 'pipes/debug (api/string "oasis-render-kb-out"))
+ (defncall 'oasis-render-drag-out 'pipes/debug (api/string "oasis-render-drag-out"))
+ (defncall 'oasis-render-hover-out 'pipes/debug (api/string "oasis-render-hover-out"))
+ (defncall 'oasis-render-out 'pipes/debug (api/string "oasis-render-out"))
+ (defncall 'scroll-state 'pipes/debug (api/string "scroll-state"))
+ (defncall 'log-view 'pipes/log (api/string "view: "))
+ (defncall 'log-mouse2 'pipes/log (api/string "mouse2: "))
+ (defncall 'log-hov 'pipes/log (api/string "hov: "))
+
+ ;; dark theme based on base16-atelierdune-dark
+ ;; (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune)
+ (defmap 'get-color
+ {(api/keyword :cell-active) (api/string "#4d4a41")
+ (api/keyword :cell-edit) (api/string "#6684e1")
+ (api/keyword :cell-seclight) (api/string "#999580")
+ (api/keyword :cell-background) (api/string "#292824")
+ (api/keyword :cell-content) (api/string "#e8e4cf")
+ (api/keyword :cell-active-content) (api/string "#fefbec")
+ (api/keyword :cell-dividers) (api/string "#6e6b5e")
+ (api/keyword :cell-type-fill) (api/string "#6e6b5e")
+ (api/keyword :cell-type-stroke) (api/string "#20201d")
+ (api/keyword :cell-counter-stroke) (api/string "#6e6b5e")
+ (api/keyword :node-selected) (api/string "#6684e1")
+ (api/keyword :node-bg) (api/string "#292824")
+ (api/keyword :node-name-stroke) (api/string "#e8e4cf")
+ (api/keyword :node-gutter) (api/string "#292824")
+ (api/keyword :element-highlight-stroke) (api/string "#6684e1")
+ (api/keyword :pipe-fill) (api/string "#292824")
+ (api/keyword :pipe-glow) (api/string "#6684e1")
+ (api/keyword :pipe-stroke) (api/string "#a6a28c")
+ (api/keyword :pipe-drag) (api/string "#b65611")
+ (api/keyword :module-bg) (api/string "#6684e1")
+ (api/keyword :module-border) (api/string "#1fad83")
+ (api/keyword :edge-in) (api/string "#6684e1")
+ (api/keyword :edge-out) (api/string "#b65611")
+ (api/keyword :edge-neutral) (api/string "#a6a28c")
+ (api/keyword :graph-background) (api/string "#20201d")
+ (api/keyword :shadow-flood) (api/string "#292824")
+ (api/keyword :menu-entry-bg) (api/string "#999580")
+ (api/keyword :menu-entry-active-bg) (api/string "#a6a28c")
+ (api/keyword :menu-entry-text) (api/string "#fefbec")
+ (api/keyword :menu-bar-bg) (api/string "#6e6b5e")
+ (api/keyword :menu-bar-text) (api/string "#a6a28c")
+ })
+
+ (defmap 'get-font
+ {(api/string "str") (api/string "serif")})
+
+ (defmap 'get-syntax-color
+ {(api/keyword :caravan/str) (api/map {(api/keyword :cell-content) (api/string "#60ac39")
+ (api/keyword :cell-active-content) (api/string "#60ac39")})
+ (api/keyword :caravan/kw) (api/map {(api/keyword :cell-content) (api/string "#b65611")
+ (api/keyword :cell-active-content) (api/string "#b65611")})
+ (api/keyword :caravan/int) (api/map {(api/keyword :cell-content) (api/string "#1fad83")
+ (api/keyword :cell-active-content) (api/string "#1fad83")})
+ (api/keyword :caravan/float) (api/map {(api/keyword :cell-content) (api/string "#1fad83")
+ (api/keyword :cell-active-content) (api/string "#1fad83")})
+ (api/keyword :caravan/acc) (api/map {(api/keyword :cell-content) (api/string "#ae9513")
+ (api/keyword :cell-active-content) (api/string "#ae9513")})
+ (api/keyword :caravan/func) (api/map {(api/keyword :cell-content) (api/string "#6684e1")
+ (api/keyword :cell-active-content) (api/string "#6684e1")})
+ (api/keyword :caravan/table) (api/map {(api/keyword :cell-content) (api/string "#d43552")
+ (api/keyword :cell-active-content) (api/string "#d43552")})
+ (api/keyword :caravan/list) (api/map {(api/keyword :cell-content) (api/string "#b854d4")
+ (api/keyword :cell-active-content) (api/string "#b854d4")})})
+
+
+ ;; View handling
+
+ (defncall 'view-raw 'pipes/debug (api/string "view-raw") ;; (api/keyword :oasis.spec/mouse-state)
+ )
+ (defncall 'view-state 'pipes/debug (api/string "view-state") ;; (api/keyword :oasis.spec/mouse-state)
+ )
+ (defncall 'view-deltas 'pipes/debug (api/string "view-deltas") ;; (api/keyword :oasis.spec/mouse-state)
+ )
+ (defncall 'view-commands 'pipes/debug (api/string "view-commands"))
+ (defncall 'view-events 'pipes/debug (api/string "view-events"))
+ (defncall 'zoom-events 'pipes/debug (api/string "zoom-events"))
+
+ (defncall 'init-view '->
+ (api/map {(api/keyword :zoom) (api/integer 1)
+ (api/keyword :x) (api/integer 150)
+ (api/keyword :y) (api/integer 50)}))
+
+ (defncall 'make-zoom 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/map {(api/keyword :zoom) (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :zoom)])
+ (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :zoom)])])})])
+ (api/map {(api/keyword :zoom) (api/integer 1)}))
+
+
+ (defncall 'view-delta 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/map {(api/keyword :x)
+ (api/fn-call (api/symbol '+) [(api/fn-call (api/symbol '->)
+ [(api/key-fn :next)
+ (api/key-fn :x)])
+ (api/fn-call (api/symbol '->)
+ [(api/key-fn :state)
+ (api/key-fn :x)])])
+ (api/keyword :y)
+ (api/fn-call (api/symbol '+) [(api/fn-call (api/symbol '->)
+ [(api/key-fn :next)
+ (api/key-fn :y)])
+ (api/fn-call (api/symbol '->)
+ [(api/key-fn :state)
+ (api/key-fn :y)])])}
+ )])
+ (api/map {(api/keyword :x) (api/integer 150)
+ (api/keyword :y) (api/integer 50)}))
+
+ (defncall 'construct-view '->
+ (api/key-fn :mouse)
+ (api/map {(api/keyword :x) (api/fn-call (api/symbol '->) [(api/key-fn :delta)
+ (api/key-fn :x)])
+ (api/keyword :y) (api/fn-call (api/symbol '->) [(api/key-fn :delta)
+ (api/key-fn :y)])}))
+
+ (defncall 'center-view 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/map {(api/keyword :x) (api/integer 150)
+ (api/keyword :y) (api/integer 50)})])
+ (api/map {}))
+
+ (defncall 'view-reduce 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/fn-call (api/symbol 'into) [(api/key-fn :state) (api/key-fn :next)])])
+ (api/map {(api/keyword :zoom) (api/integer 1)
+ (api/keyword :x) (api/integer 150)
+ (api/keyword :y) (api/integer 50)}))
+
+ (defncall 'tag-view '->
+ (api/map {(api/keyword :view) (api/symbol '_)}))
+
+
+ ;; Mouse handling
+ (defncall 'drag-events 'pipes/debug (api/string "drag-events"))
+
+ (defncall 'is-mouse-move '->
+ (api/key-fn :next)
+ (api/key-fn :samak.mouse/type)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :move)]))
+
+ (defncall 'is-mouse-down '->
+ (api/key-fn :next)
+ (api/key-fn :samak.mouse/type)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :down)]))
+
+ (defncall 'handle-mouse-down '->
+ (api/map {(api/keyword :state) (api/key-fn :state)
+ (api/keyword :next) (api/fn-call (api/symbol '->)
+ [(api/key-fn :next)
+ (api/map {(api/keyword :drag) (api/map {(api/keyword :begin) (api/keyword :true)
+ (api/keyword :active) (api/keyword :true)
+ (api/keyword :button) (api/key-fn :samak.mouse/button)
+ (api/keyword :source) (api/key-fn :samak.mouse/target)})
+
+ (api/keyword :position) (api/map {(api/keyword :x) (api/key-fn :samak.mouse/page-x)
+ (api/keyword :y) (api/symbol 'get-mouse-y)})
+ (api/keyword :start) (api/map {(api/keyword :x) (api/key-fn :samak.mouse/page-x)
+ (api/keyword :y) (api/symbol 'get-mouse-y)})})])}))
+
+ (defncall 'is-mouse-up '->
+ (api/key-fn :next)
+ (api/key-fn :samak.mouse/type)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :up)]))
+
+ (defncall 'handle-mouse-up '->
+ (api/map {(api/keyword :state) (api/key-fn :state)
+ (api/keyword :next) (api/map {(api/keyword :drag)
+ (api/map {(api/keyword :active) (api/keyword :false)
+ (api/keyword :end) (api/keyword :end)
+ (api/keyword :button) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :samak.mouse/button)])
+ (api/keyword :target) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :samak.mouse/target)])
+ (api/keyword :source) (api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :mouse) (api/key-fn :drag) (api/key-fn :source)])})})}))
+
+
+ (defncall 'handle-mouse-move '->
+ (api/map {(api/keyword :state) (api/key-fn :state)
+ (api/keyword :next) (api/map {(api/keyword :position)
+ (api/map {(api/keyword :x) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/key-fn :samak.mouse/page-x)])
+ (api/keyword :y) (api/fn-call (api/symbol '->) [(api/key-fn :next) (api/symbol 'get-mouse-y)])})
+ (api/keyword :delta)
+ (api/map {(api/keyword :x)
+ (api/symbol 'calculate-mouse-delta-x)
+ (api/keyword :y)
+ (api/symbol 'calculate-mouse-delta-y)})
+ (api/keyword :drag)
+ (api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :mouse) (api/key-fn :drag)
+ (api/map {(api/keyword :active) (api/key-fn :active)
+ (api/keyword :source) (api/key-fn :source)
+ (api/keyword :begin) (api/keyword :false)
+ (api/keyword :button) (api/key-fn :button)})])})}))
+
+
+ (defncall 'mouse-reduce 'pipes/reductions
+ (api/fn-call (api/symbol '->)
+ [(api/fn-call (api/symbol 'incase) [(api/symbol 'is-mouse-move)
+ (api/symbol 'handle-mouse-move)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-mouse-down)
+ (api/symbol 'handle-mouse-down)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-mouse-up)
+ (api/symbol 'handle-mouse-up)])
+ (api/vector [(api/fn-call (api/symbol '->) [(api/key-fn :state)
+ (api/key-fn :mouse)])
+ (api/key-fn :next)])
+ (api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)])
+ (api/map {(api/keyword :mouse) (api/symbol '_)})])
+ (api/map {(api/keyword :mouse) (api/map {})}))
+
+ (defncall 'mouse-state 'pipes/debug (api/string "mouse-state") ;; (api/keyword :oasis.spec/mouse-state)
+ )
+
+ (defncall 'is-drag '->
+ (api/key-fn :mouse)
+ (api/key-fn :drag)
+ (api/key-fn :active)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :true)]))
+
+ (defncall 'is-drag-end '->
+ (api/key-fn :drag)
+ (api/key-fn :end)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :end)]))
+
+ (defncall 'is-drag-start '->
+ (api/key-fn :drag)
+ (api/key-fn :begin)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :true)]))
+
+ (defncall 'is-drag-or-end 'or
+ (api/symbol 'is-drag)
+ (api/fn-call (api/symbol '->) [(api/key-fn :mouse) (api/symbol 'is-drag-end)]))
+
+ (defncall 'is-drag-end-or-start 'or
+ (api/fn-call (api/symbol '->) [(api/key-fn :mouse) (api/symbol 'is-drag-start)])
+ (api/fn-call (api/symbol '->) [(api/key-fn :mouse) (api/symbol 'is-drag-end)]))
+
+ (defncall 'filter-drag-end-or-start 'only (api/symbol 'is-drag-end-or-start))
+
+ (defncall 'filter-drag 'only (api/symbol 'is-drag-or-end))
+
+
+ (defncall 'is-scroll '->
+ (api/key-fn :mouse)
+ (api/key-fn :drag)
+ (api/key-fn :button)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :secondary)]))
+
+ (defncall 'filter-scroll 'only (api/fn-call (api/symbol 'and) [(api/symbol 'is-scroll)
+ (api/symbol 'is-drag-or-end)]))
+
+ (defncall 'split-target-hover '->
+ (api/fn-call (api/symbol 'str-split) [(api/symbol '_) (api/string "/")])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-valid-target)
+ (api/map {(api/keyword :type) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
+ (api/keyword :name) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])})]))
+
+ (defncall 'make-target-hover '->
+ (api/map {(api/keyword :split) (api/symbol 'split-target-hover)
+ (api/keyword :orig) (api/symbol '_)})
+ (api/map {(api/keyword :type) (api/fn-call (api/symbol '->) [(api/key-fn :split) (api/key-fn :type)])
+ (api/keyword :name) (api/fn-call (api/symbol '->) [(api/key-fn :split) (api/key-fn :name)])
+ (api/keyword :id) (api/key-fn :orig)}))
+
+
+ (defncall 'target-reduce 'pipes/reductions
+ (api/fn-call (api/symbol '->) [
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "target")])
+ (api/map {(api/keyword :prev) (api/fn-call (api/symbol '->) [(api/key-fn :state)
+ (api/key-fn :current)])
+ (api/keyword :current) (api/fn-call (api/symbol '->) [(api/key-fn :next)
+ (api/key-fn :samak.mouse/target)
+ (api/symbol 'make-target-hover)])})])
+ (api/map {(api/keyword :current) (api/map {(api/keyword :type) (api/string "none")
+ (api/keyword :name) (api/string "none")
+ (api/keyword :id) (api/string "none")})
+ (api/keyword :prev) (api/map {(api/keyword :type) (api/string "none")
+ (api/keyword :name) (api/string "none")
+ (api/keyword :id) (api/string "none")})}))
+
+ (defncall 'target-events 'pipes/debug (api/string "target-events") ;; (api/keyword :oasis.spec/mouse-state)
+ )
+
+ (defncall 'only-different '->
+ (api/fn-call (api/symbol 'except) [(api/fn-call (api/symbol '->) [(api/vector [(api/key-fn :prev) (api/key-fn :current)])
+ (api/fn-call (api/symbol 'distinct) [(api/symbol '_)])
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/integer 1)])])]))
+
+ (defncall 'hover-events 'pipes/debug (api/string "hover-events") ;; (api/keyword :oasis.spec/mouse-state)
+ )
+ (defncall 'hover-out 'pipes/debug (api/string "hover-out") ;; (api/keyword :oasis.spec/mouse-state)
+ )
+ (defncall 'tag-hover '->
+ (api/map {(api/keyword :hover) (api/symbol '_)}))
+
+ ;; keyboard handling
+
+
+ (defncall 'is-kb-move-left '->
+ (api/key-fn :key)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "ArrowLeft")]))
+
+ (defncall 'is-kb-move-right '->
+ (api/key-fn :key)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "ArrowRight")]))
+
+ (defncall 'is-kb-move-up '->
+ (api/key-fn :key)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "ArrowUp")]))
+
+ (defncall 'is-kb-move-down '->
+ (api/key-fn :key)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "ArrowDown")]))
+
+ (defncall 'construct-move-left '->
+ (api/map {(api/keyword :command) (api/keyword :move)
+ (api/keyword :x) (api/integer 50)
+ (api/keyword :y) (api/integer 0)
+ (api/keyword :zoom) (api/integer 1)}))
+
+ (defncall 'construct-move-right '->
+ (api/map {(api/keyword :command) (api/keyword :move)
+ (api/keyword :x) (api/integer -50)
+ (api/keyword :y) (api/integer 0)
+ (api/keyword :zoom) (api/integer 1)}))
+
+ (defncall 'construct-move-up '->
+ (api/map {(api/keyword :command) (api/keyword :move)
+ (api/keyword :x) (api/integer 0)
+ (api/keyword :y) (api/integer 50)
+ (api/keyword :zoom) (api/integer 1)}))
+
+ (defncall 'construct-move-down '->
+ (api/map {(api/keyword :command) (api/keyword :move)
+ (api/keyword :x) (api/integer 0)
+ (api/keyword :y) (api/integer -50)
+ (api/keyword :zoom) (api/integer 1)}))
+
+ (defncall 'is-kb-zoom-in '->
+ (api/key-fn :key)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "+")]))
+
+ (defncall 'is-kb-zoom-out '->
+ (api/key-fn :key)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "-")]))
+
+ (defncall 'construct-zoom-out '->
+ (api/map {(api/keyword :command) (api/keyword :zoom)
+ (api/keyword :zoom) (api/float 0.9)}))
+
+ (defncall 'construct-zoom-in '->
+ (api/map {(api/keyword :command) (api/keyword :zoom)
+ (api/keyword :zoom) (api/float 1.1)}))
+
+ (defncall 'filter-view '->
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-move-left)
+ (api/symbol 'construct-move-left)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-move-right)
+ (api/symbol 'construct-move-right)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-move-up)
+ (api/symbol 'construct-move-up)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-move-down)
+ (api/symbol 'construct-move-down)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-phase-up)
+ (api/fn-call (api/symbol '->) [(api/map {(api/keyword :key) (api/keyword :ignore)})])])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-zoom-in)
+ (api/symbol 'construct-zoom-in)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-kb-zoom-out)
+ (api/symbol 'construct-zoom-out)])
+ (api/fn-call (api/symbol 'unless) [(api/key-fn :command)
+ (api/symbol 'ignore)]))
+
+
+ ;; render handlers
+ (defncall 'translate-str 'str
+ (api/string "translate(")
+ (api/fn-call (api/symbol 'or) [(api/key-fn :x) (api/integer 0)])
+ (api/string ",")
+ (api/fn-call (api/symbol 'or) [(api/key-fn :y) (api/integer 0)])
+ (api/string ")"))
+
+ (defncall 'translate-graph-str 'str
+ (api/string "matrix(")
+ (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol 'nth) [(api/key-fn :matrix) (api/integer 0)])
+ (api/key-fn :zoom)])
+ (api/string ",")
+ (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol 'nth) [(api/key-fn :matrix) (api/integer 1)])
+ (api/key-fn :zoom)])
+ (api/string ",")
+ (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol 'nth) [(api/key-fn :matrix) (api/integer 2)])
+ (api/key-fn :zoom)])
+ (api/string ",")
+ (api/fn-call (api/symbol '*) [(api/fn-call (api/symbol 'nth) [(api/key-fn :matrix) (api/integer 3)])
+ (api/key-fn :zoom)])
+ (api/string ",")
+ (api/key-fn :x)
+ (api/string ",")
+ (api/key-fn :y)
+ (api/string ")"))
+
+ (defncall 'translate-dialog '->
+ (api/map {(api/keyword :x)
+ (api/integer 150)
+ (api/keyword :y)
+ (api/integer 50)
+ (api/keyword :zoom)
+ (api/float 1.5)
+ (api/keyword :matrix)
+ (api/vector [(api/float 1.0)
+ (api/float 0.0)
+ (api/float 0.0)
+ (api/float 1.0)])})
+ (api/symbol 'translate-graph-str))
+
+ (defncall 'translate-func '->
+ (api/fn-call (api/symbol 'into) [(api/symbol '_)
+ (api/map {(api/keyword :zoom)
+ (api/float 1.5)
+ ;; (api/keyword :x)
+ ;; (api/integer 150)
+ ;; (api/keyword :y)
+ ;; (api/integer -60)
+ (api/keyword :matrix)
+ (api/vector [(api/float 1.0)
+ (api/float 0.0)
+ (api/float 0.0)
+ (api/float 1.0)])})])
+ (api/symbol 'translate-graph-str))
+
+ (defncall 'translate-blur '->
+ (api/fn-call (api/symbol 'into) [(api/symbol '_)
+ (api/map {(api/keyword :zoom)
+ (api/float 2.0)
+ (api/keyword :x)
+ (api/fn-call (api/symbol '-) [(api/key-fn :x) (api/integer 100)])
+ ;; (api/keyword :y)
+ ;; (api/integer -50)
+ (api/keyword :matrix)
+ (api/vector [(api/float 1.0)
+ (api/float 0.0)
+ (api/float 0.0)
+ (api/float 1.0)])})])
+ (api/symbol 'translate-graph-str))
+
+ (defncall 'translate-graph '->
+ (api/fn-call (api/symbol 'assoc) [(api/symbol '_) (api/keyword :matrix)
+ (api/vector [(api/float 1.0)
+ (api/float -0.5)
+ (api/float 1.0)
+ (api/float 0.5)])])
+ (api/symbol 'translate-graph-str))
+
+ (defncall 'translate-ident '->
+ (api/fn-call (api/symbol 'into) [(api/symbol '_)
+ (api/map {(api/keyword :zoom)
+ (api/float 1.0)
+ (api/keyword :matrix)
+ (api/vector [(api/float 1.0)
+ (api/float 0.0)
+ (api/float 0.0)
+ (api/float 1.0)])})])
+ (api/symbol 'translate-graph-str))
+
+ ;; FIXME: menu
+
+ (defncall 'calculate-y '->
+ (api/fn-call (api/symbol '*) [(api/integer 100) (api/key-fn :position)])
+ (api/fn-call (api/symbol '+) [(api/integer 10) (api/symbol '_)]))
+
+ (defncall 'menu-transform '->
+ (api/key-fn :item)
+ (api/map {(api/keyword :x) (api/integer 50)
+ (api/keyword :y) (api/symbol 'calculate-y)})
+ (api/symbol 'translate-str))
+
+ (defncall 'animate-sink '->
+ (api/vector [(api/vector [(api/keyword :animate)
+ (api/map {(api/keyword :attributeName) (api/string "stroke")
+ (api/keyword :values) (api/string "#999580;#6684e1;#6684e1;#6684e1;#999580")
+ (api/keyword :dur) (api/string "3s")
+ (api/keyword :repeatCount) (api/string "indefinite")})])
+ (api/vector [(api/keyword :animate)
+ (api/map {(api/keyword :attributeName) (api/string "r")
+ (api/keyword :values) (api/string "43;37;37;37;35")
+ (api/keyword :dur) (api/string "3s")
+ (api/keyword :repeatCount) (api/string "indefinite")})])]))
+
+ (defncall 'animate-source '->
+ (api/vector [(api/vector [(api/keyword :animate)
+ (api/map {(api/keyword :attributeName) (api/string "stroke")
+ (api/keyword :values) (api/string "#999580;#6684e1;#6684e1;#6684e1;#999580")
+ (api/keyword :dur) (api/string "3s")
+ (api/keyword :repeatCount) (api/string "indefinite")})])
+ (api/vector [(api/keyword :animate)
+ (api/map {(api/keyword :attributeName) (api/string "r")
+ (api/keyword :values) (api/string "35;37;37;37;43")
+ (api/keyword :dur) (api/string "3s")
+ (api/keyword :repeatCount) (api/string "indefinite")})])]))
+
+ (defncall 'is-hovered-entry '->
+ (api/vector [(api/fn-call (api/symbol '->) [(api/key-fn :item)
+ (api/vector [(api/key-fn :type) (api/key-fn :name)])])
+ (api/fn-call (api/symbol '->) [(api/key-fn :context)
+ (api/key-fn :hover)
+ (api/key-fn :current)
+ (api/vector [(api/key-fn :type) (api/key-fn :id)])])])
+ (api/fn-call (api/symbol '->) [(api/fn-call (api/symbol 'distinct) [(api/symbol '_)])
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/integer 1)])]))
+
+ (defncall 'is-entry-sink '->
+ (api/key-fn :item)
+ (api/key-fn :type)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "sink")]))
+
+ (defncall 'get-animation-style '->
+ (api/fn-call (api/symbol 'if) [(api/symbol 'is-hovered-entry)
+ (api/fn-call (api/symbol 'if) [(api/symbol 'is-entry-sink)
+ (api/symbol 'animate-sink)
+ (api/symbol 'animate-source)])
+ (api/string "")]))
+
+ (defncall 'get-entry-bg '->
+ (api/fn-call (api/symbol 'if) [(api/symbol 'is-hovered-entry)
+ (api/keyword :menu-entry-active-bg)
+ (api/keyword :menu-entry-bg)]))
+
+ (defncall 'render-menu-entry '->
+ (api/vector [(api/keyword :g)
+ (api/map {(api/keyword :transform) (api/symbol 'menu-transform)})
+ (api/vector [(api/keyword :circle)
+ (api/map {(api/keyword :cx) (api/integer 0)
+ (api/keyword :cy) (api/integer 45)
+ (api/keyword :r) (api/integer 40)
+ (api/keyword :style) (api/map {(api/keyword :filter) (api/string "url(#shadow)")
+ (api/keyword :pointer-events) (api/string "all")})
+ (api/keyword :fill) (api/fn-call (api/symbol 'get-color) [(api/keyword :menu-entry-bg)])
+ (api/keyword :stroke) (api/fn-call (api/symbol 'get-color) [(api/keyword :menu-entry-text)])})])
+ (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :circle)
+ (api/map {(api/keyword :cx) (api/integer 0)
+ (api/keyword :cy) (api/integer 45)
+ (api/keyword :r) (api/integer 35)
+ (api/keyword :stroke-width) (api/integer 2)
+ (api/keyword :stroke) (api/fn-call (api/symbol '->) [(api/keyword :element-highlight-stroke)
+ (api/symbol 'get-color)])
+ (api/keyword :fill) (api/fn-call (api/symbol '->) [(api/symbol 'get-entry-bg)
+ (api/symbol 'get-color)])})])
+ (api/symbol 'get-animation-style)])
+ (api/vector [(api/keyword :text)
+ (api/map {(api/keyword :height) (api/integer 20)
+ (api/keyword :width) (api/string "100%")
+ (api/keyword :fill) (api/fn-call (api/symbol '->) [(api/keyword :menu-entry-text) (api/symbol 'get-color)])
+ (api/keyword :text-anchor) (api/keyword :middle)
+ (api/keyword :x) (api/integer 0)
+ (api/keyword :y) (api/integer 35)
+ (api/keyword :dy) (api/integer 14)})
+ (api/fn-call (api/symbol '->) [(api/key-fn :item)
+ (api/key-fn :name)])])
+ (api/vector [(api/keyword :circle)
+ (api/map {(api/keyword :id) (api/fn-call (api/symbol '->) [(api/key-fn :item)
+ (api/key-fn :id)])
+ (api/keyword :style) (api/map {(api/keyword :pointer-events) (api/string "all")})
+ (api/keyword :cx) (api/integer 0)
+ (api/keyword :cy) (api/integer 45)
+ (api/keyword :r) (api/integer 40)
+ (api/keyword :fill-opacity) (api/integer 0)})])]))
+
+ (defncall 'get-menu-fill '->
+ (api/keyword :menu-bar-bg)
+ (api/symbol 'get-color))
+
+ (defncall 'get-menu-fg '->
+ (api/keyword :menu-bar-text)
+ (api/symbol 'get-color))
+
+
+ (defncall 'tag-item-context '->
+ (api/map {(api/keyword :item) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
+ (api/keyword :context) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])}))
+
+ (defncall 'get-menu-items '->
+ (api/key-fn :items)
+ (api/fn-call (api/symbol 'map) [(api/symbol 'tag-item-context) (api/symbol '_)])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'render-menu-entry) (api/symbol '_)])
+ (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :g)]) (api/symbol '_)])
+ )
+
+
+ (defncall 'render-source-menu '->
+ (api/key-fn :source-menu)
+ (api/map {(api/keyword :items) (api/key-fn :items)
+ (api/keyword :context) (api/map {(api/keyword :hover) (api/key-fn :hover)
+ (api/keyword :resize) (api/key-fn :resize)})})
+ (api/map {(api/keyword :items) (api/fn-call (api/symbol 'myzip) [(api/key-fn :items)
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol 'count) [(api/key-fn :items)])
+ (api/key-fn :context)])])
+ (api/keyword :context) (api/key-fn :context)})
+ (api/vector [(api/keyword :g)
+ (api/vector [(api/keyword :rect)
+ (api/map {(api/keyword :id) (api/string "menu/source")
+ (api/keyword :height) (api/string "100%")
+ (api/keyword :width) (api/integer 100)
+ (api/keyword :stroke) (api/symbol 'get-menu-fg)
+ (api/keyword :style) (api/map {(api/keyword :filter) (api/string "url(#shadow)")
+ (api/keyword :pointer-events) (api/string "all")})
+ (api/keyword :fill-opacity) (api/float 0.8)
+ (api/keyword :fill) (api/symbol 'get-menu-fill)})])
+ (api/symbol 'get-menu-items)])
+ (api/map {(api/keyword :source-menu) (api/symbol '_)}))
+
+ (defncall 'get-sink-position '->
+ (api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :resize) (api/key-fn :width)])
+ (api/fn-call (api/symbol '-) [(api/symbol '_) (api/integer 100)])
+ (api/map {(api/keyword :x) (api/symbol '_)})
+ (api/symbol 'translate-str))
+
+ (defncall 'render-sink-menu '->
+ (api/key-fn :sink-menu)
+ (api/map {(api/keyword :items) (api/key-fn :items)
+ (api/keyword :context) (api/map {(api/keyword :hover) (api/key-fn :hover)
+ (api/keyword :resize) (api/key-fn :resize)})})
+ (api/map {(api/keyword :items) (api/fn-call (api/symbol 'myzip) [(api/key-fn :items)
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol 'count) [(api/key-fn :items)])
+ (api/key-fn :context)])])
+ (api/keyword :context) (api/key-fn :context)})
+ (api/vector [(api/keyword :g)
+ (api/map {(api/keyword :transform) (api/symbol 'get-sink-position)})
+ (api/vector [(api/keyword :rect)
+ (api/map {(api/keyword :id) (api/string "menu/sink")
+ (api/keyword :height) (api/string "100%")
+ (api/keyword :width) (api/integer 100)
+ (api/keyword :stroke) (api/symbol 'get-menu-fg)
+ (api/keyword :style) (api/map {(api/keyword :filter) (api/string "url(#leftshadow)")
+ (api/keyword :pointer-events) (api/string "all")})
+ (api/keyword :fill-opacity) (api/float 0.8)
+ (api/keyword :fill) (api/symbol 'get-menu-fill)})])
+ (api/symbol 'get-menu-items)])
+ (api/map {(api/keyword :sink-menu) (api/symbol '_)}))
+
+ (defncall 'get-menu-state '->
+ (api/vector [(api/string "mode: ")
+ (api/fn-call (api/symbol '->) [(api/key-fn :editor)
+ (api/key-fn :mode)])
+ (api/string "/")
+ (api/fn-call (api/symbol '->) [(api/key-fn :editor)
+ (api/key-fn :activity)])
+ (api/string " - scope: ")
+ (api/fn-call (api/symbol '->) [(api/key-fn :editor)
+ (api/key-fn :scope)])])
+ (api/fn-call (api/symbol 'str-join) [(api/string " ") (api/symbol '_)]))
+
+ (defncall 'render-menu-action '->
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "render action")])
+ (api/symbol '_))
+
+ (defncall 'get-menu-actions '->
+ (api/fn-call (api/symbol '->) [(api/key-fn :mode)
+ (api/key-fn :actions)
+ (api/fn-call (api/symbol 'map) [(api/symbol 'render-menu-action) (api/symbol '_)])])
+ (api/fn-call (api/symbol 'str-join) [(api/string ", ") (api/symbol '_)])
+ (api/vector [(api/string "type: ") (api/symbol '_)])
+ (api/fn-call (api/symbol 'str-join) [(api/string "") (api/symbol '_)]))
+
+ (defncall 'get-action-position '->
+ (api/fn-call (api/symbol '->) [(api/key-fn :resize) (api/key-fn :height)])
+ (api/fn-call (api/symbol '-) [(api/symbol '_) (api/integer 50)])
+ (api/map {(api/keyword :y) (api/symbol '_)})
+ (api/symbol 'translate-str))
+
+ (defncall 'render-action-menu '->
+ (api/map {(api/keyword :action-menu)
+ (api/vector [(api/keyword :g)
+ (api/map {(api/keyword :transform) (api/symbol 'get-action-position)})
+ (api/vector [(api/keyword :rect)
+ (api/map {(api/keyword :id) (api/string "menu/action")
+ (api/keyword :height) (api/integer 50)
+ (api/keyword :width) (api/string "100%")
+ (api/keyword :stroke) (api/symbol 'get-menu-fg)
+ (api/keyword :style) (api/map {(api/keyword :filter) (api/string "url(#upshadow)")
+ (api/keyword :pointer-events) (api/string "all")})
+ (api/keyword :fill-opacity) (api/float 0.8)
+ (api/keyword :fill) (api/symbol 'get-menu-fill)})])
+ (api/vector [(api/keyword :text)
+ (api/map {(api/keyword :height) (api/integer 20)
+ (api/keyword :width) (api/string "100%")
+ (api/keyword :text-anchor) (api/keyword :middle)
+ (api/keyword :x) (api/integer 600)
+ (api/keyword :y) (api/integer 5)
+ (api/keyword :dy) (api/integer 14)})
+ (api/fn-call (api/symbol '->)
+ [(api/vector [(api/string "state: ")
+ (api/symbol 'get-menu-state)])
+ (api/fn-call (api/symbol 'str-join) [(api/string "") (api/symbol '_)])])])
+ (api/vector [(api/keyword :text)
+ (api/map {(api/keyword :height) (api/integer 20)
+ (api/keyword :width) (api/string "100%")
+ (api/keyword :text-anchor) (api/keyword :middle)
+ (api/keyword :x) (api/integer 600)
+ (api/keyword :y) (api/integer 25)
+ (api/keyword :dy) (api/integer 14)})
+ (api/fn-call (api/symbol '->)
+ [(api/vector [(api/string "actions: ")
+ (api/symbol 'get-menu-actions)])
+ (api/fn-call (api/symbol 'str-join) [(api/string "") (api/symbol '_)])])])])}))
+
+
+ ;; state
(defncall 'state-reduce 'pipes/reductions
(api/fn-call (api/symbol '->)
@@ -2678,34 +2814,131 @@
(api/fn-call (api/symbol 'into) [(api/map {}) (api/symbol '_)]) ])
(api/map {}))
- (defncall 'state-dedupe 'pipes/reductions
- (api/fn-call (api/symbol '->)
- [(api/map {(api/keyword :next) (api/key-fn :next)
- (api/keyword :state) (api/fn-call (api/symbol '->) [(api/key-fn :state) (api/key-fn :state)])
- (api/keyword :key) (api/fn-call (api/symbol 'first) [(api/fn-call (api/symbol 'keys) [(api/key-fn :next)])])})
- (api/map {(api/keyword :next) (api/key-fn :next)
- (api/keyword :state) (api/key-fn :state)
- (api/keyword :existing) (api/fn-call (api/symbol 'lookup) [(api/key-fn :state) (api/key-fn :key) (api/keyword :not-found)])})
- (api/map {(api/keyword :dupe) (api/fn-call (api/symbol 'if) [(api/fn-call (api/symbol '=) [(api/key-fn :existing) (api/key-fn :next)])
- (api/keyword :dupe)
- (api/keyword :unique)])
- (api/keyword :state) (api/fn-call (api/symbol 'into) [(api/map {}) (api/vector [(api/key-fn :state) (api/key-fn :next)])])})])
- (api/map {(api/keyword :state) (api/map {})}))
-
(defncall 'filter-state '->
(api/fn-call (api/symbol 'if) [(api/fn-call (api/symbol '=) [(api/key-fn :dupe) (api/keyword :unique)])
(api/key-fn :state)
(api/fn-call (api/symbol '->) [(api/fn-call (api/symbol 'spy) [(api/string "DROP")])
(api/symbol 'ignore)])]))
- (defncall 'condensed-state 'pipes/debug ;; (api/keyword :oasis.spec/state)
+ (defncall 'condensed-state 'pipes/debug (api/string "condensed-state") ;; (api/keyword :oasis.spec/state)
)
(defncall 'only-resize '->
(api/map {(api/keyword :resize) (api/key-fn :resize)}))
+
+ ;; cell handling
+
+ (defncall 'func-id '->
+ (api/key-fn :node)
+ (api/key-fn :id))
+
+ (defncall 'is-same '->
+ (api/fn-call (api/symbol 'distinct) [(api/symbol '_)])
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/integer 1)]))
+
+ (defncall 'is-selected '->
+ (api/vector [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :selected)])
+ (api/symbol 'func-id)])
+ (api/symbol 'is-same))
+
+ (defncall 'is-hovered '->
+ (api/vector [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :hovered) (api/key-fn :id)])
+ (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :id)])])
+ (api/symbol 'is-same))
+
+ (defncall 'cell-y '->
+ (api/fn-call (api/symbol '*) [(api/integer 20)
+ (api/key-fn :counter)])
+ (api/fn-call (api/symbol '+) [(api/integer 10)
+ (api/symbol '_)]))
+
+ (defncall 'cell-x '->
+ (api/fn-call (api/symbol '*) [(api/integer 15)
+ (api/key-fn :level)]))
+
+ (defncall 'cell-pos '->
+ (api/map {(api/keyword :x)
+ (api/integer 0)
+ (api/keyword :y)
+ (api/symbol 'cell-y)})
+ (api/symbol 'translate-str))
+
+ (defncall 'line-pos '->
+ (api/map {(api/keyword :x)
+ (api/integer 0)
+ (api/keyword :y)
+ (api/integer -15)})
+ (api/symbol 'translate-str))
+
+
+ (defncall 'text-pos '->
+ (api/map {(api/keyword :x)
+ (api/symbol 'cell-x)
+ (api/keyword :y)
+ (api/integer 0)})
+ (api/symbol 'translate-str))
+
+ (defncall 'counter-pos '->
+ (api/map {(api/keyword :x)
+ (api/integer 10)
+ (api/keyword :y)
+ (api/integer 0)})
+ (api/symbol 'translate-str))
+
+ (defncall 'type-pos '->
+ (api/map {(api/keyword :x)
+ (api/fn-call (api/symbol '+) [(api/integer 190)
+ ;; (api/symbol 'cell-x)
+ (api/integer 10)])
+ (api/keyword :y)
+ (api/integer 0)})
+ (api/symbol 'translate-str))
+
+ (defncall 'is-marked-cell '->
+ (api/fn-call (api/symbol '-) [(api/fn-call (api/symbol '->) [(api/key-fn :context)
+ (api/key-fn :mark)])
+ (api/fn-call (api/symbol '->) [(api/key-fn :exp)
+ (api/key-fn :counter)])])
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/integer 0)]))
+
+ (defncall 'is-active-cell '->
+ (api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '->) [(api/key-fn :context)
+ (api/key-fn :selected)])
+ (api/symbol 'is-marked-cell)]))
+
+ (defncall 'is-edited-cell '->
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "edited")])
+ (api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '->) [(api/key-fn :context)
+ (api/key-fn :activity)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :edit)])])
+ (api/fn-call (api/symbol '->) [(api/key-fn :context)
+ (api/key-fn :selected)])
+ (api/symbol 'is-marked-cell)]))
+
+ (defncall 'is-active-branch '->
+ (api/key-fn :exp)
+ (api/key-fn :counter)
+ (api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '>) [(api/symbol '_) (api/integer 100)])
+ (api/fn-call (api/symbol '<) [(api/symbol '_) (api/integer 101)])]))
+
;; graphing of nodes
+ (defncall 'get-fill '->
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-edited-cell)
+ (api/fn-call (api/symbol '->) [(api/keyword :cell-edit)
+ (api/symbol 'get-color)])])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-active-cell)
+ (api/fn-call (api/symbol '->) [(api/keyword :cell-active)
+ (api/symbol 'get-color)])])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-active-branch)
+ (api/fn-call (api/symbol '->) [(api/keyword :cell-seclight)
+ (api/symbol 'get-color)])])
+ (api/fn-call (api/symbol 'incase) [(api/key-fn :exp)
+ (api/fn-call (api/symbol '->) [(api/keyword :cell-background)
+ (api/symbol 'get-color)])]))
+
(defncall 'get-func-stroke '->
(api/fn-call (api/symbol 'if) [(api/fn-call (api/symbol 'or) [(api/symbol 'is-selected) (api/key-fn :expanded)])
(api/fn-call (api/symbol '->) [(api/keyword :node-selected)
@@ -2953,26 +3186,26 @@
(api/keyword :expanded) (api/fn-call (api/symbol '>) [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :view) (api/key-fn :zoom)])
(api/integer 1)])})
(api/symbol 'graph-func-single)])])
- ;; (api/fn-call (api/symbol 'incase) [(api/symbol 'is-hovered) (api/vector [(api/keyword :g)
- ;; (api/map {(api/keyword :filter) (api/string "url(#blur)")
- ;; (api/keyword :opacity) (api/string "0.6")
- ;; (api/keyword :transform)
- ;; (api/fn-call (api/symbol '->) [(api/key-fn :node)
- ;; (api/symbol 'translate-blur)])})
- ;; (api/symbol 'graph-func-single)])])
- (api/fn-call (api/symbol 'if) [(api/fn-call (api/symbol 'and) [(api/symbol 'is-hovered)
- (api/fn-call (api/symbol '->) [(api/key-fn :context)
- (api/symbol 'is-change-navigate)])])
- (api/vector [(api/keyword :g)
- (api/map {(api/keyword :opacity) (api/string "1")
- (api/keyword :transform)
- (api/fn-call (api/symbol '->) [(api/key-fn :node)
- (api/symbol 'translate-func)])})
- (api/fn-call (api/symbol '->) [(api/map {(api/keyword :node) (api/key-fn :node)
- (api/keyword :context) (api/key-fn :context)
- (api/keyword :expanded) (api/keyword :expand)})
- (api/symbol 'graph-func-single)])])
- (api/string "")])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-hovered) (api/vector [(api/keyword :g)
+ (api/map {(api/keyword :filter) (api/string "url(#blur)")
+ (api/keyword :opacity) (api/string "0.6")
+ (api/keyword :transform)
+ (api/fn-call (api/symbol '->) [(api/key-fn :node)
+ (api/symbol 'translate-blur)])})
+ (api/symbol 'graph-func-single)])])
+ ;; (api/fn-call (api/symbol 'if) [(api/fn-call (api/symbol 'and) [(api/symbol 'is-hovered)
+ ;; (api/fn-call (api/symbol '->) [(api/key-fn :context)
+ ;; (api/symbol 'is-change-navigate)])])
+ ;; (api/vector [(api/keyword :g)
+ ;; (api/map {(api/keyword :opacity) (api/string "1")
+ ;; (api/keyword :transform)
+ ;; (api/fn-call (api/symbol '->) [(api/key-fn :node)
+ ;; (api/symbol 'translate-func)])})
+ ;; (api/fn-call (api/symbol '->) [(api/map {(api/keyword :node) (api/key-fn :node)
+ ;; (api/keyword :context) (api/key-fn :context)
+ ;; (api/keyword :expanded) (api/keyword :expand)})
+ ;; (api/symbol 'graph-func-single)])])
+ ;; (api/string "")])
]))
(defncall 'graph-focused '->
@@ -3012,7 +3245,8 @@
(api/keyword :pointer-events) (api/string "all")})})])
(api/vector [(api/keyword :g)])])
(api/vector [(api/keyword :circle)
- (api/map {(api/keyword :id) (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/symbol 'pipe-id)])
+ (api/map {(api/keyword :id) (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :id)])
+ (api/keyword :data-name) (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/symbol 'pipe-id)])
(api/keyword :cx) (api/integer 50)
(api/keyword :cy) (api/integer 50)
(api/keyword :r) (api/integer 50)
@@ -3043,25 +3277,28 @@
(api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :name)])])]))
(defncall 'is-dragging '->
- (api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '=) [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :editor) (api/key-fn :mode)])
+ (api/key-fn :context)
+ (api/key-fn :editor)
+ (api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '=) [(api/key-fn :mode)
(api/keyword :navigate)])
- (api/fn-call (api/symbol '=) [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :editor) (api/key-fn :activity)])
+ (api/fn-call (api/symbol '=) [(api/key-fn :activity)
(api/keyword :dragging)])]))
(defncall 'is-pipe-drag-begin '->
- (api/fn-call (api/symbol '=) [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :mouse) (api/key-fn :drag) (api/key-fn :source)])
- (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/symbol 'pipe-id)])]))
+ (api/vector [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :mouse) (api/key-fn :drag) (api/key-fn :source)])
+ (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :id)])])
+ (api/symbol 'is-same))
(defncall 'is-pipe-target '->
(api/key-fn :node)
(api/key-fn :type)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :caravan/sink)]))
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "sink")]))
(defncall 'is-pipe-hovered '->
(api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '=) [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :hovered) (api/key-fn :type)])
- (api/string "pipe")])
- (api/fn-call (api/symbol '=) [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :hovered) (api/key-fn :name)])
- (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :name)])])]))
+ (api/string "d")])
+ (api/fn-call (api/symbol '=) [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :hovered) (api/key-fn :id)])
+ (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :id)])])]))
(defncall 'graph-pipe '->
(api/map {(api/keyword :node) (api/key-fn :node)
@@ -3071,36 +3308,10 @@
(api/keyword :hovered) (api/symbol 'is-pipe-hovered)})
(api/symbol 'graph-pipe-single))
- (defncall 'is-pipe-node '->
- (api/key-fn :node)
- (api/key-fn :type)
- (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :caravan/sink)]))
-
- (defncall 'is-func-node '->
- (api/key-fn :node)
- (api/key-fn :value))
-
- (defncall 'graph-node '->
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-pipe-node)
- (api/symbol 'graph-pipe)])
- (api/fn-call (api/symbol 'incase) [(api/symbol 'is-func-node)
- (api/symbol 'graph-func)]))
-
(defncall 'merge-node '->
(api/map {(api/keyword :node) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 0)])
(api/keyword :context) (api/fn-call (api/symbol 'nth) [(api/symbol '_) (api/integer 1)])}))
- (defncall 'graph-nodes '->
- (api/fn-call (api/symbol 'myzip) [(api/fn-call (api/symbol '->) [(api/key-fn :layout)
- (api/key-fn :children)])
- (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol '->) [(api/key-fn :layout)
- (api/key-fn :children)
- (api/fn-call (api/symbol 'count) [(api/symbol '_)])])
- (api/key-fn :context)])])
- (api/fn-call (api/symbol 'map) [(api/symbol 'merge-node) (api/symbol '_)])
- (api/fn-call (api/symbol 'map) [(api/symbol 'graph-node) (api/symbol '_)])
- (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :g)]) (api/symbol '_)]))
-
(defncall 'graph-coords 'str
(api/key-fn :x)
(api/string " ")
@@ -3111,12 +3322,12 @@
(defncall 'is-incoming '->
(api/fn-call (api/symbol '=) [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :hovered) (api/key-fn :name)])
- (api/fn-call (api/symbol '->) [(api/key-fn :edge) (api/key-fn :to)])]))
+ (api/fn-call (api/symbol 'str) [(api/fn-call (api/symbol '->) [(api/key-fn :edge) (api/key-fn :to)])])]))
(defncall 'is-outgoing '->
(api/fn-call (api/symbol 'and) [(api/key-fn :edge)
(api/fn-call (api/symbol '=) [(api/fn-call (api/symbol '->) [(api/key-fn :context) (api/key-fn :hovered) (api/key-fn :name)])
- (api/fn-call (api/symbol '->) [(api/key-fn :edge) (api/key-fn :from)])])]))
+ (api/fn-call (api/symbol 'str) [(api/fn-call (api/symbol '->) [(api/key-fn :edge) (api/key-fn :from)])])])]))
(defncall 'get-edge-color '->
(api/fn-call (api/symbol 'incase) [(api/symbol 'is-incoming)
@@ -3148,18 +3359,124 @@
(defncall 'prepare-edges '->
(api/fn-call (api/symbol 'map) [(api/symbol 'build-edge)
- (api/fn-call (api/symbol '->) [(api/key-fn :layout)
- (api/key-fn :edges)])]))
+ (api/key-fn :edges)]))
(defncall 'graph-connections '->
- (api/fn-call (api/symbol 'myzip) [(api/symbol 'prepare-edges)
+ (api/fn-call (api/symbol 'myzip) [(api/fn-call (api/symbol '->) [(api/key-fn :layout) (api/symbol 'prepare-edges)])
(api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol '->) [(api/key-fn :layout)
(api/key-fn :edges)
(api/fn-call (api/symbol 'count) [(api/symbol '_)])])
(api/key-fn :context)])])
(api/fn-call (api/symbol 'map) [(api/symbol 'merge-connection) (api/symbol '_)])
+ (api/fn-call (api/symbol 'filter) [(api/fn-call (api/symbol '->) [(api/key-fn :edge) (api/key-fn :section)]) (api/symbol '_)])
(api/fn-call (api/symbol 'map) [(api/symbol 'graph-connection) (api/symbol '_)])
- (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :g)]) (api/symbol '_)]))
+ (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :g) (api/map {(api/keyword :id) (api/string "edges")})]) (api/symbol '_)]))
+
+ (defncall 'graph-module-edges '->
+ (api/fn-call (api/symbol 'myzip) [(api/fn-call (api/symbol '->) [(api/key-fn :node) (api/symbol 'prepare-edges)])
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol '->) [(api/key-fn :node)
+ (api/key-fn :edges)
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])])
+ (api/key-fn :context)])])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'merge-connection) (api/symbol '_)])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'graph-connection) (api/symbol '_)])
+ (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :g) (api/map {(api/keyword :id) (api/string "edges")})]) (api/symbol '_)]))
+
+ (defncall 'graph-module-stub '->
+ (api/vector [(api/keyword :g)
+ (api/vector [(api/keyword :rect)
+ (api/map {(api/keyword :id) (api/fn-call (api/symbol 'str) [(api/string "m/") (api/symbol 'func-id)])
+ (api/keyword :fill-opacity) (api/float 0.4)
+
+ (api/keyword :style) (api/map {(api/keyword :fill) (api/fn-call (api/symbol '->) [(api/keyword :module-bg) (api/symbol 'get-color)])
+ (api/keyword :stroke) (api/fn-call (api/symbol '->) [(api/keyword :module-border) (api/symbol 'get-color)])
+ (api/keyword :pointer-events) (api/string "all")})
+ (api/keyword :rx) (api/integer 10)
+ ;; (api/keyword :y) (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :y)])
+ (api/keyword :width) (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :width)])
+ (api/keyword :height) (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :height)])})])
+ (api/vector [(api/keyword :text)
+ (api/map {;; (api/keyword :transform) (api/string "rotate(90 50 50)")
+ ;; (api/keyword :x) (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :x)])
+ ;; (api/keyword :y) (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :y)])
+ (api/keyword :dy) (api/integer 14)
+ (api/keyword :fill) (api/fn-call (api/symbol '->) [(api/keyword :node-name-stroke) (api/symbol 'get-color)])
+ (api/keyword :text-anchor) (api/keyword :middle)
+ (api/keyword :font-weight) (api/string "bold")
+ (api/keyword :pointer-events) (api/string "none")})
+ (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :name)])])]))
+
+ (defncall 'is-module '->
+ (api/key-fn :node)
+ (api/key-fn :type)
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :caravan/module)]))
+
+ (defncall 'is-pipe-node '->
+ (api/key-fn :node)
+ (api/key-fn :type)
+ (api/fn-call (api/symbol 'or) [(api/fn-call (api/symbol '=) [(api/symbol '_) (api/string "sink")])
+ (api/fn-call (api/symbol '=) [(api/symbol '_) (api/keyword :caravan/sink)])]))
+
+ (defncall 'is-func-node '->
+ (api/key-fn :node)
+ (api/key-fn :value))
+
+ (defncall 'graph-inner '->
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-module)
+ (api/symbol 'graph-module-stub)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-pipe-node)
+ (api/symbol 'graph-pipe)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-func-node)
+ (api/symbol 'graph-func)]))
+
+ (defncall 'graph-module-elems '->
+ (api/fn-call (api/symbol 'myzip) [(api/fn-call (api/symbol '->) [(api/key-fn :node)
+ (api/key-fn :children)])
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol '->) [(api/key-fn :node)
+ (api/key-fn :children)
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])])
+ (api/key-fn :context)])])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'merge-node) (api/symbol '_)])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'graph-inner) (api/symbol '_)])
+ (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :g) (api/map {(api/keyword :id) (api/string "inner")})]) (api/symbol '_)])
+ )
+
+ (defncall 'graph-port '->
+ (api/vector [(api/keyword :g)
+ (api/map {(api/keyword :id) (api/key-fn :id)
+ (api/keyword :name) (api/key-fn :name)
+ (api/keyword :transform) (api/symbol 'translate-str)})
+ (api/vector [(api/keyword :rect)
+ (api/map {(api/keyword :style) (api/map {(api/keyword :fill) (api/fn-call (api/symbol '->) [(api/keyword :module-bg) (api/symbol 'get-color)])
+ (api/keyword :stroke) (api/symbol 'get-func-stroke)
+ (api/keyword :filter) (api/string "url(#shadow)")
+ (api/keyword :pointer-events) (api/string "all")})
+ (api/keyword :width) (api/key-fn :width)
+ (api/keyword :height) (api/key-fn :height)})])]))
+
+ (defncall 'graph-module-ports '->
+ (api/key-fn :node)
+ (api/key-fn :ports)
+ (api/fn-call (api/symbol 'map) [(api/symbol 'graph-port) (api/symbol '_)])
+ (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :g) (api/map {(api/keyword :id) (api/string "ports")})]) (api/symbol '_)]))
+
+ (defncall 'graph-module '->
+ (api/vector [(api/keyword :g)
+ (api/map {(api/keyword :id) (api/fn-call (api/symbol 'str) [(api/string "mod/") (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/key-fn :id)])])
+ (api/keyword :transform) (api/fn-call (api/symbol '->) [(api/key-fn :node) (api/symbol 'translate-str)])})
+ (api/symbol 'graph-module-stub)
+ (api/symbol 'graph-module-ports)
+ (api/symbol 'graph-module-elems)
+ (api/symbol 'graph-module-edges)
+ ]))
+
+ (defncall 'graph-node '->
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-module)
+ (api/symbol 'graph-module)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-pipe-node)
+ (api/symbol 'graph-pipe)])
+ (api/fn-call (api/symbol 'incase) [(api/symbol 'is-func-node)
+ (api/symbol 'graph-func)]))
(defncall 'build-context '->
(api/map {(api/keyword :editor) (api/key-fn :editor)
@@ -3186,13 +3503,26 @@
;; (api/symbol 'get-color)])
(api/keyword :style) (api/map {(api/keyword :pointer-events) (api/string "all")})})]))
+ (defncall 'graph-nodes '->
+ (api/fn-call (api/symbol 'myzip) [(api/fn-call (api/symbol '->) [(api/key-fn :layout)
+ (api/key-fn :children)])
+ (api/fn-call (api/symbol 'repeat) [(api/fn-call (api/symbol '->) [(api/key-fn :layout)
+ (api/key-fn :children)
+ (api/fn-call (api/symbol 'count) [(api/symbol '_)])])
+ (api/key-fn :context)])])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'merge-node) (api/symbol '_)])
+ (api/fn-call (api/symbol 'map) [(api/symbol 'graph-node) (api/symbol '_)])
+ (api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :g) (api/map {(api/keyword :id) (api/string "nodes")})]) (api/symbol '_)]))
+
+
+
(defncall 'graph '->
- (api/map {(api/keyword :layout) (api/key-fn :layout)
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "graph")])
+ (api/map {(api/keyword :layout) (api/key-fn :layout) ;;(api/symbol 'prep-layout)
(api/keyword :view) (api/key-fn :view)
(api/keyword :context) (api/symbol 'build-context)})
(api/map {(api/keyword :graph)
(api/vector [(api/keyword :g)
- (api/map {(api/keyword :transform) (api/fn-call (api/symbol '->) [(api/key-fn :view) (api/symbol 'translate-graph)])})
(api/symbol 'graph-background)
(api/symbol 'graph-connections)
(api/symbol 'graph-nodes)])}))
@@ -3268,6 +3598,7 @@
(defncall 'graph-drag '->
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "drag")])
(api/map {(api/keyword :graph-drag)
(api/fn-call (api/symbol 'if) [(api/fn-call (api/symbol 'and) [(api/fn-call (api/symbol '=) [(api/fn-call (api/symbol '->) [(api/key-fn :editor) (api/key-fn :activity)])
(api/keyword :dragging)])
@@ -3289,11 +3620,12 @@
(api/keyword :action-menu) (api/vector [(api/keyword :g)])
(api/keyword :graph-drag) (api/vector [(api/keyword :g)])
(api/keyword :graph-dialog) (api/vector [(api/keyword :g)])
- (api/keyword :resize) (api/map {})}))
+ (api/keyword :resize) (api/map {})
+ (api/keyword :view) (api/map {})}))
;; render elements to hiccup
- (defncall 'svg-reduced 'pipes/debug ;; (api/keyword :oasis.spec/render)
+ (defncall 'svg-reduced 'pipes/debug (api/string "svg-reduced") ;; (api/keyword :oasis.spec/render)
)
(defncall 'svg-defs '->
@@ -3313,8 +3645,7 @@
(api/vector [(api/keyword :feDropShadow)
(api/map {(api/keyword :dx) (api/string "3")
(api/keyword :dy) (api/string "3")
- (api/keyword :flood-color) (api/fn-call (api/symbol '->) [(api/keyword :shadow-flood)
- (api/symbol 'get-color)])
+ (api/keyword :flood-color) (api/fn-call (api/symbol 'get-color) [(api/keyword :shadow-flood)])
(api/keyword :flood-opacity) (api/string "0.3")
(api/keyword :stdDeviation) (api/string "3")})])])
@@ -3349,8 +3680,7 @@
(api/vector [(api/keyword :feDropShadow)
(api/map {(api/keyword :dx) (api/string "-3")
(api/keyword :dy) (api/string "3")
- (api/keyword :flood-color) (api/fn-call (api/symbol '->) [(api/keyword :shadow-flood)
- (api/symbol 'get-color)])
+ (api/keyword :flood-color) (api/fn-call (api/symbol 'get-color) [(api/keyword :shadow-flood)])
(api/keyword :flood-opacity) (api/string "0.3")
(api/keyword :stdDeviation) (api/string "3")})])])
(api/vector [(api/keyword :filter)
@@ -3358,8 +3688,7 @@
(api/vector [(api/keyword :feDropShadow)
(api/map {(api/keyword :dx) (api/string "0")
(api/keyword :dy) (api/string "-3")
- (api/keyword :flood-color) (api/fn-call (api/symbol '->) [(api/keyword :shadow-flood)
- (api/symbol 'get-color)])
+ (api/keyword :flood-color) (api/fn-call (api/symbol 'get-color) [(api/keyword :shadow-flood)])
(api/keyword :flood-opacity) (api/string "0.3")
(api/keyword :stdDeviation) (api/string "3")})])])]))
@@ -3373,7 +3702,7 @@
;; render SVG components
- (defncall 'svg-render 'pipes/debug)
+ (defncall 'svg-render 'pipes/debug (api/string "svg-render"))
(defncall 'render-svg '->
(api/map {(api/keyword :svg)
(api/map {(api/keyword :oasis.gui/order)
@@ -3384,7 +3713,10 @@
(api/keyword :viewBox) (api/fn-call (api/symbol 'str) [(api/string "0 0 ") (api/symbol 'get-width) (api/string " ") (api/symbol 'get-height)])
})
(api/symbol 'svg-defs)
- (api/key-fn :graph)
+ (api/vector [(api/keyword :g)
+ (api/map {(api/keyword :id) (api/string "view")
+ (api/keyword :transform) (api/fn-call (api/symbol '->) [(api/key-fn :view) (api/symbol 'translate-graph)])})
+ (api/key-fn :graph)])
(api/key-fn :graph-focused)
(api/key-fn :source-menu)
(api/key-fn :sink-menu)
@@ -3394,8 +3726,18 @@
])})}))
- (api/defmodule 'oasis-render (api/map {(api/keyword :sources) (api/map {(api/keyword :state) (api/symbol 'oasis-render-in)})
- (api/keyword :sinks) (api/map {(api/keyword :svg-elems) (api/symbol 'oasis-render-out)})}))
+ (api/defmodule 'oasis-render (api/map {(api/keyword :sources) (api/map {(api/keyword :state) (api/symbol 'oasis-render-in)
+ (api/keyword :mouse) (api/symbol 'oasis-render-mouse-in)
+ (api/keyword :kb) (api/symbol 'oasis-render-kb-in)
+ (api/keyword :kb-out) (api/symbol 'oasis-render-kb-out)
+ (api/keyword :init) (api/symbol 'oasis-render-init)
+ (api/keyword :svg-elems) (api/symbol 'oasis-render-out)
+ (api/keyword :drag) (api/symbol 'oasis-render-drag-out)
+ (api/keyword :hover) (api/symbol 'oasis-render-hover-out)})
+ (api/keyword :sinks) (api/map {(api/keyword :svg-elems) (api/symbol 'oasis-render-out)
+ (api/keyword :kb) (api/symbol 'oasis-render-kb-out)
+ (api/keyword :drag) (api/symbol 'oasis-render-drag-out)
+ (api/keyword :hover) (api/symbol 'oasis-render-hover-out)})}))
])
(def oasis-render-net
@@ -3403,6 +3745,55 @@
(pipe 'oasis-render-in 'state-reduce)
(pipe 'state-reduce 'condensed-state)
+ ;; (pipe 'oasis-render-mouse-in 'oasis-render-mouse-out)
+
+ ;; mouse handling
+ (pipe 'oasis-render-mouse-in 'mouse-reduce)
+ (pipe 'mouse-reduce 'mouse-state)
+ (pipe 'mouse-state 'filter-drag 'drag-events)
+
+ ;; (pipe 'drag-events 'log-mouse2)
+
+ (pipe 'drag-events 'state-reduce)
+ (pipe 'drag-events 'filter-drag-end-or-start 'oasis-render-drag-out) ;; FIXME reduce
+ (pipe 'mouse-state 'filter-scroll 'scroll-state)
+
+ (pipe 'oasis-render-mouse-in 'target-reduce)
+ (pipe 'target-reduce 'target-events)
+ (pipe 'target-events 'only-different 'hover-events)
+ (pipe 'hover-events 'tag-hover 'hover-out)
+ (pipe 'hover-out 'oasis-render-hover-out)
+ ;; (pipe 'hover-out 'log-hov)
+
+ ;; keyboard handling
+
+ ;; (pipe 'oasis-render-kb-in 'log-mouse2)
+ (pipe 'oasis-render-kb-in 'oasis-render-kb-out)
+
+ (pipe 'oasis-render-kb-in 'filter-view 'view-commands)
+
+ ;; view handling
+
+ (pipe 'view-commands 'make-zoom)
+ (pipe 'make-zoom 'zoom-events)
+ (pipe 'zoom-events 'view-events)
+ (pipe 'view-commands 'view-deltas)
+
+ (pipe 'scroll-state 'construct-view 'view-deltas)
+ (pipe 'view-deltas 'view-delta)
+ (pipe 'view-delta 'view-events)
+ (pipe 'view-events 'view-reduce)
+ (pipe 'view-reduce 'view-raw)
+ (pipe 'view-raw 'tag-view 'view-state)
+ ;; (pipe 'view-state 'log-view)
+ ;; (pipe 'view-state 'state-reduce)
+ (pipe 'view-state 'svg-elements-reduce)
+
+ (pipe 'oasis-render-init 'init-view 'view-events)
+
+
+ ;; state rendering
+
(pipe 'condensed-state 'only-resize 'svg-render)
(pipe 'condensed-state 'graph 'svg-render)
(pipe 'condensed-state 'graph-drag 'svg-render)
@@ -3420,123 +3811,284 @@
(def oasis-ui-defs
[
- (defncall 'oasis-ui-in 'pipes/debug)
- (defncall 'oasis-ui-out 'pipes/ui (api/integer 2))
- (defncall 'oasis-ui-mouse 'pipes/mouse (api/integer 2))
+ ;; (api/defexp 'ui-mod (api/fn-call (api/symbol 'modules/ui) []))
+ ;; (api/defexp 'm-ui (api/fn-call (api/symbol 'ui-mod) []))
+
+ ;; (defncall 'm-ui-kb '->
+ ;; (api/symbol 'm-ui)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :keyboard))
+ ;; (defncall 'oasis-ui-mod-kb 'm-ui-kb)
+ ;; (defncall 'm-ui-mouse '->
+ ;; (api/symbol 'm-ui)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :mouse))
+ ;; (defncall 'oasis-ui-mod-mouse 'm-ui-mouse)
+ ;; (defncall 'm-ui-events '->
+ ;; (api/symbol 'm-ui)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :events))
+ ;; (defncall 'oasis-ui-mod-events 'm-ui-events)
+ ;; (defncall 'm-ui-render '->
+ ;; (api/symbol 'm-ui)
+ ;; (api/key-fn :sinks)
+ ;; (api/key-fn :render))
+ ;; (defncall 'oasis-ui-out 'm-ui-render)
+
+ (defncall 'oasis-ui-render 'pipes/ui (api/integer 2))
+ (defncall 'oasis-ui-events 'pipes/events (api/integer 2))
+ (defncall 'oasis-ui-mouse 'pipes/mouse)
(defncall 'oasis-ui-kb 'pipes/keyboard)
- (defncall 'render 'pipes/debug ;; (api/keyword :oasis.spec/render)
+ (defncall 'oasis-ev 'pipes/debug (api/string "oasis-ev"))
+ (defncall 'oasis-ui-mouse-out 'pipes/debug (api/string "oasis-ui-mouse-out"))
+ (defncall 'oasis-ui-kb-out 'pipes/debug (api/string "oasis-ui-kb-out"))
+ (defncall 'oasis-ui-in 'pipes/debug (api/string "oasis-ui-in"))
+ (defncall 'render 'pipes/debug (api/string "render") ;; (api/keyword :oasis.spec/render)
)
- (defncall 'reducer 'pipes/debug ;; (api/keyword :oasis.spec/gui)
+ (defncall 'reducer 'pipes/debug (api/string "reducer") ;; (api/keyword :oasis.spec/gui)
)
(defncall 'elements-reduce 'pipes/reductions
(api/fn-call (api/symbol 'into) [(api/key-fn :state) (api/key-fn :next)])
(api/map {}))
(defncall 'render-elements '->
- ;; (api/fn-call (api/symbol 'spy) [(api/string "vals1")])
+ ;; (api/fn-call (api/symbol 'spy) [(api/string "vals")])
(api/fn-call (api/symbol 'vals) [(api/symbol '_)])
;; (api/fn-call (api/symbol 'sort-by [(api/symbol '_)]))
(api/fn-call (api/symbol 'map) [(api/key-fn :oasis.gui/element) (api/symbol '_)])
(api/fn-call (api/symbol 'into) [(api/vector [(api/keyword :div) (api/map {(api/keyword :class) (api/string "fullscreen")})])
(api/symbol '_)]))
-
- (api/defmodule 'oasis-ui (api/map {(api/keyword :sources) (api/map {(api/keyword :render) (api/symbol 'oasis-ui-in)})
- (api/keyword :sinks) (api/map {(api/keyword :mouse) (api/symbol 'oasis-ui-mouse)
- (api/keyword :kb) (api/symbol 'oasis-ui-kb)})
- (api/keyword :tests) (api/map {(api/keyword :t1) (api/map {(api/keyword :when) (api/map {(api/string "oasis-ui-in") (api/vector [(api/map {(api/keyword :header)
- (api/map {(api/keyword :oasis.gui/order)
- (api/integer 1)
- (api/keyword :oasis.gui/element)
- (api/vector [(api/keyword :h1)
- (api/string "사막 Oasis")])})})])})
- (api/keyword :then) (api/map {(api/string "oasis-ui-out")
- (api/vector [(api/fn-call (api/symbol 'incase) [(api/fn-call (api/symbol '=) [(api/keyword :div)
- (api/fn-call (api/symbol 'first) [(api/symbol '_)])])
- (api/keyword :success)])])})})})}))
+ (defncall 'log-render2 'pipes/log (api/string "render2: "))
+
+ (api/defmodule 'oasis-ui (api/map {;; (api/keyword :depends) (api/map {(api/keyword :ui) (api/symbol 'modules/ui)})
+ (api/keyword :sources) (api/map {(api/keyword :render) (api/symbol 'oasis-ui-in)
+ ;; (api/keyword :m-ui) (api/symbol 'm-ui)
+ ;; (api/keyword :ui-mod) (api/symbol 'ui-mod)
+ ;; (api/keyword :m-ui-kb) (api/symbol 'm-ui-kb)
+ ;;(api/keyword :mod-kb) (api/symbol 'oasis-ui-mod-kb)
+ ;;(api/keyword :mod-mouse) (api/symbol 'oasis-ui-mod-mouse)
+ ;;(api/keyword :kb) (api/symbol 'oasis-ui-kb)
+ ;;(api/keyword :mouse) (api/symbol 'oasis-ui-mouse)
+ ;;(api/keyword :m-ui-mouse) (api/symbol 'm-ui-mouse)
+ ;;(api/keyword :m-ui-render) (api/symbol 'm-ui-render)
+ ;;(api/keyword :oasis-ui-out) (api/symbol 'oasis-ui-out)
+ ;;(api/keyword :events) (api/symbol 'oasis-ui-events)
+ ;;(api/keyword :events-mod) (api/symbol 'oasis-ui-mod-events)
+ })
+ (api/keyword :sinks) (api/map {;;(api/keyword :mouse) (api/symbol 'oasis-ui-mouse-out)
+ ;;(api/keyword :kb) (api/symbol 'oasis-ui-kb-out)
+ ;;(api/keyword :events) (api/symbol 'oasis-ev)
+ })
+ ;; (api/keyword :tests) (api/map {(api/keyword :t1) (api/map {(api/keyword :when) (api/map {(api/string "oasis-ui-in") (api/vector [(api/map {(api/keyword :header)
+ ;; (api/map {(api/keyword :oasis.gui/order)
+ ;; (api/integer 1)
+ ;; (api/keyword :oasis.gui/element)
+ ;; (api/vector [(api/keyword :h1)
+ ;; (api/string "사막 Oasis")])})})])})
+ ;; (api/keyword :then) (api/map {(api/string "oasis-ui-out")
+ ;; (api/vector [(api/fn-call (api/symbol 'incase) [(api/fn-call (api/symbol '=) [(api/keyword :div)
+ ;; (api/fn-call (api/symbol 'first) [(api/symbol '_)])])
+ ;; (api/keyword :success)])])})})})
+ }))
])
(def oasis-ui-net
- [(pipe 'oasis-ui-in 'render)
+ [
+ (pipe 'oasis-ui-in 'render)
+ (pipe 'oasis-ui-in 'log-render2)
(pipe 'render 'elements-reduce)
(pipe 'elements-reduce 'reducer)
- (pipe 'reducer 'render-elements 'oasis-ui-out)
- ;; (pipe 'reducer 'render-elements 'log-render)
+ (pipe 'reducer 'render-elements 'oasis-ui-render)
+ ;; (pipe 'oasis-ui-events 'oasis-ev)
+
+ ;; (pipe 'oasis-ui-mouse 'oasis-ui-mouse-out)
+ ;; (pipe 'oasis-ui-kb 'oasis-ui-kb-out)
+
+ ;; (pipe 'oasis-ui-in 'render)
+ ;; (pipe 'render 'elements-reduce)
+ ;; (pipe 'elements-reduce 'reducer)
+
+ ;; (pipe 'reducer 'render-elements 'oasis-ui-render)
+ ;; (pipe 'oasis-ui-events 'oasis-ev)
+ ;; (pipe 'oasis-ui-events 'log-render2)
+ ;; ;; (pipe 'oasis-ui-render 'log-render2)
+ ;; (pipe 'reducer 'render-elements 'log-render2)
])
(def oasis-module-defs
- [(defncall 'm-ui '->
- (api/symbol 'oasis-ui))
+ [
+ (defncall 'm-ui-mod 'oasis-ui)
+ (defncall 'm-oasis-ui 'm-ui-mod)
(defncall 'm-render-fn '->
- (api/symbol 'm-ui)
+ (api/symbol 'm-oasis-ui)
(api/key-fn :sources)
(api/key-fn :render))
(defncall 'ui-render 'm-render-fn)
- (defncall 'm-mouse-fn '->
- (api/symbol 'm-ui)
- (api/key-fn :sinks)
- (api/key-fn :mouse))
- (defncall 'oasis-mouse 'm-mouse-fn)
- (defncall 'm-kb-fn '->
- (api/symbol 'm-ui)
- (api/key-fn :sinks)
- (api/key-fn :kb))
- (defncall 'oasis-kb 'm-kb-fn)
-
- (defncall 'm-render '->
- (api/symbol 'oasis-render))
- (defncall 'm-state-fn '->
- (api/symbol 'm-render)
- (api/key-fn :sources)
- (api/key-fn :state))
- (defncall 'render-state 'm-state-fn)
- (defncall 'm-elems-fn '->
- (api/symbol 'm-render)
- (api/key-fn :sinks)
- (api/key-fn :svg-elems))
- (defncall 'render-elems 'm-elems-fn)
-
- (defncall 'm-core '->
- (api/symbol 'oasis-core))
- (defncall 'm-state-out-fn '->
- (api/symbol 'm-core)
- (api/key-fn :sinks)
- (api/key-fn :state))
- (defncall 'core-state 'm-state-out-fn)
- (defncall 'm-init-fn '->
- (api/symbol 'm-core)
- (api/key-fn :sources)
- (api/key-fn :init))
- (defncall 'core-init 'm-init-fn)
+ ;; (defncall 'm-mouse-fn '->
+ ;; (api/symbol 'm-oasis-ui)
+ ;; (api/key-fn :sinks)
+ ;; (api/key-fn :mouse))
+ ;; (defncall 'oasis-bug 'm-mouse-fn)
+ ;; (defncall 'm-kb-fn '->
+ ;; (api/symbol 'm-oasis-ui)
+ ;; (api/key-fn :sinks)
+ ;; (api/key-fn :kb))
+ ;; (defncall 'oasis-keyboard 'm-kb-fn)
+ ;; (defncall 'm-events-fn '->
+ ;; (api/symbol 'm-oasis-ui)
+ ;; (api/key-fn :sinks)
+ ;; (api/key-fn :events))
+ ;; (defncall 'oasis-events 'm-events-fn)
+
+ ;; (defncall 'm-render-mod 'oasis-render)
+ ;; (defncall 'm-render 'm-render-mod)
+ ;; (defncall 'm-state-fn '->
+ ;; (api/symbol 'm-render)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :state))
+ ;; (defncall 'render-state 'm-state-fn)
+ ;; (defncall 'm-ro-init-fn '->
+ ;; (api/symbol 'm-render)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :init))
+ ;; (defncall 'render-init 'm-ro-init-fn)
+ ;; (defncall 'm-r-mouse-fn '->
+ ;; (api/symbol 'm-render)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :mouse))
+ ;; (defncall 'render-mouse-in 'm-r-mouse-fn)
+ ;; (defncall 'm-r-kb-fn '->
+ ;; (api/symbol 'm-render)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :kb))
+ ;; (defncall 'render-kb-in 'm-r-kb-fn)
+ ;; (defncall 'm-elems-fn '->
+ ;; (api/symbol 'm-render)
+ ;; (api/key-fn :sinks)
+ ;; (api/key-fn :svg-elems))
+ ;; (defncall 'render-elems 'm-elems-fn)
+ ;; (defncall 'm-ro-hover-fn '->
+ ;; (api/symbol 'm-render)
+ ;; (api/key-fn :sinks)
+ ;; (api/key-fn :hover))
+ ;; (defncall 'render-hover-out 'm-ro-hover-fn)
+ ;; (defncall 'm-ro-drag-fn '->
+ ;; (api/symbol 'm-render)
+ ;; (api/key-fn :sinks)
+ ;; (api/key-fn :drag))
+ ;; (defncall 'render-drag-out 'm-ro-drag-fn)
+ ;; (defncall 'm-ro-kb-fn '->
+ ;; (api/symbol 'm-render)
+ ;; (api/key-fn :sinks)
+ ;; (api/key-fn :kb))
+ ;; (defncall 'render-kb-out 'm-ro-kb-fn)
+
+ ;; (defncall 'm-core-mod 'oasis-core)
+ ;; (defncall 'm-core 'm-core-mod)
+ ;; (defncall 'm-state-out-fn '->
+ ;; (api/symbol 'm-core)
+ ;; (api/key-fn :sinks)
+ ;; (api/key-fn :state))
+ ;; (defncall 'core-state 'm-state-out-fn)
+ ;; (defncall 'm-init-fn '->
+ ;; (api/symbol 'm-core)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :init))
+ ;; (defncall 'core-init 'm-init-fn)
+ ;; (defncall 'm-core-kb-fn '->
+ ;; (api/symbol 'm-core)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :kb))
+ ;; (defncall 'core-kb-in 'm-core-kb-fn)
+ ;; (defncall 'm-core-drag-fn '->
+ ;; (api/symbol 'm-core)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :drag))
+ ;; (defncall 'core-drag-in 'm-core-drag-fn)
+ ;; (defncall 'm-core-hover-fn '->
+ ;; (api/symbol 'm-core)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :hover))
+ ;; (defncall 'core-hover-in 'm-core-hover-fn)
+ ;; (defncall 'm-core-events-fn '->
+ ;; (api/symbol 'm-core)
+ ;; (api/key-fn :sources)
+ ;; (api/key-fn :events))
+ ;; (defncall 'core-events-in 'm-core-events-fn)
(defncall 'log-state 'pipes/log (api/string "log-state: "))
(defncall 'log-render 'pipes/log (api/string "render: "))
+ (defncall 'log-foo 'pipes/log (api/string "foo: "))
- (defncall 'oasis-init 'pipes/debug)
- (defncall 'init 'pipes/debug)
- (api/defexp 'oasis-main (api/pipe (api/symbol 'oasis-init)
- (api/symbol 'init)))
- (api/defexp 'oasis (api/map {(api/keyword :sources) (api/map {(api/keyword :main) (api/symbol 'oasis-init)
-
- (api/keyword :mouse) (api/symbol 'oasis-mouse)
- (api/keyword :kb) (api/symbol 'oasis-kb)
- (api/keyword :eval) (api/symbol 'oasis-eval)
- (api/keyword :layout) (api/symbol 'oasis-layout)
- })
- ;; (api/keyword :sink) (api/vector [(api/symbol 'oasisp)])
- (api/keyword :tests) (api/map {(api/keyword ::test)
- (api/map {(api/keyword :when) (api/map {(api/string "init")
- (api/vector [(api/integer 1)])})
- (api/keyword :then) (api/map {(api/string "oasis-ui-out")
- (api/vector [(api/keyword :success)])})})})}))])
+ (defncall 'header '->
+ (api/map {(api/keyword :header)
+ (api/map {(api/keyword :oasis.gui/order)
+ (api/integer 1)
+ (api/keyword :oasis.gui/element)
+ (api/vector [(api/keyword :h1)
+ (api/string "사막 Oasis")])})}))
+
+ (defncall 'oasis-init 'pipes/debug (api/string "oasis-init"))
+ (api/defmodule 'oasis (api/map {(api/keyword :depends) (api/map {;; (api/keyword :oasis-core) (api/symbol 'oasis-core)
+
+ ;; (api/keyword :oasis-render) (api/symbol 'oasis-render)
+ (api/keyword :oasis-ui) (api/symbol 'oasis-ui)
+ })
+ (api/keyword :sources) (api/map {;; (api/keyword :module-core-out) (api/symbol 'core-state)
+ ;(api/keyword :module-core-kb-in) (api/symbol 'core-kb-in)
+ ;(api/keyword :module-core-drag-in) (api/symbol 'core-drag-in)
+ ;(api/keyword :module-core-scroll-in) (api/symbol 'core-scroll-in)
+ ;; (api/keyword :module-core-hover-in) (api/symbol 'core-hover-in)
+ ;; (api/keyword :module-render-state) (api/symbol 'render-state)
+ ;; (api/keyword :module-render-init) (api/symbol 'render-init)
+ ;; (api/keyword :module-render-mouse-in) (api/symbol 'render-mouse-in)
+ ;; (api/keyword :module-render-kb-in) (api/symbol 'render-kb-in)
+ ;; (api/keyword :module-render-kb-out) (api/symbol 'render-kb-out)
+ ;; (api/keyword :module-render-drag-out) (api/symbol 'render-drag-out)
+ ;; (api/keyword :module-render-hover-out) (api/symbol 'render-hover-out)
+ ;; (api/keyword :module-render-out) (api/symbol 'render-elems)
+ ;; (api/keyword :kb) (api/symbol 'oasis-keyboard)
+ ;; (api/keyword :mouse) (api/symbol 'oasis-bug)
+ ;; (api/keyword :events) (api/symbol 'oasis-events)
+ ;; (api/keyword :main-inst-fn) (api/symbol 'core-init)
+ (api/keyword :main) (api/symbol 'oasis-init)
+ (api/keyword :ui-r) (api/symbol 'ui-render)
+ ;(api/keyword :ui-m-r) (api/symbol 'm-render-fn)
+ })}))
+ ;; (api/defexp 'oasis-legacy (api/map {(api/keyword :sources) (api/map {(api/keyword :main) (api/symbol 'oasis-init)
+
+ ;; (api/keyword :mouse) (api/symbol 'oasis-mouse)
+ ;; (api/keyword :kb) (api/symbol 'oasis-kb)
+ ;; (api/keyword :eval) (api/symbol 'oasis-eval)
+ ;; (api/keyword :layout) (api/symbol 'oasis-layout)
+ ;; })
+ ;; ;; (api/keyword :sink) (api/vector [(api/symbol 'oasisp)])
+ ;; (api/keyword :tests) (api/map {(api/keyword (api/string "test)
+ ;; (api/map {(api/keyword :when) (api/map {(api/string "init")
+ ;; (api/vector [(api/integer 1)])})
+ ;; (api/keyword :then) (api/map {(api/string "oasis-ui-out")
+ ;; (api/vector [(api/keyword :success)])})})})}))
+ ])
(def oasis-module-net
[
- (pipe 'init 'header 'ui-render)
- (pipe 'init 'core-init)
+ (pipe 'oasis-init 'header 'ui-render)
+ (pipe 'oasis-init 'header 'log-render)
+ ;; (pipe 'oasis-init 'core-init)
+ ;; (pipe 'oasis-init 'render-init)
;; (pipe 'core-state 'log-state)
- (pipe 'core-state 'render-state)
+ ;; (pipe 'core-state 'render-state)
;; (pipe 'render-elems 'log-render)
- (pipe 'render-elems 'ui-render)
+ ;; (pipe 'render-elems 'ui-render)
+
+ ;; (pipe 'oasis-keyboard 'render-kb-in)
+ ;; (pipe 'render-kb-out 'core-kb-in)
+ ;; (pipe 'oasis-bug 'render-mouse-in)
+ ;; (pipe 'render-drag-out 'core-drag-in)
+ ;; (pipe 'render-hover-out 'core-hover-in)
+ ;; ;; (pipe 'render-drag-out 'log-foo)
+ ;; (pipe 'oasis-events 'core-events-in)
+ ;; (pipe 'oasis-events 'log-state)
])
@@ -3544,12 +4096,12 @@
(into oasis-ui-defs (flatten oasis-ui-net)))
(def network (concat oasis-module-net oasis-ui-net oasis-core-net oasis-render-net))
-(def oasis (into oasis1 (into oasis2 (into oasis3 (into oasis-core-defs (into oasis-render-defs (into oasis-ui-defs oasis-module-defs)))))))
+(def oasis (into oasis1 (into oasis2 (into oasis-core-defs (into oasis-render-defs (into oasis-ui-defs oasis-module-defs))))))
(defn start []
(into oasis (flatten network)))
-(defn store [stores]
- (.persist-tree! stores oasis)
- (.persist-tree! stores (flatten network))
- stores)
+(defn store [s]
+ (stores/persist-tree! s oasis)
+ (stores/persist-tree! s (flatten network))
+ s)
diff --git a/ui_src/samak/ui_stdlib.cljs b/ui_src/samak/ui_stdlib.cljs
index d5a70d8..9212326 100644
--- a/ui_src/samak/ui_stdlib.cljs
+++ b/ui_src/samak/ui_stdlib.cljs
@@ -82,37 +82,83 @@
(map #(transform-element % ch) children)))
x))
-(defn ui [n events]
- (let [ui-in (chan (a/sliding-buffer 1))
- ui-out (chan (a/sliding-buffer 1000))
- init (atom true)]
- (go-loop []
- (when-some [i (clj e :keywordize-keys true)]
+ (fn [e] (do (println "rez: " n)
+ (put-meta! c (let [event (js->clj e :keywordize-keys true)]
{:data :resize
:width (.-clientWidth (.-documentElement js/document))
:height (.-clientHeight (.-documentElement js/document))
:samak.view/target (.-id (.-target event))}
)
::view)
- false)))
- (pipes/pipe ui-in ui-out)))
+ (println "EVS: " n)
+ false)))
+ (when @init
+ (reset! init false)
+ (put-meta! c
+ {:data :resize
+ :width (.-clientWidth (.-documentElement js/document))
+ :height (.-clientHeight (.-documentElement js/document))}
+ ::view))
+ (pipes/source c)))
+
+(def content (atom {}))
+
+(defn render-cb
+ ""
+ [n node]
+ (r/render (get @content n) node)
+ (swap! content dissoc n))
+
+(defn render
+ ""
+ [n node x events c]
+ (if (not (get @content n))
+ (helpers/debounce #(render-cb n node)))
+ (swap! content assoc n (if events (transform-element x c) x)))
+
+
+(defn ui
+ ([n]
+ (ui n false)) ;;FIXME
+ ([n events]
+ (let [ui-in (chan (a/sliding-buffer 1))
+ ui-out (chan (a/sliding-buffer 1000))
+ init (atom true)]
+ (go-loop []
+ (when-some [i (clj e :keywordize-keys true)]
+ ;; {:data :resize
+ ;; :width (.-clientWidth (.-documentElement js/document))
+ ;; :height (.-clientHeight (.-documentElement js/document))
+ ;; :samak.view/target (.-id (.-target event))}
+ ;; )
+ ;; ::view)
+ ;; false)))
+ (pipes/pipe ui-in ui-out (str "render-" n)))))
(defn translate-coords
""
@@ -122,7 +168,7 @@
(defn mouse [n]
- (let [c (chan)
+ (let [c (pipes/pipe-chan ::mouse nil)
elem (if n (js/document.getElementById (str "samak" n)) (.-body js/document))
bound (.getBoundingClientRect elem)]
(set! (.-onmousedown elem)
@@ -183,7 +229,7 @@
(defn keyboard []
- (let [c (chan)]
+ (let [c (pipes/pipe-chan ::keyboard nil)]
(set! (.-onkeypress js/document)
(fn [e] (do (let [event (js->clj e :keywordize-keys true)]
(put-meta! c (convert-key-event event :press) ::keyboard)
@@ -195,12 +241,17 @@
(pipes/source c)))
(defn ui-module
- [id]
- (let [render (ui id true)]
- {:sources {:events render
- :mouse (mouse id)
- :keyboard (keyboard)}
- :sinks {:render render}}))
+ []
+ (println "init ui")
+ (fn []
+ (let [xid 2
+ render (ui xid true)
+ m (mouse xid)]
+ (println "start ui:" m)
+ {:sources {:events render
+ :mouse m
+ :keyboard (keyboard)}
+ :sinks {:render render}})))
;; Exported symbols
@@ -208,5 +259,6 @@
(def ui-symbols
{'modules/ui ui-module
'pipes/ui ui
+ 'pipes/events events
'pipes/mouse mouse
'pipes/keyboard keyboard})
diff --git a/ui_src/samak/worker.cljc b/ui_src/samak/worker.cljc
index ef9c8ac..46389e9 100644
--- a/ui_src/samak/worker.cljc
+++ b/ui_src/samak/worker.cljc
@@ -5,54 +5,49 @@
[clojure.string :as str]
[clojure.edn :as edn]
[clojure.core.async :as a :refer [! chan go go-loop close! put! pipe]]
+ [promesa.core :as p]
[samak.api :as api]
+ [samak.helpers :as helpers]
[samak.runtime :as run]
[samak.stdlib :as std]
[samak.builtins :as builtins]
[samak.caravan :as caravan]
- [samak.test-programs :as test-programs]
[samak.trace :as trace]
[samak.oasis :as oasis]
- [samak.lisparser :as p]
[samak.pipes :as pipes]
- [samak.runtime.servers :as servers]
- [samak.runtime.stores :as stores])]
+ [samak.scheduler :as sched])]
:cljs
[(:require
[clojure.string :as str]
[cljs.reader :as edn]
[clojure.core.async :as a :refer [! chan close! put! pipe]]
+ [promesa.core :as p]
[samak.api :as api]
+ [samak.helpers :as helpers]
[samak.runtime :as run]
[samak.stdlib :as std]
[samak.builtins :as builtins]
[samak.layout :as layout]
[samak.caravan :as caravan]
- [samak.test-programs :as test-programs]
[samak.trace :as trace]
[samak.oasis :as oasis]
- [samak.lisparser :as p]
[samak.pipes :as pipes]
- [samak.runtime.servers :as servers]
- [samak.runtime.stores :as stores])
+ [samak.scheduler :as sched])
(:require-macros [cljs.core.async.macros :refer [go go-loop]])]))
-(defn make-piped
- ""
- [name]
- {:target :pipe :named (keyword name)})
-
(def ui-mock-symbols
- {'pipes/ui (make-piped 'pipes/ui)
- 'pipes/mouse (make-piped 'pipes/mouse)
- 'pipes/keyboard (make-piped 'pipes/keyboard)})
+ {'modules/ui :blank
+ 'pipes/ui :blank
+ 'pipes/events :blank
+ 'pipes/mouse :blank
+ 'pipes/keyboard :blank})
(def worker-symbols
(merge builtins/samak-symbols
+ std/pipe-symbols
caravan/symbols
- #?(:cljs layout/layout-symbols)
ui-mock-symbols
- std/pipe-symbols))
+ #?(:cljs layout/layout-symbols)))
(defn handle-update
@@ -65,86 +60,82 @@
(println "got" msg p))
(recur))))
-(def sched
- (fn [broadcast]
+(def scheduler
+ (let [broadcast (pipes/pipe (chan) ::worker-broadcast)
+ to-rt (pipes/pipe (chan) ::worker-scheduler)]
(println "sched")
- (let [to-rt (pipes/pipe (chan))]
- ;; (handle-update "out" broadcast)
- ;; (handle-update "in" to-rt)
- to-rt)))
+ ;; (handle-update "out" broadcast)
+ ;; (handle-update "in" to-rt)
+ (fn [] [to-rt broadcast])))
(def rt (atom {}))
-(defn fire-event-into-named-pipe
- [pipe-name event]
- (let [pipe (run/get-definition-by-name @rt (symbol pipe-name))]
- (if (pipes/pipe? pipe)
- (do (let [arg (edn/read-string event)]
- (pipes/fire! pipe arg pipe-name))
- {})
- (println (str "could not find pipe " pipe-name)))))
-
-(defn eval-test
- ""
- []
- (let [code (str/join " " test-programs/tw)
- parsed (p/parse-all code)]
- (swap! rt #(reduce run/eval-expression! % (:value parsed)))
- (fire-event-into-named-pipe "in" "5")))
-
-(defn eval-oasis
- ""
- [length cb state [nr exp]]
- (let [progress (int (* (/ nr length) 100))]
- (when (= 0 (mod progress 10))
- (put! cb progress)
- (println (str progress "%")))
- (run/eval-expression! state exp)))
-
-(defn run-oasis
- ""
- [state cb]
- (put! cb 100)
- (reset! rt state)
- (caravan/init @rt)
- (fire-event-into-named-pipe "init" "1")
- (println "oasis started")
- (let [parsed [(api/defexp 'start (api/fn-call (api/symbol 'pipes/debug) []))]]
- (doseq [expression parsed]
- (caravan/repl-eval expression)))
- (servers/get-defined (:server @rt)))
-
-
-(defn start-oasis
- [cb]
- (let [c (chan)
- exps (oasis/start)
- numbered (map-indexed vector exps)
- cnt (count numbered)]
- (go-loop [state @rt]
- (let [part (" mod "/" pipe))))
+
+(def get-named-pipe-memo (memoize get-named-pipe))
+
+(defn start-oasis
+ ""
+ []
+ (println "worker oasis")
+ ;; (pipes/link! (pipes/source in) (:scheduler @rt))
+ (p/do! (sched/start-module rt {} 'oasis-core)
+ (caravan/init @rt)
+ (println "worker started core")))
+
+(defn handle-input
+ ""
+ [rt c]
+ (go-loop []
+ (let [p (