@wox-launcher/wox-plugin 0.0.84 → 0.0.87

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wox-launcher/wox-plugin",
3
- "version": "0.0.84",
3
+ "version": "0.0.87",
4
4
  "description": "All nodejs plugin for Wox should use types in this package",
5
5
  "repository": {
6
6
  "type": "git",
package/types/ai.d.ts CHANGED
@@ -1,12 +1,12 @@
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 type ChatStreamFunc = (dataType: ChatStreamDataType, data: string) => void
12
- }
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 type ChatStreamFunc = (dataType: ChatStreamDataType, data: string) => void
12
+ }
package/types/index.d.ts CHANGED
@@ -1,284 +1,500 @@
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
- // 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
35
- }
36
-
37
- export interface Query {
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
86
- }
87
-
88
- export interface Result {
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>
106
- }
107
-
108
- export interface ResultTail {
109
- Type: "text" | "image"
110
- Text?: string
111
- Image?: WoxImage
112
- }
113
-
114
- export interface RefreshableResult {
115
- Title: string
116
- SubTitle: string
117
- Icon: WoxImage
118
- Preview: WoxPreview
119
- Tails: ResultTail[]
120
- ContextData: string
121
- RefreshInterval: number
122
- Actions: ResultAction[]
123
- }
124
-
125
- export interface ResultAction {
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
149
- }
150
-
151
- export interface ActionContext {
152
- ContextData: string
153
- }
154
-
155
- export interface MRUData {
156
- PluginID: string
157
- Title: string
158
- SubTitle: string
159
- Icon: WoxImage
160
- ContextData: string
161
- }
162
-
163
- export interface PluginInitParams {
164
- API: PublicAPI
165
- PluginDirectory: string
166
- }
167
-
168
- export interface ChangeQueryParam {
169
- QueryType: "input" | "selection"
170
- QueryText?: string
171
- QuerySelection?: Selection
172
- }
173
-
174
- export interface PublicAPI {
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>
256
- }
257
-
258
- export type WoxImageType = "absolute" | "relative" | "base64" | "svg" | "url" | "emoji" | "lottie"
259
-
260
- export interface WoxImage {
261
- ImageType: WoxImageType
262
- ImageData: string
263
- }
264
-
265
- export type WoxPreviewType = "markdown" | "text" | "image" | "url" | "file"
266
-
267
- export interface WoxPreview {
268
- PreviewType: WoxPreviewType
269
- PreviewData: string
270
- PreviewProperties: Record<string, string>
271
- }
272
-
273
- export declare interface Context {
274
- Values: { [key: string]: string }
275
- Get: (key: string) => string | undefined
276
- Set: (key: string, value: string) => void
277
- Exists: (key: string) => boolean
278
- }
279
-
280
- export function NewContext(): Context
281
-
282
- export function NewContextWithValue(key: string, value: string): Context
283
-
284
- export function NewBase64WoxImage(imageData: string): WoxImage
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
+ // refresh result after specified interval, in milliseconds. If this value is 0, Wox will not refresh this result
106
+ // interval can only divisible by 100, if not, Wox will use the nearest number which is divisible by 100
107
+ // E.g. if you set 123, Wox will use 200, if you set 1234, Wox will use 1300
108
+ RefreshInterval?: number
109
+ // refresh result by calling OnRefresh function
110
+ OnRefresh?: (current: RefreshableResult) => Promise<RefreshableResult>
111
+ }
112
+
113
+ export interface ResultTail {
114
+ Type: "text" | "image"
115
+ Text?: string
116
+ Image?: WoxImage
117
+ /** Tail id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you */
118
+ Id?: string
119
+ /** Additional data associate with this tail, can be retrieved later */
120
+ ContextData?: string
121
+ }
122
+
123
+ export interface RefreshableResult {
124
+ Title: string
125
+ SubTitle: string
126
+ Icon: WoxImage
127
+ Preview: WoxPreview
128
+ Tails: ResultTail[]
129
+ ContextData: string
130
+ RefreshInterval: number
131
+ Actions: ResultAction[]
132
+ }
133
+
134
+ /**
135
+ * Result that can be updated directly in the UI.
136
+ *
137
+ * Unlike RefreshableResult which uses polling, UpdateableResult directly pushes updates to the UI.
138
+ * All fields except Id are optional. Only non-undefined fields will be updated.
139
+ *
140
+ * Example usage:
141
+ * ```typescript
142
+ * // Update only the title
143
+ * const success = await api.updateResult(ctx, {
144
+ * Id: resultId,
145
+ * Title: "Downloading... 50%"
146
+ * })
147
+ *
148
+ * // Update title and tails
149
+ * const success = await api.updateResult(ctx, {
150
+ * Id: resultId,
151
+ * Title: "Processing...",
152
+ * Tails: [{ Type: "text", Text: "Step 1/3" }]
153
+ * })
154
+ * ```
155
+ */
156
+ export interface UpdateableResult {
157
+ /** Required - identifies which result to update */
158
+ Id: string
159
+ /** Optional - update the title */
160
+ Title?: string
161
+ /** Optional - update the subtitle */
162
+ SubTitle?: string
163
+ /** Optional - update the tails */
164
+ Tails?: ResultTail[]
165
+ /** Optional - update the preview */
166
+ Preview?: WoxPreview
167
+ /** Optional - update the actions */
168
+ Actions?: ResultAction[]
169
+ }
170
+
171
+ /**
172
+ * Represents an action that can be updated directly in the UI.
173
+ *
174
+ * This allows updating a single action's UI (name, icon, action callback) without replacing the entire actions array.
175
+ * All fields except ResultId and ActionId are optional. Only non-undefined fields will be updated.
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * // Update only the action name
180
+ * const success = await api.UpdateResultAction(ctx, {
181
+ * ResultId: actionContext.ResultId,
182
+ * ActionId: actionContext.ResultActionId,
183
+ * Name: "Remove from favorite"
184
+ * })
185
+ *
186
+ * // Update name, icon and action callback
187
+ * const success = await api.UpdateResultAction(ctx, {
188
+ * ResultId: actionContext.ResultId,
189
+ * ActionId: actionContext.ResultActionId,
190
+ * Name: "Add to favorite",
191
+ * Icon: { ImageType: "emoji", ImageData: "⭐" },
192
+ * Action: async (actionContext) => {
193
+ * // New action logic
194
+ * }
195
+ * })
196
+ * ```
197
+ */
198
+ export interface UpdateableResultAction {
199
+ /** Required - identifies which result contains the action */
200
+ ResultId: string
201
+ /** Required - identifies which action to update */
202
+ ActionId: string
203
+ /** Optional - update the action name */
204
+ Name?: string
205
+ /** Optional - update the action icon */
206
+ Icon?: WoxImage
207
+ /** Optional - update the action callback */
208
+ Action?: (actionContext: ActionContext) => Promise<void>
209
+ }
210
+
211
+ export interface ResultAction {
212
+ /**
213
+ * Result id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you
214
+ */
215
+ Id?: string
216
+ Name: string
217
+ Icon?: WoxImage
218
+ /**
219
+ * If true, Wox will use this action as default action. There can be only one default action in results
220
+ * This can be omitted, if you don't set it, Wox will use the first action as default action
221
+ */
222
+ IsDefault?: boolean
223
+ /**
224
+ * If true, Wox will not hide after user select this result
225
+ */
226
+ PreventHideAfterAction?: boolean
227
+ Action: (actionContext: ActionContext) => Promise<void>
228
+ /**
229
+ * Hotkey to trigger this action. E.g. "ctrl+Shift+Space", "Ctrl+1", "Command+K"
230
+ * Case insensitive, space insensitive
231
+ *
232
+ * If IsDefault is true, Hotkey will be set to enter key by default
233
+ */
234
+ Hotkey?: string
235
+ }
236
+
237
+ export interface ActionContext {
238
+ /**
239
+ * The ID of the result that triggered this action
240
+ * This is automatically set by Wox when the action is invoked
241
+ * Useful for calling UpdateResult API to update the result's UI
242
+ */
243
+ ResultId: string
244
+ /**
245
+ * The ID of the action that was triggered
246
+ * This is automatically set by Wox when the action is invoked
247
+ * Useful for calling UpdateResultAction API to update this action's UI
248
+ */
249
+ ResultActionId: string
250
+ /**
251
+ * Additional data associated with this result
252
+ */
253
+ ContextData: string
254
+ }
255
+
256
+ export interface MRUData {
257
+ PluginID: string
258
+ Title: string
259
+ SubTitle: string
260
+ Icon: WoxImage
261
+ ContextData: string
262
+ }
263
+
264
+ export interface PluginInitParams {
265
+ API: PublicAPI
266
+ PluginDirectory: string
267
+ }
268
+
269
+ export interface ChangeQueryParam {
270
+ QueryType: "input" | "selection"
271
+ QueryText?: string
272
+ QuerySelection?: Selection
273
+ }
274
+
275
+ export interface PublicAPI {
276
+ /**
277
+ * Change Wox query
278
+ */
279
+ ChangeQuery: (ctx: Context, query: ChangeQueryParam) => Promise<void>
280
+
281
+ /**
282
+ * Hide Wox
283
+ */
284
+ HideApp: (ctx: Context) => Promise<void>
285
+
286
+ /**
287
+ * Show Wox
288
+ */
289
+ ShowApp: (ctx: Context) => Promise<void>
290
+
291
+ /**
292
+ * Notify message
293
+ */
294
+ Notify: (ctx: Context, message: string) => Promise<void>
295
+
296
+ /**
297
+ * Write log
298
+ */
299
+ Log: (ctx: Context, level: "Info" | "Error" | "Debug" | "Warning", msg: string) => Promise<void>
300
+
301
+ /**
302
+ * Get translation of current language
303
+ */
304
+ GetTranslation: (ctx: Context, key: string) => Promise<string>
305
+
306
+ /**
307
+ * Get customized setting
308
+ *
309
+ * will try to get platform specific setting first, if not found, will try to get global setting
310
+ */
311
+ GetSetting: (ctx: Context, key: string) => Promise<string>
312
+
313
+ /**
314
+ * Save customized setting
315
+ *
316
+ * @isPlatformSpecific If true, setting will be only saved in current platform. If false, setting will be available in all platforms
317
+ */
318
+ SaveSetting: (ctx: Context, key: string, value: string, isPlatformSpecific: boolean) => Promise<void>
319
+
320
+ /**
321
+ * Register setting changed callback
322
+ */
323
+ OnSettingChanged: (ctx: Context, callback: (key: string, value: string) => void) => Promise<void>
324
+
325
+ /**
326
+ * Get dynamic setting definition
327
+ */
328
+ OnGetDynamicSetting: (ctx: Context, callback: (key: string) => PluginSettingDefinitionItem) => Promise<void>
329
+
330
+ /**
331
+ * Register deep link callback
332
+ */
333
+ OnDeepLink: (ctx: Context, callback: (arguments: MapString) => void) => Promise<void>
334
+
335
+ /**
336
+ * Register on load event
337
+ */
338
+ OnUnload: (ctx: Context, callback: () => Promise<void>) => Promise<void>
339
+
340
+ /**
341
+ * Register query commands
342
+ */
343
+ RegisterQueryCommands: (ctx: Context, commands: MetadataCommand[]) => Promise<void>
344
+
345
+ /**
346
+ * Chat using LLM
347
+ */
348
+ LLMStream: (ctx: Context, conversations: AI.Conversation[], callback: AI.ChatStreamFunc) => Promise<void>
349
+
350
+ /**
351
+ * Register MRU restore callback
352
+ * @param ctx Context
353
+ * @param callback Callback function that takes MRUData and returns Result or null
354
+ * Return null if the MRU data is no longer valid
355
+ */
356
+ OnMRURestore: (ctx: Context, callback: (mruData: MRUData) => Promise<Result | null>) => Promise<void>
357
+
358
+ /**
359
+ * Get the current state of a result that is displayed in the UI.
360
+ *
361
+ * Returns UpdateableResult with current values if the result is still visible.
362
+ * Returns null if the result is no longer visible.
363
+ *
364
+ * Note: System actions and tails (like favorite icon) are automatically filtered out.
365
+ * They will be re-added by the system when you call UpdateResult().
366
+ *
367
+ * Example:
368
+ * ```typescript
369
+ * // In an action handler
370
+ * Action: async (actionContext) => {
371
+ * // Get current result state
372
+ * const updatableResult = await api.GetUpdatableResult(ctx, actionContext.ResultId)
373
+ * if (updatableResult === null) {
374
+ * return // Result no longer visible
375
+ * }
376
+ *
377
+ * // Modify the result
378
+ * updatableResult.Title = "Updated title"
379
+ * updatableResult.Tails?.push({ Type: "text", Text: "New tail" })
380
+ *
381
+ * // Update the result
382
+ * await api.UpdateResult(ctx, updatableResult)
383
+ * }
384
+ * ```
385
+ *
386
+ * @param ctx Context
387
+ * @param resultId ID of the result to get
388
+ * @returns Promise<UpdateableResult | null> Current result state, or null if not visible
389
+ */
390
+ GetUpdatableResult: (ctx: Context, resultId: string) => Promise<UpdateableResult | null>
391
+
392
+ /**
393
+ * Update a query result that is currently displayed in the UI.
394
+ *
395
+ * Returns true if the result was successfully updated (still visible in UI).
396
+ * Returns false if the result is no longer visible.
397
+ *
398
+ * This method is designed for long-running operations within Action handlers.
399
+ * Best practices:
400
+ * - Set PreventHideAfterAction: true in your action
401
+ * - Only use during action execution or in background tasks spawned by actions
402
+ * - For periodic updates, use RefreshableResult with OnRefresh instead
403
+ *
404
+ * Example:
405
+ * ```typescript
406
+ * // In an action handler
407
+ * Action: async (actionContext) => {
408
+ * // Update only the title
409
+ * const success = await api.UpdateResult(ctx, {
410
+ * Id: actionContext.ResultId,
411
+ * Title: "Downloading... 50%"
412
+ * })
413
+ *
414
+ * // Update title and tails
415
+ * const success = await api.UpdateResult(ctx, {
416
+ * Id: actionContext.ResultId,
417
+ * Title: "Processing...",
418
+ * Tails: [{ Type: "text", Text: "Step 1/3" }]
419
+ * })
420
+ * }
421
+ * ```
422
+ *
423
+ * @param ctx Context
424
+ * @param result UpdateableResult with Id (required) and optional fields to update
425
+ * @returns Promise<boolean> True if updated successfully, false if result no longer visible
426
+ */
427
+ UpdateResult: (ctx: Context, result: UpdateableResult) => Promise<boolean>
428
+
429
+ /**
430
+ * Update a single action within a query result that is currently displayed in the UI.
431
+ *
432
+ * Returns true if the action was successfully updated (result still visible in UI).
433
+ * Returns false if the result is no longer visible.
434
+ *
435
+ * This method is designed for updating action UI after execution, such as toggling
436
+ * between "Add to favorite" and "Remove from favorite" states.
437
+ *
438
+ * Best practices:
439
+ * - Set PreventHideAfterAction: true in your action
440
+ * - Use actionContext.ResultActionId to identify which action to update
441
+ * - Only update fields that have changed (use undefined for fields you don't want to update)
442
+ *
443
+ * Example:
444
+ * ```typescript
445
+ * // In an action handler
446
+ * Action: async (actionContext) => {
447
+ * if (isFavorite) {
448
+ * removeFavorite()
449
+ * const success = await api.UpdateResultAction(ctx, {
450
+ * ResultId: actionContext.ResultId,
451
+ * ActionId: actionContext.ResultActionId,
452
+ * Name: "Add to favorite",
453
+ * Icon: { ImageType: "emoji", ImageData: "⭐" }
454
+ * })
455
+ * } else {
456
+ * addFavorite()
457
+ * const success = await api.UpdateResultAction(ctx, {
458
+ * ResultId: actionContext.ResultId,
459
+ * ActionId: actionContext.ResultActionId,
460
+ * Name: "Remove from favorite",
461
+ * Icon: { ImageType: "emoji", ImageData: "❌" }
462
+ * })
463
+ * }
464
+ * }
465
+ * ```
466
+ *
467
+ * @param ctx Context
468
+ * @param action UpdateableResultAction with ResultId, ActionId (required) and optional fields to update
469
+ * @returns Promise<boolean> True if updated successfully, false if result no longer visible
470
+ */
471
+ UpdateResultAction: (ctx: Context, action: UpdateableResultAction) => Promise<boolean>
472
+ }
473
+
474
+ export type WoxImageType = "absolute" | "relative" | "base64" | "svg" | "url" | "emoji" | "lottie"
475
+
476
+ export interface WoxImage {
477
+ ImageType: WoxImageType
478
+ ImageData: string
479
+ }
480
+
481
+ export type WoxPreviewType = "markdown" | "text" | "image" | "url" | "file"
482
+
483
+ export interface WoxPreview {
484
+ PreviewType: WoxPreviewType
485
+ PreviewData: string
486
+ PreviewProperties: Record<string, string>
487
+ }
488
+
489
+ export declare interface Context {
490
+ Values: { [key: string]: string }
491
+ Get: (key: string) => string | undefined
492
+ Set: (key: string, value: string) => void
493
+ Exists: (key: string) => boolean
494
+ }
495
+
496
+ export function NewContext(): Context
497
+
498
+ export function NewContextWithValue(key: string, value: string): Context
499
+
500
+ export function NewBase64WoxImage(imageData: string): WoxImage
@@ -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
+ }