mirror of
https://github.com/penpot/penpot.git
synced 2025-07-16 17:05:16 +02:00
🎉 Add options for creating library build context
With the ability to pass referer.
This commit is contained in:
parent
264aef277d
commit
50a6355537
3 changed files with 24 additions and 11 deletions
|
@ -54,7 +54,7 @@
|
|||
[:map {:title "Manifest"}
|
||||
[:version ::sm/int]
|
||||
[:type :string]
|
||||
|
||||
[:referer {:optional true} :string]
|
||||
[:generated-by {:optional true} :string]
|
||||
|
||||
[:files
|
||||
|
|
|
@ -271,11 +271,19 @@
|
|||
(fn []
|
||||
(json/->js @state))))
|
||||
|
||||
(def ^:private schema:context-options
|
||||
[:map {:title "ContextOptions"}
|
||||
[:referer {:optional true} ::sm/text]])
|
||||
|
||||
(def ^:private decode-context-options
|
||||
(sm/decoder schema:context-options sm/json-transformer))
|
||||
|
||||
(defn create-build-context
|
||||
"Create an empty builder state context."
|
||||
[]
|
||||
(let [state (atom {})
|
||||
api (create-builder-api state)]
|
||||
[options]
|
||||
(let [options (some-> options decode-params decode-context-options)
|
||||
state (atom {:options options})
|
||||
api (create-builder-api state)]
|
||||
|
||||
(specify! api
|
||||
cljs.core/IDeref
|
||||
|
|
|
@ -183,17 +183,22 @@
|
|||
|
||||
(defn- generate-manifest-procs
|
||||
[state]
|
||||
(let [files (->> (get state ::fb/files)
|
||||
(mapv (fn [[file-id file]]
|
||||
{:id file-id
|
||||
:name (:name file)
|
||||
:features (:features file)})))
|
||||
(let [opts (get state :options)
|
||||
files (->> (get state ::fb/files)
|
||||
(mapv (fn [[file-id file]]
|
||||
{:id file-id
|
||||
:name (:name file)
|
||||
:features (:features file)})))
|
||||
params {:type "penpot/export-files"
|
||||
:version 1
|
||||
:generated-by "penpot-library/%version%"
|
||||
:referer (get opts :referer)
|
||||
:files files
|
||||
:relations []}]
|
||||
["manifest.json" (delay (json/encode params))]))
|
||||
:relations []}
|
||||
params (d/without-nils params)]
|
||||
|
||||
["manifest.json"
|
||||
(delay (json/encode params))]))
|
||||
|
||||
(defn- generate-procs
|
||||
[state]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue