mirror of
https://github.com/penpot/penpot.git
synced 2025-01-04 13:50:12 -05:00
♻️ Remove all usage of graalvm js runtime
And replace it with a commandline call to nodejs for execute a custom svgo based command line script.
This commit is contained in:
parent
15b33488c6
commit
cc6e071f48
17 changed files with 576 additions and 40723 deletions
|
@ -7,6 +7,8 @@ set -ex
|
|||
rm -rf target;
|
||||
mkdir -p target/classes;
|
||||
mkdir -p target/dist;
|
||||
mkdir -p target/dist/scripts;
|
||||
|
||||
echo "$CURRENT_VERSION" > target/classes/version.txt;
|
||||
cp ../CHANGES.md target/classes/changelog.md;
|
||||
|
||||
|
@ -15,6 +17,7 @@ mv target/penpot.jar target/dist/penpot.jar
|
|||
cp resources/log4j2.xml target/dist/log4j2.xml
|
||||
cp scripts/run.template.sh target/dist/run.sh;
|
||||
cp scripts/manage.py target/dist/manage.py
|
||||
cp scripts/svgo-cli.js target/dist/scripts/;
|
||||
chmod +x target/dist/run.sh;
|
||||
chmod +x target/dist/manage.py
|
||||
|
||||
|
|
214
backend/scripts/svgo-cli.js
Normal file
214
backend/scripts/svgo-cli.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -41,6 +41,7 @@
|
|||
[app.common.types.shape.path :as ctsp]
|
||||
[app.common.types.shape.text :as ctsx]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.db.sql :as sql]
|
||||
[app.features.fdata :as fdata]
|
||||
|
@ -1381,7 +1382,9 @@
|
|||
(defn get-optimized-svg
|
||||
[sid]
|
||||
(let [svg-text (get-sobject-content sid)
|
||||
svg-text (svgo/optimize *system* svg-text)]
|
||||
svg-text (if (contains? cf/flags :backend-svgo)
|
||||
(svgo/optimize *system* svg-text)
|
||||
svg-text)]
|
||||
(csvg/parse svg-text)))
|
||||
|
||||
(def base-path "/data/cache")
|
||||
|
@ -1484,11 +1487,6 @@
|
|||
:file-id (str (:id fdata))
|
||||
:id (str (:id mobj)))
|
||||
|
||||
(instance? org.graalvm.polyglot.PolyglotException cause)
|
||||
(l/inf :hint "skip processing media object: invalid svg found"
|
||||
:file-id (str (:id fdata))
|
||||
:id (str (:id mobj)))
|
||||
|
||||
(= (:type edata) :not-found)
|
||||
(l/inf :hint "skip processing media object: underlying object does not exist"
|
||||
:file-id (str (:id fdata))
|
||||
|
|
|
@ -319,7 +319,6 @@
|
|||
::mtx/metrics (ig/ref ::mtx/metrics)
|
||||
::mbus/msgbus (ig/ref ::mbus/msgbus)
|
||||
::rds/redis (ig/ref ::rds/redis)
|
||||
::svgo/optimizer (ig/ref ::svgo/optimizer)
|
||||
|
||||
::rpc/climit (ig/ref ::rpc/climit)
|
||||
::rpc/rlimit (ig/ref ::rpc/rlimit)
|
||||
|
@ -430,9 +429,6 @@
|
|||
;; module requires the migrations to run before initialize.
|
||||
::migrations (ig/ref :app.migrations/migrations)}
|
||||
|
||||
::svgo/optimizer
|
||||
{}
|
||||
|
||||
:app.loggers.audit.archive-task/handler
|
||||
{::setup/props (ig/ref ::setup/props)
|
||||
::db/pool (ig/ref ::db/pool)
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
(ns app.storage.fs
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.spec :as us]
|
||||
[app.common.uri :as u]
|
||||
|
|
|
@ -7,36 +7,32 @@
|
|||
(ns app.svgo
|
||||
"A SVG Optimizer service"
|
||||
(:require
|
||||
[app.common.jsrt :as jsrt]
|
||||
[app.common.logging :as l]
|
||||
[app.worker :as-alias wrk]
|
||||
[integrant.core :as ig]
|
||||
[promesa.exec.semaphore :as ps]
|
||||
[promesa.util :as pu]))
|
||||
[app.util.shell :as shell]
|
||||
[datoteka.fs :as fs]
|
||||
[promesa.exec.semaphore :as ps]))
|
||||
|
||||
(def ^:dynamic *semaphore*
|
||||
"A dynamic variable that can optionally contain a traffic light to
|
||||
appropriately delimit the use of resources, managed externally."
|
||||
nil)
|
||||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
||||
(defn optimize
|
||||
[{pool ::optimizer} data]
|
||||
[system data]
|
||||
(try
|
||||
(some-> *semaphore* ps/acquire!)
|
||||
(jsrt/run! pool
|
||||
(fn [context]
|
||||
(jsrt/set! context "svgData" data)
|
||||
(jsrt/eval! context "penpotSvgo.optimize(svgData, {plugins: ['safeAndFastPreset']})")))
|
||||
(let [script (fs/join fs/*cwd* "scripts/svgo-cli.js")
|
||||
cmd ["node" (str script)]
|
||||
result (shell/exec! system
|
||||
:cmd cmd
|
||||
:in data)]
|
||||
(if (= (:exit result) 0)
|
||||
(:out result)
|
||||
(do
|
||||
(l/raw! :warn (str "Error on optimizing svg, returning svg as-is." (:err result)))
|
||||
data)))
|
||||
|
||||
(finally
|
||||
(some-> *semaphore* ps/release!))))
|
||||
|
||||
(defmethod ig/init-key ::optimizer
|
||||
[_ _]
|
||||
(l/inf :hint "initializing svg optimizer pool")
|
||||
(let [init (jsrt/resource->source "app/common/svg/optimizer.js")]
|
||||
(jsrt/pool :init init)))
|
||||
|
||||
(defmethod ig/halt-key! ::optimizer
|
||||
[_ pool]
|
||||
(l/info :hint "stopping svg optimizer pool")
|
||||
(pu/close! pool))
|
||||
|
|
71
backend/src/app/util/shell.clj
Normal file
71
backend/src/app/util/shell.clj
Normal file
|
@ -0,0 +1,71 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.util.shell
|
||||
"A penpot specific, modern api for executing external (shell)
|
||||
subprocesses"
|
||||
(:require
|
||||
[app.worker :as-alias wrk]
|
||||
[datoteka.io :as io]
|
||||
[promesa.exec :as px])
|
||||
(:import
|
||||
java.io.InputStream
|
||||
java.io.OutputStream
|
||||
java.util.List
|
||||
org.apache.commons.io.IOUtils))
|
||||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
||||
(defn- read-as-bytes
|
||||
[in]
|
||||
(with-open [^InputStream input (io/input-stream in)]
|
||||
(io/read input)))
|
||||
|
||||
(defn- read-as-string
|
||||
([in] (read-as-string in "UTF-8"))
|
||||
([in enc]
|
||||
(IOUtils/toString ^InputStream in ^String enc)))
|
||||
|
||||
(defn- read-with-enc
|
||||
[stream enc]
|
||||
(if (= enc :bytes)
|
||||
(read-as-bytes stream)
|
||||
(read-as-string stream enc)))
|
||||
|
||||
(defn- set-env
|
||||
[penv k v]
|
||||
(.put ^java.util.Map penv
|
||||
^String k
|
||||
^String v))
|
||||
|
||||
(defn exec!
|
||||
[system & {:keys [cmd in out-enc in-enc env]
|
||||
:or {out-enc "UTF-8"
|
||||
in-enc "UTF-8"}}]
|
||||
(assert (vector? cmd) "a command parameter should be a vector")
|
||||
(assert (every? string? cmd) "the command should be a vector of strings")
|
||||
|
||||
(let [executor (::wrk/executor system)
|
||||
builder (ProcessBuilder. ^List cmd)
|
||||
env-map (.environment ^ProcessBuilder builder)
|
||||
_ (reduce-kv set-env env-map env)
|
||||
process (.start builder)]
|
||||
|
||||
(if in
|
||||
(px/run! executor
|
||||
(fn []
|
||||
(with-open [^OutputStream stdin (.getOutputStream ^Process process)]
|
||||
(io/write stdin in :encoding in-enc))))
|
||||
(io/close (.getOutputStream ^Process process)))
|
||||
|
||||
(with-open [stdout (.getInputStream ^Process process)
|
||||
stderr (.getErrorStream ^Process process)]
|
||||
(let [out (px/submit! executor (fn [] (read-with-enc stdout out-enc)))
|
||||
err (px/submit! executor (fn [] (read-as-string stderr)))
|
||||
ext (.waitFor ^Process process)]
|
||||
{:exit ext
|
||||
:out @out
|
||||
:err @err}))))
|
|
@ -27,9 +27,6 @@
|
|||
java-http-clj/java-http-clj {:mvn/version "0.4.3"}
|
||||
integrant/integrant {:mvn/version "0.8.1"}
|
||||
|
||||
org.apache.commons/commons-pool2 {:mvn/version "2.12.0"}
|
||||
org.graalvm.js/js {:mvn/version "23.0.4"}
|
||||
|
||||
funcool/tubax {:mvn/version "2021.05.20-0"}
|
||||
funcool/cuerdas {:mvn/version "2023.11.09-407"}
|
||||
funcool/promesa
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.common.jsrt
|
||||
"A JS runtime for the JVM"
|
||||
(:refer-clojure :exclude [run!])
|
||||
(:require
|
||||
[clojure.java.io :as io])
|
||||
(:import
|
||||
org.apache.commons.pool2.ObjectPool
|
||||
org.apache.commons.pool2.PooledObject
|
||||
org.apache.commons.pool2.PooledObjectFactory
|
||||
org.apache.commons.pool2.impl.DefaultPooledObject
|
||||
org.apache.commons.pool2.impl.SoftReferenceObjectPool
|
||||
org.graalvm.polyglot.Context
|
||||
org.graalvm.polyglot.Source
|
||||
org.graalvm.polyglot.Value))
|
||||
|
||||
(defn resource->source
|
||||
[path]
|
||||
(let [resource (io/resource path)]
|
||||
(.. (Source/newBuilder "js" resource)
|
||||
(build))))
|
||||
|
||||
(defn pool?
|
||||
[o]
|
||||
(instance? ObjectPool o))
|
||||
|
||||
(defn pool
|
||||
[& {:keys [init]}]
|
||||
(SoftReferenceObjectPool.
|
||||
(reify PooledObjectFactory
|
||||
(activateObject [_ _])
|
||||
(destroyObject [_ o]
|
||||
(let [context (.getObject ^PooledObject o)]
|
||||
(.close ^java.lang.AutoCloseable context)))
|
||||
|
||||
(destroyObject [_ o _]
|
||||
(let [context (.getObject ^PooledObject o)]
|
||||
(.close ^java.lang.AutoCloseable context)))
|
||||
|
||||
(passivateObject [_ _])
|
||||
(validateObject [_ _] true)
|
||||
|
||||
(makeObject [_]
|
||||
(let [context (Context/create (into-array String ["js"]))]
|
||||
(.initialize ^Context context "js")
|
||||
(when (instance? Source init)
|
||||
(.eval ^Context context ^Source init))
|
||||
(DefaultPooledObject. context))))))
|
||||
|
||||
(defn run!
|
||||
[^ObjectPool pool f]
|
||||
(let [ctx (.borrowObject pool)]
|
||||
(try
|
||||
(f ctx)
|
||||
(finally
|
||||
(.returnObject pool ctx)))))
|
||||
|
||||
(defn eval!
|
||||
[context data & {:keys [as] :or {as :string}}]
|
||||
(let [result (.eval ^Context context "js" ^String data)]
|
||||
(case as
|
||||
(:string :str) (.asString ^Value result)
|
||||
:long (.asLong ^Value result)
|
||||
:int (.asInt ^Value result)
|
||||
:float (.asFloat ^Value result)
|
||||
:double (.asDouble ^Value result))))
|
||||
|
||||
(defn set!
|
||||
[context attr value]
|
||||
(let [bindings (.getBindings ^Context context "js")]
|
||||
(.putMember ^Value bindings ^String attr ^String value)
|
||||
context))
|
|
@ -8,7 +8,6 @@
|
|||
(:require
|
||||
#?(:clj [clojure.xml :as xml]
|
||||
:cljs [tubax.core :as tubax])
|
||||
#?(:cljs ["./svg/optimizer.js" :as svgo])
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
|
@ -1052,10 +1051,3 @@
|
|||
:clj (let [text (strip-doctype text)]
|
||||
(dm/with-open [istream (IOUtils/toInputStream text "UTF-8")]
|
||||
(xml/parse istream secure-parser-factory)))))
|
||||
|
||||
;; FIXME pass correct plugin set
|
||||
#?(:cljs
|
||||
(defn optimize
|
||||
([input] (optimize input nil))
|
||||
([input options]
|
||||
(svgo/optimize input (clj->js options)))))
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -18,6 +18,7 @@
|
|||
"luxon": "^3.5.0",
|
||||
"playwright": "^1.48.1",
|
||||
"raw-body": "^3.0.0",
|
||||
"svgo": "penpot/svgo#v3",
|
||||
"xml-js": "^1.6.11",
|
||||
"xregexp": "^5.1.1"
|
||||
},
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
(ns app.renderer.svg
|
||||
(:require
|
||||
["svgo" :as svgo]
|
||||
["xml-js" :as xml]
|
||||
[app.browser :as bw]
|
||||
[app.common.data :as d]
|
||||
[app.common.logging :as l]
|
||||
[app.common.svg :as svg]
|
||||
[app.common.uri :as u]
|
||||
[app.config :as cf]
|
||||
[app.util.mime :as mime]
|
||||
|
@ -319,7 +319,7 @@
|
|||
result (str/replace result " " " ")
|
||||
|
||||
result (if (contains? cf/flags :exporter-svgo)
|
||||
(svg/optimize result)
|
||||
(svgo/optimize result svgo/defaultOptions)
|
||||
result)]
|
||||
|
||||
;; (println "------- ORIGIN:")
|
||||
|
|
|
@ -65,6 +65,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@trysound/sax@npm:0.2.0":
|
||||
version: 0.2.0
|
||||
resolution: "@trysound/sax@npm:0.2.0"
|
||||
checksum: 10c0/44907308549ce775a41c38a815f747009ac45929a45d642b836aa6b0a536e4978d30b8d7d680bbd116e9dd73b7dbe2ef0d1369dcfc2d09e83ba381e485ecbe12
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"abbrev@npm:^2.0.0":
|
||||
version: 2.0.0
|
||||
resolution: "abbrev@npm:2.0.0"
|
||||
|
@ -230,6 +237,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"boolbase@npm:^1.0.0":
|
||||
version: 1.0.0
|
||||
resolution: "boolbase@npm:1.0.0"
|
||||
checksum: 10c0/e4b53deb4f2b85c52be0e21a273f2045c7b6a6ea002b0e139c744cb6f95e9ec044439a52883b0d74dedd1ff3da55ed140cfdddfed7fb0cccbed373de5dce1bcf
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"brace-expansion@npm:^2.0.1":
|
||||
version: 2.0.1
|
||||
resolution: "brace-expansion@npm:2.0.1"
|
||||
|
@ -593,6 +607,55 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"css-select@npm:^5.1.0":
|
||||
version: 5.1.0
|
||||
resolution: "css-select@npm:5.1.0"
|
||||
dependencies:
|
||||
boolbase: "npm:^1.0.0"
|
||||
css-what: "npm:^6.1.0"
|
||||
domhandler: "npm:^5.0.2"
|
||||
domutils: "npm:^3.0.1"
|
||||
nth-check: "npm:^2.0.1"
|
||||
checksum: 10c0/551c60dba5b54054741032c1793b5734f6ba45e23ae9e82761a3c0ed1acbb8cfedfa443aaba3a3c1a54cac12b456d2012a09d2cd5f0e82e430454c1b9d84d500
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"css-tree@npm:^3.0.0":
|
||||
version: 3.0.0
|
||||
resolution: "css-tree@npm:3.0.0"
|
||||
dependencies:
|
||||
mdn-data: "npm:2.10.0"
|
||||
source-map-js: "npm:^1.0.1"
|
||||
checksum: 10c0/43d44fdf7004ae91d73d486f17894fef77efa33747a6752b9241cf0f5fb47fabc16ec34a96a993651d9014dfdeee803d7c5fcd3548214252ee19f4e5c98999b2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"css-tree@npm:~2.2.0":
|
||||
version: 2.2.1
|
||||
resolution: "css-tree@npm:2.2.1"
|
||||
dependencies:
|
||||
mdn-data: "npm:2.0.28"
|
||||
source-map-js: "npm:^1.0.1"
|
||||
checksum: 10c0/47e87b0f02f8ac22f57eceb65c58011dd142d2158128882a0bf963cf2eabb81a4ebbc2e3790c8289be7919fa8b83750c7b69272bd66772c708143b772ba3c186
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"css-what@npm:^6.1.0":
|
||||
version: 6.1.0
|
||||
resolution: "css-what@npm:6.1.0"
|
||||
checksum: 10c0/a09f5a6b14ba8dcf57ae9a59474722e80f20406c53a61e9aedb0eedc693b135113ffe2983f4efc4b5065ae639442e9ae88df24941ef159c218b231011d733746
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"csso@npm:^5.0.5":
|
||||
version: 5.0.5
|
||||
resolution: "csso@npm:5.0.5"
|
||||
dependencies:
|
||||
css-tree: "npm:~2.2.0"
|
||||
checksum: 10c0/ab4beb1e97dd7e207c10e9925405b45f15a6cd1b4880a8686ad573aa6d476aed28b4121a666cffd26c37a26179f7b54741f7c257543003bfb244d06a62ad569b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"debug@npm:4, debug@npm:^4.3.4":
|
||||
version: 4.3.4
|
||||
resolution: "debug@npm:4.3.4"
|
||||
|
@ -662,6 +725,17 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dom-serializer@npm:^2.0.0":
|
||||
version: 2.0.0
|
||||
resolution: "dom-serializer@npm:2.0.0"
|
||||
dependencies:
|
||||
domelementtype: "npm:^2.3.0"
|
||||
domhandler: "npm:^5.0.2"
|
||||
entities: "npm:^4.2.0"
|
||||
checksum: 10c0/d5ae2b7110ca3746b3643d3ef60ef823f5f078667baf530cec096433f1627ec4b6fa8c072f09d079d7cda915fd2c7bc1b7b935681e9b09e591e1e15f4040b8e2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"domain-browser@npm:^1.1.1":
|
||||
version: 1.2.0
|
||||
resolution: "domain-browser@npm:1.2.0"
|
||||
|
@ -669,6 +743,33 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"domelementtype@npm:^2.3.0":
|
||||
version: 2.3.0
|
||||
resolution: "domelementtype@npm:2.3.0"
|
||||
checksum: 10c0/686f5a9ef0fff078c1412c05db73a0dce096190036f33e400a07e2a4518e9f56b1e324f5c576a0a747ef0e75b5d985c040b0d51945ce780c0dd3c625a18cd8c9
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"domhandler@npm:^5.0.2, domhandler@npm:^5.0.3":
|
||||
version: 5.0.3
|
||||
resolution: "domhandler@npm:5.0.3"
|
||||
dependencies:
|
||||
domelementtype: "npm:^2.3.0"
|
||||
checksum: 10c0/bba1e5932b3e196ad6862286d76adc89a0dbf0c773e5ced1eb01f9af930c50093a084eff14b8de5ea60b895c56a04d5de8bbc4930c5543d029091916770b2d2a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"domutils@npm:^3.0.1":
|
||||
version: 3.1.0
|
||||
resolution: "domutils@npm:3.1.0"
|
||||
dependencies:
|
||||
dom-serializer: "npm:^2.0.0"
|
||||
domelementtype: "npm:^2.3.0"
|
||||
domhandler: "npm:^5.0.3"
|
||||
checksum: 10c0/342d64cf4d07b8a0573fb51e0a6312a88fb520c7fefd751870bf72fa5fc0f2e0cb9a3958a573610b1d608c6e2a69b8e9b4b40f0bfb8f87a71bce4f180cca1887
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"eastasianwidth@npm:^0.2.0":
|
||||
version: 0.2.0
|
||||
resolution: "eastasianwidth@npm:0.2.0"
|
||||
|
@ -714,6 +815,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"entities@npm:^4.2.0":
|
||||
version: 4.5.0
|
||||
resolution: "entities@npm:4.5.0"
|
||||
checksum: 10c0/5b039739f7621f5d1ad996715e53d964035f75ad3b9a4d38c6b3804bb226e282ffeae2443624d8fdd9c47d8e926ae9ac009c54671243f0c3294c26af7cc85250
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"env-paths@npm:^2.2.0":
|
||||
version: 2.2.1
|
||||
resolution: "env-paths@npm:2.2.1"
|
||||
|
@ -790,6 +898,7 @@ __metadata:
|
|||
raw-body: "npm:^3.0.0"
|
||||
shadow-cljs: "npm:2.28.18"
|
||||
source-map-support: "npm:^0.5.21"
|
||||
svgo: "penpot/svgo#v3"
|
||||
xml-js: "npm:^1.6.11"
|
||||
xregexp: "npm:^5.1.1"
|
||||
languageName: unknown
|
||||
|
@ -1215,7 +1324,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"lodash@npm:^4.17.15":
|
||||
"lodash@npm:^4.17.15, lodash@npm:^4.17.21":
|
||||
version: 4.17.21
|
||||
resolution: "lodash@npm:4.17.21"
|
||||
checksum: 10c0/d8cbea072bb08655bb4c989da418994b073a608dffa608b09ac04b43a791b12aeae7cd7ad919aa4c925f33b48490b5cfe6c1f71d827956071dae2e7bb3a6b74c
|
||||
|
@ -1267,6 +1376,20 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mdn-data@npm:2.0.28":
|
||||
version: 2.0.28
|
||||
resolution: "mdn-data@npm:2.0.28"
|
||||
checksum: 10c0/20000932bc4cd1cde9cba4e23f08cc4f816398af4c15ec81040ed25421d6bf07b5cf6b17095972577fb498988f40f4cb589e3169b9357bb436a12d8e07e5ea7b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mdn-data@npm:2.10.0":
|
||||
version: 2.10.0
|
||||
resolution: "mdn-data@npm:2.10.0"
|
||||
checksum: 10c0/f6f1a6a6eb092bab250d06f6f6c7cb1733a77a17e7119aac829ad67d4322bbf6a30df3c6d88686e71942e66bd49274b2ddfede22a1d3df0d6c49a56fbd09eb7c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"miller-rabin@npm:^4.0.0":
|
||||
version: 4.0.1
|
||||
resolution: "miller-rabin@npm:4.0.1"
|
||||
|
@ -1494,6 +1617,15 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"nth-check@npm:^2.0.1":
|
||||
version: 2.1.1
|
||||
resolution: "nth-check@npm:2.1.1"
|
||||
dependencies:
|
||||
boolbase: "npm:^1.0.0"
|
||||
checksum: 10c0/5fee7ff309727763689cfad844d979aedd2204a817fbaaf0e1603794a7c20db28548d7b024692f953557df6ce4a0ee4ae46cd8ebd9b36cfb300b9226b567c479
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"object-inspect@npm:^1.13.1":
|
||||
version: 1.13.1
|
||||
resolution: "object-inspect@npm:1.13.1"
|
||||
|
@ -1989,6 +2121,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"source-map-js@npm:^1.0.1":
|
||||
version: 1.2.1
|
||||
resolution: "source-map-js@npm:1.2.1"
|
||||
checksum: 10c0/7bda1fc4c197e3c6ff17de1b8b2c20e60af81b63a52cb32ec5a5d67a20a7d42651e2cb34ebe93833c5a2a084377e17455854fee3e21e7925c64a51b6a52b0faf
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"source-map-support@npm:^0.4.15":
|
||||
version: 0.4.18
|
||||
resolution: "source-map-support@npm:0.4.18"
|
||||
|
@ -2147,6 +2286,19 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"svgo@penpot/svgo#v3":
|
||||
version: 4.0.0
|
||||
resolution: "svgo@https://github.com/penpot/svgo.git#commit=71c0db44c3c2665f2ffc0c4c5383acaebd5c524f"
|
||||
dependencies:
|
||||
"@trysound/sax": "npm:0.2.0"
|
||||
css-select: "npm:^5.1.0"
|
||||
css-tree: "npm:^3.0.0"
|
||||
csso: "npm:^5.0.5"
|
||||
lodash: "npm:^4.17.21"
|
||||
checksum: 10c0/642c583372a610e484382cbf8a8fe28256dd354598d2e65ade2a3a63bf841b4d3dab4106f929f183ae3610007db2fc1413e82acc23793fe1a2e882bc923acc72
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tar-stream@npm:^3.0.0":
|
||||
version: 3.1.7
|
||||
resolution: "tar-stream@npm:3.1.7"
|
||||
|
|
|
@ -111,6 +111,7 @@
|
|||
"rxjs": "8.0.0-alpha.14",
|
||||
"sax": "^1.4.1",
|
||||
"source-map-support": "^0.5.21",
|
||||
"svgo": "penpot/svgo#v3",
|
||||
"tdigest": "^0.1.2",
|
||||
"ua-parser-js": "^1.0.39",
|
||||
"xregexp": "^5.1.1"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.main.data.workspace.media
|
||||
(:require
|
||||
["svgo" :as svgo]
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.exceptions :as ex]
|
||||
|
@ -14,7 +15,6 @@
|
|||
[app.common.logging :as log]
|
||||
[app.common.math :as mth]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.svg :refer [optimize]]
|
||||
[app.common.svg.shapes-builder :as csvg.shapes-builder]
|
||||
[app.common.types.container :as ctn]
|
||||
[app.common.types.shape :as cts]
|
||||
|
@ -37,15 +37,15 @@
|
|||
[promesa.core :as p]
|
||||
[tubax.core :as tubax]))
|
||||
|
||||
(def ^:private svgo-config
|
||||
{:multipass false
|
||||
:plugins ["safeAndFastPreset"]})
|
||||
(defn- optimize
|
||||
[input]
|
||||
(svgo/optimize input svgo/defaultOptions))
|
||||
|
||||
(defn svg->clj
|
||||
[[name text]]
|
||||
(try
|
||||
(let [text (if (contains? cf/flags :frontend-svgo)
|
||||
(optimize text svgo-config)
|
||||
(optimize text)
|
||||
text)
|
||||
data (-> (tubax/xml->clj text)
|
||||
(assoc :name name))]
|
||||
|
|
|
@ -3427,6 +3427,19 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"css-select@npm:^5.1.0":
|
||||
version: 5.1.0
|
||||
resolution: "css-select@npm:5.1.0"
|
||||
dependencies:
|
||||
boolbase: "npm:^1.0.0"
|
||||
css-what: "npm:^6.1.0"
|
||||
domhandler: "npm:^5.0.2"
|
||||
domutils: "npm:^3.0.1"
|
||||
nth-check: "npm:^2.0.1"
|
||||
checksum: 10c0/551c60dba5b54054741032c1793b5734f6ba45e23ae9e82761a3c0ed1acbb8cfedfa443aaba3a3c1a54cac12b456d2012a09d2cd5f0e82e430454c1b9d84d500
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"css-selector-parser@npm:^1.4.1":
|
||||
version: 1.4.1
|
||||
resolution: "css-selector-parser@npm:1.4.1"
|
||||
|
@ -3444,7 +3457,27 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"css-what@npm:^6.0.1":
|
||||
"css-tree@npm:^3.0.0":
|
||||
version: 3.0.0
|
||||
resolution: "css-tree@npm:3.0.0"
|
||||
dependencies:
|
||||
mdn-data: "npm:2.10.0"
|
||||
source-map-js: "npm:^1.0.1"
|
||||
checksum: 10c0/43d44fdf7004ae91d73d486f17894fef77efa33747a6752b9241cf0f5fb47fabc16ec34a96a993651d9014dfdeee803d7c5fcd3548214252ee19f4e5c98999b2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"css-tree@npm:~2.2.0":
|
||||
version: 2.2.1
|
||||
resolution: "css-tree@npm:2.2.1"
|
||||
dependencies:
|
||||
mdn-data: "npm:2.0.28"
|
||||
source-map-js: "npm:^1.0.1"
|
||||
checksum: 10c0/47e87b0f02f8ac22f57eceb65c58011dd142d2158128882a0bf963cf2eabb81a4ebbc2e3790c8289be7919fa8b83750c7b69272bd66772c708143b772ba3c186
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"css-what@npm:^6.0.1, css-what@npm:^6.1.0":
|
||||
version: 6.1.0
|
||||
resolution: "css-what@npm:6.1.0"
|
||||
checksum: 10c0/a09f5a6b14ba8dcf57ae9a59474722e80f20406c53a61e9aedb0eedc693b135113ffe2983f4efc4b5065ae639442e9ae88df24941ef159c218b231011d733746
|
||||
|
@ -3480,6 +3513,15 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"csso@npm:^5.0.5":
|
||||
version: 5.0.5
|
||||
resolution: "csso@npm:5.0.5"
|
||||
dependencies:
|
||||
css-tree: "npm:~2.2.0"
|
||||
checksum: 10c0/ab4beb1e97dd7e207c10e9925405b45f15a6cd1b4880a8686ad573aa6d476aed28b4121a666cffd26c37a26179f7b54741f7c257543003bfb244d06a62ad569b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"cssom@npm:^0.5.0":
|
||||
version: 0.5.0
|
||||
resolution: "cssom@npm:0.5.0"
|
||||
|
@ -3768,6 +3810,17 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dom-serializer@npm:^2.0.0":
|
||||
version: 2.0.0
|
||||
resolution: "dom-serializer@npm:2.0.0"
|
||||
dependencies:
|
||||
domelementtype: "npm:^2.3.0"
|
||||
domhandler: "npm:^5.0.2"
|
||||
entities: "npm:^4.2.0"
|
||||
checksum: 10c0/d5ae2b7110ca3746b3643d3ef60ef823f5f078667baf530cec096433f1627ec4b6fa8c072f09d079d7cda915fd2c7bc1b7b935681e9b09e591e1e15f4040b8e2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"domain-browser@npm:^1.1.1":
|
||||
version: 1.2.0
|
||||
resolution: "domain-browser@npm:1.2.0"
|
||||
|
@ -3775,7 +3828,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"domelementtype@npm:^2.0.1, domelementtype@npm:^2.2.0":
|
||||
"domelementtype@npm:^2.0.1, domelementtype@npm:^2.2.0, domelementtype@npm:^2.3.0":
|
||||
version: 2.3.0
|
||||
resolution: "domelementtype@npm:2.3.0"
|
||||
checksum: 10c0/686f5a9ef0fff078c1412c05db73a0dce096190036f33e400a07e2a4518e9f56b1e324f5c576a0a747ef0e75b5d985c040b0d51945ce780c0dd3c625a18cd8c9
|
||||
|
@ -3791,6 +3844,15 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"domhandler@npm:^5.0.2, domhandler@npm:^5.0.3":
|
||||
version: 5.0.3
|
||||
resolution: "domhandler@npm:5.0.3"
|
||||
dependencies:
|
||||
domelementtype: "npm:^2.3.0"
|
||||
checksum: 10c0/bba1e5932b3e196ad6862286d76adc89a0dbf0c773e5ced1eb01f9af930c50093a084eff14b8de5ea60b895c56a04d5de8bbc4930c5543d029091916770b2d2a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"domutils@npm:^2.8.0":
|
||||
version: 2.8.0
|
||||
resolution: "domutils@npm:2.8.0"
|
||||
|
@ -3802,6 +3864,17 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"domutils@npm:^3.0.1":
|
||||
version: 3.1.0
|
||||
resolution: "domutils@npm:3.1.0"
|
||||
dependencies:
|
||||
dom-serializer: "npm:^2.0.0"
|
||||
domelementtype: "npm:^2.3.0"
|
||||
domhandler: "npm:^5.0.3"
|
||||
checksum: 10c0/342d64cf4d07b8a0573fb51e0a6312a88fb520c7fefd751870bf72fa5fc0f2e0cb9a3958a573610b1d608c6e2a69b8e9b4b40f0bfb8f87a71bce4f180cca1887
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"draft-js@git+https://github.com/penpot/draft-js.git#commit=4a99b2a6020b2af97f6dc5fa1b4275ec16b559a0":
|
||||
version: 0.11.7
|
||||
resolution: "draft-js@https://github.com/penpot/draft-js.git#commit=4a99b2a6020b2af97f6dc5fa1b4275ec16b559a0"
|
||||
|
@ -3924,7 +3997,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"entities@npm:^4.4.0":
|
||||
"entities@npm:^4.2.0, entities@npm:^4.4.0":
|
||||
version: 4.5.0
|
||||
resolution: "entities@npm:4.5.0"
|
||||
checksum: 10c0/5b039739f7621f5d1ad996715e53d964035f75ad3b9a4d38c6b3804bb226e282ffeae2443624d8fdd9c47d8e926ae9ac009c54671243f0c3294c26af7cc85250
|
||||
|
@ -4871,6 +4944,7 @@ __metadata:
|
|||
source-map-support: "npm:^0.5.21"
|
||||
storybook: "npm:^8.3.6"
|
||||
svg-sprite: "npm:^2.0.4"
|
||||
svgo: "penpot/svgo#v3"
|
||||
tdigest: "npm:^0.1.2"
|
||||
typescript: "npm:^5.6.3"
|
||||
ua-parser-js: "npm:^1.0.39"
|
||||
|
@ -6362,6 +6436,20 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mdn-data@npm:2.0.28":
|
||||
version: 2.0.28
|
||||
resolution: "mdn-data@npm:2.0.28"
|
||||
checksum: 10c0/20000932bc4cd1cde9cba4e23f08cc4f816398af4c15ec81040ed25421d6bf07b5cf6b17095972577fb498988f40f4cb589e3169b9357bb436a12d8e07e5ea7b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mdn-data@npm:2.10.0":
|
||||
version: 2.10.0
|
||||
resolution: "mdn-data@npm:2.10.0"
|
||||
checksum: 10c0/f6f1a6a6eb092bab250d06f6f6c7cb1733a77a17e7119aac829ad67d4322bbf6a30df3c6d88686e71942e66bd49274b2ddfede22a1d3df0d6c49a56fbd09eb7c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"media-typer@npm:0.3.0":
|
||||
version: 0.3.0
|
||||
resolution: "media-typer@npm:0.3.0"
|
||||
|
@ -8816,7 +8904,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"source-map-js@npm:^1.2.1":
|
||||
"source-map-js@npm:^1.0.1, source-map-js@npm:^1.2.1":
|
||||
version: 1.2.1
|
||||
resolution: "source-map-js@npm:1.2.1"
|
||||
checksum: 10c0/7bda1fc4c197e3c6ff17de1b8b2c20e60af81b63a52cb32ec5a5d67a20a7d42651e2cb34ebe93833c5a2a084377e17455854fee3e21e7925c64a51b6a52b0faf
|
||||
|
@ -9229,6 +9317,19 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"svgo@penpot/svgo#v3":
|
||||
version: 4.0.0
|
||||
resolution: "svgo@https://github.com/penpot/svgo.git#commit=71c0db44c3c2665f2ffc0c4c5383acaebd5c524f"
|
||||
dependencies:
|
||||
"@trysound/sax": "npm:0.2.0"
|
||||
css-select: "npm:^5.1.0"
|
||||
css-tree: "npm:^3.0.0"
|
||||
csso: "npm:^5.0.5"
|
||||
lodash: "npm:^4.17.21"
|
||||
checksum: 10c0/642c583372a610e484382cbf8a8fe28256dd354598d2e65ade2a3a63bf841b4d3dab4106f929f183ae3610007db2fc1413e82acc23793fe1a2e882bc923acc72
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"symbol-tree@npm:^3.2.4":
|
||||
version: 3.2.4
|
||||
resolution: "symbol-tree@npm:3.2.4"
|
||||
|
|
Loading…
Reference in a new issue