@wox-launcher/wox-plugin 0.0.111 → 0.0.114
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 +41 -11
- package/package.json +1 -1
- package/types/index.d.ts +20 -10
- package/types/setting.d.ts +89 -61
package/README.md
CHANGED
|
@@ -139,17 +139,47 @@ Define settings for your plugin:
|
|
|
139
139
|
|
|
140
140
|
```typescript
|
|
141
141
|
const settings: PluginSettingDefinitionItem[] = [
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
142
|
+
{
|
|
143
|
+
Type: "textbox",
|
|
144
|
+
Value: {
|
|
145
|
+
Key: "apiKey",
|
|
146
|
+
Label: "API Key",
|
|
147
|
+
Suffix: "",
|
|
148
|
+
DefaultValue: "",
|
|
149
|
+
Tooltip: "Enter your API key",
|
|
150
|
+
MaxLines: 1,
|
|
151
|
+
Validators: [],
|
|
152
|
+
Style: {
|
|
153
|
+
PaddingLeft: 0,
|
|
154
|
+
PaddingTop: 0,
|
|
155
|
+
PaddingRight: 0,
|
|
156
|
+
PaddingBottom: 0,
|
|
157
|
+
Width: 0,
|
|
158
|
+
LabelWidth: 0
|
|
159
|
+
}
|
|
160
|
+
} as PluginSettingValueTextBox,
|
|
161
|
+
DisabledInPlatforms: [],
|
|
162
|
+
IsPlatformSpecific: false
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
Type: "checkbox",
|
|
166
|
+
Value: {
|
|
167
|
+
Key: "enabled",
|
|
168
|
+
Label: "Enable Feature",
|
|
169
|
+
DefaultValue: "true",
|
|
170
|
+
Tooltip: "",
|
|
171
|
+
Style: {
|
|
172
|
+
PaddingLeft: 0,
|
|
173
|
+
PaddingTop: 0,
|
|
174
|
+
PaddingRight: 0,
|
|
175
|
+
PaddingBottom: 0,
|
|
176
|
+
Width: 0,
|
|
177
|
+
LabelWidth: 0
|
|
178
|
+
}
|
|
179
|
+
} as PluginSettingValueCheckBox,
|
|
180
|
+
DisabledInPlatforms: [],
|
|
181
|
+
IsPlatformSpecific: false
|
|
182
|
+
}
|
|
153
183
|
]
|
|
154
184
|
```
|
|
155
185
|
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { MetadataCommand, PluginSettingDefinitionItem } from "./setting.js"
|
|
2
2
|
import { AI } from "./ai.js"
|
|
3
3
|
|
|
4
|
+
export * from "./setting.js"
|
|
5
|
+
export * from "./ai.js"
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* A dictionary type for string key-value pairs.
|
|
6
9
|
*
|
|
@@ -706,16 +709,23 @@ export interface ExecuteResultAction {
|
|
|
706
709
|
* Name: "Create New Item",
|
|
707
710
|
* Icon: { ImageType: "emoji", ImageData: "➕" },
|
|
708
711
|
* Form: [
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
*
|
|
717
|
-
*
|
|
718
|
-
* }
|
|
712
|
+
* {
|
|
713
|
+
* Key: "name",
|
|
714
|
+
* Label: "Name",
|
|
715
|
+
* Suffix: "",
|
|
716
|
+
* DefaultValue: "",
|
|
717
|
+
* Tooltip: "",
|
|
718
|
+
* MaxLines: 1,
|
|
719
|
+
* Validators: [],
|
|
720
|
+
* Style: {} as PluginSettingValueStyle
|
|
721
|
+
* } as PluginSettingValueTextBox,
|
|
722
|
+
* {
|
|
723
|
+
* Key: "enabled",
|
|
724
|
+
* Label: "Enable",
|
|
725
|
+
* DefaultValue: "true",
|
|
726
|
+
* Tooltip: "",
|
|
727
|
+
* Style: {} as PluginSettingValueStyle
|
|
728
|
+
* } as PluginSettingValueCheckBox
|
|
719
729
|
* ],
|
|
720
730
|
* OnSubmit: async (ctx, formCtx) => {
|
|
721
731
|
* console.log("Name:", formCtx.Values["name"])
|
package/types/setting.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Platform } from "./index.js"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Type of plugin setting UI element.
|
|
@@ -19,7 +19,6 @@ import { Context, Platform } from "./index.js"
|
|
|
19
19
|
*/
|
|
20
20
|
export type PluginSettingDefinitionType = "head" | "textbox" | "checkbox" | "select" | "label" | "newline" | "table" | "dynamic"
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
/**
|
|
24
23
|
* Visual styling properties for a setting element.
|
|
25
24
|
*
|
|
@@ -69,32 +68,8 @@ export interface PluginSettingValueStyle {
|
|
|
69
68
|
|
|
70
69
|
/**
|
|
71
70
|
* Base interface for all setting value types.
|
|
72
|
-
*
|
|
73
|
-
* Provides common methods for key retrieval, default values,
|
|
74
|
-
* and translation.
|
|
75
71
|
*/
|
|
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
|
-
*/
|
|
84
|
-
GetKey: () => string
|
|
85
|
-
/**
|
|
86
|
-
* Get the default value for this setting.
|
|
87
|
-
*
|
|
88
|
-
* @returns The default value as a string
|
|
89
|
-
*/
|
|
90
|
-
GetDefaultValue: () => string
|
|
91
|
-
/**
|
|
92
|
-
* Translate labels and messages.
|
|
93
|
-
*
|
|
94
|
-
* @param translator - Translation function that takes context and key
|
|
95
|
-
*/
|
|
96
|
-
Translate: (translator: (ctx: Context, key: string) => string) => void
|
|
97
|
-
}
|
|
72
|
+
export interface PluginSettingDefinitionValue {}
|
|
98
73
|
|
|
99
74
|
/**
|
|
100
75
|
* A single setting item in the plugin settings UI.
|
|
@@ -105,11 +80,16 @@ export interface PluginSettingDefinitionValue {
|
|
|
105
80
|
* ```typescript
|
|
106
81
|
* const setting: PluginSettingDefinitionItem = {
|
|
107
82
|
* Type: "textbox",
|
|
108
|
-
* Value:
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
83
|
+
* Value: {
|
|
84
|
+
* Key: "apiKey",
|
|
85
|
+
* Label: "API Key",
|
|
86
|
+
* Suffix: "",
|
|
87
|
+
* DefaultValue: "",
|
|
88
|
+
* Tooltip: "",
|
|
89
|
+
* MaxLines: 1,
|
|
90
|
+
* Validators: [],
|
|
91
|
+
* Style: {} as PluginSettingValueStyle
|
|
92
|
+
* } as PluginSettingValueTextBox,
|
|
113
93
|
* DisabledInPlatforms: ["linux"],
|
|
114
94
|
* IsPlatformSpecific: false
|
|
115
95
|
* }
|
|
@@ -185,10 +165,7 @@ export interface MetadataCommand {
|
|
|
185
165
|
* Label: "Enable Feature",
|
|
186
166
|
* DefaultValue: "true",
|
|
187
167
|
* Tooltip: "When enabled, the feature will be active",
|
|
188
|
-
* Style:
|
|
189
|
-
* GetKey: () => "enabled",
|
|
190
|
-
* GetDefaultValue: () => "true",
|
|
191
|
-
* Translate: (translator) => {}
|
|
168
|
+
* Style: {} as PluginSettingValueStyle
|
|
192
169
|
* }
|
|
193
170
|
* ```
|
|
194
171
|
*/
|
|
@@ -215,6 +192,62 @@ export interface PluginSettingValueCheckBox extends PluginSettingDefinitionValue
|
|
|
215
192
|
Style: PluginSettingValueStyle
|
|
216
193
|
}
|
|
217
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Textbox setting value configuration.
|
|
197
|
+
*
|
|
198
|
+
* Represents a text input field in the settings UI.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* const textbox: PluginSettingValueTextBox = {
|
|
203
|
+
* Key: "apiKey",
|
|
204
|
+
* Label: "API Key",
|
|
205
|
+
* Suffix: "",
|
|
206
|
+
* DefaultValue: "",
|
|
207
|
+
* Tooltip: "Enter your API key",
|
|
208
|
+
* MaxLines: 1,
|
|
209
|
+
* Validators: [],
|
|
210
|
+
* Style: {} as PluginSettingValueStyle
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
export interface PluginSettingValueTextBox extends PluginSettingDefinitionValue {
|
|
215
|
+
/**
|
|
216
|
+
* Unique key for storing this setting.
|
|
217
|
+
*/
|
|
218
|
+
Key: string
|
|
219
|
+
/**
|
|
220
|
+
* Display label for the textbox.
|
|
221
|
+
*/
|
|
222
|
+
Label: string
|
|
223
|
+
/**
|
|
224
|
+
* Suffix text displayed after the value.
|
|
225
|
+
*/
|
|
226
|
+
Suffix: string
|
|
227
|
+
/**
|
|
228
|
+
* Default value.
|
|
229
|
+
*/
|
|
230
|
+
DefaultValue: string
|
|
231
|
+
/**
|
|
232
|
+
* Tooltip shown on hover.
|
|
233
|
+
*/
|
|
234
|
+
Tooltip: string
|
|
235
|
+
/**
|
|
236
|
+
* Max lines for the textbox. Default is 1.
|
|
237
|
+
*/
|
|
238
|
+
MaxLines: number
|
|
239
|
+
/**
|
|
240
|
+
* Validation rules for the input value.
|
|
241
|
+
*
|
|
242
|
+
* All validators must be satisfied for the value to be valid.
|
|
243
|
+
*/
|
|
244
|
+
Validators: PluginSettingValidator[]
|
|
245
|
+
/**
|
|
246
|
+
* Visual styling for this element.
|
|
247
|
+
*/
|
|
248
|
+
Style: PluginSettingValueStyle
|
|
249
|
+
}
|
|
250
|
+
|
|
218
251
|
/**
|
|
219
252
|
* Dynamic setting value configuration.
|
|
220
253
|
*
|
|
@@ -224,13 +257,22 @@ export interface PluginSettingValueCheckBox extends PluginSettingDefinitionValue
|
|
|
224
257
|
* ```typescript
|
|
225
258
|
* await api.OnGetDynamicSetting(ctx, (ctx, key) => {
|
|
226
259
|
* if (key === "dynamicOption") {
|
|
227
|
-
* return
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
260
|
+
* return {
|
|
261
|
+
* Key: "dynamicOption",
|
|
262
|
+
* Label: "Dynamic Option",
|
|
263
|
+
* Suffix: "",
|
|
264
|
+
* DefaultValue: "loaded from callback",
|
|
265
|
+
* Tooltip: "",
|
|
266
|
+
* MaxLines: 1,
|
|
267
|
+
* Validators: [],
|
|
268
|
+
* Style: {} as PluginSettingValueStyle
|
|
269
|
+
* } as PluginSettingValueTextBox
|
|
232
270
|
* }
|
|
233
|
-
* return
|
|
271
|
+
* return {
|
|
272
|
+
* Content: "Unknown setting",
|
|
273
|
+
* Tooltip: "",
|
|
274
|
+
* Style: {} as PluginSettingValueStyle
|
|
275
|
+
* } as PluginSettingValueLabel
|
|
234
276
|
* })
|
|
235
277
|
* ```
|
|
236
278
|
*/
|
|
@@ -254,10 +296,7 @@ export interface PluginSettingValueDynamic extends PluginSettingDefinitionValue
|
|
|
254
296
|
* const head: PluginSettingValueHead = {
|
|
255
297
|
* Content: "API Configuration",
|
|
256
298
|
* Tooltip: "Configure your API credentials",
|
|
257
|
-
* Style: { ...
|
|
258
|
-
* GetKey: () => "",
|
|
259
|
-
* GetDefaultValue: () => "",
|
|
260
|
-
* Translate: () => {}
|
|
299
|
+
* Style: { ...({} as PluginSettingValueStyle), PaddingTop: 20 }
|
|
261
300
|
* }
|
|
262
301
|
* ```
|
|
263
302
|
*/
|
|
@@ -286,10 +325,7 @@ export interface PluginSettingValueHead extends PluginSettingDefinitionValue {
|
|
|
286
325
|
* const label: PluginSettingValueLabel = {
|
|
287
326
|
* Content: "Note: API key is required for this feature to work.",
|
|
288
327
|
* Tooltip: "",
|
|
289
|
-
* Style:
|
|
290
|
-
* GetKey: () => "",
|
|
291
|
-
* GetDefaultValue: () => "",
|
|
292
|
-
* Translate: () => {}
|
|
328
|
+
* Style: {} as PluginSettingValueStyle
|
|
293
329
|
* }
|
|
294
330
|
* ```
|
|
295
331
|
*/
|
|
@@ -316,10 +352,7 @@ export interface PluginSettingValueLabel extends PluginSettingDefinitionValue {
|
|
|
316
352
|
* @example
|
|
317
353
|
* ```typescript
|
|
318
354
|
* const newline: PluginSettingValueNewline = {
|
|
319
|
-
* Style:
|
|
320
|
-
* GetKey: () => "",
|
|
321
|
-
* GetDefaultValue: () => "",
|
|
322
|
-
* Translate: () => {}
|
|
355
|
+
* Style: {} as PluginSettingValueStyle
|
|
323
356
|
* }
|
|
324
357
|
* ```
|
|
325
358
|
*/
|
|
@@ -348,10 +381,7 @@ export interface PluginSettingValueNewline extends PluginSettingDefinitionValue
|
|
|
348
381
|
* { Label: "Light", Value: "light" }
|
|
349
382
|
* ],
|
|
350
383
|
* Validators: [],
|
|
351
|
-
* Style:
|
|
352
|
-
* GetKey: () => "theme",
|
|
353
|
-
* GetDefaultValue: () => "dark",
|
|
354
|
-
* Translate: () => {}
|
|
384
|
+
* Style: {} as PluginSettingValueStyle
|
|
355
385
|
* }
|
|
356
386
|
* ```
|
|
357
387
|
*/
|
|
@@ -508,6 +538,4 @@ export interface PluginSettingValidatorIsNumber extends PluginSettingValidatorVa
|
|
|
508
538
|
* }
|
|
509
539
|
* ```
|
|
510
540
|
*/
|
|
511
|
-
export interface PluginSettingValidatorNotEmpty extends PluginSettingValidatorValue {
|
|
512
|
-
|
|
513
|
-
}
|
|
541
|
+
export interface PluginSettingValidatorNotEmpty extends PluginSettingValidatorValue {}
|