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