From 45da7df4b40bef0e3f9acade59f56c51598e16d1 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 1 Dec 2020 11:33:52 +0100 Subject: [PATCH] Revert ":sparkles: Add export macro helper for properly reexpor vars." This reverts commit 9ca683026708e59d6518619c7880470cd610671e. --- common/app/common/data.cljc | 20 --------- common/app/common/geom/shapes.cljc | 39 ++++++++++-------- frontend/src/app/main/data/workspace.cljs | 50 ++++++++++++----------- 3 files changed, 48 insertions(+), 61 deletions(-) diff --git a/common/app/common/data.cljc b/common/app/common/data.cljc index b61d02c85..be573163b 100644 --- a/common/app/common/data.cljc +++ b/common/app/common/data.cljc @@ -7,13 +7,10 @@ (ns app.common.data "Data manipulation and query helper functions." (:refer-clojure :exclude [concat read-string hash-map]) - #?(:cljs - (:require-macros [app.common.data])) (:require [clojure.set :as set] [linked.set :as lks] [app.common.math :as mth] - #?(:clj [cljs.analyzer.api :as aapi]) #?(:cljs [cljs.reader :as r] :clj [clojure.edn :as r]) #?(:cljs [cljs.core :as core] @@ -284,20 +281,3 @@ valid and the number otherwise." [v] (if (or (not v) (mth/nan? v)) 0 v)) - -(defmacro export - "A helper macro that allows reexport a var in a current namespace." - [v] - (let [sym (symbol (name v)) - mdata (aapi/resolve &env v) - andsym (symbol "&") - arglists (second (get-in mdata [:meta :arglists]))] - (if (pos? (count arglists)) - `(def - ~(with-meta sym (:meta mdata)) - (fn ~@(for [args arglists] - (if (some #(= andsym %) args) - (let [[sargs dargs] (split-with #(not= andsym %) args)] - `([~@sargs ~@dargs] (apply ~v ~@sargs ~@(rest dargs)))) - `([~@args] (~v ~@args)))))) - `(def ~(with-meta sym (:meta mdata)) ~v)))) diff --git a/common/app/common/geom/shapes.cljc b/common/app/common/geom/shapes.cljc index 10d7f6bb4..de210cdaa 100644 --- a/common/app/common/geom/shapes.cljc +++ b/common/app/common/geom/shapes.cljc @@ -9,16 +9,16 @@ (ns app.common.geom.shapes (:require - [app.common.data :as d] + [clojure.spec.alpha :as s] + [app.common.spec :as us] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes.common :as gco] - [app.common.geom.shapes.path :as gsp] - [app.common.geom.shapes.rect :as gpr] [app.common.geom.shapes.transforms :as gtr] + [app.common.geom.shapes.rect :as gpr] + [app.common.geom.shapes.path :as gsp] [app.common.math :as mth] - [app.common.spec :as us] - [clojure.spec.alpha :as s])) + [app.common.data :as d])) ;; --- Relative Movement @@ -252,17 +252,22 @@ ;; EXPORTS -(d/export gco/center-shape) -(d/export gco/center-selrect) -(d/export gco/center-rect) -(d/export gpr/rect->selrect) -(d/export gpr/rect->points) -(d/export gpr/points->selrect) -(d/export gtr/transform-shape) -(d/export gtr/transform-matrix) -(d/export gtr/transform-point-center) -(d/export gtr/transform-rect) +(defn center-shape [shape] (gco/center-shape shape)) +(defn center-selrect [selrect] (gco/center-selrect selrect)) +(defn center-rect [rect] (gco/center-rect rect)) + +(defn rect->selrect [rect] (gpr/rect->selrect rect)) +(defn rect->points [rect] (gpr/rect->points rect)) +(defn points->selrect [points] (gpr/points->selrect points)) + +(defn transform-shape [shape] (gtr/transform-shape shape)) +(defn transform-matrix + ([shape] (gtr/transform-matrix shape)) + ([shape options] (gtr/transform-matrix shape options))) + +(defn transform-point-center [point center transform] (gtr/transform-point-center point center transform)) +(defn transform-rect [rect mtx] (gtr/transform-rect rect mtx)) ;; PATHS -(d/export gsp/content->points) -(d/export gsp/content->selrect) +(defn content->points [content] (gsp/content->points content)) +(defn content->selrect [content] (gsp/content->selrect content)) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index f85f2da3d..e66eb73d8 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1576,36 +1576,38 @@ ;; Transform -(d/export dwt/start-rotate) -(d/export dwt/start-resize) -(d/export dwt/start-move-selected) -(d/export dwt/move-selected) -(d/export dwt/set-rotation) -(d/export dwt/set-modifiers) -(d/export dwt/apply-modifiers) +(def start-rotate dwt/start-rotate) +(def start-resize dwt/start-resize) +(def start-move-selected dwt/start-move-selected) +(def move-selected dwt/move-selected) + +(def set-rotation dwt/set-rotation) +(def set-modifiers dwt/set-modifiers) +(def apply-modifiers dwt/apply-modifiers) ;; Persistence -(d/export dwp/set-file-shared) -(d/export dwp/fetch-shared-files) -(d/export dwp/link-file-to-library) -(d/export dwp/unlink-file-from-library) -(d/export dwp/upload-media-objects) +(def set-file-shared dwp/set-file-shared) +(def fetch-shared-files dwp/fetch-shared-files) +(def link-file-to-library dwp/link-file-to-library) +(def unlink-file-from-library dwp/unlink-file-from-library) +(def upload-media-objects dwp/upload-media-objects) ;; Selection -(d/export dws/select-shape) -(d/export dws/select-all) -(d/export dws/deselect-all) -(d/export dwc/select-shapes) -(d/export dws/duplicate-selected) -(d/export dws/handle-selection) -(d/export dws/select-inside-group) -(d/export dwd/select-for-drawing) -(d/export dwc/clear-edition-mode) -(d/export dwc/add-shape) -(d/export dwc/start-edition-mode) -(d/export dwdp/start-path-edit) +(def select-shape dws/select-shape) +(def select-all dws/select-all) +(def deselect-all dws/deselect-all) +(def select-shapes dwc/select-shapes) +(def duplicate-selected dws/duplicate-selected) +(def handle-selection dws/handle-selection) +(def select-inside-group dws/select-inside-group) +(def select-for-drawing dwd/select-for-drawing) +(def clear-edition-mode dwc/clear-edition-mode) +(def add-shape dwc/add-shape) +(def start-edition-mode dwc/start-edition-mode) + +(defn start-path-edit [id] (dwdp/start-path-edit id)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Shortcuts