0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Changed order of plugins initialization

This commit is contained in:
alonso.torres 2024-06-21 12:44:35 +02:00
parent c70d20f95d
commit fb1429956a
3 changed files with 20 additions and 15 deletions

View file

@ -105,8 +105,7 @@
(rx/map deref) (rx/map deref)
(rx/filter du/is-authenticated?) (rx/filter du/is-authenticated?)
(rx/take 1) (rx/take 1)
(rx/map #(ws/initialize)) (rx/map #(ws/initialize)))))))
(rx/tap #(plugins/init!)))))))
(defn ^:export init (defn ^:export init
[] []
@ -116,7 +115,8 @@
(cur/init-styles) (cur/init-styles)
(thr/init!) (thr/init!)
(init-ui) (init-ui)
(st/emit! (initialize))) (st/emit! (plugins/initialize)
(initialize)))
(defn ^:export reinit (defn ^:export reinit
([] ([]

View file

@ -16,15 +16,20 @@
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[potok.v2.core :as ptk])) [potok.v2.core :as ptk]))
(defn init! (defn init-plugins-runtime!
[] []
(->> st/stream (when-let [init-runtime (obj/get global "initPluginsRuntime")]
(rx/filter (ptk/type? ::features/initialize)) (init-runtime (fn [plugin-id] (api/create-context plugin-id)))))
(rx/take 1)
;; We need to wait to the init event to finish (defn initialize
(rx/observe-on :async) []
(rx/subs! (ptk/reify ::initialize
(fn [] ptk/WatchEvent
(when (features/active-feature? @st/state "plugins/runtime") (watch [_ _ stream]
(when-let [init-runtime (obj/get global "initPluginsRuntime")] (->> stream
(init-runtime (fn [plugin-id] (api/create-context plugin-id))))))))) (rx/filter (ptk/type? ::features/initialize))
(rx/observe-on :async)
(rx/filter #(features/active-feature? @st/state "plugins/runtime"))
(rx/take 1)
(rx/tap init-plugins-runtime!)
(rx/ignore)))))

View file

@ -27,6 +27,6 @@
(defn ^:export plugins [] (defn ^:export plugins []
(st/emit! (features/enable-feature "plugins/runtime")) (st/emit! (features/enable-feature "plugins/runtime"))
(plugins/init!) (plugins/init-plugins-runtime!)
nil) nil)