Merge remote-tracking branch 'origin/staging' into develop

This commit is contained in:
Alejandro Alonso 2024-06-11 07:34:48 +02:00
commit 3bb5db6490
24 changed files with 554 additions and 129 deletions

View file

@ -69,9 +69,10 @@
(cpc/check-changes! undo-changes)))
(let [commit-id (or commit-id (uuid/next))
source (d/nilv source :local)
commit {:id commit-id
:created-at (dt/now)
:source (d/nilv source :local)
:source source
:origin (ptk/type origin)
:features features
:file-id file-id
@ -110,9 +111,7 @@
redo-changes (if pending
(into redo-changes
(comp
(map :redo-changes)
(mapcat identity))
(mapcat :redo-changes)
pending)
redo-changes)]

View file

@ -182,7 +182,7 @@
(log/debug :hint "initialize persistence")
(let [stoper-s (rx/filter (ptk/type? ::initialize-persistence) stream)
commits-s
local-commits-s
(->> stream
(rx/filter dch/commit?)
(rx/map deref)
@ -192,28 +192,34 @@
notifier-s
(rx/merge
(->> commits-s
(->> local-commits-s
(rx/debounce 3000)
(rx/tap #(log/trc :hint "persistence beat")))
(->> stream
(rx/filter #(= % ::force-persist))))]
(rx/merge
(->> commits-s
(->> local-commits-s
(rx/debounce 200)
(rx/map (fn [_]
(update-status :pending)))
(rx/take-until stoper-s))
(->> local-commits-s
(rx/buffer-time 200)
(rx/mapcat merge-commit)
(rx/map dch/update-indexes)
(rx/take-until stoper-s)
(rx/finalize (fn []
(log/debug :hint "finalize persistence: changes watcher [index]"))))
;; Here we watch for local commits, buffer them in a small
;; chunks (very near in time commits) and append them to the
;; persistence queue
(->> commits-s
(->> local-commits-s
(rx/buffer-until notifier-s)
(rx/mapcat merge-commit)
(rx/mapcat (fn [commit]
(rx/of (append-commit commit)
(dch/update-indexes commit))))
(rx/map append-commit)
(rx/take-until (rx/delay 100 stoper-s))
(rx/finalize (fn []
(log/debug :hint "finalize persistence: changes watcher"))))

View file

@ -253,6 +253,18 @@
;; --- Zoom Management
(def update-zoom-querystring
(ptk/reify ::update-zoom-querystring
ptk/WatchEvent
(watch [_ state _]
(let [zoom-type (get-in state [:viewer-local :zoom-type])
route (:route state)
screen (-> route :data :name keyword)
qparams (:query-params route)
pparams (:path-params route)]
(rx/of (rt/nav screen pparams (assoc qparams :zoom zoom-type)))))))
(def increase-zoom
(ptk/reify ::increase-zoom
ptk/UpdateEvent
@ -293,7 +305,10 @@
minzoom (min wdiff hdiff)]
(-> state
(assoc-in [:viewer-local :zoom] minzoom)
(assoc-in [:viewer-local :zoom-type] :fit))))))
(assoc-in [:viewer-local :zoom-type] :fit))))
ptk/WatchEvent
(watch [_ _ _] (rx/of update-zoom-querystring))))
(def zoom-to-fill
(ptk/reify ::zoom-to-fill
@ -309,7 +324,9 @@
maxzoom (max wdiff hdiff)]
(-> state
(assoc-in [:viewer-local :zoom] maxzoom)
(assoc-in [:viewer-local :zoom-type] :fill))))))
(assoc-in [:viewer-local :zoom-type] :fill))))
ptk/WatchEvent
(watch [_ _ _] (rx/of update-zoom-querystring))))
(def toggle-zoom-style
(ptk/reify ::toggle-zoom-style

View file

@ -431,7 +431,7 @@
(watch [_ state stream]
(let [initial (deref ms/mouse-position)
stopper (mse/drag-stopper stream)
stopper (mse/drag-stopper stream {:interrupt? false})
zoom (get-in state [:workspace-local :zoom] 1)
;; We toggle the selection so we don't have to wait for the event

View file

@ -149,7 +149,7 @@
svg-raw-wrapper (mf/use-memo (mf/deps objects) #(svg-raw-wrapper-factory objects))
bool-wrapper (mf/use-memo (mf/deps objects) #(bool-wrapper-factory objects))
frame-wrapper (mf/use-memo (mf/deps objects) #(frame-wrapper-factory objects))]
(when (and shape (not (:hidden shape)))
(when shape
(let [opts #js {:shape shape}
svg-raw? (= :svg-raw (:type shape))]
(if-not svg-raw?

View file

@ -50,6 +50,9 @@
(defn bool->str [val]
(when (some? val) (str val)))
(defn touched->str [val]
(str/join " " (map str val)))
(defn add-factory [shape]
(fn add!
([props attr]
@ -136,7 +139,6 @@
(cond-> bool?
(add! :bool-type)))))
(defn add-library-refs [props shape]
(let [add! (add-factory shape)]
(-> props
@ -150,7 +152,8 @@
(add! :component-id)
(add! :component-root)
(add! :main-instance)
(add! :shape-ref))))
(add! :shape-ref)
(add! :touched touched->str))))
(defn prefix-keys [m]
(letfn [(prefix-entry [[k v]]

View file

@ -72,6 +72,8 @@
(obj/set! "pointerEvents" pointer-events)
(cond-> (not (cfh/frame-shape? shape))
(obj/set! "opacity" (:opacity shape)))
(cond-> (:hidden shape)
(obj/set! "display" "none"))
(cond-> (and blend-mode (not= blend-mode :normal))
(obj/set! "mixBlendMode" (d/name blend-mode))))

View file

@ -138,7 +138,7 @@
(mf/deps page)
(fn []
(modal/show! :share-link {:page page :file file})
(modal/allow-click-outside!)))
(modal/disallow-click-outside!)))
handle-increase
(mf/use-fn

View file

@ -402,9 +402,11 @@
(st/emit! (dwl/nav-to-component-file library-id comp))))
do-show-component
#(if local-component?
(do-show-local-component)
(do-show-remote-component))
(fn []
(st/emit! dw/hide-context-menu)
(if local-component?
(do-show-local-component)
(do-show-remote-component)))
do-restore-component
#(let [;; Extract a map of component-id -> component-file in order to avoid duplicates

View file

@ -72,12 +72,20 @@
(defn drag-stopper
"Creates a stream to stop drag events. Takes into account the mouse and also
if the window loses focus or the esc key is pressed."
[stream]
(rx/merge
(->> stream
(rx/filter blur-event?))
(->> stream
(rx/filter mouse-event?)
(rx/filter mouse-up-event?))
(->> stream
(rx/filter #(= % :interrupt)))))
([stream]
(drag-stopper stream nil))
([stream {:keys [blur? up-mouse? interrupt?] :or {blur? true up-mouse? true interrupt? true}}]
(rx/merge
(if blur?
(->> stream
(rx/filter blur-event?))
(rx/empty))
(if up-mouse?
(->> stream
(rx/filter mouse-event?)
(rx/filter mouse-up-event?))
(rx/empty))
(if interrupt?
(->> stream
(rx/filter #(= % :interrupt)))
(rx/empty)))))

View file

@ -12,6 +12,7 @@
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.svg.path :as svg.path]
[app.common.types.component :as ctk]
[app.common.types.shape.interactions :as ctsi]
[app.common.uuid :as uuid]
[app.util.json :as json]
@ -129,6 +130,15 @@
(into {}))
style-str))
(defn parse-touched
"Transform a string of :touched-groups into a set"
[touched-str]
(let [touched (->> (str/split touched-str " ")
(map #(keyword (subs % 1)))
(filter ctk/valid-touched-group?)
(into #{}))]
touched))
(defn add-attrs
[m attrs]
(reduce-kv
@ -424,7 +434,8 @@
component-file (get-meta node :component-file uuid/uuid)
shape-ref (get-meta node :shape-ref uuid/uuid)
component-root? (get-meta node :component-root str->bool)
main-instance? (get-meta node :main-instance str->bool)]
main-instance? (get-meta node :main-instance str->bool)
touched (get-meta node :touched parse-touched)]
(cond-> props
(some? stroke-color-ref-id)
@ -442,7 +453,10 @@
(assoc :main-instance main-instance?)
(some? shape-ref)
(assoc :shape-ref shape-ref))))
(assoc :shape-ref shape-ref)
(seq touched)
(assoc :touched touched))))
(defn add-fill
[props node svg-data]