@wox-launcher/wox-plugin 0.0.83 → 0.0.85

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 +9 -9
  2. package/types/index.d.ts +225 -209
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wox-launcher/wox-plugin",
3
- "version": "0.0.83",
3
+ "version": "0.0.85",
4
4
  "description": "All nodejs plugin for Wox should use types in this package",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,6 +13,13 @@
13
13
  "dist",
14
14
  "types"
15
15
  ],
16
+ "scripts": {
17
+ "build": "pnpm clean && tsc",
18
+ "clean": "node -e \"var { rmdirSync, existsSync } = require('fs'), path = require('path'); ['./dist'].forEach(fPath => {if (existsSync(path.join(__dirname, fPath))) rmdirSync(path.join(__dirname, fPath), { recursive: true })}); process.exit(0);\"",
19
+ "clean:all": "npm run clean && (rm -r ./node_modules || true)",
20
+ "lint": "eslint --ext .ts --fix src/**/*.ts",
21
+ "pub": "pnpm build && pnpm version patch && pnpm publish --no-git-checks --access public"
22
+ },
16
23
  "devDependencies": {
17
24
  "@typescript-eslint/eslint-plugin": "^7.13.1",
18
25
  "@typescript-eslint/parser": "^7.13.1",
@@ -21,12 +28,5 @@
21
28
  "prettier": "3.3.2",
22
29
  "typescript": "^5.4.5"
23
30
  },
24
- "dependencies": {},
25
- "scripts": {
26
- "build": "pnpm clean && tsc",
27
- "clean": "node -e \"var { rmdirSync, existsSync } = require('fs'), path = require('path'); ['./dist'].forEach(fPath => {if (existsSync(path.join(__dirname, fPath))) rmdirSync(path.join(__dirname, fPath), { recursive: true })}); process.exit(0);\"",
28
- "clean:all": "npm run clean && (rm -r ./node_modules || true)",
29
- "lint": "eslint --ext .ts --fix src/**/*.ts",
30
- "pub": "pnpm build && pnpm version patch && pnpm publish --no-git-checks --access public"
31
- }
31
+ "dependencies": {}
32
32
  }
package/types/index.d.ts CHANGED
@@ -1,264 +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
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
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
35
  }
36
36
 
37
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
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
86
  }
87
87
 
88
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>
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
106
  }
107
107
 
108
108
  export interface ResultTail {
109
- Type: "text" | "image"
110
- Text?: string
111
- Image?: WoxImage
109
+ Type: "text" | "image"
110
+ Text?: string
111
+ Image?: WoxImage
112
112
  }
113
113
 
114
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[]
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
123
  }
124
124
 
125
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
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
149
  }
150
150
 
151
151
  export interface ActionContext {
152
- 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
153
161
  }
154
162
 
155
163
  export interface PluginInitParams {
156
- API: PublicAPI
157
- PluginDirectory: string
164
+ API: PublicAPI
165
+ PluginDirectory: string
158
166
  }
159
167
 
160
168
  export interface ChangeQueryParam {
161
- QueryType: "input" | "selection"
162
- QueryText?: string
163
- QuerySelection?: Selection
169
+ QueryType: "input" | "selection"
170
+ QueryText?: string
171
+ QuerySelection?: Selection
164
172
  }
165
173
 
166
174
  export interface PublicAPI {
167
- /**
168
- * Change Wox query
169
- */
170
- ChangeQuery: (ctx: Context, query: ChangeQueryParam) => Promise<void>
171
-
172
- /**
173
- * Hide Wox
174
- */
175
- HideApp: (ctx: Context) => Promise<void>
176
-
177
- /**
178
- * Show Wox
179
- */
180
- ShowApp: (ctx: Context) => Promise<void>
181
-
182
- /**
183
- * Notify message
184
- */
185
- Notify: (ctx: Context, message: string) => Promise<void>
186
-
187
- /**
188
- * Write log
189
- */
190
- Log: (ctx: Context, level: "Info" | "Error" | "Debug" | "Warning", msg: string) => Promise<void>
191
-
192
- /**
193
- * Get translation of current language
194
- */
195
- GetTranslation: (ctx: Context, key: string) => Promise<string>
196
-
197
- /**
198
- * Get customized setting
199
- *
200
- * will try to get platform specific setting first, if not found, will try to get global setting
201
- */
202
- GetSetting: (ctx: Context, key: string) => Promise<string>
203
-
204
- /**
205
- * Save customized setting
206
- *
207
- * @isPlatformSpecific If true, setting will be only saved in current platform. If false, setting will be available in all platforms
208
- */
209
- SaveSetting: (ctx: Context, key: string, value: string, isPlatformSpecific: boolean) => Promise<void>
210
-
211
- /**
212
- * Register setting changed callback
213
- */
214
- OnSettingChanged: (ctx: Context, callback: (key: string, value: string) => void) => Promise<void>
215
-
216
- /**
217
- * Get dynamic setting definition
218
- */
219
- OnGetDynamicSetting: (ctx: Context, callback: (key: string) => PluginSettingDefinitionItem) => Promise<void>
220
-
221
- /**
222
- * Register deep link callback
223
- */
224
- OnDeepLink: (ctx: Context, callback: (arguments: MapString) => void) => Promise<void>
225
-
226
- /**
227
- * Register on load event
228
- */
229
- OnUnload: (ctx: Context, callback: () => Promise<void>) => Promise<void>
230
-
231
- /**
232
- * Register query commands
233
- */
234
- RegisterQueryCommands: (ctx: Context, commands: MetadataCommand[]) => Promise<void>
235
-
236
- /**
237
- * Chat using LLM
238
- */
239
- 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) => PluginSettingDefinitionItem) => 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>
240
256
  }
241
257
 
242
258
  export type WoxImageType = "absolute" | "relative" | "base64" | "svg" | "url" | "emoji" | "lottie"
243
259
 
244
260
  export interface WoxImage {
245
- ImageType: WoxImageType
246
- ImageData: string
261
+ ImageType: WoxImageType
262
+ ImageData: string
247
263
  }
248
264
 
249
265
  export type WoxPreviewType = "markdown" | "text" | "image" | "url" | "file"
250
266
 
251
267
  export interface WoxPreview {
252
- PreviewType: WoxPreviewType
253
- PreviewData: string
254
- PreviewProperties: Record<string, string>
268
+ PreviewType: WoxPreviewType
269
+ PreviewData: string
270
+ PreviewProperties: Record<string, string>
255
271
  }
256
272
 
257
273
  export declare interface Context {
258
- Values: { [key: string]: string }
259
- Get: (key: string) => string | undefined
260
- Set: (key: string, value: string) => void
261
- 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
262
278
  }
263
279
 
264
280
  export function NewContext(): Context