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