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"}
|
[:map {:title "Manifest"}
|
||||||
[:version ::sm/int]
|
[:version ::sm/int]
|
||||||
[:type :string]
|
[:type :string]
|
||||||
|
[:referer {:optional true} :string]
|
||||||
[:generated-by {:optional true} :string]
|
[:generated-by {:optional true} :string]
|
||||||
|
|
||||||
[:files
|
[:files
|
||||||
|
|
|
@ -271,11 +271,19 @@
|
||||||
(fn []
|
(fn []
|
||||||
(json/->js @state))))
|
(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
|
(defn create-build-context
|
||||||
"Create an empty builder state context."
|
"Create an empty builder state context."
|
||||||
[]
|
[options]
|
||||||
(let [state (atom {})
|
(let [options (some-> options decode-params decode-context-options)
|
||||||
api (create-builder-api state)]
|
state (atom {:options options})
|
||||||
|
api (create-builder-api state)]
|
||||||
|
|
||||||
(specify! api
|
(specify! api
|
||||||
cljs.core/IDeref
|
cljs.core/IDeref
|
||||||
|
|
|
@ -183,17 +183,22 @@
|
||||||
|
|
||||||
(defn- generate-manifest-procs
|
(defn- generate-manifest-procs
|
||||||
[state]
|
[state]
|
||||||
(let [files (->> (get state ::fb/files)
|
(let [opts (get state :options)
|
||||||
(mapv (fn [[file-id file]]
|
files (->> (get state ::fb/files)
|
||||||
{:id file-id
|
(mapv (fn [[file-id file]]
|
||||||
:name (:name file)
|
{:id file-id
|
||||||
:features (:features file)})))
|
:name (:name file)
|
||||||
|
:features (:features file)})))
|
||||||
params {:type "penpot/export-files"
|
params {:type "penpot/export-files"
|
||||||
:version 1
|
:version 1
|
||||||
:generated-by "penpot-library/%version%"
|
:generated-by "penpot-library/%version%"
|
||||||
|
:referer (get opts :referer)
|
||||||
:files files
|
:files files
|
||||||
:relations []}]
|
:relations []}
|
||||||
["manifest.json" (delay (json/encode params))]))
|
params (d/without-nils params)]
|
||||||
|
|
||||||
|
["manifest.json"
|
||||||
|
(delay (json/encode params))]))
|
||||||
|
|
||||||
(defn- generate-procs
|
(defn- generate-procs
|
||||||
[state]
|
[state]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue