@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/types/index.d.ts +225 -200
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wox-launcher/wox-plugin",
3
- "version": "0.0.82",
3
+ "version": "0.0.84",
4
4
  "description": "All nodejs plugin for Wox should use types in this package",
5
5
  "repository": {
6
6
  "type": "git",
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
- init: (ctx: Context, initParams: PluginInitParams) => Promise<void>
10
- query: (ctx: Context, query: Query) => Promise<Result[]>
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
- Type: "text" | "file"
15
- // Only available when Type is text
16
- Text: string
17
- // Only available when Type is file
18
- FilePaths: string[]
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
- * Active window title when user query
24
- */
25
- ActiveWindowTitle: string
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
- * 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
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
- 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>
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
- Type: "text" | "image"
101
- Text?: string
102
- Image?: WoxImage
109
+ Type: "text" | "image"
110
+ Text?: string
111
+ Image?: WoxImage
103
112
  }
104
113
 
105
114
  export interface RefreshableResult {
106
- Title: string
107
- SubTitle: string
108
- Icon: WoxImage
109
- Preview: WoxPreview
110
- Tails: ResultTail[]
111
- ContextData: string
112
- RefreshInterval: number
113
- Actions: ResultAction[]
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
- * Result id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you
119
- */
120
- Id?: string
121
- Name: string
122
- Icon?: WoxImage
123
- /**
124
- * If true, Wox will use this action as default action. There can be only one default action in results
125
- * This can be omitted, if you don't set it, Wox will use the first action as default action
126
- */
127
- IsDefault?: boolean
128
- /**
129
- * If true, Wox will not hide after user select this result
130
- */
131
- PreventHideAfterAction?: boolean
132
- Action: (actionContext: ActionContext) => Promise<void>
133
- /**
134
- * Hotkey to trigger this action. E.g. "ctrl+Shift+Space", "Ctrl+1", "Command+K"
135
- * Case insensitive, space insensitive
136
- *
137
- * If IsDefault is true, Hotkey will be set to enter key by default
138
- */
139
- Hotkey?: string
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
- ContextData: string
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
- API: PublicAPI
148
- PluginDirectory: string
164
+ API: PublicAPI
165
+ PluginDirectory: string
149
166
  }
150
167
 
151
168
  export interface ChangeQueryParam {
152
- QueryType: "input" | "selection"
153
- QueryText?: string
154
- QuerySelection?: Selection
169
+ QueryType: "input" | "selection"
170
+ QueryText?: string
171
+ QuerySelection?: Selection
155
172
  }
156
173
 
157
174
  export interface PublicAPI {
158
- /**
159
- * Change Wox query
160
- */
161
- ChangeQuery: (ctx: Context, query: ChangeQueryParam) => Promise<void>
162
-
163
- /**
164
- * Hide Wox
165
- */
166
- HideApp: (ctx: Context) => Promise<void>
167
-
168
- /**
169
- * Show Wox
170
- */
171
- ShowApp: (ctx: Context) => Promise<void>
172
-
173
- /**
174
- * Notify message
175
- */
176
- Notify: (ctx: Context, message: string) => Promise<void>
177
-
178
- /**
179
- * Write log
180
- */
181
- Log: (ctx: Context, level: "Info" | "Error" | "Debug" | "Warning", msg: string) => Promise<void>
182
-
183
- /**
184
- * Get translation of current language
185
- */
186
- GetTranslation: (ctx: Context, key: string) => Promise<string>
187
-
188
- /**
189
- * Get customized setting
190
- *
191
- * will try to get platform specific setting first, if not found, will try to get global setting
192
- */
193
- GetSetting: (ctx: Context, key: string) => Promise<string>
194
-
195
- /**
196
- * Save customized setting
197
- *
198
- * @isPlatformSpecific If true, setting will be only saved in current platform. If false, setting will be available in all platforms
199
- */
200
- SaveSetting: (ctx: Context, key: string, value: string, isPlatformSpecific: boolean) => Promise<void>
201
-
202
- /**
203
- * Register setting changed callback
204
- */
205
- OnSettingChanged: (ctx: Context, callback: (key: string, value: string) => void) => Promise<void>
206
-
207
- /**
208
- * Get dynamic setting definition
209
- */
210
- OnGetDynamicSetting: (ctx: Context, callback: (key: string) => PluginSettingDefinitionItem) => Promise<void>
211
-
212
- /**
213
- * Register deep link callback
214
- */
215
- OnDeepLink: (ctx: Context, callback: (arguments: MapString) => void) => Promise<void>
216
-
217
- /**
218
- * Register on load event
219
- */
220
- OnUnload: (ctx: Context, callback: () => Promise<void>) => Promise<void>
221
-
222
- /**
223
- * Register query commands
224
- */
225
- RegisterQueryCommands: (ctx: Context, commands: MetadataCommand[]) => Promise<void>
226
-
227
- /**
228
- * Chat using LLM
229
- */
230
- LLMStream: (ctx: Context, conversations: AI.Conversation[], callback: AI.ChatStreamFunc) => Promise<void>
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
- ImageType: WoxImageType
237
- ImageData: string
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
- PreviewType: WoxPreviewType
244
- PreviewData: string
245
- PreviewProperties: Record<string, string>
268
+ PreviewType: WoxPreviewType
269
+ PreviewData: string
270
+ PreviewProperties: Record<string, string>
246
271
  }
247
272
 
248
273
  export declare interface Context {
249
- Values: { [key: string]: string }
250
- Get: (key: string) => string | undefined
251
- Set: (key: string, value: string) => void
252
- Exists: (key: string) => boolean
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