mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 23:26:10 +02:00
✨ Add to plugins clone and remove
This commit is contained in:
parent
e30c21a71f
commit
9243ba937d
4 changed files with 112 additions and 71 deletions
|
@ -8,12 +8,11 @@
|
|||
"RPC for plugins runtime."
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.spec :as us]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.util.object :as obj]
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
(def uuid-regex
|
||||
#"\w{8}-\w{4}-\w{4}-\w{4}-\w{12}")
|
||||
[cuerdas.core :as str]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn get-data
|
||||
([self attr]
|
||||
|
@ -42,7 +41,7 @@
|
|||
(let [v (cond (map? v)
|
||||
(from-js v)
|
||||
|
||||
(and (string? v) (re-matches uuid-regex v))
|
||||
(and (string? v) (re-matches us/uuid-rx v))
|
||||
(uuid/uuid v)
|
||||
|
||||
:else v)]
|
||||
|
@ -50,7 +49,6 @@
|
|||
{}
|
||||
ret)))
|
||||
|
||||
|
||||
(defn to-js
|
||||
"Converts to javascript an camelize the keys"
|
||||
[obj]
|
||||
|
@ -65,5 +63,19 @@
|
|||
obj)]
|
||||
(clj->js result)))
|
||||
|
||||
|
||||
|
||||
(defn result-p
|
||||
"Creates a pair of atom+promise. The promise will be resolved when the atom gets a value.
|
||||
We use this to return the promise to the library clients and resolve its value when a value is passed
|
||||
to the atom"
|
||||
[]
|
||||
(let [ret-v (atom nil)
|
||||
ret-p
|
||||
(p/create
|
||||
(fn [resolve _]
|
||||
(add-watch
|
||||
ret-v
|
||||
::watcher
|
||||
(fn [_ _ _ value]
|
||||
(remove-watch ret-v ::watcher)
|
||||
(resolve value)))))]
|
||||
[ret-v ret-p]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue