@wox-launcher/wox-plugin 0.0.96 → 0.0.98
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 +1 -85
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -150,46 +150,6 @@ export interface UpdatableResult {
|
|
|
150
150
|
Actions?: ResultAction[]
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
* Represents an action that can be updated directly in the UI.
|
|
155
|
-
*
|
|
156
|
-
* This allows updating a single action's UI (name, icon, action callback) without replacing the entire actions array.
|
|
157
|
-
* All fields except ResultId and ActionId are optional. Only non-undefined fields will be updated.
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* // Update only the action name
|
|
162
|
-
* const success = await api.UpdateResultAction(ctx, {
|
|
163
|
-
* ResultId: actionContext.ResultId,
|
|
164
|
-
* ActionId: actionContext.ResultActionId,
|
|
165
|
-
* Name: "Remove from favorite"
|
|
166
|
-
* })
|
|
167
|
-
*
|
|
168
|
-
* // Update name, icon and action callback
|
|
169
|
-
* const success = await api.UpdateResultAction(ctx, {
|
|
170
|
-
* ResultId: actionContext.ResultId,
|
|
171
|
-
* ActionId: actionContext.ResultActionId,
|
|
172
|
-
* Name: "Add to favorite",
|
|
173
|
-
* Icon: { ImageType: "emoji", ImageData: "⭐" },
|
|
174
|
-
* Action: async (actionContext) => {
|
|
175
|
-
* // New action logic
|
|
176
|
-
* }
|
|
177
|
-
* })
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
export interface UpdatableResultAction {
|
|
181
|
-
/** Required - identifies which result contains the action */
|
|
182
|
-
ResultId: string
|
|
183
|
-
/** Required - identifies which action to update */
|
|
184
|
-
ActionId: string
|
|
185
|
-
/** Optional - update the action name */
|
|
186
|
-
Name?: string
|
|
187
|
-
/** Optional - update the action icon */
|
|
188
|
-
Icon?: WoxImage
|
|
189
|
-
/** Optional - update the action callback */
|
|
190
|
-
Action?: (actionContext: ActionContext) => Promise<void>
|
|
191
|
-
}
|
|
192
|
-
|
|
193
153
|
export type ResultActionType = "execute" | "form"
|
|
194
154
|
|
|
195
155
|
export type ResultAction = ExecuteResultAction | FormResultAction
|
|
@@ -267,7 +227,7 @@ export interface ActionContext {
|
|
|
267
227
|
/**
|
|
268
228
|
* The ID of the action that was triggered
|
|
269
229
|
* This is automatically set by Wox when the action is invoked
|
|
270
|
-
* Useful for calling
|
|
230
|
+
* Useful for calling UpdateResult API to update this action's UI
|
|
271
231
|
*/
|
|
272
232
|
ResultActionId: string
|
|
273
233
|
/**
|
|
@@ -467,50 +427,6 @@ export interface PublicAPI {
|
|
|
467
427
|
*/
|
|
468
428
|
UpdateResult: (ctx: Context, result: UpdatableResult) => Promise<boolean>
|
|
469
429
|
|
|
470
|
-
/**
|
|
471
|
-
* Update a single action within a query result that is currently displayed in the UI.
|
|
472
|
-
*
|
|
473
|
-
* Returns true if the action was successfully updated (result still visible in UI).
|
|
474
|
-
* Returns false if the result is no longer visible.
|
|
475
|
-
*
|
|
476
|
-
* This method is designed for updating action UI after execution, such as toggling
|
|
477
|
-
* between "Add to favorite" and "Remove from favorite" states.
|
|
478
|
-
*
|
|
479
|
-
* Best practices:
|
|
480
|
-
* - Set PreventHideAfterAction: true in your action
|
|
481
|
-
* - Use actionContext.ResultActionId to identify which action to update
|
|
482
|
-
* - Only update fields that have changed (use undefined for fields you don't want to update)
|
|
483
|
-
*
|
|
484
|
-
* Example:
|
|
485
|
-
* ```typescript
|
|
486
|
-
* // In an action handler
|
|
487
|
-
* Action: async (actionContext) => {
|
|
488
|
-
* if (isFavorite) {
|
|
489
|
-
* removeFavorite()
|
|
490
|
-
* const success = await api.UpdateResultAction(ctx, {
|
|
491
|
-
* ResultId: actionContext.ResultId,
|
|
492
|
-
* ActionId: actionContext.ResultActionId,
|
|
493
|
-
* Name: "Add to favorite",
|
|
494
|
-
* Icon: { ImageType: "emoji", ImageData: "⭐" }
|
|
495
|
-
* })
|
|
496
|
-
* } else {
|
|
497
|
-
* addFavorite()
|
|
498
|
-
* const success = await api.UpdateResultAction(ctx, {
|
|
499
|
-
* ResultId: actionContext.ResultId,
|
|
500
|
-
* ActionId: actionContext.ResultActionId,
|
|
501
|
-
* Name: "Remove from favorite",
|
|
502
|
-
* Icon: { ImageType: "emoji", ImageData: "❌" }
|
|
503
|
-
* })
|
|
504
|
-
* }
|
|
505
|
-
* }
|
|
506
|
-
* ```
|
|
507
|
-
*
|
|
508
|
-
* @param ctx Context
|
|
509
|
-
* @param action UpdatableResultAction with ResultId, ActionId (required) and optional fields to update
|
|
510
|
-
* @returns Promise<boolean> True if updated successfully, false if result no longer visible
|
|
511
|
-
*/
|
|
512
|
-
UpdateResultAction: (ctx: Context, action: UpdatableResultAction) => Promise<boolean>
|
|
513
|
-
|
|
514
430
|
/**
|
|
515
431
|
* Re-execute the current query with the existing query text.
|
|
516
432
|
* This is useful when plugin data changes and you want to update the displayed results.
|