mirror of
https://github.com/logseq/logseq.git
synced 2026-04-26 07:05:10 +00:00
Feat/plugin marketplace (#2766)
* Squashed commit of the following: commitea9af272e4Author: Tienson Qin <tiensonqin@gmail.com> Date: Fri Aug 27 00:23:24 2021 +0800 feat: type c to git commit also, fixed an issue that backspace can delete selected blocks when there's a dialog. commit78e24f7479Author: Tienson Qin <tiensonqin@gmail.com> Date: Fri Aug 27 00:01:21 2021 +0800 fix: add patch parser worker to yarn watch commit7f6e777bcdAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Thu Aug 26 23:57:46 2021 +0800 fix: add several shortcuts to the Others category commit509697b276Author: Tienson Qin <tiensonqin@gmail.com> Date: Thu Aug 26 23:55:40 2021 +0800 fix: git username and email configuration * Squashed commit of the following: commit401d85be5fAuthor: Peng Xiao <pengxiao@outlook.com> Date: Fri Aug 27 11:10:32 2021 +0800 feat: add protobuf mode commitdc1e9fdfc9Author: Tienson Qin <tiensonqin@gmail.com> Date: Fri Aug 27 13:33:47 2021 +0800 chore: replace : with comma for git path ':' is a reserved character on Windows commitea9af272e4Author: Tienson Qin <tiensonqin@gmail.com> Date: Fri Aug 27 00:23:24 2021 +0800 feat: type c to git commit also, fixed an issue that backspace can delete selected blocks when there's a dialog. commit78e24f7479Author: Tienson Qin <tiensonqin@gmail.com> Date: Fri Aug 27 00:01:21 2021 +0800 fix: add patch parser worker to yarn watch commit7f6e777bcdAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Thu Aug 26 23:57:46 2021 +0800 fix: add several shortcuts to the Others category commit509697b276Author: Tienson Qin <tiensonqin@gmail.com> Date: Thu Aug 26 23:55:40 2021 +0800 fix: git username and email configuration * feat(plugin): ui of marketplace plugins list * improve(plugin): support reload * improve(plugin): installation from marketplace * fix conflicts * improve(plugin): installation from github public repo * chore: remove unwanted dependency * chore: remove console * improve(plugin): add shortcuts * ui(plugin): polish LOADING indicator * improve(plugin): support up-to-date of marketplace plugin * fix: remove debug option * improve(plugin): better interaction of themes picker * improve(plugin): better experience when installing theme from marketplace * fix(plugin): downloads label of marketplace plugin * improve(plugin): update package name field * improve(plugin): change marketplace packages repo to `logseq/marketplace` * fix(plugin): plugin title when updating notification * fix: conflicts * enhance(plugin): i18n related marketplace & lifecycle of plugin installation * improve(plugin): handle offline situation * ui(plugin): header plugin icons container * fix(ui): add class identity for journal page with date page name * improve(plugin): remote readme for marketplace plugin * enhance(plugin): polish plugin card * chore(plugin): build libs core * Squashed commit of the following: commit751db4828cAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Tue Sep 7 16:58:25 2021 +0800 enhance: log git errors commitc2dbbc77bfAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Tue Sep 7 16:27:00 2021 +0800 enhance: display refresh status commitf734b6db37Author: Tienson Qin <tiensonqin@gmail.com> Date: Tue Sep 7 16:03:57 2021 +0800 fix: .git doesn't work well with third-party cloud services commit7e44d81f1dAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Tue Sep 7 13:52:38 2021 +0800 fix: git init into the current graph folder instead of a separate git directory because .gitdir might has different paths on multiple devices, another reason is that the graph might have different histories considering the .git directory is not synced. commitb86a801514Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 23:23:27 2021 +0800 enhance: don't show diff if there's only blank changes commit0b55d119aaAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 22:39:06 2021 +0800 fix: save the previous content in Logseq first and commit it to avoid overwritten when syncing with iCloud/Dropbox/syncthing. commite0baf4b05cAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 22:18:45 2021 +0800 fix: close file watcher when exit the app commit10e7a9fbd6Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 21:05:38 2021 +0800 fix: disable cut selections in the query result block commit90c2bd7cc2Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 18:42:17 2021 +0800 fix: terminate parser and persist dbs when reloading the app (electron) commit571c81af30Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 17:57:33 2021 +0800 enhance: add sync from local files (the old refresh way) commita16e5c98baAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 17:23:57 2021 +0800 fix: Dragging blocks to update notes does not synchronize updates to the notes file in real time. close #2744 commit6897a22a3fAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 16:43:30 2021 +0800 fix: disable page/block auto-complete once the cursor went outside commitfeb4404874Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 13:28:47 2021 +0800 fix: wrong page metadata saved for another graph commitb96332122fAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 13:08:28 2021 +0800 enhance: catch errors when app quits commit1ee0c240c3Author: Jiang Hailong <gombiuda@gmail.com> Date: Wed Sep 1 20:54:13 2021 +0800 FIX: Linked reference is not refresh after file altering #2694 commit0550c8a876Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 12:25:39 2021 +0800 fix: display logbook for scheduled tasks commit2a5f0cee7cAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 12:21:19 2021 +0800 fix: spent hours for logbook commit1f2c9e4d3fAuthor: leizhe <lzhes43@gmail.com> Date: Sat Sep 4 12:59:09 2021 +0900 fix(timestamp): remove old SCHEDULED/DEADLINE timestamp When using `date-picker` to update the SCHEDULED/DEADLINE timestamp by clicking an existing one, logseq will add a new timestamp instead of updating the old one. This patch fixs this issue. commitcb23b967e4Author: leizhe <lzhes43@gmail.com> Date: Sat Sep 4 11:36:34 2021 +0900 fix(repeat): more consistent with orgmode style Ref: https://orgmode.org/manual/Tracking-your-habits.html commit229c7f2594Author: leizhe <lzhes43@gmail.com> Date: Sat Sep 4 15:11:07 2021 +0900 enhance(property): remove empty properties drawer commita76df9ce97Author: leizhe <lzhes43@gmail.com> Date: Sat Sep 4 10:27:30 2021 +0900 fix(clock): duplicate clock-in log twice 1. `set-marker` will not log time anymore. The time logging is moved to `with-timetracking` 2. Concat `logbook` only if `new-clocks` is nil, which fixs the duplication of clock-in log. commitc79e9f9e3eAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 12:04:16 2021 +0800 code: cleanup commit9ec85db09aAuthor: DarshanSudhakar <$K3Ug1i&> Date: Mon Sep 6 08:32:07 2021 +0530 Fixing typo for the tooltip 'Block reference' commiteec677873bAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 11:49:58 2021 +0800 enhance: page history support reverting back commit7273112a00Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 11:23:31 2021 +0800 git: revert back commitcd853b5864Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 10:39:08 2021 +0800 git: should compare ignored-files with disk content commita84dfb5effAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 10:31:16 2021 +0800 git: add ignore-files to avoid repeated notifications commit86577e7ebfAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 10:07:39 2021 +0800 fix: ignore permission denied error when git add all commit8dc0ca9ff5Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 09:54:03 2021 +0800 fix: run git config core.safecrlf false on windows commit9edaae559dAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 09:20:06 2021 +0800 refactor: extract file ops commitf12f58d3faAuthor: tiagodevezas <tiagodevezas@gmail.com> Date: Fri Sep 3 23:25:07 2021 +0100 fix typos commit9e82f0117cAuthor: tiagodevezas <tiagodevezas@gmail.com> Date: Fri Sep 3 21:32:03 2021 +0100 Translate shortcuts to Portuguese (pt-PT) commit9a2c17bb05Author: tiagodevezas <tiagodevezas@gmail.com> Date: Fri Sep 3 20:58:33 2021 +0100 Translate new settings to pt-PT commitc05034cc34Author: Sebastian Bensusan <sbensu@gmail.com> Date: Sat Sep 4 07:57:07 2021 -0700 feat(calc): Understand percentages commitbfe6a5d6cbAuthor: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 6 08:46:30 2021 +0800 enhance: commit the content in logseq when detecting any disk changes * improve(plugin): add install plugin api * fix(plugin): protected plugin installation api * improve(plugin): tweak readme display for local * fix: conflicts * fix(plugin): get block option with include children * improve(plugin): copy more marketplace manifest fields to plugin * fix: conflicts * improve(plugin): shortcut for copying plugin id * Squashed commit of the following: commite51ea54a75Author: Tienson Qin <tiensonqin@gmail.com> Date: Mon Sep 13 10:40:25 2021 +0800 fix: change ack timeout * fix(plugin): non blank icon string * fix: conflicts * fix: e name * fix: remove debug from state * chore(plugin): bump libs minor version Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
This commit is contained in:
@@ -10,14 +10,16 @@
|
||||
[frontend.state :as state]
|
||||
[medley.core :as md]
|
||||
[electron.ipc :as ipc]
|
||||
[reitit.frontend.easy :as rfe]
|
||||
[cljs-bean.core :as bean]
|
||||
[clojure.string :as string]
|
||||
[lambdaisland.glogi :as log]
|
||||
[frontend.components.svg :as svg]
|
||||
[frontend.format :as format]))
|
||||
|
||||
(defonce lsp-enabled?
|
||||
(and (util/electron?)
|
||||
(= (storage/get "developer-mode") "true")))
|
||||
(and (util/electron?)
|
||||
(= (storage/get "developer-mode") "true")))
|
||||
|
||||
(defn invoke-exported-api
|
||||
[type & args]
|
||||
@@ -26,6 +28,142 @@
|
||||
(catch js/Error e (js/console.error e))))
|
||||
|
||||
;; state handlers
|
||||
(defonce central-endpoint "https://raw.githubusercontent.com/logseq/marketplace/master/")
|
||||
(defonce plugins-url (str central-endpoint "plugins.json"))
|
||||
(defonce stats-url (str central-endpoint "stats.json"))
|
||||
(declare select-a-plugin-theme)
|
||||
|
||||
(defn gh-repo-url [repo]
|
||||
(str "https://github.com/" repo))
|
||||
|
||||
(defn pkg-asset [id asset]
|
||||
(if (and asset (string/starts-with? asset "http"))
|
||||
asset (if-let [asset (and asset (string/replace asset #"^[./]+" ""))]
|
||||
(str central-endpoint "packages/" id "/" asset))))
|
||||
|
||||
(defn load-marketplace-plugins
|
||||
[refresh?]
|
||||
(if (or refresh? (nil? (:plugin/marketplace-pkgs @state/state)))
|
||||
(p/create
|
||||
(fn [resolve reject]
|
||||
(-> (util/fetch plugins-url
|
||||
(fn [res]
|
||||
(let [pkgs (:packages res)]
|
||||
(state/set-state! :plugin/marketplace-pkgs pkgs)
|
||||
(resolve pkgs)))
|
||||
reject)
|
||||
(p/catch reject))))
|
||||
(p/resolved (:plugin/marketplace-pkgs @state/state))))
|
||||
|
||||
(defn load-marketplace-stats
|
||||
[refresh?]
|
||||
(if (or refresh? (nil? (:plugin/marketplace-stats @state/state)))
|
||||
(p/create
|
||||
(fn [resolve reject]
|
||||
(util/fetch stats-url
|
||||
(fn [res]
|
||||
(state/set-state! :plugin/marketplace-stats res)
|
||||
(resolve nil))
|
||||
reject)))
|
||||
(p/resolved nil)))
|
||||
|
||||
(defn installed?
|
||||
[id]
|
||||
(and (contains? (:plugin/installed-plugins @state/state) (keyword id))
|
||||
(get-in @state/state [:plugin/installed-plugins (keyword id) :iir])))
|
||||
|
||||
(defn install-marketplace-plugin
|
||||
[{:keys [repo id] :as mft}]
|
||||
(when-not (and (:plugin/installing @state/state)
|
||||
(installed? id))
|
||||
(p/create
|
||||
(fn [resolve]
|
||||
(state/set-state! :plugin/installing mft)
|
||||
(ipc/ipc "installMarketPlugin" mft)
|
||||
(resolve id)))))
|
||||
|
||||
(defn update-marketplace-plugin
|
||||
[{:keys [id] :as pkg} error-handler]
|
||||
(when-not (and (:plugin/installing @state/state)
|
||||
(not (installed? id)))
|
||||
(p/catch
|
||||
(p/then
|
||||
(do (state/set-state! :plugin/installing pkg)
|
||||
(load-marketplace-plugins false))
|
||||
(fn [mfts]
|
||||
(if-let [mft (some #(if (= (:id %) id) %) mfts)]
|
||||
(do
|
||||
(ipc/ipc "updateMarketPlugin" (merge (dissoc pkg :logger) mft)))
|
||||
(throw (js/Error. (str ":central-not-matched " id))))
|
||||
true))
|
||||
|
||||
(fn [^js e]
|
||||
(error-handler "Update Error: remote error")
|
||||
(state/set-state! :plugin/installing nil)
|
||||
(js/console.error e)))))
|
||||
|
||||
(defn get-plugin-inst
|
||||
[id]
|
||||
(try
|
||||
(js/LSPluginCore.ensurePlugin id)
|
||||
(catch js/Error e
|
||||
nil)))
|
||||
|
||||
(defn setup-install-listener!
|
||||
[t]
|
||||
(let [channel (name :lsp-installed)
|
||||
listener (fn [^js _ ^js e]
|
||||
(js/console.debug :lsp-installed e)
|
||||
|
||||
(when-let [{:keys [status payload]} (bean/->clj e)]
|
||||
(case (keyword status)
|
||||
|
||||
:completed
|
||||
(let [{:keys [id dst name title version theme]} payload
|
||||
name (or title name "Untitled")]
|
||||
(if (installed? id)
|
||||
(when-let [^js pl (get-plugin-inst id)] ;; update
|
||||
(p/then
|
||||
(.reload pl)
|
||||
#(do
|
||||
(if theme (select-a-plugin-theme id))
|
||||
(notifications/show!
|
||||
(str (t :plugin/update) (t :plugins) ": " name " - " (.-version (.-options pl))) :success))))
|
||||
|
||||
(do ;; register new
|
||||
(p/then
|
||||
(js/LSPluginCore.register (bean/->js {:key id :url dst}))
|
||||
(fn [] (if theme (js/setTimeout #(select-a-plugin-theme id) 300))))
|
||||
(notifications/show!
|
||||
(str (t :plugin/installed) (t :plugins) ": " name) :success))))
|
||||
|
||||
:error
|
||||
(let [[msg type] (case (keyword (string/replace payload #"^[\s\:]+" ""))
|
||||
|
||||
:no-new-version
|
||||
[(str (t :plugin/up-to-date) " :)") :success]
|
||||
|
||||
[payload :error])]
|
||||
|
||||
(notifications/show!
|
||||
(str
|
||||
(if (= :error type) "[Install Error]" "")
|
||||
msg) type)
|
||||
|
||||
(js/console.error payload))
|
||||
|
||||
:dunno))
|
||||
|
||||
;; reset
|
||||
(state/set-state! :plugin/installing nil)
|
||||
true)]
|
||||
|
||||
(js/window.apis.addListener channel listener)
|
||||
|
||||
;; clear
|
||||
(fn []
|
||||
(js/window.apis.removeAllListeners channel))))
|
||||
|
||||
(defn register-plugin
|
||||
[pl]
|
||||
(swap! state/state update-in [:plugin/installed-plugins] assoc (keyword (:id pl)) pl))
|
||||
@@ -75,6 +213,18 @@
|
||||
[pid]
|
||||
(swap! state/state assoc-in [:plugin/installed-ui-items (keyword pid)] []))
|
||||
|
||||
(defn unregister-plugin-themes
|
||||
[pid]
|
||||
(js/LSPluginCore.unregisterTheme pid))
|
||||
|
||||
(defn select-a-plugin-theme
|
||||
[pid]
|
||||
(when-let [themes (get (group-by :pid (:plugin/installed-themes @state/state)) pid)]
|
||||
(when-let [theme (first themes)]
|
||||
(let [theme-mode (:mode theme)]
|
||||
(and theme-mode (state/set-theme! (if (= theme-mode "light") "white" theme-mode)))
|
||||
(js/LSPluginCore.selectTheme (bean/->js theme))))))
|
||||
|
||||
(defn update-plugin-settings
|
||||
[id settings]
|
||||
(swap! state/state update-in [:plugin/installed-plugins id] assoc :settings settings))
|
||||
@@ -85,11 +235,11 @@
|
||||
(when-not (string/blank? content)
|
||||
(let [content (if-not (string/blank? url)
|
||||
(string/replace
|
||||
content #"!\[[^\]]*\]\((.*?)\s*(\"(?:.*[^\"])\")?\s*\)"
|
||||
(fn [[matched link]]
|
||||
(if (and link (not (string/starts-with? link "http")))
|
||||
(string/replace matched link (util/node-path.join url link))
|
||||
matched)))
|
||||
content #"!\[[^\]]*\]\((.*?)\s*(\"(?:.*[^\"])\")?\s*\)"
|
||||
(fn [[matched link]]
|
||||
(if (and link (not (string/starts-with? link "http")))
|
||||
(string/replace matched link (util/node-path.join url link))
|
||||
matched)))
|
||||
content)]
|
||||
(format/to-html content :markdown (mldoc/default-config :markdown))))
|
||||
(catch js/Error e
|
||||
@@ -98,14 +248,18 @@
|
||||
|
||||
(defn open-readme!
|
||||
[url item display]
|
||||
(when url
|
||||
(-> (p/let [content (invoke-exported-api "load_plugin_readme" url)
|
||||
content (parse-user-md-content content item)]
|
||||
(and (string/blank? (string/trim content)) (throw nil))
|
||||
(state/set-state! :plugin/active-readme [content item])
|
||||
(state/set-modal! display))
|
||||
(p/catch #(do (js/console.warn %)
|
||||
(notifications/show! "No README content." :warn))))))
|
||||
(let [repo (:repo item)]
|
||||
(if (nil? repo)
|
||||
;; local
|
||||
(-> (p/let [content (invoke-exported-api "load_plugin_readme" url)
|
||||
content (parse-user-md-content content item)]
|
||||
(and (string/blank? (string/trim content)) (throw nil))
|
||||
(state/set-state! :plugin/active-readme [content item])
|
||||
(state/set-modal! (fn [_] (display))))
|
||||
(p/catch #(do (js/console.warn %)
|
||||
(notifications/show! "No README content." :warn))))
|
||||
;; market
|
||||
(state/set-modal! (fn [_] (display repo nil))))))
|
||||
|
||||
(defn load-unpacked-plugin
|
||||
[]
|
||||
@@ -141,93 +295,107 @@
|
||||
[]
|
||||
(ipc/ipc "getLogseqDotDirRoot"))
|
||||
|
||||
(defn show-themes-modal!
|
||||
[]
|
||||
(state/pub-event! [:modal/show-themes-modal]))
|
||||
|
||||
(defn goto-plugins-dashboard!
|
||||
[]
|
||||
(rfe/push-state :plugins))
|
||||
|
||||
(defn- get-user-default-plugins
|
||||
[]
|
||||
(p/catch
|
||||
(p/let [files ^js (ipc/ipc "getUserDefaultPlugins")
|
||||
files (js->clj files)]
|
||||
(map #(hash-map :url %) files))
|
||||
(fn [e]
|
||||
(js/console.error e))))
|
||||
(p/let [files ^js (ipc/ipc "getUserDefaultPlugins")
|
||||
files (js->clj files)]
|
||||
(map #(hash-map :url %) files))
|
||||
(fn [e]
|
||||
(js/console.error e))))
|
||||
|
||||
;; components
|
||||
(rum/defc lsp-indicator < rum/reactive
|
||||
[]
|
||||
(let [text (state/sub :plugin/indicator-text)]
|
||||
(if (= text "END")
|
||||
[:span]
|
||||
[:div
|
||||
{:style
|
||||
{:width "100%"
|
||||
:height "100vh"
|
||||
:display "flex"
|
||||
:align-items "center"
|
||||
:justify-content "center"}}
|
||||
[:span
|
||||
{:style
|
||||
{:color "#aaa"
|
||||
:font-size "38px"}} (or text "Loading ...")]])))
|
||||
(if-not (= text "END")
|
||||
[:div.flex.align-items.justify-center.h-screen.w-full
|
||||
[:span.flex.items-center.justify-center.w-60.flex-col
|
||||
[:small.scale-250.opacity-70.mb-10.animate-pulse (svg/logo false)]
|
||||
[:small.block.text-sm.relative.opacity-50 {:style {:right "-8px"}} text]]])))
|
||||
|
||||
(defn init-plugins
|
||||
(defn init-plugins!
|
||||
[callback]
|
||||
|
||||
(let [el (js/document.createElement "div")]
|
||||
(.appendChild js/document.body el)
|
||||
(rum/mount
|
||||
(lsp-indicator) el))
|
||||
(lsp-indicator) el))
|
||||
|
||||
(state/set-state! :plugin/indicator-text "Loading...")
|
||||
(state/set-state! :plugin/indicator-text "LOADING")
|
||||
|
||||
(p/then
|
||||
(p/let [root (get-ls-dotdir-root)
|
||||
_ (.setupPluginCore js/LSPlugin (bean/->js {:localUserConfigRoot root :dotConfigRoot root}))
|
||||
_ (doto js/LSPluginCore
|
||||
(.on "registered"
|
||||
(fn [^js pl]
|
||||
(register-plugin
|
||||
(bean/->clj (.parse js/JSON (.stringify js/JSON pl))))))
|
||||
(p/let [root (get-ls-dotdir-root)
|
||||
_ (.setupPluginCore js/LSPlugin (bean/->js {:localUserConfigRoot root :dotConfigRoot root}))
|
||||
_ (doto js/LSPluginCore
|
||||
(.on "registered"
|
||||
(fn [^js pl]
|
||||
(register-plugin
|
||||
(bean/->clj (.parse js/JSON (.stringify js/JSON pl))))))
|
||||
|
||||
(.on "unregistered" (fn [pid]
|
||||
(let [pid (keyword pid)]
|
||||
(.on "reloaded"
|
||||
(fn [^js pl]
|
||||
(register-plugin
|
||||
(bean/->clj (.parse js/JSON (.stringify js/JSON pl))))))
|
||||
|
||||
(.on "unregistered" (fn [pid]
|
||||
(let [pid (keyword pid)]
|
||||
;; effects
|
||||
(unregister-plugin-themes (name pid))
|
||||
;; plugins
|
||||
(swap! state/state md/dissoc-in [:plugin/installed-plugins (keyword pid)])
|
||||
(swap! state/state md/dissoc-in [:plugin/installed-plugins pid])
|
||||
;; commands
|
||||
(unregister-plugin-slash-command pid)
|
||||
(unregister-plugin-simple-command pid)
|
||||
(unregister-plugin-ui-items pid))))
|
||||
(unregister-plugin-slash-command pid)
|
||||
(unregister-plugin-simple-command pid)
|
||||
(unregister-plugin-ui-items pid))))
|
||||
|
||||
(.on "disabled" (fn [pid]
|
||||
(unregister-plugin-slash-command pid)
|
||||
(unregister-plugin-simple-command pid)
|
||||
(unregister-plugin-ui-items pid)))
|
||||
(.on "unlink-plugin" (fn [pid]
|
||||
(let [pid (keyword pid)]
|
||||
(ipc/ipc "uninstallMarketPlugin" (name pid)))))
|
||||
|
||||
(.on "theme-changed" (fn [^js themes]
|
||||
(swap! state/state assoc :plugin/installed-themes
|
||||
(vec (mapcat (fn [[_ vs]] (bean/->clj vs)) (bean/->clj themes))))))
|
||||
(.on "disabled" (fn [pid]
|
||||
;; effects
|
||||
(unregister-plugin-themes pid)
|
||||
;; commands
|
||||
(unregister-plugin-slash-command pid)
|
||||
(unregister-plugin-simple-command pid)
|
||||
(unregister-plugin-ui-items pid)))
|
||||
|
||||
(.on "theme-selected" (fn [^js opts]
|
||||
(let [opts (bean/->clj opts)
|
||||
url (:url opts)
|
||||
mode (:mode opts)]
|
||||
(when mode (state/set-theme! mode))
|
||||
(state/set-state! :plugin/selected-theme url))))
|
||||
(.on "theme-changed" (fn [^js themes]
|
||||
(swap! state/state assoc :plugin/installed-themes
|
||||
(vec (mapcat (fn [[pid vs]] (mapv #(assoc % :pid pid) (bean/->clj vs))) (bean/->clj themes))))))
|
||||
|
||||
(.on "settings-changed" (fn [id ^js settings]
|
||||
(let [id (keyword id)]
|
||||
(when (and settings
|
||||
(contains? (:plugin/installed-plugins @state/state) id))
|
||||
(update-plugin-settings id (bean/->clj settings)))))))
|
||||
(.on "theme-selected" (fn [^js opts]
|
||||
(let [opts (bean/->clj opts)
|
||||
url (:url opts)
|
||||
mode (:mode opts)]
|
||||
(when mode (state/set-theme! mode))
|
||||
(state/set-state! :plugin/selected-theme url))))
|
||||
|
||||
default-plugins (get-user-default-plugins)
|
||||
(.on "settings-changed" (fn [id ^js settings]
|
||||
(let [id (keyword id)]
|
||||
(when (and settings
|
||||
(contains? (:plugin/installed-plugins @state/state) id))
|
||||
(update-plugin-settings id (bean/->clj settings)))))))
|
||||
|
||||
_ (.register js/LSPluginCore (bean/->js (if (seq default-plugins) default-plugins [])) true)])
|
||||
#(do
|
||||
(state/set-state! :plugin/indicator-text "END")
|
||||
(callback))))
|
||||
default-plugins (get-user-default-plugins)
|
||||
|
||||
_ (.register js/LSPluginCore (bean/->js (if (seq default-plugins) default-plugins [])) true)])
|
||||
#(do
|
||||
(state/set-state! :plugin/indicator-text "END")
|
||||
(callback))))
|
||||
|
||||
(defn setup!
|
||||
"setup plugin core handler"
|
||||
[callback]
|
||||
(if (not lsp-enabled?)
|
||||
(callback)
|
||||
(init-plugins callback)))
|
||||
(init-plugins! callback)))
|
||||
|
||||
Reference in New Issue
Block a user