@wox-launcher/wox-plugin 0.0.61 → 0.0.62

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.
@@ -0,0 +1,3 @@
1
+ import { Context } from "types/index";
2
+ export declare function NewContext(): Context;
3
+ export declare function NewContextWithValue(key: string, value: string): Context;
@@ -0,0 +1,2 @@
1
+ import { WoxImage } from "types/index";
2
+ export declare function NewBase64WoxImage(imageData: string): WoxImage;
@@ -0,0 +1,2 @@
1
+ export * from "src/context";
2
+ export * from "src/image";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wox-launcher/wox-plugin",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
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,190 +1,185 @@
1
- export = wox
2
-
3
- declare module wox {
4
- export interface Plugin {
5
- init: (ctx: Context, initParams: PluginInitParams) => Promise<void>
6
- query: (ctx: Context, query: Query) => Promise<Result[]>
7
- }
8
-
9
- export interface Selection {
10
- Type: "text" | "file"
11
- // Only available when Type is text
12
- Text: string
13
- // Only available when Type is file
14
- FilePaths: string[]
15
- }
16
-
17
- export interface Query {
18
- /**
19
- * By default, Wox will only pass input query to plugin.
20
- * plugin author need to enable MetadataFeatureQuerySelection feature to handle selection query
21
- */
22
- Type: "input" | "selection"
23
- /**
24
- * Raw query, this includes trigger keyword if it has
25
- * We didn't recommend use this property directly. You should always use Search property.
26
- *
27
- * NOTE: Only available when query type is input
28
- */
29
- RawQuery: string
30
- /**
31
- * Trigger keyword of a query. It can be empty if user is using global trigger keyword.
32
- *
33
- * NOTE: Only available when query type is input
34
- */
35
- TriggerKeyword?: string
36
- /**
37
- * Command part of a query.
38
- *
39
- * NOTE: Only available when query type is input
40
- */
41
- Command?: string
42
- /**
43
- * Search part of a query.
44
- *
45
- * NOTE: Only available when query type is input
46
- */
47
- Search: string
48
-
49
- /**
50
- * User selected or drag-drop data, can be text or file or image etc
51
- *
52
- * NOTE: Only available when query type is selection
53
- */
54
- Selection: Selection
55
- }
56
-
57
- export interface Result {
58
- Id?: string
59
- Title: string
60
- SubTitle?: string
61
- Icon: WoxImage
62
- Preview?: WoxPreview
63
- Score?: number
64
- ContextData?: string
65
- Actions?: ResultAction[]
66
- // refresh result after specified interval, in milliseconds. If this value is 0, Wox will not refresh this result
67
- // interval can only divisible by 100, if not, Wox will use the nearest number which is divisible by 100
68
- // E.g. if you set 123, Wox will use 200, if you set 1234, Wox will use 1300
69
- RefreshInterval?: number
70
- // refresh result by calling OnRefresh function
71
- OnRefresh?: (current: RefreshableResult) => Promise<RefreshableResult>
72
- }
73
-
74
- export interface RefreshableResult {
75
- Title: string
76
- SubTitle: string
77
- Icon: WoxImage
78
- Preview: WoxPreview
79
- ContextData: string
80
- RefreshInterval: number
81
- }
82
-
83
- export interface ResultAction {
84
- /**
85
- * Result id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you
86
- */
87
- Id?: string
88
- Name: string
89
- Icon?: WoxImage
90
- /**
91
- * If true, Wox will use this action as default action. There can be only one default action in results
92
- * This can be omitted, if you don't set it, Wox will use the first action as default action
93
- */
94
- IsDefault?: boolean
95
- /**
96
- * If true, Wox will not hide after user select this result
97
- */
98
- PreventHideAfterAction?: boolean
99
- Action: (actionContext: ActionContext) => Promise<void>
100
- }
101
-
102
- export interface ActionContext {
103
- ContextData: string
104
- }
105
-
106
- export interface PluginInitParams {
107
- API: PublicAPI
108
- PluginDirectory: string
109
- }
110
-
111
- export interface ChangeQueryParam {
112
- QueryType: "input" | "selection"
113
- QueryText?: string
114
- QuerySelection?: Selection
115
- }
116
-
117
- export interface PublicAPI {
118
- /**
119
- * Change Wox query
120
- */
121
- ChangeQuery: (ctx: Context, query: ChangeQueryParam) => Promise<void>
122
-
123
- /**
124
- * Hide Wox
125
- */
126
- HideApp: (ctx: Context) => Promise<void>
127
-
128
- /**
129
- * Show Wox
130
- */
131
- ShowApp: (ctx: Context) => Promise<void>
132
-
133
- /**
134
- * Notify message
135
- */
136
- Notify: (ctx: Context, title: string, description?: string) => Promise<void>
137
-
138
- /**
139
- * Write log
140
- */
141
- Log: (ctx: Context, level: "Info" | "Error" | "Debug" | "Warning", msg: string) => Promise<void>
142
-
143
- /**
144
- * Get translation of current language
145
- */
146
- GetTranslation: (ctx: Context, key: string) => Promise<string>
147
-
148
- /**
149
- * Get customized setting
150
- *
151
- * will try to get platform specific setting first, if not found, will try to get global setting
152
- */
153
- GetSetting: (ctx: Context, key: string) => Promise<string>
154
-
155
- /**
156
- * Save customized setting
157
- *
158
- * @isPlatformSpecific If true, setting will be only saved in current platform. If false, setting will be available in all platforms
159
- */
160
- SaveSetting: (ctx: Context, key: string, value: string, isPlatformSpecific: boolean) => Promise<void>
161
-
162
- /**
163
- * Register setting changed callback
164
- */
165
- OnSettingChanged: (ctx: Context, callback: (key: string, value: string) => void) => Promise<void>
166
- }
167
-
168
- export type WoxImageType = "absolute" | "relative" | "base64" | "svg" | "url" | "emoji"
169
-
170
- export interface WoxImage {
171
- ImageType: WoxImageType
172
- ImageData: string
173
- }
174
-
175
- export type WoxPreviewType = "markdown" | "text" | "image" | "url" | "pdf"
176
-
177
- export interface WoxPreview {
178
- PreviewType: WoxPreviewType
179
- PreviewData: string
180
- PreviewProperties: Record<string, string>
181
- }
182
-
183
- export interface Context {
184
- Values: { [key: string]: string }
185
- Get: (key: string) => string | undefined
186
- Set: (key: string, value: string) => void
187
- Exists: (key: string) => boolean
188
- }
1
+ export interface Plugin {
2
+ init: (ctx: Context, initParams: PluginInitParams) => Promise<void>
3
+ query: (ctx: Context, query: Query) => Promise<Result[]>
4
+ }
5
+
6
+ export interface Selection {
7
+ Type: "text" | "file"
8
+ // Only available when Type is text
9
+ Text: string
10
+ // Only available when Type is file
11
+ FilePaths: string[]
12
+ }
13
+
14
+ export interface Query {
15
+ /**
16
+ * By default, Wox will only pass input query to plugin.
17
+ * plugin author need to enable MetadataFeatureQuerySelection feature to handle selection query
18
+ */
19
+ Type: "input" | "selection"
20
+ /**
21
+ * Raw query, this includes trigger keyword if it has
22
+ * We didn't recommend use this property directly. You should always use Search property.
23
+ *
24
+ * NOTE: Only available when query type is input
25
+ */
26
+ RawQuery: string
27
+ /**
28
+ * Trigger keyword of a query. It can be empty if user is using global trigger keyword.
29
+ *
30
+ * NOTE: Only available when query type is input
31
+ */
32
+ TriggerKeyword?: string
33
+ /**
34
+ * Command part of a query.
35
+ *
36
+ * NOTE: Only available when query type is input
37
+ */
38
+ Command?: string
39
+ /**
40
+ * Search part of a query.
41
+ *
42
+ * NOTE: Only available when query type is input
43
+ */
44
+ Search: string
45
+
46
+ /**
47
+ * User selected or drag-drop data, can be text or file or image etc
48
+ *
49
+ * NOTE: Only available when query type is selection
50
+ */
51
+ Selection: Selection
52
+ }
53
+
54
+ export interface Result {
55
+ Id?: string
56
+ Title: string
57
+ SubTitle?: string
58
+ Icon: WoxImage
59
+ Preview?: WoxPreview
60
+ Score?: number
61
+ ContextData?: string
62
+ Actions?: ResultAction[]
63
+ // refresh result after specified interval, in milliseconds. If this value is 0, Wox will not refresh this result
64
+ // interval can only divisible by 100, if not, Wox will use the nearest number which is divisible by 100
65
+ // E.g. if you set 123, Wox will use 200, if you set 1234, Wox will use 1300
66
+ RefreshInterval?: number
67
+ // refresh result by calling OnRefresh function
68
+ OnRefresh?: (current: RefreshableResult) => Promise<RefreshableResult>
69
+ }
70
+
71
+ export interface RefreshableResult {
72
+ Title: string
73
+ SubTitle: string
74
+ Icon: WoxImage
75
+ Preview: WoxPreview
76
+ ContextData: string
77
+ RefreshInterval: number
78
+ }
79
+
80
+ export interface ResultAction {
81
+ /**
82
+ * Result id, should be unique. It's optional, if you don't set it, Wox will assign a random id for you
83
+ */
84
+ Id?: string
85
+ Name: string
86
+ Icon?: WoxImage
87
+ /**
88
+ * If true, Wox will use this action as default action. There can be only one default action in results
89
+ * This can be omitted, if you don't set it, Wox will use the first action as default action
90
+ */
91
+ IsDefault?: boolean
92
+ /**
93
+ * If true, Wox will not hide after user select this result
94
+ */
95
+ PreventHideAfterAction?: boolean
96
+ Action: (actionContext: ActionContext) => Promise<void>
97
+ }
98
+
99
+ export interface ActionContext {
100
+ ContextData: string
101
+ }
102
+
103
+ export interface PluginInitParams {
104
+ API: PublicAPI
105
+ PluginDirectory: string
106
+ }
107
+
108
+ export interface ChangeQueryParam {
109
+ QueryType: "input" | "selection"
110
+ QueryText?: string
111
+ QuerySelection?: Selection
112
+ }
113
+
114
+ export interface PublicAPI {
115
+ /**
116
+ * Change Wox query
117
+ */
118
+ ChangeQuery: (ctx: Context, query: ChangeQueryParam) => Promise<void>
119
+
120
+ /**
121
+ * Hide Wox
122
+ */
123
+ HideApp: (ctx: Context) => Promise<void>
124
+
125
+ /**
126
+ * Show Wox
127
+ */
128
+ ShowApp: (ctx: Context) => Promise<void>
129
+
130
+ /**
131
+ * Notify message
132
+ */
133
+ Notify: (ctx: Context, title: string, description?: string) => Promise<void>
134
+
135
+ /**
136
+ * Write log
137
+ */
138
+ Log: (ctx: Context, level: "Info" | "Error" | "Debug" | "Warning", msg: string) => Promise<void>
139
+
140
+ /**
141
+ * Get translation of current language
142
+ */
143
+ GetTranslation: (ctx: Context, key: string) => Promise<string>
144
+
145
+ /**
146
+ * Get customized setting
147
+ *
148
+ * will try to get platform specific setting first, if not found, will try to get global setting
149
+ */
150
+ GetSetting: (ctx: Context, key: string) => Promise<string>
151
+
152
+ /**
153
+ * Save customized setting
154
+ *
155
+ * @isPlatformSpecific If true, setting will be only saved in current platform. If false, setting will be available in all platforms
156
+ */
157
+ SaveSetting: (ctx: Context, key: string, value: string, isPlatformSpecific: boolean) => Promise<void>
158
+
159
+ /**
160
+ * Register setting changed callback
161
+ */
162
+ OnSettingChanged: (ctx: Context, callback: (key: string, value: string) => void) => Promise<void>
163
+ }
164
+
165
+ export type WoxImageType = "absolute" | "relative" | "base64" | "svg" | "url" | "emoji"
166
+
167
+ export interface WoxImage {
168
+ ImageType: WoxImageType
169
+ ImageData: string
170
+ }
171
+
172
+ export type WoxPreviewType = "markdown" | "text" | "image" | "url" | "pdf"
173
+
174
+ export interface WoxPreview {
175
+ PreviewType: WoxPreviewType
176
+ PreviewData: string
177
+ PreviewProperties: Record<string, string>
178
+ }
189
179
 
180
+ export interface Context {
181
+ Values: { [key: string]: string }
182
+ Get: (key: string) => string | undefined
183
+ Set: (key: string, value: string) => void
184
+ Exists: (key: string) => boolean
190
185
  }