diff --git a/backend/src/app/binfile/v3.clj b/backend/src/app/binfile/v3.clj index 70a9960e69..f90ff08621 100644 --- a/backend/src/app/binfile/v3.clj +++ b/backend/src/app/binfile/v3.clj @@ -54,7 +54,7 @@ [:map {:title "Manifest"} [:version ::sm/int] [:type :string] - + [:referer {:optional true} :string] [:generated-by {:optional true} :string] [:files diff --git a/library/src/lib/builder.cljs b/library/src/lib/builder.cljs index f77f6f8ae5..c7b87d32c3 100644 --- a/library/src/lib/builder.cljs +++ b/library/src/lib/builder.cljs @@ -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 diff --git a/library/src/lib/export.cljs b/library/src/lib/export.cljs index 7fee373440..1d5d5cfcb6 100644 --- a/library/src/lib/export.cljs +++ b/library/src/lib/export.cljs @@ -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]