Browse Source

improve(plugin): update types

charlie 3 years ago
parent
commit
7bd32fb911
3 changed files with 10 additions and 3 deletions
  1. 6 2
      libs/src/LSPlugin.user.ts
  2. 3 0
      libs/src/callable.apis.ts
  3. 1 1
      src/main/frontend/components/page.cljs

+ 6 - 2
libs/src/LSPlugin.user.ts

@@ -5,6 +5,7 @@ import {
   safetyPathJoin,
 } from './helpers'
 import { LSPluginCaller } from './LSPlugin.caller'
+import * as callableAPIs from './callable.apis'
 import {
   IAppProxy,
   IDBProxy,
@@ -48,6 +49,9 @@ declare global {
   }
 }
 
+type callableMethods =
+  keyof typeof callableAPIs | string // host exported SDK apis & host platform related apis
+
 const PROXY_CONTINUE = Symbol.for('proxy-continue')
 const debug = Debug('LSPlugin:user')
 
@@ -623,14 +627,14 @@ export class LSPluginUser
     })
   }
 
-  _execCallableAPIAsync(method, ...args) {
+  _execCallableAPIAsync(method: callableMethods, ...args) {
     return this._caller.callAsync(`api:call`, {
       method,
       args,
     })
   }
 
-  _execCallableAPI(method, ...args) {
+  _execCallableAPI(method: callableMethods, ...args) {
     this._caller.call(`api:call`, {
       method,
       args,

+ 3 - 0
libs/src/callable.apis.ts

@@ -1,5 +1,8 @@
 import { PluginLocal } from './LSPlugin.core'
 
+/**
+ * Run in host
+ */
 export function setSDKMetadata(this: PluginLocal, data: any) {
   if (this?.sdk && data) {
     this.sdk = Object.assign({}, this.sdk, data)

+ 1 - 1
src/main/frontend/components/page.cljs

@@ -91,7 +91,7 @@
       [:div.flex.flex-row.items-center.mr-2.ml-1 {:style {:height 24}}
        [:span.bullet-container.cursor
         [:span.bullet]]]
-      [:div.flex.flex-1 {:tabindex 0
+      [:div.flex.flex-1 {:tabIndex 0
                          :on-key-press (fn [e]
                                          (when (= "Enter" (util/ekey e))
                                            (handler-fn)))