user.clj 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (ns shadow.user
  2. (:require [shadow.cljs.devtools.api :as api]))
  3. (defn cljs-repl
  4. []
  5. (api/watch :app)
  6. (api/repl :app))
  7. (defn electron-repl
  8. []
  9. (api/watch :electron)
  10. (api/repl :electron))
  11. (defn capacitor-repl
  12. []
  13. (api/watch :capacitor-new)
  14. (api/repl :capacitor-new))
  15. ;; Get the runtime id from http://localhost:9630/runtimes, pick the one which shows `browser-worker`
  16. (defn worker-repl
  17. ([]
  18. (when-let [runtime-id (->> (api/repl-runtimes :app)
  19. (filter (fn [runtime] (= :browser-worker (:host runtime))))
  20. (map :client-id)
  21. (apply max))]
  22. (worker-repl runtime-id)))
  23. ([runtime-id-or-which]
  24. (assert runtime-id-or-which "runtime-id shouldn't be empty")
  25. (if
  26. (number? runtime-id-or-which)
  27. (do (prn :worker-runtime-id runtime-id-or-which)
  28. (api/repl :app {:runtime-id runtime-id-or-which}))
  29. (let [runtime-ids (->> (api/repl-runtimes :app)
  30. (filter (fn [runtime] (= :browser-worker (:host runtime))))
  31. (map :client-id))
  32. runtime-id (apply (if (= :old runtime-id-or-which) min max) runtime-ids)]
  33. (worker-repl runtime-id)))))
  34. (defn runtime-id-list
  35. []
  36. (->> (api/repl-runtimes :app)
  37. (filter (fn [runtime] (= :browser-worker (:host runtime))))
  38. (map :client-id)))