@wox-launcher/wox-plugin 0.0.26 → 0.0.28

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/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@wox-launcher/wox-plugin",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "All nodejs plugin for Wox should use types in this package",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/Wox-launcher/Wox.git"
8
8
  },
9
- "type": "module",
10
- "main": "./dist/index.js",
11
- "types": "./dist/index.d.ts",
9
+ "main": "./src/index.js",
10
+ "types": "./src/index.ts",
12
11
  "files": [
13
- "dist"
12
+ "src"
14
13
  ],
15
14
  "devDependencies": {
16
15
  "@tsconfig/node-lts": "^18.12.5",
package/src/index.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WoxImageBuilder = void 0;
4
+ exports.WoxImageBuilder = {
5
+ FromAbsolutePath: (path) => {
6
+ return {
7
+ ImageType: "AbsolutePath",
8
+ ImageData: path
9
+ };
10
+ },
11
+ FromRelativeToPluginPath: (path) => {
12
+ return {
13
+ ImageType: "RelativeToPluginPath",
14
+ ImageData: path
15
+ };
16
+ },
17
+ FromSvg: (svg) => {
18
+ return {
19
+ ImageType: "Svg",
20
+ ImageData: svg
21
+ };
22
+ },
23
+ FromBase64: (base64) => {
24
+ return {
25
+ ImageType: "Base64",
26
+ ImageData: base64
27
+ };
28
+ },
29
+ FromRemote: (url) => {
30
+ return {
31
+ ImageType: "Remote",
32
+ ImageData: url
33
+ };
34
+ }
35
+ };
package/src/index.ts ADDED
@@ -0,0 +1,125 @@
1
+ export interface Plugin {
2
+ init: (context: PluginInitContext) => Promise<void>;
3
+ query: (query: Query) => Promise<Result[]>;
4
+ }
5
+
6
+ export interface Query {
7
+ /**
8
+ * Raw query, this includes trigger keyword if it has
9
+ * We didn't recommend use this property directly. You should always use Search property.
10
+ */
11
+ RawQuery: string;
12
+ /**
13
+ * Trigger keyword of a query. It can be empty if user is using global trigger keyword.
14
+ */
15
+ TriggerKeyword?: string;
16
+ /**
17
+ * Command part of a query.
18
+ */
19
+ Command?: string;
20
+ /**
21
+ * Search part of a query.
22
+ */
23
+ Search: string;
24
+ }
25
+
26
+ export interface Result {
27
+ Id?: string;
28
+ Title: string;
29
+ SubTitle?: string;
30
+ Icon: WoxImage;
31
+ Score?: number;
32
+ Action: () => Promise<boolean>;
33
+ }
34
+
35
+ export interface PluginInitContext {
36
+ API: PublicAPI;
37
+ }
38
+
39
+ export interface PublicAPI {
40
+ /**
41
+ * Change Wox query
42
+ */
43
+ ChangeQuery: (query: string) => Promise<void>;
44
+
45
+ /**
46
+ * Hide Wox
47
+ */
48
+ HideApp: () => Promise<void>;
49
+
50
+ /**
51
+ * Show Wox
52
+ */
53
+ ShowApp: () => Promise<void>;
54
+
55
+ /**
56
+ * Show message box
57
+ */
58
+ ShowMsg: (title: string, description?: string, iconPath?: string) => Promise<void>;
59
+
60
+ /**
61
+ * Write log
62
+ */
63
+ Log: (msg: string) => Promise<void>;
64
+
65
+ /**
66
+ * Get translation of current language
67
+ */
68
+ GetTranslation: (key: string) => Promise<string>;
69
+ }
70
+
71
+ export type WoxImageType = "AbsolutePath" | "RelativeToPluginPath" | "Svg" | "Base64" | "Remote"
72
+
73
+ export interface WoxImage {
74
+ ImageType: WoxImageType;
75
+ ImageData: string;
76
+ }
77
+
78
+ export interface WoxImageCreator {
79
+ FromAbsolutePath(path: string): WoxImage;
80
+
81
+ FromRelativeToPluginPath(path: string): WoxImage;
82
+
83
+ FromSvg(svg: string): WoxImage;
84
+
85
+ FromBase64(base64: string): WoxImage;
86
+
87
+ FromRemote(url: string): WoxImage;
88
+ }
89
+
90
+ export const WoxImageBuilder: WoxImageCreator = {
91
+ FromAbsolutePath: (path: string) => {
92
+ return {
93
+ ImageType: "AbsolutePath",
94
+ ImageData: path
95
+ };
96
+ },
97
+
98
+ FromRelativeToPluginPath: (path: string) => {
99
+ return {
100
+ ImageType: "RelativeToPluginPath",
101
+ ImageData: path
102
+ };
103
+ },
104
+
105
+ FromSvg: (svg: string) => {
106
+ return {
107
+ ImageType: "Svg",
108
+ ImageData: svg
109
+ };
110
+ },
111
+
112
+ FromBase64: (base64: string) => {
113
+ return {
114
+ ImageType: "Base64",
115
+ ImageData: base64
116
+ };
117
+ },
118
+
119
+ FromRemote: (url: string) => {
120
+ return {
121
+ ImageType: "Remote",
122
+ ImageData: url
123
+ };
124
+ }
125
+ };