@wox-launcher/wox-plugin 0.0.78 → 0.0.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/types/index.d.ts +198 -191
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,246 +1,253 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {MetadataCommand, PluginSettingDefinitionItem} from "./setting.js"
|
|
2
|
+
import {AI} from "./ai.js"
|
|
3
3
|
|
|
4
4
|
export type MapString = { [key: string]: string }
|
|
5
5
|
|
|
6
6
|
export type Platform = "windows" | "darwin" | "linux"
|
|
7
7
|
|
|
8
8
|
export interface Plugin {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
init: (ctx: Context, initParams: PluginInitParams) => Promise<void>
|
|
10
|
+
query: (ctx: Context, query: Query) => Promise<Result[]>
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface Selection {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
Type: "text" | "file"
|
|
15
|
+
// Only available when Type is text
|
|
16
|
+
Text: string
|
|
17
|
+
// Only available when Type is file
|
|
18
|
+
FilePaths: string[]
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface QueryEnv {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Active window title when user query
|
|
24
|
+
*/
|
|
25
|
+
ActiveWindowTitle: string
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface Query {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
29
|
+
/**
|
|
30
|
+
* By default, Wox will only pass input query to plugin.
|
|
31
|
+
* plugin author need to enable MetadataFeatureQuerySelection feature to handle selection query
|
|
32
|
+
*/
|
|
33
|
+
Type: "input" | "selection"
|
|
34
|
+
/**
|
|
35
|
+
* Raw query, this includes trigger keyword if it has
|
|
36
|
+
* We didn't recommend use this property directly. You should always use Search property.
|
|
37
|
+
*
|
|
38
|
+
* NOTE: Only available when query type is input
|
|
39
|
+
*/
|
|
40
|
+
RawQuery: string
|
|
41
|
+
/**
|
|
42
|
+
* Trigger keyword of a query. It can be empty if user is using global trigger keyword.
|
|
43
|
+
*
|
|
44
|
+
* NOTE: Only available when query type is input
|
|
45
|
+
*/
|
|
46
|
+
TriggerKeyword?: string
|
|
47
|
+
/**
|
|
48
|
+
* Command part of a query.
|
|
49
|
+
*
|
|
50
|
+
* NOTE: Only available when query type is input
|
|
51
|
+
*/
|
|
52
|
+
Command?: string
|
|
53
|
+
/**
|
|
54
|
+
* Search part of a query.
|
|
55
|
+
*
|
|
56
|
+
* NOTE: Only available when query type is input
|
|
57
|
+
*/
|
|
58
|
+
Search: string
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* User selected or drag-drop data, can be text or file or image etc
|
|
62
|
+
*
|
|
63
|
+
* NOTE: Only available when query type is selection
|
|
64
|
+
*/
|
|
65
|
+
Selection: Selection
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Additional query environment data
|
|
69
|
+
* expose more context env data to plugin, E.g. plugin A only show result when active window title is "Chrome"
|
|
70
|
+
*/
|
|
71
|
+
Env: QueryEnv
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether current query is global query
|
|
75
|
+
*/
|
|
76
|
+
IsGlobalQuery(): boolean
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export interface Result {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
Id?: string
|
|
81
|
+
Title: string
|
|
82
|
+
SubTitle?: string
|
|
83
|
+
Icon: WoxImage
|
|
84
|
+
Preview?: WoxPreview
|
|
85
|
+
Score?: number
|
|
86
|
+
Group?: string
|
|
87
|
+
GroupScore?: number
|
|
88
|
+
Tails?: ResultTail[]
|
|
89
|
+
ContextData?: string
|
|
90
|
+
Actions?: ResultAction[]
|
|
91
|
+
// refresh result after specified interval, in milliseconds. If this value is 0, Wox will not refresh this result
|
|
92
|
+
// interval can only divisible by 100, if not, Wox will use the nearest number which is divisible by 100
|
|
93
|
+
// E.g. if you set 123, Wox will use 200, if you set 1234, Wox will use 1300
|
|
94
|
+
RefreshInterval?: number
|
|
95
|
+
// refresh result by calling OnRefresh function
|
|
96
|
+
OnRefresh?: (current: RefreshableResult) => Promise<RefreshableResult>
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export interface ResultTail {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
Type: "text" | "image"
|
|
101
|
+
Text?: string
|
|
102
|
+
Image?: WoxImage
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export interface RefreshableResult {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
Title: string
|
|
107
|
+
SubTitle: string
|
|
108
|
+
Icon: WoxImage
|
|
109
|
+
Preview: WoxPreview
|
|
110
|
+
ContextData: string
|
|
111
|
+
RefreshInterval: number
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export interface ResultAction {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Result id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you
|
|
117
|
+
*/
|
|
118
|
+
Id?: string
|
|
119
|
+
Name: string
|
|
120
|
+
Icon?: WoxImage
|
|
121
|
+
/**
|
|
122
|
+
* If true, Wox will use this action as default action. There can be only one default action in results
|
|
123
|
+
* This can be omitted, if you don't set it, Wox will use the first action as default action
|
|
124
|
+
*/
|
|
125
|
+
IsDefault?: boolean
|
|
126
|
+
/**
|
|
127
|
+
* If true, Wox will not hide after user select this result
|
|
128
|
+
*/
|
|
129
|
+
PreventHideAfterAction?: boolean
|
|
130
|
+
Action: (actionContext: ActionContext) => Promise<void>
|
|
131
|
+
/**
|
|
132
|
+
* Hotkey to trigger this action. E.g. "ctrl+Shift+Space", "Ctrl+1", "Command+K"
|
|
133
|
+
* Case insensitive, space insensitive
|
|
134
|
+
*
|
|
135
|
+
* If IsDefault is true, Hotkey will be set to enter key by default
|
|
136
|
+
*/
|
|
137
|
+
Hotkey?: string
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
export interface ActionContext {
|
|
134
|
-
|
|
141
|
+
ContextData: string
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
export interface PluginInitParams {
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
API: PublicAPI
|
|
146
|
+
PluginDirectory: string
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
export interface ChangeQueryParam {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
QueryType: "input" | "selection"
|
|
151
|
+
QueryText?: string
|
|
152
|
+
QuerySelection?: Selection
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
export interface PublicAPI {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Change Wox query
|
|
158
|
+
*/
|
|
159
|
+
ChangeQuery: (ctx: Context, query: ChangeQueryParam) => Promise<void>
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Hide Wox
|
|
163
|
+
*/
|
|
164
|
+
HideApp: (ctx: Context) => Promise<void>
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Show Wox
|
|
168
|
+
*/
|
|
169
|
+
ShowApp: (ctx: Context) => Promise<void>
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Notify message
|
|
173
|
+
*/
|
|
174
|
+
Notify: (ctx: Context, title: string, description?: string) => Promise<void>
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Write log
|
|
178
|
+
*/
|
|
179
|
+
Log: (ctx: Context, level: "Info" | "Error" | "Debug" | "Warning", msg: string) => Promise<void>
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get translation of current language
|
|
183
|
+
*/
|
|
184
|
+
GetTranslation: (ctx: Context, key: string) => Promise<string>
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Get customized setting
|
|
188
|
+
*
|
|
189
|
+
* will try to get platform specific setting first, if not found, will try to get global setting
|
|
190
|
+
*/
|
|
191
|
+
GetSetting: (ctx: Context, key: string) => Promise<string>
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Save customized setting
|
|
195
|
+
*
|
|
196
|
+
* @isPlatformSpecific If true, setting will be only saved in current platform. If false, setting will be available in all platforms
|
|
197
|
+
*/
|
|
198
|
+
SaveSetting: (ctx: Context, key: string, value: string, isPlatformSpecific: boolean) => Promise<void>
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Register setting changed callback
|
|
202
|
+
*/
|
|
203
|
+
OnSettingChanged: (ctx: Context, callback: (key: string, value: string) => void) => Promise<void>
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Get dynamic setting definition
|
|
207
|
+
*/
|
|
208
|
+
OnGetDynamicSetting: (ctx: Context, callback: (key: string) => PluginSettingDefinitionItem) => Promise<void>
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Register deep link callback
|
|
212
|
+
*/
|
|
213
|
+
OnDeepLink: (ctx: Context, callback: (arguments: MapString) => void) => Promise<void>
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Register on load event
|
|
217
|
+
*/
|
|
218
|
+
OnUnload: (ctx: Context, callback: () => Promise<void>) => Promise<void>
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Register query commands
|
|
222
|
+
*/
|
|
223
|
+
RegisterQueryCommands: (ctx: Context, commands: MetadataCommand[]) => Promise<void>
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Chat using LLM
|
|
227
|
+
*/
|
|
228
|
+
LLMStream: (ctx: Context, conversations: AI.Conversation[], callback: AI.ChatStreamFunc) => Promise<void>
|
|
222
229
|
}
|
|
223
230
|
|
|
224
231
|
export type WoxImageType = "absolute" | "relative" | "base64" | "svg" | "url" | "emoji" | "lottie"
|
|
225
232
|
|
|
226
233
|
export interface WoxImage {
|
|
227
|
-
|
|
228
|
-
|
|
234
|
+
ImageType: WoxImageType
|
|
235
|
+
ImageData: string
|
|
229
236
|
}
|
|
230
237
|
|
|
231
238
|
export type WoxPreviewType = "markdown" | "text" | "image" | "url" | "file"
|
|
232
239
|
|
|
233
240
|
export interface WoxPreview {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
241
|
+
PreviewType: WoxPreviewType
|
|
242
|
+
PreviewData: string
|
|
243
|
+
PreviewProperties: Record<string, string>
|
|
237
244
|
}
|
|
238
245
|
|
|
239
246
|
export declare interface Context {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
247
|
+
Values: { [key: string]: string }
|
|
248
|
+
Get: (key: string) => string | undefined
|
|
249
|
+
Set: (key: string, value: string) => void
|
|
250
|
+
Exists: (key: string) => boolean
|
|
244
251
|
}
|
|
245
252
|
|
|
246
253
|
export function NewContext(): Context
|