Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
8b23232
Cleanup
Aug 8, 2019
01f22e5
Allow instrumentation to pass through metadata
Aug 29, 2019
c7db064
WIP: events as maps with metadata
FossiFoo Jul 22, 2019
f7a9b21
do something with tracing
FossiFoo Sep 3, 2019
2891b93
WIP: tracing
FossiFoo Sep 9, 2019
cc9fc0e
add span ids
FossiFoo Sep 19, 2019
ae826f6
clean up; integration tests and test runner
FossiFoo Sep 22, 2019
3158c33
fix applying verify pipe to sink's sources
FossiFoo Oct 7, 2019
d0a3d97
attach pipes nicely and read from end
FossiFoo Oct 11, 2019
0028757
collect result from verify functions
FossiFoo Oct 16, 2019
232993e
repair test and make runner work with several tests
FossiFoo Oct 20, 2019
ff8bf6e
refactor out test programs
FossiFoo Oct 20, 2019
b7ad310
test chuck more
FossiFoo Oct 21, 2019
68526a1
Merge pull request #85 from FossiFoo/master
rbuchmann Oct 21, 2019
2843d25
fix integration test setup
FossiFoo Oct 25, 2019
5f98412
repair reductions
FossiFoo Oct 25, 2019
4cf318b
make tests run in oasis/cljs
FossiFoo Oct 26, 2019
b88f238
change chuck tests
FossiFoo Oct 26, 2019
de24f62
try to get oasis test to run
FossiFoo Oct 26, 2019
d7d8b07
actually make test run from cli
FossiFoo Oct 27, 2019
b797224
make integration test run from oasis
FossiFoo Oct 27, 2019
f791c2e
Merge pull request #86 from FossiFoo/master
rbuchmann Oct 28, 2019
efde98a
get oasis back to work
FossiFoo Oct 28, 2019
3e65cbe
fix more of oasis
FossiFoo Oct 29, 2019
21cda59
fix rendering
FossiFoo Oct 31, 2019
441f8a9
even more fixes
FossiFoo Oct 31, 2019
487055f
make oasis render itself, some optimizations
FossiFoo Nov 3, 2019
2de830a
add activity; fixes to editing
FossiFoo Nov 10, 2019
910bcb9
rework loading with caravan pipe
FossiFoo Nov 16, 2019
756eb10
render details when zoomed in
FossiFoo Nov 17, 2019
1501b38
Merge pull request #87 from FossiFoo/master
rbuchmann Nov 18, 2019
baf9944
loading and dragging
FossiFoo Nov 21, 2019
b1ba88a
bugfixes and cache layout
FossiFoo Nov 22, 2019
667e135
Merge pull request #92 from FossiFoo/master
rbuchmann Nov 22, 2019
aff57b5
highlight sinks on drag
FossiFoo Nov 22, 2019
e0b3beb
handle resizing screen and place menus
FossiFoo Nov 24, 2019
d4b4be1
Merge pull request #93 from FossiFoo/master
rbuchmann Nov 26, 2019
d63f13d
Remove unnecessary |> operator
rbuchmann Dec 5, 2019
a31558c
fix caravan test
FossiFoo Dec 7, 2019
63b37b1
WIP: piped runtime on a webworker
FossiFoo Nov 28, 2019
6e19964
fix hex string generation for java and add test
FossiFoo Jan 1, 2020
da06d61
modules
FossiFoo Jan 1, 2020
bc58f2e
scroll with arrow keys
FossiFoo Jan 18, 2020
df69164
implement request cancellation for fire! events
FossiFoo Dec 14, 2019
b8dca82
fix loading and nicer graph edges
FossiFoo Feb 19, 2020
3f96fac
highlight connected edges on hover
FossiFoo Feb 28, 2020
5d8edc7
refactor menus to be rendered from state
FossiFoo Feb 28, 2020
27bf2ed
fiddle with optimisation
FossiFoo Mar 4, 2020
ef01558
Merge pull request #98 from FossiFoo/fossifoo
rbuchmann Mar 6, 2020
0dab089
actually dedupe
FossiFoo Mar 6, 2020
59d516e
fix integration tests, modularise oasis
FossiFoo May 1, 2020
5e38d83
split out render module
FossiFoo May 19, 2020
63620c8
Merge pull request #99 from FossiFoo/fossifoo
rbuchmann May 20, 2020
4f9ceaf
Bump electron from 1.8.8 to 9.1.0
dependabot[bot] Jul 7, 2020
ab98d1a
Merge pull request #100 from rbuchmann/dependabot/npm_and_yarn/electr…
rbuchmann Jul 15, 2020
bf621cc
WIP: oasis in 3 proper modules
FossiFoo Jun 1, 2020
07aae8f
WIP runtime module loading
FossiFoo Jun 8, 2020
6f5c54a
Implement proper module handling and port Oasis over
FossiFoo Jul 23, 2020
2862096
display modules in oasis
FossiFoo Sep 13, 2020
46a4c78
move scrolling to render module
FossiFoo Sep 13, 2020
8669b56
module, render thread and loading improvements
FossiFoo Oct 4, 2020
e14349b
repair create sink & hover
FossiFoo Oct 6, 2020
8bd058d
base module; linking & adding sinks to module
FossiFoo Oct 14, 2020
05da93c
fix highlight
FossiFoo Oct 18, 2020
70be65c
try async promise-chan for storage
FossiFoo Oct 20, 2020
3f4d10a
WIP: refactor runtime communication
FossiFoo Oct 31, 2020
f85bab3
refactor and test
FossiFoo Nov 20, 2020
cbda438
context for evaluation to allow duplicate reductions/modules
FossiFoo Dec 16, 2020
2800a9a
fix modules/runtimes to allow contexts
FossiFoo Dec 29, 2020
9344955
debugging handlers and async
FossiFoo Jun 3, 2021
e4546e6
kbn
FossiFoo Jun 5, 2021
c76d738
repl works
FossiFoo Mar 12, 2022
9744d5b
more repl improvements
FossiFoo May 16, 2022
7455e82
cli with multiple rts
FossiFoo May 25, 2022
8a1e48e
rework pipes with explicit scheduling
ChristophMewes Mar 17, 2023
f08e2a5
lots of things with terminal cli
ChristophMewes Apr 14, 2023
8fcbea2
lotsa stuff, terminal, tracing, debugger
ChristophMewes Jun 5, 2023
674f4ff
add reductions to rt and more metrics
ChristophMewes Jun 24, 2023
3569703
add init to splitter and reproduce module reuse issues
ChristophMewes Aug 10, 2023
cfb343d
module debugging
ChristophMewes Aug 21, 2023
ab9d61e
fix bugs
ChristophMewes Feb 14, 2024
d82d5a7
fixes
FossiFoo Feb 24, 2024
a123910
WIP make samak build with shadow cljs
rbuchmann May 7, 2022
22ae7f4
Remove java only exception from node evaluation
rbuchmann May 7, 2022
5b93d85
try
FossiFoo Feb 25, 2024
76dbd2b
mid progress of fixing oasis on shadow and conveyor
FossiFoo Mar 3, 2024
f1a1e27
activate more pieces and fix UI module
FossiFoo Mar 3, 2024
c9ea4a9
reconnect more things
FossiFoo Mar 4, 2024
b8786fc
make elkjs layout work
FossiFoo Mar 9, 2024
c36648d
fix oasis loading itself & caravan
FossiFoo Mar 21, 2024
d037ed0
test
FossiFoo Mar 21, 2024
bbfd60c
bump dependencies and get lein run to work
FossiFoo Mar 28, 2024
1678837
bump datascript version and implement hash-referencing
FossiFoo Apr 1, 2024
410a8f2
repair oasis and kara
FossiFoo May 24, 2024
7e10bde
remove bogus file
FossiFoo May 24, 2024
4f4674b
connect storage, repl & oasis main
FossiFoo Jun 1, 2024
73933a1
formalize protocol between rts and improve remote store impl
FossiFoo Nov 23, 2024
6d90936
some fixes for wiring
FossiFoo Sep 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pom.xml.asc
.lein-plugins/
.lein-failures
.nrepl-port
.shadow-cljs
resources/public/js
*-init.clj
figwheel_server.log
Expand Down
9 changes: 3 additions & 6 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@ ventures on it...”
#+BEGIN_SRC bash
$ npm install # or yarn, you know, whatever

$ lein build-all
$ lein compile

# samak-cli for console programs
$ ./samak-cli examples/basic.sk
$ lein run examples/basic.sk

# samak-ui for electron based ui programs

$ ./samak-ui examples/chuck_norris.sk
$ npx shadow-cljs start

#+END_SRC

In case you don't have electron installed globally, run =npm run start=.

* Roadmaps

** Samak
Expand Down
14 changes: 10 additions & 4 deletions cli_src/cli/node_core.cljs
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
(ns cli.node-core
(:require [cljs.nodejs :as nodejs]
[clojure.string :as str]
[cli.runtime :as rt]
[promesa.core :as prom]
[samak.repl :as repl]))

(nodejs/enable-util-print!)

(def fs ^js/fs (nodejs/require "fs"))

(defn load-samak-file [filename]
(->> (.readFileSync fs filename)
(defn load-samak-file [filename rt]
(-> (.readFileSync fs filename)
str/split-lines
repl/eval-lines))
(rt/eval-lines rt)))

(defn -main [& [filename & args]]
(if (not-empty filename)
(load-samak-file filename)
(prom/let [w (rt/make-runtime-remote {:store :remote :id "cli-w1"})
rt (rt/make-runtime {:id "cli-main" :env {:connects [w]}})]
res (load-samak-file filename rt)
res)

(println "Usage: node samak-cli.js <filename>")))

(set! *main-cli-fn* -main)
115 changes: 115 additions & 0 deletions cli_src/cli/runtime.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
(ns cli.runtime
(:require [cljs.nodejs :as nodejs]
[clojure.string :as str]
[clojure.core.async :as a]
[promesa.core :as prom]
[cognitect.transit :as t]
[metosin.transit.dates :as d]
[samak.repl :as repl]
[samak.runtime :as run]
[samak.stdlib :as std]
[samak.builtins :as builtins]
[samak.caravan :as caravan]
[samak.pipes :as pipes]
[samak.layout :as layout])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))

(def ui-mock-symbols
{'modules/ui :blank
'pipes/ui :blank
'pipes/events :blank
'pipes/mouse :blank
'pipes/keyboard :blank})

(def cli-symbols
(merge builtins/samak-symbols
std/pipe-symbols
caravan/symbols
ui-mock-symbols
layout/layout-symbols
))

(defn make-scheduler []
(let [broadcast (pipes/pipe (a/chan) ::main-broadcast)
to-rt (pipes/pipe (a/chan) ::main-scheduler)]
(println "sched")
;; (handle-update "out" broadcast)
;; (handle-update "in" to-rt)
(fn [] [to-rt broadcast])))

(def worker_threads (nodejs/require "worker_threads"))

(defn make-worker
""
[url]
(println "make worker" (.-isMainThread worker_threads))
;; (println "returning worker: " worker_threads)
(let [Worker (.-Worker worker_threads)]
(Worker. url)))

(def json-reader (t/reader :json {:handlers d/readers}))
(defn make-handler
""
[from-worker conf]
(fn
[event]
(let [data (t/read json-reader event)]
;; (println "recv from" (:id conf) ":" data)
(condp = (:target data)
(a/put! from-worker data)))))

(defn handle-send
""
[worker c conf]
(let [w (t/writer :json {:handlers d/writers})]
(go-loop []
(let [p (<! c)]
;; (println "send to" (:id conf) p)
(.postMessage worker (t/write w p)))
(recur))))

(defn make-runtime-remote [conf]
(prom/let [to-worker (a/chan)
from-worker (a/chan)
from-mult (a/mult from-worker)
worker (make-worker "./cli/samak-cli-worker.js")]
;; race condition on finished worker code before messaging is set up
(handle-send worker to-worker conf)
(.on worker "message" (make-handler from-worker conf))
{:to to-worker :from from-mult :id (:id conf) :conf conf}))

(defn init-runtime-remote [worker init]
(let [p (prom/deferred)
from (a/chan)]
(a/tap (:from worker) from)
(go-loop []
(let [m (<! from)]
(when (and (= (:target m) :bootstrap))
(a/put! (:to worker) {:cmd :init :param init}))
(when (and (= (:target m) :load) (= (:data m) 100))
(prom/resolve! p true)))
(recur))
p))


(defn make-runtime [conf]
(prom/let [in-main (pipes/pipe-chan ::to-main nil)
out-main (pipes/pipe-chan ::from-main nil)
out-mult (a/mult out-main)
rt (run/make-runtime cli-symbols (make-scheduler) (merge {:modules {}} conf))
w (first (:connects (:env conf)))]
(when w
(a/tap out-mult (:to w))
(a/tap (:from w) in-main))
(pipes/link! (pipes/source in-main) (:scheduler rt))
(pipes/link! (:broadcast rt) (pipes/sink out-main))
(prom/do!
(println "init w")
(when w (init-runtime-remote w :foo))
(println "done w")
(repl/init rt))))

(defn eval-lines
""
[lines rt]
(repl/eval-lines lines rt))
57 changes: 57 additions & 0 deletions cli_src/cli/worker.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
(ns cli.worker-core
(:require [cljs.nodejs :as nodejs]
[clojure.core.async :as a :refer [<! >! chan close! put!]]
[cognitect.transit :as t]
[metosin.transit.dates :as d]
[samak.helpers :as helpers]
[samak.worker :as worker])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))

(def worker_threads (nodejs/require "worker_threads"))

(defn handle-update
""
[c]
(let [w (t/writer :json {:handlers d/writers})]
(go-loop []
(let [p (<! c)]
(.postMessage (.-parentPort worker_threads) (t/write w {:target :load :data p})))
(recur))))


(defn handle-request
""
[c]
(let [w (t/writer :json {:handlers d/writers})]
(go-loop []
(let [p (<! c)
before (helpers/now)]
;; (println "to main" p)
(.postMessage (.-parentPort worker_threads) (t/write w p)))
(recur))))

(def json-reader (t/reader :json {:handlers d/readers}))
(defn make-handler
""
[in init]
(fn
[event]
(let [data (t/read json-reader event)]
;; (println "worker in" data)
(if (= (:cmd data) :init)
(helpers/debounce #(init (:param data)))
(put! in data)))))

(defn bootstrap
""
[]
(println "bootstrap")
(let [loading (chan)
in (chan)
out (chan)]
(handle-update loading)
(handle-request out)
(.on (.-parentPort worker_threads) "message" (make-handler in #(worker/start-rt loading in out)))
(put! out {:target :bootstrap})))

(bootstrap)
Loading