Browse Source

dev: suppress message

Junyi Du 2 years ago
parent
commit
a4bd83701e
3 changed files with 11 additions and 5 deletions
  1. 4 1
      libs/CHANGELOG.md
  2. 7 3
      src/main/frontend/ai/text_encoder.cljs
  3. 0 1
      src/main/logseq/api.cljs

+ 4 - 1
libs/CHANGELOG.md

@@ -59,6 +59,8 @@ All notable changes to this project will be documented in this file.
   `Experiments.registerExtensionsEnhancer<T = any>(type: 'katex' | 'codemirror', enhancer: (v: T) => Promise<any>)`
   `Experiments.registerExtensionsEnhancer<T = any>(type: 'katex' | 'codemirror', enhancer: (v: T) => Promise<any>)`
 - Support hooks for app search service. _#Alpha stage_
 - Support hooks for app search service. _#Alpha stage_
   `App.registerSearchService<T extends IPluginSearchServiceHooks>(s: T): void`
   `App.registerSearchService<T extends IPluginSearchServiceHooks>(s: T): void`
+- Support hooks for text encoder service. _#Alpha stage_
+  `App.registerTextEncoderService<T extends IPluginTextEncoderServiceHooks>(s: T): void`
 - Support `focus` option for `App.insertBlock`. Credit
 - Support `focus` option for `App.insertBlock`. Credit
   to [[[tennox](https://github.com/tennox)]] [#PR](https://github.com/logseq/logseq/commit/4217057a44de65e5c64be37857af2fb4e9534b24)
   to [[[tennox](https://github.com/tennox)]] [#PR](https://github.com/logseq/logseq/commit/4217057a44de65e5c64be37857af2fb4e9534b24)
 
 
@@ -66,4 +68,5 @@ All notable changes to this project will be documented in this file.
 
 
 - Adjust build script to be compatible for `shadow-cljs` bundler.
 - Adjust build script to be compatible for `shadow-cljs` bundler.
   > How to set up a clojurescript project with shadow-cljs?
   > How to set up a clojurescript project with shadow-cljs?
-  > https://github.com/rlhk/logseq-url-plus/blob/main/doc/dev-notes.md
+  > https://github.com/rlhk/logseq-url-plus/blob/main/doc/dev-notes.md
+  

+ 7 - 3
src/main/frontend/ai/text_encoder.cljs

@@ -3,7 +3,8 @@
   (:require [promesa.core :as p]
   (:require [promesa.core :as p]
             [frontend.state :as state]
             [frontend.state :as state]
             [frontend.handler.plugin :as plugin-handler]
             [frontend.handler.plugin :as plugin-handler]
-            [cljs-bean.core :as bean]))
+            [cljs-bean.core :as bean]
+            [lambdaisland.glogi :as log]))
 
 
 (defn- call-service!
 (defn- call-service!
   "Handling communication with text encoder plugin
   "Handling communication with text encoder plugin
@@ -21,14 +22,17 @@
                             (fn [^js e]
                             (fn [^js e]
                               (resolve (bean/->clj e))))))
                               (resolve (bean/->clj e))))))
              (p/timeout 20000)
              (p/timeout 20000)
-             (p/catch #(prn "Timeout waiting reply from text encoder service" hookEvent %))))))))
+             (p/catch #(log/error :ai-text-encoder/encode-text-timeout {:message "Timeout waiting reply from text encoder service" 
+                                                                        :hookEvent hookEvent 
+                                                                        :error %}))))))))
 
 
 (defn- text-encode'
 (defn- text-encode'
   [text service]
   [text service]
   (call-service! service "textEncoder:textEncode" {:text text} true))
   (call-service! service "textEncoder:textEncode" {:text text} true))
 
 
 (defn text-encode
 (defn text-encode
-  "Return a promise of the encoded text"
+  "Return a promise of the encoded text
+   Or return nil if no matching text encoder available"
   ([text]
   ([text]
    (text-encode' text (when state/lsp-enabled?
    (text-encode' text (when state/lsp-enabled?
                         (->> (state/get-all-plugin-services-with-type :text-encoder)
                         (->> (state/get-all-plugin-services-with-type :text-encoder)

+ 0 - 1
src/main/logseq/api.cljs

@@ -398,7 +398,6 @@
 
 
 (defn ^:export register_text_encoder_service
 (defn ^:export register_text_encoder_service
   [pid name ^js opts]
   [pid name ^js opts]
-  (prn "register_text_encoder_service") ;; TODO Junyi
   (plugin-handler/register-plugin-text-encoder pid name (bean/->clj opts)))
   (plugin-handler/register-plugin-text-encoder pid name (bean/->clj opts)))
 
 
 (defn ^:export unregister_text_encoder_services
 (defn ^:export unregister_text_encoder_services