瀏覽代碼

refactor(plugin): names

charlie 10 月之前
父節點
當前提交
208ca930eb

+ 0 - 1
libs/src/LSPlugin.core.ts

@@ -591,7 +591,6 @@ class PluginLocal extends EventEmitter<
     this._options.icon = icon && this._resolveResourceFullUrl(icon)
     this._options.theme = Boolean(logseq.theme || !!logseq.themes)
 
-    // TODO: strategy for Logseq plugins center
     if (this.isInstalledInDotRoot) {
       this._id = path.basename(localRoot)
     } else if (!this.isWebPlugin) {

+ 2 - 2
src/electron/electron/handler.cljs

@@ -467,8 +467,8 @@
   nil)
 
 
-(defmethod handle :installMarketPlugin [_ [_ mft]]
-  (plugin/install-or-update! mft))
+(defmethod handle :installMarketPlugin [_ [_ manifest]]
+  (plugin/install-or-update! manifest))
 
 (defmethod handle :updateMarketPlugin [_ [_ pkg]]
   (plugin/install-or-update! pkg))

+ 10 - 10
src/main/frontend/handler/common/plugin.cljs

@@ -37,34 +37,34 @@
   (js/window.apis.emit (name :lsp-updates) (bean/->js payload)))
 
 (defn async-install-or-update-for-web!
-  [{:keys [version repo only-check _plugin-action] :as mft}]
-  (js/console.log "debug:install-or-update" mft)
+  [{:keys [version repo only-check _plugin-action] :as manifest}]
+  (js/console.log "debug:install-or-update" manifest)
   (-> (fetch-web-plugin-entry-info repo version)
     (p/then (fn [{:keys [_version] :as web-pkg}]
-             (let [web-pkg (merge web-pkg (dissoc mft :stat))]
+             (let [web-pkg (merge web-pkg (dissoc manifest :stat))]
               (emit-lsp-updates!
                {:status     :completed
                 :only-check only-check
                 :payload    (if only-check
-                             (assoc mft :latest-version version :latest-notes "TODO: update notes")
-                             (assoc mft :dst repo :installed-version version :web-pkg web-pkg))}))))
+                             (assoc manifest :latest-version version :latest-notes "TODO: update notes")
+                             (assoc manifest :dst repo :installed-version version :web-pkg web-pkg))}))))
     (p/catch (fn [^js e]
                (emit-lsp-updates!
                  {:status :error
                   :only-check only-check
-                  :payload (assoc mft :error-code (.-message e))})))))
+                  :payload (assoc manifest :error-code (.-message e))})))))
 
 (defn install-marketplace-plugin!
   "Installs plugin given plugin map with id"
-  [{:keys [id] :as mft}]
+  [{:keys [id] :as manifest}]
   (when-not (and (:plugin/installing @state/state)
                  (installed? id))
     (p/create
      (fn [resolve]
-       (state/set-state! :plugin/installing mft)
+       (state/set-state! :plugin/installing manifest)
        (if (util/electron?)
-         (ipc/ipc :installMarketPlugin mft)
-         (async-install-or-update-for-web! mft))
+         (ipc/ipc :installMarketPlugin manifest)
+         (async-install-or-update-for-web! manifest))
        (resolve id)))))
 
 (defn unregister-plugin

+ 2 - 2
src/main/frontend/handler/plugin.cljs

@@ -143,8 +143,8 @@
     (state/set-state! :plugin/installing pkg)
 
     (-> (load-marketplace-plugins false)
-      (p/then (fn [mfts]
-                (let [mft (some #(when (= (:id %) id) %) mfts)]
+      (p/then (fn [manifests]
+                (let [mft (some #(when (= (:id %) id) %) manifests)]
                   ;;TODO: (throw (js/Error. [:not-found-in-marketplace id]))
                   (ipc/ipc :updateMarketPlugin (merge (dissoc pkg :logger) mft)))
                 true))

+ 2 - 2
src/main/logseq/api.cljs

@@ -1047,10 +1047,10 @@
 
 (def ^:export __install_plugin
   (fn [^js manifest]
-    (when-let [{:keys [repo id] :as mft} (bean/->clj manifest)]
+    (when-let [{:keys [repo id] :as manifest} (bean/->clj manifest)]
       (if-not (and repo id)
         (throw (js/Error. "[required] :repo :id"))
-        (plugin-common-handler/install-marketplace-plugin! mft)))))
+        (plugin-common-handler/install-marketplace-plugin! manifest)))))
 
 ;; db
 (defn ^:export q