@wox-launcher/wox-plugin 0.0.97 → 0.0.100
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/ai.d.ts +21 -21
- package/types/index.d.ts +499 -484
- package/types/setting.d.ts +97 -97
package/package.json
CHANGED
package/types/ai.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export namespace AI {
|
|
2
|
-
export type ConversationRole = "user" | "system"
|
|
3
|
-
export type ChatStreamDataType = "streaming" | "finished" | "error"
|
|
4
|
-
|
|
5
|
-
export interface Conversation {
|
|
6
|
-
Role: ConversationRole
|
|
7
|
-
Text: string
|
|
8
|
-
Timestamp: number
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ChatStreamData {
|
|
12
|
-
/** Stream status */
|
|
13
|
-
Status: ChatStreamDataType
|
|
14
|
-
/** Aggregated content data */
|
|
15
|
-
Data: string
|
|
16
|
-
/** Reasoning content from models that support reasoning (e.g., DeepSeek, OpenAI o1). Separate from Data for clean processing. */
|
|
17
|
-
Reasoning: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type ChatStreamFunc = (streamData: ChatStreamData) => void
|
|
21
|
-
}
|
|
1
|
+
export namespace AI {
|
|
2
|
+
export type ConversationRole = "user" | "system"
|
|
3
|
+
export type ChatStreamDataType = "streaming" | "finished" | "error"
|
|
4
|
+
|
|
5
|
+
export interface Conversation {
|
|
6
|
+
Role: ConversationRole
|
|
7
|
+
Text: string
|
|
8
|
+
Timestamp: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ChatStreamData {
|
|
12
|
+
/** Stream status */
|
|
13
|
+
Status: ChatStreamDataType
|
|
14
|
+
/** Aggregated content data */
|
|
15
|
+
Data: string
|
|
16
|
+
/** Reasoning content from models that support reasoning (e.g., DeepSeek, OpenAI o1). Separate from Data for clean processing. */
|
|
17
|
+
Reasoning: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ChatStreamFunc = (streamData: ChatStreamData) => void
|
|
21
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,484 +1,499 @@
|
|
|
1
|
-
import { MetadataCommand, PluginSettingDefinitionItem } from "./setting.js"
|
|
2
|
-
import { AI } from "./ai.js"
|
|
3
|
-
|
|
4
|
-
export type MapString = { [key: string]: string }
|
|
5
|
-
|
|
6
|
-
export type Platform = "windows" | "darwin" | "linux"
|
|
7
|
-
|
|
8
|
-
export interface Plugin {
|
|
9
|
-
init: (ctx: Context, initParams: PluginInitParams) => Promise<void>
|
|
10
|
-
query: (ctx: Context, query: Query) => Promise<Result[]>
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface Selection {
|
|
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
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface QueryEnv {
|
|
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
|
-
/**
|
|
33
|
-
* Active window icon when user query, may be empty
|
|
34
|
-
*/
|
|
35
|
-
ActiveWindowIcon: WoxImage
|
|
36
|
-
|
|
37
|
-
// active browser url when user query
|
|
38
|
-
// Only available when active window is browser and https://github.com/Wox-launcher/Wox.Chrome.Extension is installed
|
|
39
|
-
ActiveBrowserUrl: string
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface Query {
|
|
43
|
-
/**
|
|
44
|
-
* By default, Wox will only pass input query to plugin.
|
|
45
|
-
* plugin author need to enable MetadataFeatureQuerySelection feature to handle selection query
|
|
46
|
-
*/
|
|
47
|
-
Type: "input" | "selection"
|
|
48
|
-
/**
|
|
49
|
-
* Raw query, this includes trigger keyword if it has
|
|
50
|
-
* We didn't recommend use this property directly. You should always use Search property.
|
|
51
|
-
*
|
|
52
|
-
* NOTE: Only available when query type is input
|
|
53
|
-
*/
|
|
54
|
-
RawQuery: string
|
|
55
|
-
/**
|
|
56
|
-
* Trigger keyword of a query. It can be empty if user is using global trigger keyword.
|
|
57
|
-
*
|
|
58
|
-
* NOTE: Only available when query type is input
|
|
59
|
-
*/
|
|
60
|
-
TriggerKeyword?: string
|
|
61
|
-
/**
|
|
62
|
-
* Command part of a query.
|
|
63
|
-
*
|
|
64
|
-
* NOTE: Only available when query type is input
|
|
65
|
-
*/
|
|
66
|
-
Command?: string
|
|
67
|
-
/**
|
|
68
|
-
* Search part of a query.
|
|
69
|
-
*
|
|
70
|
-
* NOTE: Only available when query type is input
|
|
71
|
-
*/
|
|
72
|
-
Search: string
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* User selected or drag-drop data, can be text or file or image etc
|
|
76
|
-
*
|
|
77
|
-
* NOTE: Only available when query type is selection
|
|
78
|
-
*/
|
|
79
|
-
Selection: Selection
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Additional query environment data
|
|
83
|
-
* expose more context env data to plugin, E.g. plugin A only show result when active window title is "Chrome"
|
|
84
|
-
*/
|
|
85
|
-
Env: QueryEnv
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Whether current query is global query
|
|
89
|
-
*/
|
|
90
|
-
IsGlobalQuery(): boolean
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface Result {
|
|
94
|
-
Id?: string
|
|
95
|
-
Title: string
|
|
96
|
-
SubTitle?: string
|
|
97
|
-
Icon: WoxImage
|
|
98
|
-
Preview?: WoxPreview
|
|
99
|
-
Score?: number
|
|
100
|
-
Group?: string
|
|
101
|
-
GroupScore?: number
|
|
102
|
-
Tails?: ResultTail[]
|
|
103
|
-
ContextData?: string
|
|
104
|
-
Actions?: ResultAction[]
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface ResultTail {
|
|
108
|
-
Type: "text" | "image"
|
|
109
|
-
Text?: string
|
|
110
|
-
Image?: WoxImage
|
|
111
|
-
/** Tail id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you */
|
|
112
|
-
Id?: string
|
|
113
|
-
/** Additional data associate with this tail, can be retrieved later */
|
|
114
|
-
ContextData?: string
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Result that can be updated directly in the UI.
|
|
119
|
-
*
|
|
120
|
-
* All fields except Id are optional. Only non-undefined fields will be updated.
|
|
121
|
-
*
|
|
122
|
-
* Example usage:
|
|
123
|
-
* ```typescript
|
|
124
|
-
* // Update only the title
|
|
125
|
-
* const success = await api.updateResult(ctx, {
|
|
126
|
-
* Id: resultId,
|
|
127
|
-
* Title: "Downloading... 50%"
|
|
128
|
-
* })
|
|
129
|
-
*
|
|
130
|
-
* // Update title and tails
|
|
131
|
-
* const success = await api.updateResult(ctx, {
|
|
132
|
-
* Id: resultId,
|
|
133
|
-
* Title: "Processing...",
|
|
134
|
-
* Tails: [{ Type: "text", Text: "Step 1/3" }]
|
|
135
|
-
* })
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
export interface UpdatableResult {
|
|
139
|
-
/** Required - identifies which result to update */
|
|
140
|
-
Id: string
|
|
141
|
-
/** Optional - update the title */
|
|
142
|
-
Title?: string
|
|
143
|
-
/** Optional - update the subtitle */
|
|
144
|
-
SubTitle?: string
|
|
145
|
-
/** Optional - update the tails */
|
|
146
|
-
Tails?: ResultTail[]
|
|
147
|
-
/** Optional - update the preview */
|
|
148
|
-
Preview?: WoxPreview
|
|
149
|
-
/** Optional - update the actions */
|
|
150
|
-
Actions?: ResultAction[]
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export type ResultActionType = "execute" | "form"
|
|
154
|
-
|
|
155
|
-
export type ResultAction = ExecuteResultAction | FormResultAction
|
|
156
|
-
|
|
157
|
-
export interface ExecuteResultAction {
|
|
158
|
-
/**
|
|
159
|
-
* Result id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you
|
|
160
|
-
*/
|
|
161
|
-
Id?: string
|
|
162
|
-
Type?: "execute"
|
|
163
|
-
Name: string
|
|
164
|
-
Icon?: WoxImage
|
|
165
|
-
/**
|
|
166
|
-
* If true, Wox will use this action as default action. There can be only one default action in results
|
|
167
|
-
* This can be omitted, if you don't set it, Wox will use the first action as default action
|
|
168
|
-
*/
|
|
169
|
-
IsDefault?: boolean
|
|
170
|
-
/**
|
|
171
|
-
* If true, Wox will not hide after user select this result
|
|
172
|
-
*/
|
|
173
|
-
PreventHideAfterAction?: boolean
|
|
174
|
-
Action: (actionContext: ActionContext) => Promise<void>
|
|
175
|
-
/**
|
|
176
|
-
* Hotkey to trigger this action. E.g. "ctrl+Shift+Space", "Ctrl+1", "Command+K"
|
|
177
|
-
* Case insensitive, space insensitive
|
|
178
|
-
*
|
|
179
|
-
* If IsDefault is true, Hotkey will be set to enter key by default
|
|
180
|
-
*/
|
|
181
|
-
Hotkey?: string
|
|
182
|
-
/**
|
|
183
|
-
* Additional data associate with this action, can be retrieved later
|
|
184
|
-
*/
|
|
185
|
-
ContextData?: string
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export interface FormResultAction {
|
|
189
|
-
/**
|
|
190
|
-
* Result id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you
|
|
191
|
-
*/
|
|
192
|
-
Id?: string
|
|
193
|
-
Type: "form"
|
|
194
|
-
Name: string
|
|
195
|
-
Icon?: WoxImage
|
|
196
|
-
/**
|
|
197
|
-
* If true, Wox will use this action as default action. There can be only one default action in results
|
|
198
|
-
* This can be omitted, if you don't set it, Wox will use the first action as default action
|
|
199
|
-
*/
|
|
200
|
-
IsDefault?: boolean
|
|
201
|
-
/**
|
|
202
|
-
* If true, Wox will not hide after user select this result
|
|
203
|
-
*/
|
|
204
|
-
PreventHideAfterAction?: boolean
|
|
205
|
-
Form: PluginSettingDefinitionItem[]
|
|
206
|
-
OnSubmit: (actionContext: FormActionContext) => Promise<void>
|
|
207
|
-
/**
|
|
208
|
-
* Hotkey to trigger this action. E.g. "ctrl+Shift+Space", "Ctrl+1", "Command+K"
|
|
209
|
-
* Case insensitive, space insensitive
|
|
210
|
-
*
|
|
211
|
-
* If IsDefault is true, Hotkey will be set to enter key by default
|
|
212
|
-
*/
|
|
213
|
-
Hotkey?: string
|
|
214
|
-
/**
|
|
215
|
-
* Additional data associate with this action, can be retrieved later
|
|
216
|
-
*/
|
|
217
|
-
ContextData?: string
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export interface ActionContext {
|
|
221
|
-
/**
|
|
222
|
-
* The ID of the result that triggered this action
|
|
223
|
-
* This is automatically set by Wox when the action is invoked
|
|
224
|
-
* Useful for calling UpdateResult API to update the result's UI
|
|
225
|
-
*/
|
|
226
|
-
ResultId: string
|
|
227
|
-
/**
|
|
228
|
-
* The ID of the action that was triggered
|
|
229
|
-
* This is automatically set by Wox when the action is invoked
|
|
230
|
-
* Useful for calling UpdateResult API to update this action's UI
|
|
231
|
-
*/
|
|
232
|
-
ResultActionId: string
|
|
233
|
-
/**
|
|
234
|
-
* Additional data associated with this result
|
|
235
|
-
*/
|
|
236
|
-
ContextData: string
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export interface FormActionContext extends ActionContext {
|
|
240
|
-
Values: Record<string, string>
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export interface MRUData {
|
|
244
|
-
PluginID: string
|
|
245
|
-
Title: string
|
|
246
|
-
SubTitle: string
|
|
247
|
-
Icon: WoxImage
|
|
248
|
-
ContextData: string
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
export interface PluginInitParams {
|
|
252
|
-
API: PublicAPI
|
|
253
|
-
PluginDirectory: string
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export interface ChangeQueryParam {
|
|
257
|
-
QueryType: "input" | "selection"
|
|
258
|
-
QueryText?: string
|
|
259
|
-
QuerySelection?: Selection
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export interface RefreshQueryParam {
|
|
263
|
-
/**
|
|
264
|
-
* Controls whether to maintain the previously selected item index after refresh.
|
|
265
|
-
* When true, the user's current selection index in the results list is preserved.
|
|
266
|
-
* When false, the selection resets to the first item (index 0).
|
|
267
|
-
*/
|
|
268
|
-
PreserveSelectedIndex: boolean
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
*
|
|
356
|
-
*/
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
export
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
export
|
|
481
|
-
|
|
482
|
-
export
|
|
483
|
-
|
|
484
|
-
|
|
1
|
+
import { MetadataCommand, PluginSettingDefinitionItem } from "./setting.js"
|
|
2
|
+
import { AI } from "./ai.js"
|
|
3
|
+
|
|
4
|
+
export type MapString = { [key: string]: string }
|
|
5
|
+
|
|
6
|
+
export type Platform = "windows" | "darwin" | "linux"
|
|
7
|
+
|
|
8
|
+
export interface Plugin {
|
|
9
|
+
init: (ctx: Context, initParams: PluginInitParams) => Promise<void>
|
|
10
|
+
query: (ctx: Context, query: Query) => Promise<Result[]>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface Selection {
|
|
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
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface QueryEnv {
|
|
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
|
+
/**
|
|
33
|
+
* Active window icon when user query, may be empty
|
|
34
|
+
*/
|
|
35
|
+
ActiveWindowIcon: WoxImage
|
|
36
|
+
|
|
37
|
+
// active browser url when user query
|
|
38
|
+
// Only available when active window is browser and https://github.com/Wox-launcher/Wox.Chrome.Extension is installed
|
|
39
|
+
ActiveBrowserUrl: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface Query {
|
|
43
|
+
/**
|
|
44
|
+
* By default, Wox will only pass input query to plugin.
|
|
45
|
+
* plugin author need to enable MetadataFeatureQuerySelection feature to handle selection query
|
|
46
|
+
*/
|
|
47
|
+
Type: "input" | "selection"
|
|
48
|
+
/**
|
|
49
|
+
* Raw query, this includes trigger keyword if it has
|
|
50
|
+
* We didn't recommend use this property directly. You should always use Search property.
|
|
51
|
+
*
|
|
52
|
+
* NOTE: Only available when query type is input
|
|
53
|
+
*/
|
|
54
|
+
RawQuery: string
|
|
55
|
+
/**
|
|
56
|
+
* Trigger keyword of a query. It can be empty if user is using global trigger keyword.
|
|
57
|
+
*
|
|
58
|
+
* NOTE: Only available when query type is input
|
|
59
|
+
*/
|
|
60
|
+
TriggerKeyword?: string
|
|
61
|
+
/**
|
|
62
|
+
* Command part of a query.
|
|
63
|
+
*
|
|
64
|
+
* NOTE: Only available when query type is input
|
|
65
|
+
*/
|
|
66
|
+
Command?: string
|
|
67
|
+
/**
|
|
68
|
+
* Search part of a query.
|
|
69
|
+
*
|
|
70
|
+
* NOTE: Only available when query type is input
|
|
71
|
+
*/
|
|
72
|
+
Search: string
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* User selected or drag-drop data, can be text or file or image etc
|
|
76
|
+
*
|
|
77
|
+
* NOTE: Only available when query type is selection
|
|
78
|
+
*/
|
|
79
|
+
Selection: Selection
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Additional query environment data
|
|
83
|
+
* expose more context env data to plugin, E.g. plugin A only show result when active window title is "Chrome"
|
|
84
|
+
*/
|
|
85
|
+
Env: QueryEnv
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Whether current query is global query
|
|
89
|
+
*/
|
|
90
|
+
IsGlobalQuery(): boolean
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface Result {
|
|
94
|
+
Id?: string
|
|
95
|
+
Title: string
|
|
96
|
+
SubTitle?: string
|
|
97
|
+
Icon: WoxImage
|
|
98
|
+
Preview?: WoxPreview
|
|
99
|
+
Score?: number
|
|
100
|
+
Group?: string
|
|
101
|
+
GroupScore?: number
|
|
102
|
+
Tails?: ResultTail[]
|
|
103
|
+
ContextData?: string
|
|
104
|
+
Actions?: ResultAction[]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface ResultTail {
|
|
108
|
+
Type: "text" | "image"
|
|
109
|
+
Text?: string
|
|
110
|
+
Image?: WoxImage
|
|
111
|
+
/** Tail id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you */
|
|
112
|
+
Id?: string
|
|
113
|
+
/** Additional data associate with this tail, can be retrieved later */
|
|
114
|
+
ContextData?: string
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Result that can be updated directly in the UI.
|
|
119
|
+
*
|
|
120
|
+
* All fields except Id are optional. Only non-undefined fields will be updated.
|
|
121
|
+
*
|
|
122
|
+
* Example usage:
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // Update only the title
|
|
125
|
+
* const success = await api.updateResult(ctx, {
|
|
126
|
+
* Id: resultId,
|
|
127
|
+
* Title: "Downloading... 50%"
|
|
128
|
+
* })
|
|
129
|
+
*
|
|
130
|
+
* // Update title and tails
|
|
131
|
+
* const success = await api.updateResult(ctx, {
|
|
132
|
+
* Id: resultId,
|
|
133
|
+
* Title: "Processing...",
|
|
134
|
+
* Tails: [{ Type: "text", Text: "Step 1/3" }]
|
|
135
|
+
* })
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export interface UpdatableResult {
|
|
139
|
+
/** Required - identifies which result to update */
|
|
140
|
+
Id: string
|
|
141
|
+
/** Optional - update the title */
|
|
142
|
+
Title?: string
|
|
143
|
+
/** Optional - update the subtitle */
|
|
144
|
+
SubTitle?: string
|
|
145
|
+
/** Optional - update the tails */
|
|
146
|
+
Tails?: ResultTail[]
|
|
147
|
+
/** Optional - update the preview */
|
|
148
|
+
Preview?: WoxPreview
|
|
149
|
+
/** Optional - update the actions */
|
|
150
|
+
Actions?: ResultAction[]
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type ResultActionType = "execute" | "form"
|
|
154
|
+
|
|
155
|
+
export type ResultAction = ExecuteResultAction | FormResultAction
|
|
156
|
+
|
|
157
|
+
export interface ExecuteResultAction {
|
|
158
|
+
/**
|
|
159
|
+
* Result id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you
|
|
160
|
+
*/
|
|
161
|
+
Id?: string
|
|
162
|
+
Type?: "execute"
|
|
163
|
+
Name: string
|
|
164
|
+
Icon?: WoxImage
|
|
165
|
+
/**
|
|
166
|
+
* If true, Wox will use this action as default action. There can be only one default action in results
|
|
167
|
+
* This can be omitted, if you don't set it, Wox will use the first action as default action
|
|
168
|
+
*/
|
|
169
|
+
IsDefault?: boolean
|
|
170
|
+
/**
|
|
171
|
+
* If true, Wox will not hide after user select this result
|
|
172
|
+
*/
|
|
173
|
+
PreventHideAfterAction?: boolean
|
|
174
|
+
Action: (actionContext: ActionContext) => Promise<void>
|
|
175
|
+
/**
|
|
176
|
+
* Hotkey to trigger this action. E.g. "ctrl+Shift+Space", "Ctrl+1", "Command+K"
|
|
177
|
+
* Case insensitive, space insensitive
|
|
178
|
+
*
|
|
179
|
+
* If IsDefault is true, Hotkey will be set to enter key by default
|
|
180
|
+
*/
|
|
181
|
+
Hotkey?: string
|
|
182
|
+
/**
|
|
183
|
+
* Additional data associate with this action, can be retrieved later
|
|
184
|
+
*/
|
|
185
|
+
ContextData?: string
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface FormResultAction {
|
|
189
|
+
/**
|
|
190
|
+
* Result id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you
|
|
191
|
+
*/
|
|
192
|
+
Id?: string
|
|
193
|
+
Type: "form"
|
|
194
|
+
Name: string
|
|
195
|
+
Icon?: WoxImage
|
|
196
|
+
/**
|
|
197
|
+
* If true, Wox will use this action as default action. There can be only one default action in results
|
|
198
|
+
* This can be omitted, if you don't set it, Wox will use the first action as default action
|
|
199
|
+
*/
|
|
200
|
+
IsDefault?: boolean
|
|
201
|
+
/**
|
|
202
|
+
* If true, Wox will not hide after user select this result
|
|
203
|
+
*/
|
|
204
|
+
PreventHideAfterAction?: boolean
|
|
205
|
+
Form: PluginSettingDefinitionItem[]
|
|
206
|
+
OnSubmit: (actionContext: FormActionContext) => Promise<void>
|
|
207
|
+
/**
|
|
208
|
+
* Hotkey to trigger this action. E.g. "ctrl+Shift+Space", "Ctrl+1", "Command+K"
|
|
209
|
+
* Case insensitive, space insensitive
|
|
210
|
+
*
|
|
211
|
+
* If IsDefault is true, Hotkey will be set to enter key by default
|
|
212
|
+
*/
|
|
213
|
+
Hotkey?: string
|
|
214
|
+
/**
|
|
215
|
+
* Additional data associate with this action, can be retrieved later
|
|
216
|
+
*/
|
|
217
|
+
ContextData?: string
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ActionContext {
|
|
221
|
+
/**
|
|
222
|
+
* The ID of the result that triggered this action
|
|
223
|
+
* This is automatically set by Wox when the action is invoked
|
|
224
|
+
* Useful for calling UpdateResult API to update the result's UI
|
|
225
|
+
*/
|
|
226
|
+
ResultId: string
|
|
227
|
+
/**
|
|
228
|
+
* The ID of the action that was triggered
|
|
229
|
+
* This is automatically set by Wox when the action is invoked
|
|
230
|
+
* Useful for calling UpdateResult API to update this action's UI
|
|
231
|
+
*/
|
|
232
|
+
ResultActionId: string
|
|
233
|
+
/**
|
|
234
|
+
* Additional data associated with this result
|
|
235
|
+
*/
|
|
236
|
+
ContextData: string
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface FormActionContext extends ActionContext {
|
|
240
|
+
Values: Record<string, string>
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface MRUData {
|
|
244
|
+
PluginID: string
|
|
245
|
+
Title: string
|
|
246
|
+
SubTitle: string
|
|
247
|
+
Icon: WoxImage
|
|
248
|
+
ContextData: string
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface PluginInitParams {
|
|
252
|
+
API: PublicAPI
|
|
253
|
+
PluginDirectory: string
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface ChangeQueryParam {
|
|
257
|
+
QueryType: "input" | "selection"
|
|
258
|
+
QueryText?: string
|
|
259
|
+
QuerySelection?: Selection
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface RefreshQueryParam {
|
|
263
|
+
/**
|
|
264
|
+
* Controls whether to maintain the previously selected item index after refresh.
|
|
265
|
+
* When true, the user's current selection index in the results list is preserved.
|
|
266
|
+
* When false, the selection resets to the first item (index 0).
|
|
267
|
+
*/
|
|
268
|
+
PreserveSelectedIndex: boolean
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export type CopyType = "text" | "image"
|
|
272
|
+
|
|
273
|
+
export interface CopyParams {
|
|
274
|
+
type: CopyType
|
|
275
|
+
text: string
|
|
276
|
+
woxImage?: WoxImage
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export interface PublicAPI {
|
|
280
|
+
/**
|
|
281
|
+
* Change Wox query
|
|
282
|
+
*/
|
|
283
|
+
ChangeQuery: (ctx: Context, query: ChangeQueryParam) => Promise<void>
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Hide Wox
|
|
287
|
+
*/
|
|
288
|
+
HideApp: (ctx: Context) => Promise<void>
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Show Wox
|
|
292
|
+
*/
|
|
293
|
+
ShowApp: (ctx: Context) => Promise<void>
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Check if Wox window is currently visible
|
|
297
|
+
*/
|
|
298
|
+
IsVisible: (ctx: Context) => Promise<boolean>
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Notify message
|
|
302
|
+
*/
|
|
303
|
+
Notify: (ctx: Context, message: string) => Promise<void>
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Write log
|
|
307
|
+
*/
|
|
308
|
+
Log: (ctx: Context, level: "Info" | "Error" | "Debug" | "Warning", msg: string) => Promise<void>
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Get translation of current language
|
|
312
|
+
*/
|
|
313
|
+
GetTranslation: (ctx: Context, key: string) => Promise<string>
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Get customized setting
|
|
317
|
+
*
|
|
318
|
+
* will try to get platform specific setting first, if not found, will try to get global setting
|
|
319
|
+
*/
|
|
320
|
+
GetSetting: (ctx: Context, key: string) => Promise<string>
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Save customized setting
|
|
324
|
+
*
|
|
325
|
+
* @isPlatformSpecific If true, setting will be only saved in current platform. If false, setting will be available in all platforms
|
|
326
|
+
*/
|
|
327
|
+
SaveSetting: (ctx: Context, key: string, value: string, isPlatformSpecific: boolean) => Promise<void>
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Register setting changed callback
|
|
331
|
+
*/
|
|
332
|
+
OnSettingChanged: (ctx: Context, callback: (key: string, value: string) => void) => Promise<void>
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Get dynamic setting definition
|
|
336
|
+
*/
|
|
337
|
+
OnGetDynamicSetting: (ctx: Context, callback: (key: string) => PluginSettingDefinitionItem) => Promise<void>
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Register deep link callback
|
|
341
|
+
*/
|
|
342
|
+
OnDeepLink: (ctx: Context, callback: (arguments: MapString) => void) => Promise<void>
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Register on load event
|
|
346
|
+
*/
|
|
347
|
+
OnUnload: (ctx: Context, callback: () => Promise<void>) => Promise<void>
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Register query commands
|
|
351
|
+
*/
|
|
352
|
+
RegisterQueryCommands: (ctx: Context, commands: MetadataCommand[]) => Promise<void>
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Chat using LLM
|
|
356
|
+
*/
|
|
357
|
+
LLMStream: (ctx: Context, conversations: AI.Conversation[], callback: AI.ChatStreamFunc) => Promise<void>
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Register MRU restore callback
|
|
361
|
+
* @param ctx Context
|
|
362
|
+
* @param callback Callback function that takes MRUData and returns Result or null
|
|
363
|
+
* Return null if the MRU data is no longer valid
|
|
364
|
+
*/
|
|
365
|
+
OnMRURestore: (ctx: Context, callback: (mruData: MRUData) => Promise<Result | null>) => Promise<void>
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Get the current state of a result that is displayed in the UI.
|
|
369
|
+
*
|
|
370
|
+
* Returns UpdatableResult with current values if the result is still visible.
|
|
371
|
+
* Returns null if the result is no longer visible.
|
|
372
|
+
*
|
|
373
|
+
* Note: System actions and tails (like favorite icon) are automatically filtered out.
|
|
374
|
+
* They will be re-added by the system when you call UpdateResult().
|
|
375
|
+
*
|
|
376
|
+
* Example:
|
|
377
|
+
* ```typescript
|
|
378
|
+
* // In an action handler
|
|
379
|
+
* Action: async (actionContext) => {
|
|
380
|
+
* // Get current result state
|
|
381
|
+
* const updatableResult = await api.GetUpdatableResult(ctx, actionContext.ResultId)
|
|
382
|
+
* if (updatableResult === null) {
|
|
383
|
+
* return // Result no longer visible
|
|
384
|
+
* }
|
|
385
|
+
*
|
|
386
|
+
* // Modify the result
|
|
387
|
+
* updatableResult.Title = "Updated title"
|
|
388
|
+
* updatableResult.Tails?.push({ Type: "text", Text: "New tail" })
|
|
389
|
+
*
|
|
390
|
+
* // Update the result
|
|
391
|
+
* await api.UpdateResult(ctx, updatableResult)
|
|
392
|
+
* }
|
|
393
|
+
* ```
|
|
394
|
+
*
|
|
395
|
+
* @param ctx Context
|
|
396
|
+
* @param resultId ID of the result to get
|
|
397
|
+
* @returns Promise<UpdatableResult | null> Current result state, or null if not visible
|
|
398
|
+
*/
|
|
399
|
+
GetUpdatableResult: (ctx: Context, resultId: string) => Promise<UpdatableResult | null>
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Update a query result that is currently displayed in the UI.
|
|
403
|
+
*
|
|
404
|
+
* Returns true if the result was successfully updated (still visible in UI).
|
|
405
|
+
* Returns false if the result is no longer visible.
|
|
406
|
+
*
|
|
407
|
+
* This method is designed for long-running operations within Action handlers.
|
|
408
|
+
* Best practices:
|
|
409
|
+
* - Set PreventHideAfterAction: true in your action
|
|
410
|
+
* - Only use during action execution or in background tasks spawned by actions
|
|
411
|
+
* - For periodic updates, start a timer in init() and track result IDs
|
|
412
|
+
*
|
|
413
|
+
* Example:
|
|
414
|
+
* ```typescript
|
|
415
|
+
* // In an action handler
|
|
416
|
+
* Action: async (actionContext) => {
|
|
417
|
+
* // Update only the title
|
|
418
|
+
* const success = await api.UpdateResult(ctx, {
|
|
419
|
+
* Id: actionContext.ResultId,
|
|
420
|
+
* Title: "Downloading... 50%"
|
|
421
|
+
* })
|
|
422
|
+
*
|
|
423
|
+
* // Update title and tails
|
|
424
|
+
* const success = await api.UpdateResult(ctx, {
|
|
425
|
+
* Id: actionContext.ResultId,
|
|
426
|
+
* Title: "Processing...",
|
|
427
|
+
* Tails: [{ Type: "text", Text: "Step 1/3" }]
|
|
428
|
+
* })
|
|
429
|
+
* }
|
|
430
|
+
* ```
|
|
431
|
+
*
|
|
432
|
+
* @param ctx Context
|
|
433
|
+
* @param result UpdatableResult with Id (required) and optional fields to update
|
|
434
|
+
* @returns Promise<boolean> True if updated successfully, false if result no longer visible
|
|
435
|
+
*/
|
|
436
|
+
UpdateResult: (ctx: Context, result: UpdatableResult) => Promise<boolean>
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Re-execute the current query with the existing query text.
|
|
440
|
+
* This is useful when plugin data changes and you want to update the displayed results.
|
|
441
|
+
*
|
|
442
|
+
* Example - Refresh after marking item as favorite:
|
|
443
|
+
* ```typescript
|
|
444
|
+
* Action: async (actionContext) => {
|
|
445
|
+
* markAsFavorite(item)
|
|
446
|
+
* // Refresh query and preserve user's current selection
|
|
447
|
+
* await api.RefreshQuery(ctx, { PreserveSelectedIndex: true })
|
|
448
|
+
* }
|
|
449
|
+
* ```
|
|
450
|
+
*
|
|
451
|
+
* Example - Refresh after deleting item:
|
|
452
|
+
* ```typescript
|
|
453
|
+
* Action: async (actionContext) => {
|
|
454
|
+
* deleteItem(item)
|
|
455
|
+
* // Refresh query and reset to first item
|
|
456
|
+
* await api.RefreshQuery(ctx, { PreserveSelectedIndex: false })
|
|
457
|
+
* }
|
|
458
|
+
* ```
|
|
459
|
+
*
|
|
460
|
+
* @param ctx Context
|
|
461
|
+
* @param param RefreshQueryParam to control refresh behavior
|
|
462
|
+
*/
|
|
463
|
+
RefreshQuery: (ctx: Context, param: RefreshQueryParam) => Promise<void>
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Copy text or image to clipboard
|
|
467
|
+
* @param ctx Context
|
|
468
|
+
* @param params CopyParams
|
|
469
|
+
*/
|
|
470
|
+
Copy: (ctx: Context, params: CopyParams) => Promise<void>
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export type WoxImageType = "absolute" | "relative" | "base64" | "svg" | "url" | "emoji" | "lottie"
|
|
474
|
+
|
|
475
|
+
export interface WoxImage {
|
|
476
|
+
ImageType: WoxImageType
|
|
477
|
+
ImageData: string
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export type WoxPreviewType = "markdown" | "text" | "image" | "url" | "file"
|
|
481
|
+
|
|
482
|
+
export interface WoxPreview {
|
|
483
|
+
PreviewType: WoxPreviewType
|
|
484
|
+
PreviewData: string
|
|
485
|
+
PreviewProperties: Record<string, string>
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export declare interface Context {
|
|
489
|
+
Values: { [key: string]: string }
|
|
490
|
+
Get: (key: string) => string | undefined
|
|
491
|
+
Set: (key: string, value: string) => void
|
|
492
|
+
Exists: (key: string) => boolean
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export function NewContext(): Context
|
|
496
|
+
|
|
497
|
+
export function NewContextWithValue(key: string, value: string): Context
|
|
498
|
+
|
|
499
|
+
export function NewBase64WoxImage(imageData: string): WoxImage
|
package/types/setting.d.ts
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { Context, Platform } from "./index.js"
|
|
2
|
-
|
|
3
|
-
export type PluginSettingDefinitionType = "head" | "textbox" | "checkbox" | "select" | "label" | "newline" | "table" | "dynamic"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface PluginSettingValueStyle {
|
|
7
|
-
PaddingLeft: number
|
|
8
|
-
PaddingTop: number
|
|
9
|
-
PaddingRight: number
|
|
10
|
-
PaddingBottom: number
|
|
11
|
-
|
|
12
|
-
Width: number
|
|
13
|
-
LabelWidth: number // if has label, E.g. select, checkbox, textbox
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface PluginSettingDefinitionValue {
|
|
17
|
-
GetKey: () => string
|
|
18
|
-
GetDefaultValue: () => string
|
|
19
|
-
Translate: (translator: (ctx: Context, key: string) => string) => void
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface PluginSettingDefinitionItem {
|
|
23
|
-
Type: PluginSettingDefinitionType
|
|
24
|
-
Value: PluginSettingDefinitionValue
|
|
25
|
-
DisabledInPlatforms: Platform[]
|
|
26
|
-
IsPlatformSpecific: boolean // if true, this setting may be different in different platforms
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface MetadataCommand {
|
|
30
|
-
Command: string
|
|
31
|
-
Description: string
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface PluginSettingValueCheckBox extends PluginSettingDefinitionValue {
|
|
35
|
-
Key: string
|
|
36
|
-
Label: string
|
|
37
|
-
DefaultValue: string
|
|
38
|
-
Tooltip: string
|
|
39
|
-
Style: PluginSettingValueStyle
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface PluginSettingValueDynamic extends PluginSettingDefinitionValue {
|
|
43
|
-
Key: string
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface PluginSettingValueHead extends PluginSettingDefinitionValue {
|
|
47
|
-
Content: string
|
|
48
|
-
Tooltip: string
|
|
49
|
-
Style: PluginSettingValueStyle
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface PluginSettingValueLabel extends PluginSettingDefinitionValue {
|
|
53
|
-
Content: string
|
|
54
|
-
Tooltip: string
|
|
55
|
-
Style: PluginSettingValueStyle
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface PluginSettingValueNewline extends PluginSettingDefinitionValue {
|
|
59
|
-
Style: PluginSettingValueStyle
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface PluginSettingValueSelect extends PluginSettingDefinitionValue {
|
|
63
|
-
Key: string
|
|
64
|
-
Label: string
|
|
65
|
-
Suffix: string
|
|
66
|
-
DefaultValue: string
|
|
67
|
-
Tooltip: string
|
|
68
|
-
Options: PluginSettingValueSelectOption[]
|
|
69
|
-
Validators: PluginSettingValidator[] // validators for this setting, every validator should be satisfied
|
|
70
|
-
|
|
71
|
-
Style: PluginSettingValueStyle
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface PluginSettingValueSelectOption {
|
|
75
|
-
Label: string
|
|
76
|
-
Value: string
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export type PluginSettingValidatorType = "is_number" | "not_empty"
|
|
80
|
-
|
|
81
|
-
export interface PluginSettingValidator {
|
|
82
|
-
Type: PluginSettingValidatorType
|
|
83
|
-
Value: PluginSettingValidatorValue
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface PluginSettingValidatorValue {
|
|
87
|
-
GetValidatorType(): PluginSettingValidatorType
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface PluginSettingValidatorIsNumber extends PluginSettingValidatorValue {
|
|
91
|
-
IsInteger: boolean
|
|
92
|
-
IsFloat: boolean
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface PluginSettingValidatorNotEmpty extends PluginSettingValidatorValue {
|
|
96
|
-
|
|
97
|
-
}
|
|
1
|
+
import { Context, Platform } from "./index.js"
|
|
2
|
+
|
|
3
|
+
export type PluginSettingDefinitionType = "head" | "textbox" | "checkbox" | "select" | "label" | "newline" | "table" | "dynamic"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export interface PluginSettingValueStyle {
|
|
7
|
+
PaddingLeft: number
|
|
8
|
+
PaddingTop: number
|
|
9
|
+
PaddingRight: number
|
|
10
|
+
PaddingBottom: number
|
|
11
|
+
|
|
12
|
+
Width: number
|
|
13
|
+
LabelWidth: number // if has label, E.g. select, checkbox, textbox
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PluginSettingDefinitionValue {
|
|
17
|
+
GetKey: () => string
|
|
18
|
+
GetDefaultValue: () => string
|
|
19
|
+
Translate: (translator: (ctx: Context, key: string) => string) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PluginSettingDefinitionItem {
|
|
23
|
+
Type: PluginSettingDefinitionType
|
|
24
|
+
Value: PluginSettingDefinitionValue
|
|
25
|
+
DisabledInPlatforms: Platform[]
|
|
26
|
+
IsPlatformSpecific: boolean // if true, this setting may be different in different platforms
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface MetadataCommand {
|
|
30
|
+
Command: string
|
|
31
|
+
Description: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PluginSettingValueCheckBox extends PluginSettingDefinitionValue {
|
|
35
|
+
Key: string
|
|
36
|
+
Label: string
|
|
37
|
+
DefaultValue: string
|
|
38
|
+
Tooltip: string
|
|
39
|
+
Style: PluginSettingValueStyle
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PluginSettingValueDynamic extends PluginSettingDefinitionValue {
|
|
43
|
+
Key: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface PluginSettingValueHead extends PluginSettingDefinitionValue {
|
|
47
|
+
Content: string
|
|
48
|
+
Tooltip: string
|
|
49
|
+
Style: PluginSettingValueStyle
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PluginSettingValueLabel extends PluginSettingDefinitionValue {
|
|
53
|
+
Content: string
|
|
54
|
+
Tooltip: string
|
|
55
|
+
Style: PluginSettingValueStyle
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface PluginSettingValueNewline extends PluginSettingDefinitionValue {
|
|
59
|
+
Style: PluginSettingValueStyle
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface PluginSettingValueSelect extends PluginSettingDefinitionValue {
|
|
63
|
+
Key: string
|
|
64
|
+
Label: string
|
|
65
|
+
Suffix: string
|
|
66
|
+
DefaultValue: string
|
|
67
|
+
Tooltip: string
|
|
68
|
+
Options: PluginSettingValueSelectOption[]
|
|
69
|
+
Validators: PluginSettingValidator[] // validators for this setting, every validator should be satisfied
|
|
70
|
+
|
|
71
|
+
Style: PluginSettingValueStyle
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface PluginSettingValueSelectOption {
|
|
75
|
+
Label: string
|
|
76
|
+
Value: string
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type PluginSettingValidatorType = "is_number" | "not_empty"
|
|
80
|
+
|
|
81
|
+
export interface PluginSettingValidator {
|
|
82
|
+
Type: PluginSettingValidatorType
|
|
83
|
+
Value: PluginSettingValidatorValue
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface PluginSettingValidatorValue {
|
|
87
|
+
GetValidatorType(): PluginSettingValidatorType
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface PluginSettingValidatorIsNumber extends PluginSettingValidatorValue {
|
|
91
|
+
IsInteger: boolean
|
|
92
|
+
IsFloat: boolean
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface PluginSettingValidatorNotEmpty extends PluginSettingValidatorValue {
|
|
96
|
+
|
|
97
|
+
}
|