Skip to content

Commit 60ead92

Browse files
committed
1.4.0
1 parent 2d4dae8 commit 60ead92

File tree

28 files changed

+1189
-447
lines changed

28 files changed

+1189
-447
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Take full control of [re-frame](https://github.com/Day8/re-frame) application.
44

5+
Latest stable version: [![Clojars](https://img.shields.io/clojars/v/re-frisk.svg)](https://clojars.org/re-frisk) [![Clojars](https://img.shields.io/clojars/v/re-frisk-remote.svg)](https://clojars.org/re-frisk-remote)
6+
57
## DEMO
68

79
https://flexsurfer.github.io/conduit-re-frisk-demo/
@@ -28,6 +30,14 @@ Render trace is supported only in the re-frisk-remote
2830

2931
<img src="/img/feature-subs.png" height="300">
3032

33+
#### Views sorted by mount order with subscripions
34+
35+
<img src="/img/feature-views.png" height="300">
36+
37+
#### re-frame handlres statistics
38+
39+
<img src="/img/feature-stat.png" height="300">
40+
3141
#### Graph for an epoch
3242

3343
<img src="/img/feature-event-subs-graph.png" height="300">
@@ -38,10 +48,8 @@ Render trace is supported only in the re-frisk-remote
3848

3949
## Usage
4050

41-
Latest stable version: [![Clojars](https://img.shields.io/clojars/v/re-frisk.svg)](https://clojars.org/re-frisk) [![Clojars](https://img.shields.io/clojars/v/re-frisk-remote.svg)](https://clojars.org/re-frisk-remote)
42-
43-
`[re-frisk "1.3.12"]`
44-
`[re-frisk-remote "1.3.12"]`
51+
`[re-frisk "1.4.0"]`
52+
`[re-frisk-remote "1.4.0"]`
4553

4654
**Important**: Please note the following compatibility table:
4755

@@ -58,7 +66,7 @@ re-frisk Version | React Version | Reagent Versions
5866

5967
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
6068

61-
1. Add re-frisk as a dev dependency `[re-frisk "1.3.12"]`
69+
1. Add re-frisk as a dev dependency `[re-frisk "1.4.0"]`
6270

6371
2. Enable re-frisk
6472

@@ -75,7 +83,7 @@ re-frisk will be embedded in the DOM of your application. So my suggestion is to
7583

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

78-
1. Add re-frisk as a dev dependency `[re-frisk-remote "1.3.12"]`
86+
1. Add re-frisk as a dev dependency `[re-frisk-remote "1.4.0"]`
7987

8088
2. Enable re-frisk on default port (4567):
8189

@@ -95,7 +103,7 @@ re-frisk will be embedded in the DOM of your application. So my suggestion is to
95103

96104
add in `deps.edn`
97105

98-
`:aliases {:dev {:extra-deps {re-frisk-remote {:mvn/version "1.3.12"}}}}}`
106+
`:aliases {:dev {:extra-deps {re-frisk-remote {:mvn/version "1.4.0"}}}}}`
99107

100108
create `re_frisk.clj`
101109

dev/re_frisk/demo.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@
193193
(fn []
194194
[:div @text])))
195195

196+
(defn empty-component [])
197+
(defn empty-component-with-param [param])
198+
196199
(defn simple-example
197200
[]
198201
(reagent/create-class
@@ -203,6 +206,8 @@
203206
(if @form1?
204207
[form1]
205208
[form2])
209+
[empty-component]
210+
[empty-component-with-param form1?]
206211
[:div]
207212
[:div {:style {:background-color "#CCCCCC" :width 150 :margin-top 10}
208213
:on-click #(re-frame/dispatch [::start-time])}

img/feature-stat.png

113 KB
Loading

img/feature-views.png

64.3 KB
Loading

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"dev-remote": "shadow-cljs watch dev-remote",
1111
"client": "shadow-cljs watch client",
1212
"client-release": "shadow-cljs release client-release",
13-
"test": "shadow-cljs compile test"
13+
"test": "shadow-cljs compile test",
14+
"server": "shadow-cljs run re-frisk-remote.core/start"
1415
},
1516
"dependencies": {
1617
"react": "16.13.0",

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject re-frisk-remote "1.3.12"
1+
(defproject re-frisk-remote "1.4.0"
22
:description "Take full control of re-frame app"
33
:url "https://github.com/flexsurfer/re-frisk"
44
:license {:name "MIT"

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.3.12"
1+
(defproject re-frisk "1.4.0"
22
:description "Take full control of re-frame app"
33
:url "https://github.com/flexsurfer/re-frisk"
44
:license {:name "MIT"
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
(ns day8.reagent.impl.batching
22
(:require
33
[reagent.impl.batching :as batching]
4-
[re-frame.trace :as trace :include-macros true]))
4+
[re-frame.trace :as trace :include-macros true]
5+
[clojure.string :as string]
6+
[reagent.impl.component :as component]))
7+
8+
(def operation-name (memoize (fn [c] (last (string/split (component/component-name c) #" > ")))))
59

610
(defonce original-next-tick reagent.impl.batching/next-tick)
711

812
(defn next-tick
913
[f]
1014
;; Schedule a trace to be emitted after a render if there is nothing else scheduled after that render.
1115
;; This signals the end of the epoch.
12-
1316
(original-next-tick
1417
(fn []
1518
(trace/with-trace
@@ -19,6 +22,21 @@
1922
(when (false? (.-scheduled? reagent.impl.batching/render-queue))
2023
(trace/with-trace {:op-type :reagent/quiescent}))))))
2124

25+
(defonce original-run-queue reagent.impl.batching/run-queue)
26+
27+
(defn run-queue [a]
28+
;; sort components by mount order, to make sure parents
29+
;; are rendered before children
30+
(.sort a batching/compare-mount-order)
31+
(dotimes [i (alength a)]
32+
(let [^js/React.Component c (aget a i)]
33+
(when (true? (.-cljsIsDirty c))
34+
(trace/with-trace
35+
{:op-type :force-update
36+
:operation (operation-name c)}
37+
(.forceUpdate c))))))
38+
2239
(defn patch-next-tick
2340
[]
24-
(set! reagent.impl.batching/next-tick next-tick))
41+
(set! reagent.impl.batching/next-tick next-tick)
42+
(set! reagent.impl.batching/run-queue run-queue))

re-frisk/src/day8/reagent/impl/component.cljs

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,49 +34,63 @@
3434
:displayName name
3535
:cljsLegacyRender legacy-render
3636
:reagentRender render-fun
37+
:componentDidMount (fn componentDidMount []
38+
(this-as c
39+
(trace/with-trace
40+
{:op-type :componentDidMount
41+
:operation (operation-name c)
42+
:tags {:order (gobj/get c "cljsMountOrder")}})
43+
(when-let [f (:componentDidMount fmap)]
44+
(.call f c))))
45+
:componentWillUnmount (fn componentWillUnmount []
46+
(this-as c
47+
(trace/with-trace
48+
{:op-type :componentWillUnmount
49+
:operation (operation-name c)})
50+
(when-let [f (:componentWillUnmount fmap)]
51+
(.call f c))))
52+
;:shouldComponentUpdate
53+
#_(fn shouldComponentUpdate [nextprops nextstate]
54+
(this-as c
55+
(trace/with-trace
56+
{:op-type :should-upd
57+
:operation (operation-name c)}
58+
(when-let [f (:shouldComponentUpdate fmap)]
59+
(.call f c nextprops nextstate)))))
3760
:render (fn render []
3861
(this-as c
3962
(trace/with-trace
4063
{:op-type :render
4164
:tags (if-let [component-name (component/component-name c)]
4265
{:component-name component-name}
4366
{})
44-
:operation (operation-name c)})
45-
(if util/*non-reactive*
46-
(component/do-render c compiler)
47-
(let [^clj rat (gobj/get c "cljsRatom")
48-
_ (batch/mark-rendered c)
49-
res (if (nil? rat)
50-
(ratom/run-in-reaction #(component/do-render c compiler) c "cljsRatom"
51-
batch/queue-render component/rat-opts)
52-
(._run rat false))
53-
cljs-ratom (gobj/get c "cljsRatom")]
54-
(trace/merge-trace!
55-
{:tags {:reaction (interop/reagent-id cljs-ratom)
56-
:input-signals (when cljs-ratom
57-
(map interop/reagent-id (gobj/get cljs-ratom "watching" :none)))}})
58-
res)))))))
67+
:operation (operation-name c)}
68+
(if util/*non-reactive*
69+
(component/do-render c compiler)
70+
(let [^clj rat (gobj/get c "cljsRatom")
71+
_ (batch/mark-rendered c)
72+
res (if (nil? rat)
73+
(ratom/run-in-reaction #(component/do-render c compiler) c "cljsRatom"
74+
batch/queue-render component/rat-opts)
75+
(._run rat false))
76+
cljs-ratom (gobj/get c "cljsRatom")]
77+
(trace/merge-trace!
78+
{:tags {:reaction (interop/reagent-id cljs-ratom)
79+
:input-signals (when cljs-ratom
80+
(map interop/reagent-id (gobj/get cljs-ratom "watching" :none)))}})
81+
res))))))))
5982

6083
(defn patch-wrap-funs
6184
[]
6285
(set! reagent.impl.component/wrap-funs wrap-funs))
6386

64-
(defonce original-custom-wrapper reagent.impl.component/custom-wrapper)
87+
;(defonce original-create-class reagent.impl.component/create-class)
6588

66-
(defn custom-wrapper
67-
[key f]
68-
(case key
69-
:componentWillUnmount
70-
(fn componentWillUnmount []
71-
(this-as c
72-
(trace/with-trace
73-
{:op-type key
74-
:operation (last (string/split (component/component-name c) #" > "))
75-
:tags {:component-name (component/component-name c)
76-
:reaction (interop/reagent-id (gobj/get c "cljsRatom"))}})
77-
(.call (original-custom-wrapper key f) c c)))
78-
(original-custom-wrapper key f)))
79-
80-
(defn patch-custom-wrapper
81-
[]
82-
(set! reagent.impl.component/custom-wrapper custom-wrapper))
89+
#_(defn create-class
90+
[body compiler]
91+
(trace/with-trace
92+
{:op-type :create-class}
93+
(let [cmp (original-create-class body compiler)]
94+
(trace/merge-trace!
95+
{:operation (.-displayName cmp)})
96+
cmp)))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(ns re-frisk.clipboard)
2+
3+
(defn copy-to-clip [text]
4+
(let [el (.createElement js/document "textarea")]
5+
(set! (.-value el) text)
6+
(.appendChild js/document.body el)
7+
(.select el)
8+
(.execCommand js/document "copy")
9+
(.removeChild js/document.body el)))

0 commit comments

Comments
 (0)