Create feature for plugins

This commit is contained in:
alonso.torres 2024-04-18 16:41:43 +02:00 committed by Andrey Antukh
parent d7324b2e98
commit 7b508f2803
4 changed files with 38 additions and 5 deletions

View file

@ -48,7 +48,8 @@
"fdata/shape-data-type" "fdata/shape-data-type"
"components/v2" "components/v2"
"styles/v2" "styles/v2"
"layout/grid"}) "layout/grid"
"plugins/runtime"})
;; A set of features enabled by default ;; A set of features enabled by default
(def default-features (def default-features
@ -62,7 +63,8 @@
;; persist on file features field but can be permanently enabled on ;; persist on file features field but can be permanently enabled on
;; team feature field ;; team feature field
(def frontend-only-features (def frontend-only-features
#{"styles/v2"}) #{"styles/v2"
"plugins/runtime"})
;; Features that are mainly backend only or there are a proper ;; Features that are mainly backend only or there are a proper
;; fallback when frontend reports no support for it ;; fallback when frontend reports no support for it
@ -78,7 +80,8 @@
(-> #{"fdata/objects-map" (-> #{"fdata/objects-map"
"fdata/pointer-map" "fdata/pointer-map"
"layout/grid" "layout/grid"
"fdata/shape-data-type"} "fdata/shape-data-type"
"plugins/runtime"}
(into frontend-only-features))) (into frontend-only-features)))
(sm/def! ::features (sm/def! ::features
@ -97,6 +100,7 @@
:feature-grid-layout "layout/grid" :feature-grid-layout "layout/grid"
:feature-fdata-objects-map "fdata/objects-map" :feature-fdata-objects-map "fdata/objects-map"
:feature-fdata-pointer-map "fdata/pointer-map" :feature-fdata-pointer-map "fdata/pointer-map"
:feature-plugins "plugins/runtime"
nil)) nil))
(defn migrate-legacy-features (defn migrate-legacy-features

View file

@ -25,7 +25,7 @@
[app.main.ui.modal :refer [modal]] [app.main.ui.modal :refer [modal]]
[app.main.ui.routes :as rt] [app.main.ui.routes :as rt]
[app.main.worker :as worker] [app.main.worker :as worker]
[app.plugins.api] [app.plugins :as plugins]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n] [app.util.i18n :as i18n]
[app.util.theme :as theme] [app.util.theme :as theme]
@ -105,7 +105,8 @@
(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
[] []

View file

@ -0,0 +1,23 @@
;; 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.plugins
"RPC for plugins runtime."
(:require
[app.main.features :as features]
[app.main.store :as st]
[app.plugins.api :as api]
[app.util.globals :refer [global]]
[app.util.object :as obj]))
(defn init!
[]
(when (features/active-feature? @st/state "plugins/runtime")
(when-let [init-runtime (obj/get global "initPluginsRuntime")]
(let [context (api/create-context)]
(when *assert*
(js/console.log "Plugins context" context))
(init-runtime context)))))

View file

@ -23,3 +23,8 @@
(defn ^:export get-team-enabled [] (defn ^:export get-team-enabled []
(clj->js (features/get-team-enabled-features @st/state))) (clj->js (features/get-team-enabled-features @st/state)))
(defn ^:export plugins []
(tm/schedule-on-idle #(st/emit! (features/toggle-feature "plugins/runtime")))
nil)