Skip to content

Commit

Permalink
improve(plugin): update types
Browse files Browse the repository at this point in the history
  • Loading branch information
xyhp915 authored and andelf committed Aug 8, 2022
1 parent 1665058 commit 7bd32fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions libs/src/LSPlugin.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
safetyPathJoin,
} from './helpers'
import { LSPluginCaller } from './LSPlugin.caller'
import * as callableAPIs from './callable.apis'
import {
IAppProxy,
IDBProxy,
Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions libs/src/callable.apis.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/components/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 7bd32fb

Please sign in to comment.