33 lines
1.2 KiB
Fennel
33 lines
1.2 KiB
Fennel
(local util (require :plugins.fennel-xl.util))
|
|
(local lume (require :plugins.fennel-xl.lume))
|
|
(local {: defmulti} (require :plugins.fennel-xl.multimethod))
|
|
|
|
(local replsession (util.hot-table ...))
|
|
|
|
(set replsession.sessions {})
|
|
(set replsession.default-repl :local)
|
|
|
|
(set replsession.submit
|
|
(defmulti (fn [session chunk callback ?suppress-crash] session.repl) :submit ...))
|
|
(set replsession.restart (defmulti (fn [session] session.repl) :restart ...))
|
|
|
|
(fn replsession.new-session [?repl ?opts]
|
|
(replsession.restart (lume.merge {:repl (or ?repl replsession.default-repl)
|
|
:submit replsession.submit}
|
|
(or ?opts {}))))
|
|
|
|
(fn replsession.activate [id] (set replsession.active-session-id id))
|
|
(fn replsession.session-id [?id ?repl]
|
|
(let [repl (or ?repl replsession.default-repl)]
|
|
(if (= ?id nil) (or replsession.active-session-id (.. repl ":REPL"))
|
|
(.. repl ":" ?id))))
|
|
|
|
(fn replsession.session [?id ?repl ?opts]
|
|
(let [id (replsession.session-id ?id ?repl)
|
|
session (or (. replsession.sessions id) (replsession.new-session ?repl ?opts))]
|
|
(tset replsession.sessions id session)
|
|
session))
|
|
|
|
replsession.hot
|
|
|