@wox-launcher/wox-plugin 0.0.78 → 0.0.79

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