@wox-launcher/wox-plugin 0.0.106 → 0.0.109
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/README.md +208 -1
- package/dist/context.js +31 -0
- package/dist/image.js +21 -0
- package/dist/index.js +20 -0
- package/package.json +1 -1
- package/types/ai.d.ts +354 -5
- package/types/index.d.ts +1040 -54
- package/types/setting.d.ts +419 -3
package/types/setting.d.ts
CHANGED
|
@@ -1,97 +1,513 @@
|
|
|
1
1
|
import { Context, Platform } from "./index.js"
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Type of plugin setting UI element.
|
|
5
|
+
*
|
|
6
|
+
* - `head`: Section header
|
|
7
|
+
* - `textbox`: Text input field
|
|
8
|
+
* - `checkbox`: Boolean checkbox
|
|
9
|
+
* - `select`: Dropdown selection
|
|
10
|
+
* - `label`: Informational label
|
|
11
|
+
* - `newline`: Line break
|
|
12
|
+
* - `table`: Data table display
|
|
13
|
+
* - `dynamic`: Dynamically loaded setting
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const settingType: PluginSettingDefinitionType = "textbox"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
3
20
|
export type PluginSettingDefinitionType = "head" | "textbox" | "checkbox" | "select" | "label" | "newline" | "table" | "dynamic"
|
|
4
21
|
|
|
5
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Visual styling properties for a setting element.
|
|
25
|
+
*
|
|
26
|
+
* Controls padding, width, and label positioning.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const style: PluginSettingValueStyle = {
|
|
31
|
+
* PaddingLeft: 10,
|
|
32
|
+
* PaddingTop: 5,
|
|
33
|
+
* PaddingRight: 10,
|
|
34
|
+
* PaddingBottom: 5,
|
|
35
|
+
* Width: 300,
|
|
36
|
+
* LabelWidth: 100
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
6
40
|
export interface PluginSettingValueStyle {
|
|
41
|
+
/**
|
|
42
|
+
* Left padding in pixels.
|
|
43
|
+
*/
|
|
7
44
|
PaddingLeft: number
|
|
45
|
+
/**
|
|
46
|
+
* Top padding in pixels.
|
|
47
|
+
*/
|
|
8
48
|
PaddingTop: number
|
|
49
|
+
/**
|
|
50
|
+
* Right padding in pixels.
|
|
51
|
+
*/
|
|
9
52
|
PaddingRight: number
|
|
53
|
+
/**
|
|
54
|
+
* Bottom padding in pixels.
|
|
55
|
+
*/
|
|
10
56
|
PaddingBottom: number
|
|
11
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Width of the setting element in pixels.
|
|
60
|
+
*/
|
|
12
61
|
Width: number
|
|
13
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Width of the label portion.
|
|
64
|
+
*
|
|
65
|
+
* Only applicable for settings with labels (textbox, checkbox, select).
|
|
66
|
+
*/
|
|
67
|
+
LabelWidth: number
|
|
14
68
|
}
|
|
15
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Base interface for all setting value types.
|
|
72
|
+
*
|
|
73
|
+
* Provides common methods for key retrieval, default values,
|
|
74
|
+
* and translation.
|
|
75
|
+
*/
|
|
16
76
|
export interface PluginSettingDefinitionValue {
|
|
77
|
+
/**
|
|
78
|
+
* Get the setting key.
|
|
79
|
+
*
|
|
80
|
+
* Used to store and retrieve the setting value.
|
|
81
|
+
*
|
|
82
|
+
* @returns The unique key for this setting
|
|
83
|
+
*/
|
|
17
84
|
GetKey: () => string
|
|
85
|
+
/**
|
|
86
|
+
* Get the default value for this setting.
|
|
87
|
+
*
|
|
88
|
+
* @returns The default value as a string
|
|
89
|
+
*/
|
|
18
90
|
GetDefaultValue: () => string
|
|
91
|
+
/**
|
|
92
|
+
* Translate labels and messages.
|
|
93
|
+
*
|
|
94
|
+
* @param translator - Translation function that takes context and key
|
|
95
|
+
*/
|
|
19
96
|
Translate: (translator: (ctx: Context, key: string) => string) => void
|
|
20
97
|
}
|
|
21
98
|
|
|
99
|
+
/**
|
|
100
|
+
* A single setting item in the plugin settings UI.
|
|
101
|
+
*
|
|
102
|
+
* Combines a type with its specific value configuration.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const setting: PluginSettingDefinitionItem = {
|
|
107
|
+
* Type: "textbox",
|
|
108
|
+
* Value: createTextboxSetting({
|
|
109
|
+
* key: "apiKey",
|
|
110
|
+
* label: "API Key",
|
|
111
|
+
* defaultValue: ""
|
|
112
|
+
* }),
|
|
113
|
+
* DisabledInPlatforms: ["linux"],
|
|
114
|
+
* IsPlatformSpecific: false
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
22
118
|
export interface PluginSettingDefinitionItem {
|
|
119
|
+
/**
|
|
120
|
+
* The type of setting element.
|
|
121
|
+
*/
|
|
23
122
|
Type: PluginSettingDefinitionType
|
|
123
|
+
/**
|
|
124
|
+
* The setting-specific value configuration.
|
|
125
|
+
*
|
|
126
|
+
* The actual type depends on the Type field.
|
|
127
|
+
*/
|
|
24
128
|
Value: PluginSettingDefinitionValue
|
|
129
|
+
/**
|
|
130
|
+
* Platforms where this setting should be disabled.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* DisabledInPlatforms: ["linux"] // Disabled on Linux only
|
|
135
|
+
* DisabledInPlatforms: [] // Enabled on all platforms
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
25
138
|
DisabledInPlatforms: Platform[]
|
|
26
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Whether this setting has platform-specific values.
|
|
141
|
+
*
|
|
142
|
+
* If true, the setting value is stored separately for each platform.
|
|
143
|
+
* If false, the same value is shared across all platforms.
|
|
144
|
+
*/
|
|
145
|
+
IsPlatformSpecific: boolean
|
|
27
146
|
}
|
|
28
147
|
|
|
148
|
+
/**
|
|
149
|
+
* A metadata command for query commands.
|
|
150
|
+
*
|
|
151
|
+
* Used to register commands that can be triggered from the query.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* await api.RegisterQueryCommands(ctx, [
|
|
156
|
+
* { Command: "search", Description: "Search the web" },
|
|
157
|
+
* { Command: "calc", Description: "Perform calculations" }
|
|
158
|
+
* ])
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
29
161
|
export interface MetadataCommand {
|
|
162
|
+
/**
|
|
163
|
+
* The command keyword.
|
|
164
|
+
*
|
|
165
|
+
* This is what users type to trigger the command.
|
|
166
|
+
*/
|
|
30
167
|
Command: string
|
|
168
|
+
/**
|
|
169
|
+
* Human-readable description of the command.
|
|
170
|
+
*
|
|
171
|
+
* Shown to users to explain what the command does.
|
|
172
|
+
*/
|
|
31
173
|
Description: string
|
|
32
174
|
}
|
|
33
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Checkbox setting value configuration.
|
|
178
|
+
*
|
|
179
|
+
* Represents a boolean toggle switch in the settings UI.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const checkbox: PluginSettingValueCheckBox = {
|
|
184
|
+
* Key: "enabled",
|
|
185
|
+
* Label: "Enable Feature",
|
|
186
|
+
* DefaultValue: "true",
|
|
187
|
+
* Tooltip: "When enabled, the feature will be active",
|
|
188
|
+
* Style: defaultStyle,
|
|
189
|
+
* GetKey: () => "enabled",
|
|
190
|
+
* GetDefaultValue: () => "true",
|
|
191
|
+
* Translate: (translator) => {}
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
34
195
|
export interface PluginSettingValueCheckBox extends PluginSettingDefinitionValue {
|
|
196
|
+
/**
|
|
197
|
+
* Unique key for storing this setting.
|
|
198
|
+
*/
|
|
35
199
|
Key: string
|
|
200
|
+
/**
|
|
201
|
+
* Display label for the checkbox.
|
|
202
|
+
*/
|
|
36
203
|
Label: string
|
|
204
|
+
/**
|
|
205
|
+
* Default value as "true" or "false" string.
|
|
206
|
+
*/
|
|
37
207
|
DefaultValue: string
|
|
208
|
+
/**
|
|
209
|
+
* Tooltip text shown on hover.
|
|
210
|
+
*/
|
|
38
211
|
Tooltip: string
|
|
212
|
+
/**
|
|
213
|
+
* Visual styling for this element.
|
|
214
|
+
*/
|
|
39
215
|
Style: PluginSettingValueStyle
|
|
40
216
|
}
|
|
41
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Dynamic setting value configuration.
|
|
220
|
+
*
|
|
221
|
+
* Represents a setting that is loaded dynamically via callback.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* await api.OnGetDynamicSetting(ctx, (ctx, key) => {
|
|
226
|
+
* if (key === "dynamicOption") {
|
|
227
|
+
* return createTextboxSetting({
|
|
228
|
+
* key: "dynamicOption",
|
|
229
|
+
* label: "Dynamic Option",
|
|
230
|
+
* defaultValue: "loaded from callback"
|
|
231
|
+
* })
|
|
232
|
+
* }
|
|
233
|
+
* return createLabelSetting({ content: "Unknown setting" })
|
|
234
|
+
* })
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
42
237
|
export interface PluginSettingValueDynamic extends PluginSettingDefinitionValue {
|
|
238
|
+
/**
|
|
239
|
+
* The key for this dynamic setting.
|
|
240
|
+
*
|
|
241
|
+
* This key is passed to the OnGetDynamicSetting callback
|
|
242
|
+
* to determine what setting to return.
|
|
243
|
+
*/
|
|
43
244
|
Key: string
|
|
44
245
|
}
|
|
45
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Header setting value configuration.
|
|
249
|
+
*
|
|
250
|
+
* Creates a section header in the settings UI.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const head: PluginSettingValueHead = {
|
|
255
|
+
* Content: "API Configuration",
|
|
256
|
+
* Tooltip: "Configure your API credentials",
|
|
257
|
+
* Style: { ...defaultStyle, PaddingTop: 20 },
|
|
258
|
+
* GetKey: () => "",
|
|
259
|
+
* GetDefaultValue: () => "",
|
|
260
|
+
* Translate: () => {}
|
|
261
|
+
* }
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
46
264
|
export interface PluginSettingValueHead extends PluginSettingDefinitionValue {
|
|
265
|
+
/**
|
|
266
|
+
* Header text to display.
|
|
267
|
+
*/
|
|
47
268
|
Content: string
|
|
269
|
+
/**
|
|
270
|
+
* Tooltip shown on hover.
|
|
271
|
+
*/
|
|
48
272
|
Tooltip: string
|
|
273
|
+
/**
|
|
274
|
+
* Visual styling for this element.
|
|
275
|
+
*/
|
|
49
276
|
Style: PluginSettingValueStyle
|
|
50
277
|
}
|
|
51
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Label setting value configuration.
|
|
281
|
+
*
|
|
282
|
+
* Creates an informational label (non-interactive).
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```typescript
|
|
286
|
+
* const label: PluginSettingValueLabel = {
|
|
287
|
+
* Content: "Note: API key is required for this feature to work.",
|
|
288
|
+
* Tooltip: "",
|
|
289
|
+
* Style: defaultStyle,
|
|
290
|
+
* GetKey: () => "",
|
|
291
|
+
* GetDefaultValue: () => "",
|
|
292
|
+
* Translate: () => {}
|
|
293
|
+
* }
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
52
296
|
export interface PluginSettingValueLabel extends PluginSettingDefinitionValue {
|
|
297
|
+
/**
|
|
298
|
+
* Label text to display.
|
|
299
|
+
*/
|
|
53
300
|
Content: string
|
|
301
|
+
/**
|
|
302
|
+
* Tooltip shown on hover.
|
|
303
|
+
*/
|
|
54
304
|
Tooltip: string
|
|
305
|
+
/**
|
|
306
|
+
* Visual styling for this element.
|
|
307
|
+
*/
|
|
55
308
|
Style: PluginSettingValueStyle
|
|
56
309
|
}
|
|
57
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Newline setting value configuration.
|
|
313
|
+
*
|
|
314
|
+
* Creates a line break in the settings layout.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* const newline: PluginSettingValueNewline = {
|
|
319
|
+
* Style: defaultStyle,
|
|
320
|
+
* GetKey: () => "",
|
|
321
|
+
* GetDefaultValue: () => "",
|
|
322
|
+
* Translate: () => {}
|
|
323
|
+
* }
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
58
326
|
export interface PluginSettingValueNewline extends PluginSettingDefinitionValue {
|
|
327
|
+
/**
|
|
328
|
+
* Visual styling for this element.
|
|
329
|
+
*/
|
|
59
330
|
Style: PluginSettingValueStyle
|
|
60
331
|
}
|
|
61
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Select dropdown setting value configuration.
|
|
335
|
+
*
|
|
336
|
+
* Creates a dropdown selection with predefined options.
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```typescript
|
|
340
|
+
* const select: PluginSettingValueSelect = {
|
|
341
|
+
* Key: "theme",
|
|
342
|
+
* Label: "Theme",
|
|
343
|
+
* Suffix: "",
|
|
344
|
+
* DefaultValue: "dark",
|
|
345
|
+
* Tooltip: "Choose your preferred theme",
|
|
346
|
+
* Options: [
|
|
347
|
+
* { Label: "Dark", Value: "dark" },
|
|
348
|
+
* { Label: "Light", Value: "light" }
|
|
349
|
+
* ],
|
|
350
|
+
* Validators: [],
|
|
351
|
+
* Style: defaultStyle,
|
|
352
|
+
* GetKey: () => "theme",
|
|
353
|
+
* GetDefaultValue: () => "dark",
|
|
354
|
+
* Translate: () => {}
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
62
358
|
export interface PluginSettingValueSelect extends PluginSettingDefinitionValue {
|
|
359
|
+
/**
|
|
360
|
+
* Unique key for storing this setting.
|
|
361
|
+
*/
|
|
63
362
|
Key: string
|
|
363
|
+
/**
|
|
364
|
+
* Display label for the dropdown.
|
|
365
|
+
*/
|
|
64
366
|
Label: string
|
|
367
|
+
/**
|
|
368
|
+
* Suffix text displayed after the value.
|
|
369
|
+
*/
|
|
65
370
|
Suffix: string
|
|
371
|
+
/**
|
|
372
|
+
* Default selected value.
|
|
373
|
+
*/
|
|
66
374
|
DefaultValue: string
|
|
375
|
+
/**
|
|
376
|
+
* Tooltip shown on hover.
|
|
377
|
+
*/
|
|
67
378
|
Tooltip: string
|
|
379
|
+
/**
|
|
380
|
+
* Available options in the dropdown.
|
|
381
|
+
*/
|
|
68
382
|
Options: PluginSettingValueSelectOption[]
|
|
69
|
-
|
|
383
|
+
/**
|
|
384
|
+
* Validation rules for the selected value.
|
|
385
|
+
*
|
|
386
|
+
* All validators must be satisfied for the value to be valid.
|
|
387
|
+
*/
|
|
388
|
+
Validators: PluginSettingValidator[]
|
|
70
389
|
|
|
390
|
+
/**
|
|
391
|
+
* Visual styling for this element.
|
|
392
|
+
*/
|
|
71
393
|
Style: PluginSettingValueStyle
|
|
72
394
|
}
|
|
73
395
|
|
|
396
|
+
/**
|
|
397
|
+
* An option in a select dropdown.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```typescript
|
|
401
|
+
* const option: PluginSettingValueSelectOption = {
|
|
402
|
+
* Label: "Dark Mode",
|
|
403
|
+
* Value: "dark"
|
|
404
|
+
* }
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
74
407
|
export interface PluginSettingValueSelectOption {
|
|
408
|
+
/**
|
|
409
|
+
* Human-readable label displayed in the dropdown.
|
|
410
|
+
*/
|
|
75
411
|
Label: string
|
|
412
|
+
/**
|
|
413
|
+
* Internal value for this option.
|
|
414
|
+
*/
|
|
76
415
|
Value: string
|
|
77
416
|
}
|
|
78
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Type of setting validator.
|
|
420
|
+
*
|
|
421
|
+
* - `is_number`: Validates that the value is a number
|
|
422
|
+
* - `not_empty`: Validates that the value is not empty
|
|
423
|
+
*/
|
|
79
424
|
export type PluginSettingValidatorType = "is_number" | "not_empty"
|
|
80
425
|
|
|
426
|
+
/**
|
|
427
|
+
* A validator for setting values.
|
|
428
|
+
*
|
|
429
|
+
* Ensures that user input meets certain criteria.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const validator: PluginSettingValidator = {
|
|
434
|
+
* Type: "is_number",
|
|
435
|
+
* Value: { IsInteger: true, IsFloat: false }
|
|
436
|
+
* }
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
81
439
|
export interface PluginSettingValidator {
|
|
440
|
+
/**
|
|
441
|
+
* The type of validator.
|
|
442
|
+
*/
|
|
82
443
|
Type: PluginSettingValidatorType
|
|
444
|
+
/**
|
|
445
|
+
* Validator-specific configuration.
|
|
446
|
+
*
|
|
447
|
+
* The actual type depends on the Type field.
|
|
448
|
+
*/
|
|
83
449
|
Value: PluginSettingValidatorValue
|
|
84
450
|
}
|
|
85
451
|
|
|
452
|
+
/**
|
|
453
|
+
* Base interface for validator values.
|
|
454
|
+
*/
|
|
86
455
|
export interface PluginSettingValidatorValue {
|
|
456
|
+
/**
|
|
457
|
+
* Get the validator type.
|
|
458
|
+
*
|
|
459
|
+
* @returns The type of this validator
|
|
460
|
+
*/
|
|
87
461
|
GetValidatorType(): PluginSettingValidatorType
|
|
88
462
|
}
|
|
89
463
|
|
|
464
|
+
/**
|
|
465
|
+
* Number validator configuration.
|
|
466
|
+
*
|
|
467
|
+
* Validates that the input is a valid number.
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* const integerValidator: PluginSettingValidatorIsNumber = {
|
|
472
|
+
* IsInteger: true,
|
|
473
|
+
* IsFloat: false,
|
|
474
|
+
* GetValidatorType: () => "is_number"
|
|
475
|
+
* }
|
|
476
|
+
*
|
|
477
|
+
* const floatValidator: PluginSettingValidatorIsNumber = {
|
|
478
|
+
* IsInteger: false,
|
|
479
|
+
* IsFloat: true,
|
|
480
|
+
* GetValidatorType: () => "is_number"
|
|
481
|
+
* }
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
90
484
|
export interface PluginSettingValidatorIsNumber extends PluginSettingValidatorValue {
|
|
485
|
+
/**
|
|
486
|
+
* Whether to validate as an integer.
|
|
487
|
+
*
|
|
488
|
+
* If true, the value must be a whole number.
|
|
489
|
+
*/
|
|
91
490
|
IsInteger: boolean
|
|
491
|
+
/**
|
|
492
|
+
* Whether to validate as a float.
|
|
493
|
+
*
|
|
494
|
+
* If true, the value can have decimal places.
|
|
495
|
+
*/
|
|
92
496
|
IsFloat: boolean
|
|
93
497
|
}
|
|
94
498
|
|
|
499
|
+
/**
|
|
500
|
+
* Not-empty validator configuration.
|
|
501
|
+
*
|
|
502
|
+
* Validates that the input is not empty.
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```typescript
|
|
506
|
+
* const validator: PluginSettingValidatorNotEmpty = {
|
|
507
|
+
* GetValidatorType: () => "not_empty"
|
|
508
|
+
* }
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
95
511
|
export interface PluginSettingValidatorNotEmpty extends PluginSettingValidatorValue {
|
|
96
512
|
|
|
97
513
|
}
|