0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

⬆️ Update shadow-cljs.

And remove the need of externs.
This commit is contained in:
Andrey Antukh 2020-05-05 14:03:04 +02:00 committed by Alonso Torres
parent fdb6d05826
commit 85d7617143
3 changed files with 7 additions and 289 deletions

View file

@ -31,7 +31,7 @@
funcool/datoteka {:mvn/version "1.2.0"} funcool/datoteka {:mvn/version "1.2.0"}
binaryage/devtools {:mvn/version "RELEASE"} binaryage/devtools {:mvn/version "RELEASE"}
thheller/shadow-cljs {:mvn/version "2.8.93"} thheller/shadow-cljs {:mvn/version "2.8.110"}
;; i18n parsing ;; i18n parsing
carocad/parcera {:mvn/version "0.11.0"} carocad/parcera {:mvn/version "0.11.0"}

View file

@ -1,8 +0,0 @@
# Externs file for google Closure Compiler
# https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs
getBrowserEvent
viewBox
baseVal
width
height

View file

@ -34,110 +34,6 @@
::modified-at ::modified-at
::user-id])) ::user-id]))
;; rename-icon-library
;; delete-icon-library
;; (declare fetch-icons)
;;
;; (defn initialize
;; [collection-id]
;; (s/assert ::us/uuid collection-id)
;; (ptk/reify ::initialize
;; ptk/UpdateEvent
;; (update [_ state]
;; (assoc-in state [:dashboard-icons :selected] #{}))
;;
;; ptk/WatchEvent
;; (watch [_ state stream]
;; (rx/of (fetch-icons collection-id)))))
;;
;; --- Fetch Collections
;; (declare collections-fetched)
;;
;; (def fetch-collections
;; (ptk/reify ::fetch-collections
;; ptk/WatchEvent
;; (watch [_ state s]
;; (->> (rp/query! :icons-collections)
;; (rx/map collections-fetched)))))
;;
;; ;; --- Collections Fetched
;;
;; (defn collections-fetched
;; [items]
;; (s/assert (s/every ::collection) items)
;; (ptk/reify ::collections-fetched
;; cljs.core/IDeref
;; (-deref [_] items)
;;
;; ptk/UpdateEvent
;; (update [_ state]
;; (reduce (fn [state {:keys [id user] :as item}]
;; (let [type (if (uuid/zero? (:user-id item)) :builtin :own)
;; item (assoc item :type type)]
;; (assoc-in state [:icons-collections id] item)))
;; state
;; items))))
;; ;; --- Create Collection
;;
;; (declare collection-created)
;;
;; (def create-collection
;; (ptk/reify ::create-collection
;; ptk/WatchEvent
;; (watch [_ state s]
;; (let [name (tr "ds.default-library-title" (gensym "c"))
;; data {:name name}]
;; (->> (rp/mutation! :create-icons-collection data)
;; (rx/map collection-created))))))
;;
;;
;; ;; --- Collection Created
;;
;; (defn collection-created
;; [item]
;; (s/assert ::collection item)
;; (ptk/reify ::collection-created
;; ptk/UpdateEvent
;; (update [_ state]
;; (let [{:keys [id] :as item} (assoc item :type :own)]
;; (update state :icons-collections assoc id item)))))
;;
;; ;; --- Rename Collection
;;
;; (defn rename-collection
;; [id name]
;; (ptk/reify ::rename-collection
;; ptk/UpdateEvent
;; (update [_ state]
;; (assoc-in state [:icons-collections id :name] name))
;;
;; ptk/WatchEvent
;; (watch [_ state s]
;; (let [params {:id id :name name}]
;; (->> (rp/mutation! :rename-icons-collection params)
;; (rx/ignore))))))
;;
;; ;; --- Delete Collection
;;
;; (defn delete-collection
;; [id on-success]
;; (ptk/reify ::delete-collection
;; ptk/UpdateEvent
;; (update [_ state]
;; (update state :icons-collections dissoc id))
;;
;; ptk/WatchEvent
;; (watch [_ state s]
;; (->> (rp/mutation! :delete-icons-collection {:id id})
;; (rx/tap on-success)
;; (rx/ignore)))))
;;
;; --- Icon Created
;; --- Create Icon ;; --- Create Icon
(defn- parse-svg (defn- parse-svg
[data] [data]
@ -156,12 +52,12 @@
(dom/append-child! g child) (dom/append-child! g child)
(dom/append-child! gc child)) (dom/append-child! gc child))
(recur (dom/get-first-child svg))) (recur (dom/get-first-child svg)))
(let [width (.. svg -width -baseVal -value) (let [width (.. ^js svg -width -baseVal -value)
height (.. svg -height -baseVal -value) height (.. ^js svg -height -baseVal -value)
view-box [(.. svg -viewBox -baseVal -x) view-box [(.. ^js svg -viewBox -baseVal -x)
(.. svg -viewBox -baseVal -y) (.. ^js svg -viewBox -baseVal -y)
(.. svg -viewBox -baseVal -width) (.. ^js svg -viewBox -baseVal -width)
(.. svg -viewBox -baseVal -height)] (.. ^js svg -viewBox -baseVal -height)]
props {:width width props {:width width
:mimetype "image/svg+xml" :mimetype "image/svg+xml"
:height height :height height
@ -204,173 +100,3 @@
(let [{:keys [id] :as item} (assoc item :type :icon)] (let [{:keys [id] :as item} (assoc item :type :icon)]
(-> state (-> state
(update-in [:library-items :icons library-id] #(into [item] %))))))) (update-in [:library-items :icons library-id] #(into [item] %)))))))
;; ;; --- Icon Persisted
;;
;; (defrecord IconPersisted [id data]
;; ptk/UpdateEvent
;; (update [_ state]
;; (assoc-in state [:icons id] data)))
;;
;; (defn icon-persisted
;; [{:keys [id] :as data}]
;; {:pre [(map? data)]}
;; (IconPersisted. id data))
;;
;; ;; --- Persist Icon
;;
;; (defn persist-icon
;; [id]
;; (s/assert ::us/uuid id)
;; (ptk/reify ::persist-icon
;; ptk/WatchEvent
;; (watch [_ state stream]
;; (let [data (get-in state [:icons id])]
;; (->> (rp/mutation! :update-icon data)
;; (rx/ignore))))))
;;
;; --- Load Icons
;; (declare icons-fetched)
;;
;; (defn fetch-icons
;; [id]
;; (ptk/reify ::fetch-icons
;; ptk/WatchEvent
;; (watch [_ state s]
;; (let [params (cond-> {} id (assoc :collection-id id))]
;; (->> (rp/query! :icons-by-collection params)
;; (rx/map icons-fetched))))))
;;
;; ;; --- Icons Fetched
;;
;; (defn icons-fetched
;; [items]
;; ;; TODO: specs
;; (ptk/reify ::icons-fetched
;; ptk/UpdateEvent
;; (update [_ state]
;; (let [icons (d/index-by :id items)]
;; (assoc state :icons icons)))))
;; ;; --- Rename Icon
;;
;; (defn rename-icon
;; [id name]
;; (s/assert ::us/uuid id)
;; (s/assert ::us/string name)
;; (ptk/reify ::rename-icon
;; ptk/UpdateEvent
;; (update [_ state]
;; (assoc-in state [:icons id :name] name))
;;
;; ptk/WatchEvent
;; (watch [_ state stream]
;; (rx/of (persist-icon id)))))
;;
;; ;; --- Icon Selection
;;
;; (defn select-icon
;; [id]
;; (ptk/reify ::select-icon
;; ptk/UpdateEvent
;; (update [_ state]
;; (update-in state [:dashboard-icons :selected] (fnil conj #{}) id))))
;;
;; (defn deselect-icon
;; [id]
;; (ptk/reify ::deselect-icon
;; ptk/UpdateEvent
;; (update [_ state]
;; (update-in state [:dashboard-icons :selected] (fnil disj #{}) id))))
;;
;; (def deselect-all-icons
;; (ptk/reify ::deselect-all-icons
;; ptk/UpdateEvent
;; (update [_ state]
;; (assoc-in state [:dashboard-icons :selected] #{}))))
;;
;; ;; --- Delete Icons
;;
;; (defn delete-icon
;; [id]
;; (ptk/reify ::delete-icon
;; ptk/UpdateEvent
;; (update [_ state]
;; (update state :icons dissoc id))
;;
;; ptk/WatchEvent
;; (watch [_ state s]
;; (rx/merge
;; (rx/of deselect-all-icons)
;; (->> (rp/mutation! :delete-icon {:id id})
;; (rx/ignore))))))
;;
;; ;; --- Delete Selected
;;
;; (def delete-selected
;; (ptk/reify ::delete-selected
;; ptk/WatchEvent
;; (watch [_ state stream]
;; (let [selected (get-in state [:dashboard-icons :selected])]
;; (->> (rx/from selected)
;; (rx/map delete-icon))))))
;; ;; --- Update Opts (Filtering & Ordering)
;;
;; (defn update-opts
;; [& {:keys [order filter edition]
;; :or {edition false}}]
;; (ptk/reify ::update-opts
;; ptk/UpdateEvent
;; (update [_ state]
;; (update state :dashboard-icons merge
;; {:edition edition}
;; (when order {:order order})
;; (when filter {:filter filter})))))
;; --- Copy Selected Icon
;; (defrecord CopySelected [id]
;; ptk/WatchEvent
;; (watch [_ state stream]
;; (let [selected (get-in state [:dashboard :icons :selected])]
;; (rx/merge
;; (->> (rx/from selected)
;; (rx/map #(get-in state [:icons %]))
;; (rx/map #(dissoc % :id))
;; (rx/map #(assoc % :collection-id id))
;; (rx/flat-map #(rp/mutation :create-icon %))
;; (rx/map :payload)
;; (rx/map icon-created))
;; (->> (rx/from selected)
;; (rx/map deselect-icon))))))
;; (defn copy-selected
;; [id]
;; {:pre [(or (uuid? id) (nil? id))]}
;; (CopySelected. id))
;; --- Move Selected Icon
;; (defrecord MoveSelected [id]
;; ptk/UpdateEvent
;; (update [_ state]
;; (let [selected (get-in state [:dashboard :icons :selected])]
;; (reduce (fn [state icon]
;; (assoc-in state [:icons icon :collection] id))
;; state
;; selected)))
;; ptk/WatchEvent
;; (watch [_ state stream]
;; (let [selected (get-in state [:dashboard :icons :selected])]
;; (rx/merge
;; (->> (rx/from selected)
;; (rx/map persist-icon))
;; (->> (rx/from selected)
;; (rx/map deselect-icon))))))
;; (defn move-selected
;; [id]
;; {:pre [(or (uuid? id) (nil? id))]}
;; (MoveSelected. id))