Skip to content

Commit ff404b1

Browse files
committed
Restore top-level API / rename
1 parent 655549f commit ff404b1

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

notebooks/tap_window.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
;; # 🪟 Windows
2-
(ns notebook.tap-window
2+
(ns tap-window
33
{:nextjournal.clerk/visibility {:code :hide :result :hide}
44
:nextjournal.clerk/no-cache true}
55
(:require [nextjournal.clerk :as clerk]
66
[nextjournal.clerk.viewer :as v]))
77

8-
#_(clerk/window! ::clerk/taps)
98
(clerk/window! :my-window (clerk/html [:div.w-8.h-8.bg-green-500]))
109

1110
(comment

src/nextjournal/clerk.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
[nextjournal.clerk.parser :as parser]
1414
[nextjournal.clerk.view :as view]
1515
[nextjournal.clerk.viewer :as v]
16+
[nextjournal.clerk.window :as window]
1617
[nextjournal.clerk.webserver :as webserver]))
1718

1819
(defonce ^:private !show-filter-fn (atom nil))
@@ -70,6 +71,9 @@
7071
#_(show! "https://raw.githubusercontent.com/nextjournal/clerk-demo/main/notebooks/rule_30.clj")
7172
#_(show! (java.io.StringReader. ";; # In Memory Notebook 👋\n(+ 41 1)"))
7273

74+
(defn window! "todo" [& args] (apply window/open! args))
75+
(defn destroy-window! "todo" [id] (window/destroy! id))
76+
7377
(defn recompute!
7478
"Recomputes the currently visible doc, without parsing it."
7579
[]

src/nextjournal/clerk/window.clj

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,40 @@
99
(nextjournal.clerk.viewer/inspect-children opts)
1010
taps))})
1111

12-
(defn window!
12+
(defn open!
1313
([id]
1414
(case id
15-
::taps (window! id {:title "🚰 Taps" :css-class "p-0"}
16-
(v/with-viewers (v/add-viewers [tap/tap-viewer])
15+
::taps (open! id {:title "🚰 Taps" :css-class "p-0"}
16+
(v/with-viewers (v/add-viewers [tap/tap-viewer])
1717
(v/with-viewer taps-viewer @tap/!taps)))))
18-
([id content] (window! id {} content))
18+
([id content] (open! id {} content))
1919
([id opts content]
2020
(webserver/update-window! id (merge opts {:nextjournal/presented (update (v/present content) :nextjournal/css-class #(or % ["px-0"]))
2121
:nextjournal/hash (gensym)
2222
:nextjournal/fetch-opts {:blob-id (str id)}
2323
:nextjournal/blob-id (str id)}))))
2424

25-
(defn destroy-window! [id] (webserver/destroy-window! id))
25+
(defn destroy! [id] (webserver/destroy-window! id))
2626

27-
(doseq [w (keys @webserver/!windows)]
28-
(destroy-window! w))
27+
(defn destroy-all! []
28+
(doseq [w (keys @webserver/!windows)]
29+
(destroy! w)))
2930

30-
#_(window! ::taps)
31+
#_(open! ::taps)
3132

32-
#_(defn tapped [x] (swap! !taps conj x) (window! ::taps))
33+
#_(defn tapped [x] (swap! !taps conj x) (open! ::taps))
3334
#_(defonce taps-setup (add-tap tapped))
3435

3536
#_(doseq [f @@(resolve 'clojure.core/tapset)] (remove-tap f))
3637
#_(reset! !taps ())
3738
#_(tap> (range 30))
38-
#_(window! ::taps)
39-
#_(destroy-window! ::taps)
39+
#_(open! ::taps)
40+
#_(destroy! ::taps)
4041
#_(tap> (v/html [:h1 "Ahoi"]))
4142
#_(tap> (v/table [[1 2] [3 4]]))
42-
#_(window! ::my-window {:title "🔭 Rear Window"} (table [[1 2] [3 4]]))
43-
#_(window! ::my-window {:title "🔭 Rear Window"} (range 30))
44-
#_(window! ::my-window {:title "🔭 Rear Window"} (plotly {:data [{:y [1 2 3]}]}))
45-
#_(window! ::my-window-2 {:title "🪟"} (range 100))
46-
#_(destroy-window! ::my-window)
43+
#_(open! ::my-window {:title "🔭 Rear Window"} (v/table [[1 2] [3 4]]))
44+
#_(open! ::my-window {:title "🔭 Rear Window"} (range 30))
45+
#_(open! ::my-window {:title "🔭 Rear Window"} (v/plotly {:data [{:y [1 2 3]}]}))
46+
#_(open! ::my-window-2 {:title "🪟"} (range 100))
47+
#_(destroy! ::my-window)
48+
#_(destroy-all!)

0 commit comments

Comments
 (0)