Skip to content

Commit a5f13c4

Browse files
committed
Upgrade plugin api
1 parent cb9540e commit a5f13c4

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "wox-plugin-emoji",
3-
"version": "0.0.1",
43
"scripts": {
54
"build": "pnpm clean && ncc build src/index.ts -o dist && babel dist --out-dir dist && cp -r images dist && cp -r plugin.json dist && cp -r node_modules/clipboardy/fallbacks dist",
65
"package": "pnpm build && cd dist && zip -r ../Wox.Plugin.Emoji.wox *.js *.json images",
@@ -24,7 +23,7 @@
2423
"typescript": "^5.2.2"
2524
},
2625
"dependencies": {
27-
"@wox-launcher/wox-plugin": "^0.0.57",
26+
"@wox-launcher/wox-plugin": "^0.0.63",
2827
"clipboardy": "^4.0.0",
2928
"emojilib": "^3.0.11"
3029
}

plugin.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"Name": "Emoji",
77
"Description": "Search emoji",
88
"Author": "Wox-Launcher",
9-
"Version": "0.0.1",
9+
"Version": "0.0.2",
1010
"MinWoxVersion": "2.0.0",
1111
"Runtime": "nodejs",
1212
"Website": "https://github.com/Wox-launcher/Wox.Plugin.Emoji",

pnpm-lock.yaml

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
import type { Plugin, PluginInitContext, Query, Result } from "@wox-launcher/wox-plugin"
1+
import { Context, Plugin, PluginInitParams, PublicAPI, Query, Result } from "@wox-launcher/wox-plugin"
22
import emoji from "emojilib"
33
import clipboard from "clipboardy"
44

5+
let api: PublicAPI
6+
57
export const plugin: Plugin = {
6-
init: async (context: PluginInitContext) => {},
8+
init: async (ctx: Context, initParams: PluginInitParams) => {
9+
api = initParams.API
10+
await api.Log(ctx, "Debug", `init, directory:${initParams.PluginDirectory}`)
11+
},
712

8-
query: async (query: Query): Promise<Result[]> => {
13+
query: async (ctx: Context, query: Query): Promise<Result[]> => {
914
let search = query.Search
1015
if (query.Search === "") {
16+
await api.Log(ctx, "Debug", "empty search, use default search")
1117
search = "smile"
1218
}
1319

1420
return Object.keys(emoji)
1521
.filter(key => {
22+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1623
// @ts-ignore
1724
const emojiData = emoji[key] as string[]
1825
return emojiData.some((keyword: string) => {
@@ -21,6 +28,7 @@ export const plugin: Plugin = {
2128
})
2229
.map(key => {
2330
return {
31+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2432
// @ts-ignore
2533
Title: (emoji[key][0] as string).replace(/_/g, " "),
2634
Icon: {

0 commit comments

Comments
 (0)