diff --git a/common/src/app/common/features.cljc b/common/src/app/common/features.cljc index e0b10c0b2..f0c35b26b 100644 --- a/common/src/app/common/features.cljc +++ b/common/src/app/common/features.cljc @@ -48,7 +48,8 @@ "fdata/shape-data-type" "components/v2" "styles/v2" - "layout/grid"}) + "layout/grid" + "plugins/runtime"}) ;; A set of features enabled by default (def default-features @@ -62,7 +63,8 @@ ;; persist on file features field but can be permanently enabled on ;; team feature field (def frontend-only-features - #{"styles/v2"}) + #{"styles/v2" + "plugins/runtime"}) ;; Features that are mainly backend only or there are a proper ;; fallback when frontend reports no support for it @@ -78,7 +80,8 @@ (-> #{"fdata/objects-map" "fdata/pointer-map" "layout/grid" - "fdata/shape-data-type"} + "fdata/shape-data-type" + "plugins/runtime"} (into frontend-only-features))) (sm/def! ::features @@ -97,6 +100,7 @@ :feature-grid-layout "layout/grid" :feature-fdata-objects-map "fdata/objects-map" :feature-fdata-pointer-map "fdata/pointer-map" + :feature-plugins "plugins/runtime" nil)) (defn migrate-legacy-features diff --git a/frontend/src/app/main.cljs b/frontend/src/app/main.cljs index ccdb0b617..522715331 100644 --- a/frontend/src/app/main.cljs +++ b/frontend/src/app/main.cljs @@ -25,7 +25,7 @@ [app.main.ui.modal :refer [modal]] [app.main.ui.routes :as rt] [app.main.worker :as worker] - [app.plugins.api] + [app.plugins :as plugins] [app.util.dom :as dom] [app.util.i18n :as i18n] [app.util.theme :as theme] @@ -105,7 +105,8 @@ (rx/map deref) (rx/filter du/is-authenticated?) (rx/take 1) - (rx/map #(ws/initialize))))))) + (rx/map #(ws/initialize)) + (rx/tap #(plugins/init!))))))) (defn ^:export init [] diff --git a/frontend/src/app/plugins.cljs b/frontend/src/app/plugins.cljs new file mode 100644 index 000000000..1ede1b72c --- /dev/null +++ b/frontend/src/app/plugins.cljs @@ -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))))) diff --git a/frontend/src/features.cljs b/frontend/src/features.cljs index 366a70207..943b5a1f7 100644 --- a/frontend/src/features.cljs +++ b/frontend/src/features.cljs @@ -23,3 +23,8 @@ (defn ^:export get-team-enabled [] (clj->js (features/get-team-enabled-features @st/state))) + +(defn ^:export plugins [] + (tm/schedule-on-idle #(st/emit! (features/toggle-feature "plugins/runtime"))) + nil) +