Skip to content

Commit 13e2cfb

Browse files
committed
1.6.0 , hotkeys, history
1 parent 2c3124f commit 13e2cfb

File tree

14 files changed

+1410
-1245
lines changed

14 files changed

+1410
-1245
lines changed

README.md

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,66 @@ https://flexsurfer.github.io/conduit-re-frisk-demo/
1010

1111
## Features
1212

13-
### Current state for app-db and subscriptions sorted by keys
13+
### - Current state for app-db and subscriptions sorted by keys
1414

15+
<details><summary>screenshot</summary>
1516
<img src="./img/feature-app-db.png" height="300">
17+
</details>
1618

17-
### Watching keys from app-db
1819

20+
### - Watching keys from app-db
21+
<details><summary>screenshot</summary>
1922
<img src="./img/feature-watch.png" height="300">
23+
</details>
2024

21-
### Events with app-db difference for each event
25+
### - History for key in app-db
26+
<details><summary>screenshot</summary>
27+
<img src="./img/feature-history.png" height="300">
28+
</details>
2229

30+
### - Events with app-db difference for each event
31+
<details><summary>screenshot</summary>
2332
<img src="./img/feature-event.png" height="300">
33+
</details>
2434

2535
### re-frame tracing (**Important**: trace should be [enabled](https://github.com/flexsurfer/re-frisk#enable-traces))
2636

27-
#### Events and timeline (**Important**: with lots of events and high zoom might be slow, pause or clear events when working with timeline)
28-
37+
#### - Events and timeline (**Important**: with lots of events and high zoom might be slow, pause or clear events when working with timeline)
38+
<details><summary>screenshot</summary>
2939
<img src="./img/feature-timeline.png" height="300">
40+
</details>
3041

31-
#### Subscriptions
42+
#### - Subscriptions
3243

3344
Render trace is supported only in the re-frisk-remote
34-
45+
<details><summary>screenshot</summary>
3546
<img src="/img/feature-subs.png" height="300">
47+
</details>
3648

37-
#### Views sorted by mount order with subscripions
38-
49+
#### - Views sorted by mount order with subscripions
50+
<details><summary>screenshot</summary>
3951
<img src="/img/feature-views.png" height="300">
52+
</details>
4053

41-
#### re-frame handlres statistics
42-
54+
#### - re-frame handlres statistics
55+
<details><summary>screenshot</summary>
4356
<img src="/img/feature-stat.png" height="300">
57+
</details>
4458

45-
#### Graph for an epoch
46-
59+
#### - Graph for an epoch
60+
<details><summary>screenshot</summary>
4761
<img src="/img/feature-event-subs-graph.png" height="300">
62+
</details>
4863

49-
#### Graph accumulated for an app life with weights (**Important**: with lots of subscriptions rendering might be slow!)
50-
64+
#### - Graph accumulated for an app life with weights (**Important**: with lots of subscriptions rendering might be slow!)
65+
<details><summary>screenshot</summary>
5166
<img src="/img/feature-subs-app-graph.png" height="300">
67+
</details>
5268

5369
## Usage
5470

55-
`[re-frisk "1.5.2"]`
56-
`[re-frisk-remote "1.5.2"]`
71+
`[re-frisk "1.6.0"]`
72+
`[re-frisk-remote "1.6.0"]`
5773

5874
**Important**: Please note the following compatibility table:
5975

@@ -70,11 +86,15 @@ re-frisk Version | React Version | Reagent Versions
7086

7187
re-frisk will be embedded in the DOM of your application. So my suggestion is to use re-frisk-remote, it doesn't affect your application and has more features
7288

73-
1. Add re-frisk as a dev dependency `[re-frisk "1.5.2"]`
89+
1. Add re-frisk as a dev dependency `[re-frisk "1.6.0"]`
7490

7591
2. Enable re-frisk
7692

77-
`:preloads [re-frisk.preload]`
93+
`:preloads [re-frisk.preload]`
94+
95+
OR if you want a hidden UI and open tool with Ctrl+H
96+
97+
`:preloads [re-frisk.preload-hidden]`
7898

7999
OR
80100

@@ -87,14 +107,14 @@ re-frisk will be embedded in the DOM of your application. So my suggestion is to
87107

88108
[![Clojars](https://img.shields.io/clojars/v/re-frisk-remote.svg)](https://clojars.org/re-frisk-remote)
89109

90-
1. Add re-frisk as a dev dependency `[re-frisk-remote "1.5.2"]`
110+
1. Add re-frisk as a dev dependency `[re-frisk-remote "1.6.0"]`
91111

92112
2. Enable re-frisk on default port (4567):
93113

94114
`:preloads [re-frisk-remote.preload]`
95115

96116
OR
97-
117+
98118
`(:require [re-frisk-remote.core :as re-frisk-remote])`
99119

100120
`(re-frisk-remote/enable)`
@@ -107,7 +127,7 @@ re-frisk will be embedded in the DOM of your application. So my suggestion is to
107127

108128
add in `deps.edn`
109129

110-
`:aliases {:dev {:extra-deps {re-frisk-remote {:mvn/version "1.5.1"}}}}}`
130+
`:aliases {:dev {:extra-deps {re-frisk-remote {:mvn/version "1.6.0"}}}}}`
111131

112132
create `re_frisk.clj`
113133

@@ -148,6 +168,13 @@ External window dimensions
148168
(re-frisk/enable {:ext_height 1000 :ext_width 1200})
149169
```
150170

171+
Hidden UI, you can open and close tool by Ctrl+H
172+
173+
```clojure
174+
(re-frisk/enable {:hidden true})
175+
```
176+
177+
151178
If you don't need to watch events you can disable them
152179

153180
```clojure

dev/re_frisk/demo.cljs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[reagent.dom :as rdom]
44
[re-frame.core :as re-frame]
55
[re-frisk.core :as re-frisk]
6+
re-frisk.db
67
[re-frisk-remote.core :as re-frisk-remote])
78
(:require-macros [reagent.ratom :refer [reaction]]))
89

@@ -28,6 +29,7 @@
2829
:time-color "#f88"
2930
:clock? true
3031
:form2-text "FORM 2"
32+
:namespaced/keyword "test"
3133
:test {:test1 {:test2 {:test3 {:test4 {:test5 "DEMO"}}}}}})
3234

3335
;; -- Event Handlers ----------------------------------------------------------
@@ -101,6 +103,11 @@
101103
(fn [{db :db} _]
102104
{:db (assoc db :change-db 3)}))
103105

106+
(re-frame/reg-event-fx
107+
::change-ns-keyword
108+
(fn [{db :db} _]
109+
{:db (assoc db :namespaced/keyword "test2")}))
110+
104111
(re-frame/reg-event-fx
105112
::do-nothing1
106113
(fn [_ _]
@@ -219,6 +226,9 @@
219226
[:div {:style {:background-color "#CCCCCC" :width 150 :margin-top 10}
220227
:on-click #(re-frame/dispatch [::change-form])}
221228
"change form"]
229+
[:div {:style {:background-color "#CCCCCC" :width 150 :margin-top 10}
230+
:on-click #(re-frame/dispatch [::change-ns-keyword])}
231+
"change ns keyword"]
222232
[:div {:style {:background-color "#CCCCCC" :width 150 :margin-top 10}
223233
:on-click #(do (re-frame/dispatch [::change-db1])
224234
(re-frame/dispatch [::change-db2])
@@ -231,7 +241,9 @@
231241
"dispatch 3 events doing nothing"]]))}))
232242

233243
(defn mount []
234-
(rdom/render [simple-example] (js/document.getElementById "app")))
244+
(rdom/render [simple-example] (js/document.getElementById "app"))
245+
(swap! re-frisk.db/tool-state update :ext-win-opened? not)
246+
(swap! re-frisk.db/tool-state update :ext-win-opened? not))
235247

236248
(defn on-js-reload []
237249
(mount))

img/feature-history.png

176 KB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"dependencies": {
1717
"react": "16.13.0",
1818
"react-dom": "16.13.0",
19-
"shadow-cljs": "^2.11.5"
19+
"shadow-cljs": "^2.18.0"
2020
}
2121
}

project.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
(defproject re-frisk-remote "1.5.2"
1+
(defproject re-frisk-remote "1.6.0"
22
:description "Take full control of re-frame app"
33
:url "https://github.com/flexsurfer/re-frisk"
44
:license {:name "MIT"
55
:url "https://opensource.org/licenses/MIT"}
66
:source-paths ["src" "dev" "re-frisk/src"]
7-
:dependencies [[org.clojure/clojure "1.10.1"]
8-
[org.clojure/clojurescript "1.10.597"]
9-
[reagent "1.0.0"]
7+
:dependencies [[org.clojure/clojure "1.11.1"]
8+
[org.clojure/clojurescript "1.11.4"]
9+
[reagent "1.1.1"]
1010
[re-frame "1.2.0"]
1111
;; handlerForForeign
1212
[com.cognitect/transit-cljs "0.8.256"]

re-frisk/project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject re-frisk "1.5.2"
1+
(defproject re-frisk "1.6.0"
22
:description "Take full control of re-frame app"
33
:url "https://github.com/flexsurfer/re-frisk"
44
:license {:name "MIT"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(ns re-frisk.preload-hidden
2+
(:require [re-frisk.core :as re-frisk]))
3+
4+
(re-frisk/enable {:hidden true})

re-frisk/src/re_frisk/ui.cljs

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,44 @@
5050
[ui.views/main-view re-frame-data db/tool-state doc]]
5151
(.getElementById doc "re-frisk-debugger-div")))))
5252

53+
(defn handle-toggle []
54+
(let [left (or (utils/normalize-draggable (:x @drag/draggable))
55+
(- js/window.innerWidth 30))]
56+
(when-not (utils/closed? left)
57+
(swap! db/tool-state assoc :latest-left (- js/window.innerWidth left)))
58+
(swap! drag/draggable assoc :x (- js/window.innerWidth
59+
(if (utils/closed? left) (:latest-left @db/tool-state) 30)))))
60+
61+
(defn handle-keydown [e]
62+
(let [input-elements #{"INPUT" "SELECT" "TEXTAREA"}
63+
input-focused? (contains? input-elements (.-tagName (.-target e)))]
64+
(when (and (not input-focused?)
65+
(= (.-key e) "h")
66+
(.-ctrlKey e))
67+
(.preventDefault e)
68+
(handle-toggle))))
69+
70+
(defonce listener (js/window.addEventListener "keydown" handle-keydown))
71+
5372
(defn inner-view [re-frame-data]
5473
(let [ext-opened? (reaction (:ext-win-opened? @db/tool-state))
55-
latest-left (reaction (:latest-left @db/tool-state))]
74+
hidden (get-in @db/tool-state [:opts :hidden])]
5675
(fn []
5776
(when-not @ext-opened?
5877
(let [left (or (utils/normalize-draggable (:x @drag/draggable))
59-
(- js/window.innerWidth 30))
60-
handle-toggle (fn []
61-
(when-not (utils/closed? left)
62-
(swap! db/tool-state assoc :latest-left (- js/window.innerWidth left)))
63-
(swap! drag/draggable assoc :x (- js/window.innerWidth
64-
(if (utils/closed? left) @latest-left 30))))
65-
66-
handle-keydown (fn [e]
67-
(let [input-elements #{"INPUT" "SELECT" "TEXTAREA"}
68-
input-focused? (contains? input-elements (.-tagName (.-target e)))]
69-
(when (and (not input-focused?)
70-
(= (.-key e) "h")
71-
(.-ctrlKey e))
72-
(.preventDefault e)
73-
(handle-toggle))))
74-
_ (js/window.addEventListener "keydown" handle-keydown)]
78+
(- js/window.innerWidth 30))]
7579
[:div {:style (style/inner-view-container left (:offset @drag/draggable))}
76-
[:div {:style {:display :flex :flex-direction :column :opacity 0.3}}
77-
[:div {:style style/external-button
78-
:on-click (open-debugger-window re-frame-data)}
79-
"\u2197"]
80-
[:div {:style {:display :flex :flex 1 :justify-content :center :flex-direction :column}}
81-
[:div {:style style/external-button
82-
:on-click handle-toggle}
83-
(if (utils/closed? left) "\u2b60" "\u2b62")]
84-
[:div {:style style/dragg-button
85-
:on-mouse-down drag/mouse-down-handler}]]]
80+
(when-not (and hidden (utils/closed? left))
81+
[:div {:style {:display :flex :flex-direction :column :opacity 0.3}}
82+
[:div {:style style/external-button
83+
:on-click (open-debugger-window re-frame-data)}
84+
"\u2197"]
85+
[:div {:style {:display :flex :flex 1 :justify-content :center :flex-direction :column}}
86+
[:div {:style style/external-button
87+
:on-click handle-toggle}
88+
(if (utils/closed? left) "\u2b60" "\u2b62")]
89+
[:div {:style style/dragg-button
90+
:on-mouse-down drag/mouse-down-handler}]]])
8691
(when-not (utils/closed? left)
8792
[:div {:style {:display :flex :flex 1 :width "100%" :height "100%"}}
8893
[:iframe {:id "re-frisk-iframe" :src-doc external-hml/html-doc :width "100%" :height "100%"

re-frisk/src/re_frisk/ui/components/frisk.cljs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@
55
[re-frisk.ui.components.components :as components]
66
[re-frisk.inlined-deps.reagent.v1v0v0.reagent.core :as reagent]
77
[re-frisk.clipboard :as clipboard]
8-
cljs.pprint))
8+
cljs.pprint
9+
[re-frisk.utils :as utils]))
910

1011
;;original idea Odin Hole Standal https://github.com/Odinodin/data-frisk-reagent
1112
(declare DataFrisk)
1213

13-
(def debounce-pending (atom {}))
14-
(defn debounce [key delay f]
15-
(let [old-timeout (get @debounce-pending key)
16-
new-timeout (js/setTimeout f delay)]
17-
(swap! debounce-pending assoc key new-timeout)
18-
(js/clearTimeout old-timeout)))
19-
2014
(defn ExpandButton [{:keys [expanded? path emit-fn]}]
2115
[:button {:style {:border 0
2216
:backgroundColor "transparent" :width "20px" :height "20px"}
@@ -276,7 +270,9 @@
276270

277271
(defn apply-filter [state id value]
278272
(let [filter (filter-parser/parse value)]
279-
(assoc-in state [:data-frisk id :filter] filter)))
273+
(-> state
274+
(assoc-in [:data-frisk id :filter] filter)
275+
(assoc-in [:data-frisk id :filter-string] value))))
280276

281277
(defn emit-fn-factory [state-atom id swappable filter-refs inp-val]
282278
(fn [event & args]
@@ -295,7 +291,7 @@
295291
:filter-change
296292
(do
297293
(reset! inp-val (first args))
298-
(debounce :filter-change 400 #(swap! state-atom apply-filter id (first args))))
294+
(utils/debounce :filter-change 400 #(swap! state-atom apply-filter id (first args))))
299295
:changed (let [[path value] args]
300296
(if (seq path)
301297
(swap! swappable assoc-in path value)

0 commit comments

Comments
 (0)