@widget-js/core 0.7.9 → 0.9.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/dist/index.cjs +25 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1383 -1356
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,1436 +1,1463 @@
|
|
|
1
1
|
import { FileTypeResult } from 'file-type';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated use DeployedMode instead
|
|
5
|
-
*/
|
|
6
|
-
declare enum HostedMode {
|
|
7
|
-
NORMAL = 1,
|
|
8
|
-
/**
|
|
9
|
-
* 悬浮窗
|
|
10
|
-
*/
|
|
11
|
-
OVERLAP = 16,
|
|
12
|
-
WALLPAPER = 256,
|
|
13
|
-
SCREEN = 4096,
|
|
14
|
-
/**
|
|
15
|
-
* 后台组件,没有界面,一般在后台执行定时任务
|
|
16
|
-
*/
|
|
17
|
-
BACKGROUND = 65536,
|
|
18
|
-
/**
|
|
19
|
-
* 页面
|
|
20
|
-
*/
|
|
21
|
-
PAGE = 1048576,
|
|
22
|
-
ALL = 1118481
|
|
23
|
-
}
|
|
24
|
-
declare enum DeployMode {
|
|
25
|
-
NORMAL = 1,
|
|
26
|
-
/**
|
|
27
|
-
* 悬浮窗
|
|
28
|
-
*/
|
|
29
|
-
OVERLAP = 16,
|
|
30
|
-
BACKGROUND = 65536,
|
|
31
|
-
ALL = 1118481
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated use DeployedMode instead
|
|
5
|
+
*/
|
|
6
|
+
declare enum HostedMode {
|
|
7
|
+
NORMAL = 1,
|
|
8
|
+
/**
|
|
9
|
+
* 悬浮窗
|
|
10
|
+
*/
|
|
11
|
+
OVERLAP = 16,
|
|
12
|
+
WALLPAPER = 256,
|
|
13
|
+
SCREEN = 4096,
|
|
14
|
+
/**
|
|
15
|
+
* 后台组件,没有界面,一般在后台执行定时任务
|
|
16
|
+
*/
|
|
17
|
+
BACKGROUND = 65536,
|
|
18
|
+
/**
|
|
19
|
+
* 页面
|
|
20
|
+
*/
|
|
21
|
+
PAGE = 1048576,
|
|
22
|
+
ALL = 1118481
|
|
23
|
+
}
|
|
24
|
+
declare enum DeployMode {
|
|
25
|
+
NORMAL = 1,
|
|
26
|
+
/**
|
|
27
|
+
* 悬浮窗
|
|
28
|
+
*/
|
|
29
|
+
OVERLAP = 16,
|
|
30
|
+
BACKGROUND = 65536,
|
|
31
|
+
ALL = 1118481
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
interface Language {
|
|
35
|
-
locale: string;
|
|
36
|
-
language: string;
|
|
37
|
-
code: string;
|
|
38
|
-
}
|
|
39
|
-
interface ILanguageMap {
|
|
40
|
-
'ar-SA': Language;
|
|
41
|
-
'bn-BD': Language;
|
|
42
|
-
'en-US': Language;
|
|
43
|
-
'de-DE': Language;
|
|
44
|
-
'el-GR': Language;
|
|
45
|
-
'es-ES': Language;
|
|
46
|
-
'fi-FI': Language;
|
|
47
|
-
'fil-PH': Language;
|
|
48
|
-
'fr-FR': Language;
|
|
49
|
-
'hi-IN': Language;
|
|
50
|
-
'hu-HU': Language;
|
|
51
|
-
'id-ID': Language;
|
|
52
|
-
'it-IT': Language;
|
|
53
|
-
'ja-JP': Language;
|
|
54
|
-
'ko-KR': Language;
|
|
55
|
-
'nl-NL': Language;
|
|
56
|
-
'pl-PL': Language;
|
|
57
|
-
'pt-BR': Language;
|
|
58
|
-
'pt-PT': Language;
|
|
59
|
-
'ro-RO': Language;
|
|
60
|
-
'ru-RU': Language;
|
|
61
|
-
'sv-SE': Language;
|
|
62
|
-
'ta-IN': Language;
|
|
63
|
-
'tr-TR': Language;
|
|
64
|
-
'uk-UA': Language;
|
|
65
|
-
'vi-VN': Language;
|
|
66
|
-
'zh-CN': Language;
|
|
67
|
-
'zh-TW': Language;
|
|
68
|
-
}
|
|
69
|
-
type LanguageCode = keyof ILanguageMap;
|
|
70
|
-
type LanguageTextMap = {
|
|
71
|
-
[key in LanguageCode]?: string;
|
|
34
|
+
interface Language {
|
|
35
|
+
locale: string;
|
|
36
|
+
language: string;
|
|
37
|
+
code: string;
|
|
38
|
+
}
|
|
39
|
+
interface ILanguageMap {
|
|
40
|
+
'ar-SA': Language;
|
|
41
|
+
'bn-BD': Language;
|
|
42
|
+
'en-US': Language;
|
|
43
|
+
'de-DE': Language;
|
|
44
|
+
'el-GR': Language;
|
|
45
|
+
'es-ES': Language;
|
|
46
|
+
'fi-FI': Language;
|
|
47
|
+
'fil-PH': Language;
|
|
48
|
+
'fr-FR': Language;
|
|
49
|
+
'hi-IN': Language;
|
|
50
|
+
'hu-HU': Language;
|
|
51
|
+
'id-ID': Language;
|
|
52
|
+
'it-IT': Language;
|
|
53
|
+
'ja-JP': Language;
|
|
54
|
+
'ko-KR': Language;
|
|
55
|
+
'nl-NL': Language;
|
|
56
|
+
'pl-PL': Language;
|
|
57
|
+
'pt-BR': Language;
|
|
58
|
+
'pt-PT': Language;
|
|
59
|
+
'ro-RO': Language;
|
|
60
|
+
'ru-RU': Language;
|
|
61
|
+
'sv-SE': Language;
|
|
62
|
+
'ta-IN': Language;
|
|
63
|
+
'tr-TR': Language;
|
|
64
|
+
'uk-UA': Language;
|
|
65
|
+
'vi-VN': Language;
|
|
66
|
+
'zh-CN': Language;
|
|
67
|
+
'zh-TW': Language;
|
|
68
|
+
}
|
|
69
|
+
type LanguageCode = keyof ILanguageMap;
|
|
70
|
+
type LanguageTextMap = {
|
|
71
|
+
[key in LanguageCode]?: string;
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
type
|
|
75
|
-
[key: string]: string | number | boolean;
|
|
76
|
-
};
|
|
77
|
-
interface IWindowSize {
|
|
78
|
-
width: number;
|
|
79
|
-
height: number;
|
|
80
|
-
maxWidth?: number;
|
|
81
|
-
maxHeight?: number;
|
|
82
|
-
minWidth?: number;
|
|
83
|
-
minHeight?: number;
|
|
84
|
-
}
|
|
85
|
-
interface IPageOptions extends IWindowSize {
|
|
86
|
-
name: string;
|
|
87
|
-
/**
|
|
88
|
-
* 当showInSearch为true时,此项必填
|
|
89
|
-
*/
|
|
90
|
-
title: LanguageTextMap;
|
|
91
|
-
/**
|
|
92
|
-
* 当showInSearch为true时,此项必填
|
|
93
|
-
*/
|
|
94
|
-
description?: LanguageTextMap;
|
|
95
|
-
/**
|
|
96
|
-
* 当showInSearch为true时,此项必填
|
|
97
|
-
*/
|
|
98
|
-
keywords?: WidgetKeyword[];
|
|
99
|
-
lang: LanguageCode;
|
|
100
|
-
packageName?: string;
|
|
101
|
-
/**
|
|
102
|
-
* 当showInSearch为true时,此项必填
|
|
103
|
-
*/
|
|
104
|
-
previewImage?: string;
|
|
105
|
-
/**
|
|
106
|
-
* 是否在搜索中显示
|
|
107
|
-
*/
|
|
108
|
-
showInSearch?: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* 悬浮窗模式 是否可移动
|
|
111
|
-
*/
|
|
112
|
-
movable?: boolean;
|
|
113
|
-
resizable?: boolean;
|
|
114
|
-
backgroundThrottling?: boolean;
|
|
115
|
-
security?: boolean;
|
|
116
|
-
path: string;
|
|
117
|
-
/**
|
|
118
|
-
* 是否只能添加一次
|
|
119
|
-
*/
|
|
120
|
-
singleton?: boolean;
|
|
121
|
-
meta?: MetaInfo;
|
|
122
|
-
broadcastChannels?: string[];
|
|
123
|
-
}
|
|
124
|
-
interface IPage {
|
|
125
|
-
readonly name: string;
|
|
126
|
-
/**
|
|
127
|
-
* 窗口标题,显示在界面上的,
|
|
128
|
-
* https://zh.m.wikipedia.org/zh-hans/ISO_639-1
|
|
129
|
-
*/
|
|
130
|
-
readonly title: LanguageTextMap;
|
|
131
|
-
/**
|
|
132
|
-
* 窗口介绍
|
|
133
|
-
*/
|
|
134
|
-
readonly description: LanguageTextMap;
|
|
135
|
-
readonly keywords: WidgetKeyword[];
|
|
136
|
-
/**
|
|
137
|
-
* 组件默认语言
|
|
138
|
-
*/
|
|
139
|
-
readonly lang: LanguageCode;
|
|
140
|
-
readonly width: number;
|
|
141
|
-
packageName?: string | null;
|
|
142
|
-
readonly height: number;
|
|
143
|
-
readonly maxWidth: number;
|
|
144
|
-
readonly maxHeight: number;
|
|
145
|
-
readonly minWidth: number;
|
|
146
|
-
readonly minHeight: number;
|
|
147
|
-
readonly movable: boolean;
|
|
148
|
-
readonly singleton: boolean;
|
|
149
|
-
readonly resizable: boolean;
|
|
150
|
-
readonly path: string;
|
|
151
|
-
readonly meta: {
|
|
152
|
-
[key: string]: string | number | boolean;
|
|
153
|
-
};
|
|
154
|
-
readonly backgroundThrottling: boolean;
|
|
155
|
-
/**
|
|
156
|
-
* 预览图片,可以是GIF
|
|
157
|
-
*/
|
|
158
|
-
readonly previewImage?: string;
|
|
159
|
-
}
|
|
160
|
-
declare class Page implements IPage {
|
|
161
|
-
readonly name: string;
|
|
162
|
-
/**
|
|
163
|
-
* 窗口标题,显示在界面上的,
|
|
164
|
-
* https://zh.m.wikipedia.org/zh-hans/ISO_639-1
|
|
165
|
-
*/
|
|
166
|
-
readonly title: LanguageTextMap;
|
|
167
|
-
/**
|
|
168
|
-
* 窗口介绍
|
|
169
|
-
*/
|
|
170
|
-
readonly description: LanguageTextMap;
|
|
171
|
-
readonly keywords: WidgetKeyword[];
|
|
172
|
-
readonly security: boolean;
|
|
173
|
-
/**
|
|
174
|
-
* 组件默认语言
|
|
175
|
-
*/
|
|
176
|
-
readonly lang: LanguageCode;
|
|
177
|
-
readonly width: number;
|
|
178
|
-
packageName?: string | null;
|
|
179
|
-
readonly height: number;
|
|
180
|
-
readonly maxWidth: number;
|
|
181
|
-
readonly maxHeight: number;
|
|
182
|
-
readonly minWidth: number;
|
|
183
|
-
readonly minHeight: number;
|
|
184
|
-
readonly movable: boolean;
|
|
185
|
-
readonly singleton: boolean;
|
|
186
|
-
readonly resizable: boolean;
|
|
187
|
-
readonly path: string;
|
|
188
|
-
readonly meta: {
|
|
189
|
-
[key: string]: string | number | boolean;
|
|
190
|
-
};
|
|
191
|
-
readonly backgroundThrottling: boolean;
|
|
192
|
-
/**
|
|
193
|
-
* 预览图片,可以是GIF
|
|
194
|
-
*/
|
|
195
|
-
readonly previewImage?: string;
|
|
196
|
-
constructor(options: IPageOptions);
|
|
197
|
-
/**
|
|
198
|
-
* 获取组件标题
|
|
199
|
-
* @param lang 语言环境,不传则获取默认语言
|
|
200
|
-
*/
|
|
201
|
-
getTitle(lang?: LanguageCode): string | undefined;
|
|
202
|
-
/**
|
|
203
|
-
* 获取组件描述
|
|
204
|
-
* @param lang 语言环境,不传则获取默认标题
|
|
205
|
-
*/
|
|
206
|
-
getDescription(lang?: LanguageCode): string | undefined;
|
|
207
|
-
static parseJSON(json: string): Page;
|
|
208
|
-
static parseObject(obj: any): Page;
|
|
209
|
-
isResizable(): boolean;
|
|
210
|
-
}
|
|
74
|
+
type WidgetPermission = 'keyboard' | 'mouse' | 'clipboard' | 'notification' | 'storage' | 'network' | 'cpu' | 'system-info';
|
|
211
75
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
*
|
|
231
|
-
*/
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
76
|
+
type MetaInfo = {
|
|
77
|
+
[key: string]: string | number | boolean;
|
|
78
|
+
};
|
|
79
|
+
interface IWindowSize {
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
maxWidth?: number;
|
|
83
|
+
maxHeight?: number;
|
|
84
|
+
minWidth?: number;
|
|
85
|
+
minHeight?: number;
|
|
86
|
+
}
|
|
87
|
+
interface IPageOptions extends IWindowSize {
|
|
88
|
+
name: string;
|
|
89
|
+
/**
|
|
90
|
+
* 当showInSearch为true时,此项必填
|
|
91
|
+
*/
|
|
92
|
+
title: LanguageTextMap;
|
|
93
|
+
/**
|
|
94
|
+
* 当showInSearch为true时,此项必填
|
|
95
|
+
*/
|
|
96
|
+
description?: LanguageTextMap;
|
|
97
|
+
/**
|
|
98
|
+
* 当showInSearch为true时,此项必填
|
|
99
|
+
*/
|
|
100
|
+
keywords?: WidgetKeyword[];
|
|
101
|
+
lang: LanguageCode;
|
|
102
|
+
packageName?: string;
|
|
103
|
+
/**
|
|
104
|
+
* 当showInSearch为true时,此项必填
|
|
105
|
+
*/
|
|
106
|
+
previewImage?: string;
|
|
107
|
+
/**
|
|
108
|
+
* 是否在搜索中显示
|
|
109
|
+
*/
|
|
110
|
+
showInSearch?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* 悬浮窗模式 是否可移动
|
|
113
|
+
*/
|
|
114
|
+
movable?: boolean;
|
|
115
|
+
resizable?: boolean;
|
|
116
|
+
backgroundThrottling?: boolean;
|
|
117
|
+
security?: boolean;
|
|
118
|
+
path: string;
|
|
119
|
+
/**
|
|
120
|
+
* 是否只能添加一次
|
|
121
|
+
*/
|
|
122
|
+
singleton?: boolean;
|
|
123
|
+
permissions?: WidgetPermission[];
|
|
124
|
+
meta?: MetaInfo;
|
|
125
|
+
broadcastChannels?: string[];
|
|
126
|
+
}
|
|
127
|
+
interface IPage {
|
|
128
|
+
readonly name: string;
|
|
129
|
+
/**
|
|
130
|
+
* 窗口标题,显示在界面上的,
|
|
131
|
+
* https://zh.m.wikipedia.org/zh-hans/ISO_639-1
|
|
132
|
+
*/
|
|
133
|
+
readonly title: LanguageTextMap;
|
|
134
|
+
readonly permissions: WidgetPermission[];
|
|
135
|
+
/**
|
|
136
|
+
* 窗口介绍
|
|
137
|
+
*/
|
|
138
|
+
readonly description: LanguageTextMap;
|
|
139
|
+
readonly keywords: WidgetKeyword[];
|
|
140
|
+
/**
|
|
141
|
+
* 组件默认语言
|
|
142
|
+
*/
|
|
143
|
+
readonly lang: LanguageCode;
|
|
144
|
+
readonly width: number;
|
|
145
|
+
packageName?: string | null;
|
|
146
|
+
readonly height: number;
|
|
147
|
+
readonly maxWidth: number;
|
|
148
|
+
readonly maxHeight: number;
|
|
149
|
+
readonly minWidth: number;
|
|
150
|
+
readonly minHeight: number;
|
|
151
|
+
readonly movable: boolean;
|
|
152
|
+
readonly singleton: boolean;
|
|
153
|
+
readonly resizable: boolean;
|
|
154
|
+
readonly path: string;
|
|
155
|
+
readonly meta: {
|
|
156
|
+
[key: string]: string | number | boolean;
|
|
157
|
+
};
|
|
158
|
+
readonly backgroundThrottling: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* 预览图片,可以是GIF
|
|
161
|
+
*/
|
|
162
|
+
readonly previewImage?: string;
|
|
163
|
+
}
|
|
164
|
+
declare class Page implements IPage {
|
|
165
|
+
readonly name: string;
|
|
166
|
+
/**
|
|
167
|
+
* 窗口标题,显示在界面上的,
|
|
168
|
+
* https://zh.m.wikipedia.org/zh-hans/ISO_639-1
|
|
169
|
+
*/
|
|
170
|
+
readonly title: LanguageTextMap;
|
|
171
|
+
/**
|
|
172
|
+
* 窗口介绍
|
|
173
|
+
*/
|
|
174
|
+
readonly description: LanguageTextMap;
|
|
175
|
+
readonly keywords: WidgetKeyword[];
|
|
176
|
+
readonly security: boolean;
|
|
177
|
+
readonly permissions: WidgetPermission[];
|
|
178
|
+
/**
|
|
179
|
+
* 组件默认语言
|
|
180
|
+
*/
|
|
181
|
+
readonly lang: LanguageCode;
|
|
182
|
+
readonly width: number;
|
|
183
|
+
packageName?: string | null;
|
|
184
|
+
readonly height: number;
|
|
185
|
+
readonly maxWidth: number;
|
|
186
|
+
readonly maxHeight: number;
|
|
187
|
+
readonly minWidth: number;
|
|
188
|
+
readonly minHeight: number;
|
|
189
|
+
readonly movable: boolean;
|
|
190
|
+
readonly singleton: boolean;
|
|
191
|
+
readonly resizable: boolean;
|
|
192
|
+
readonly path: string;
|
|
193
|
+
readonly meta: {
|
|
194
|
+
[key: string]: string | number | boolean;
|
|
195
|
+
};
|
|
196
|
+
readonly backgroundThrottling: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* 预览图片,可以是GIF
|
|
199
|
+
*/
|
|
200
|
+
readonly previewImage?: string;
|
|
201
|
+
constructor(options: IPageOptions);
|
|
202
|
+
/**
|
|
203
|
+
* 获取组件标题
|
|
204
|
+
* @param lang 语言环境,不传则获取默认语言
|
|
205
|
+
*/
|
|
206
|
+
getTitle(lang?: LanguageCode): string | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* 获取组件描述
|
|
209
|
+
* @param lang 语言环境,不传则获取默认标题
|
|
210
|
+
*/
|
|
211
|
+
getDescription(lang?: LanguageCode): string | undefined;
|
|
212
|
+
static parseJSON(json: string): Page;
|
|
213
|
+
static parseObject(obj: any): Page;
|
|
214
|
+
isResizable(): boolean;
|
|
251
215
|
}
|
|
252
216
|
|
|
253
|
-
|
|
217
|
+
interface IWidgetOptions extends IWindowSize, IPageOptions {
|
|
218
|
+
supportDeployMode?: DeployMode;
|
|
219
|
+
configPagePath?: string;
|
|
220
|
+
previewImage: string;
|
|
221
|
+
description: LanguageTextMap;
|
|
222
|
+
keywords: WidgetKeyword[];
|
|
223
|
+
/**
|
|
224
|
+
*/
|
|
225
|
+
routes?: WidgetRoute[];
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* @deprecated
|
|
229
|
+
*/
|
|
230
|
+
interface WidgetRoute {
|
|
231
|
+
url: string;
|
|
232
|
+
name: string;
|
|
233
|
+
}
|
|
234
|
+
declare class Widget extends Page {
|
|
235
|
+
readonly previewImage: string;
|
|
236
|
+
readonly supportDeployMode: number;
|
|
237
|
+
/**
|
|
238
|
+
* 配置页面路径,没有则不能修改
|
|
239
|
+
*/
|
|
240
|
+
readonly configPagePath?: string;
|
|
241
|
+
/**
|
|
242
|
+
* @deprecated
|
|
243
|
+
*/
|
|
244
|
+
readonly routes: WidgetRoute[];
|
|
245
|
+
constructor(options: IWidgetOptions);
|
|
246
|
+
static parseJSON(json: string): Widget;
|
|
247
|
+
static parseObject(obj: any): Widget;
|
|
248
|
+
/**
|
|
249
|
+
* 是否支持悬浮窗
|
|
250
|
+
*/
|
|
251
|
+
isSupportOverlap(): boolean;
|
|
252
|
+
isSupportBackground(): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* 是否支持普通模式
|
|
255
|
+
*/
|
|
256
|
+
isSupportNormal(): boolean;
|
|
257
|
+
isConfigurable(): boolean;
|
|
258
|
+
}
|
|
259
|
+
declare enum WidgetKeyword {
|
|
260
|
+
RECOMMEND = "recommend",
|
|
261
|
+
TOOLS = "tools",
|
|
262
|
+
EFFICIENCY = "efficiency",
|
|
263
|
+
PICTURE = "picture",
|
|
264
|
+
LIFE = "life",
|
|
265
|
+
SHORTCUT = "shortcut",
|
|
266
|
+
COUNTDOWN = "countdown",
|
|
267
|
+
TIMER = "timer",
|
|
268
|
+
INFO = "info",
|
|
269
|
+
DASHBOARD = "dashboard"
|
|
270
|
+
}
|
|
254
271
|
|
|
255
|
-
interface LocalPackageUrlInfo {
|
|
256
|
-
/**
|
|
257
|
-
* 入口文件,默认为index.html,也可以是/
|
|
258
|
-
* @example remote package: https://rtugeek.gitee.io/hotspot/index.html
|
|
259
|
-
* @example local package: index.html
|
|
260
|
-
*/
|
|
261
|
-
entry?: string;
|
|
262
|
-
/**
|
|
263
|
-
* 是否使用hash路由
|
|
264
|
-
*/
|
|
265
|
-
hash: boolean;
|
|
266
|
-
}
|
|
267
|
-
interface RemotePackageUrlInfo extends LocalPackageUrlInfo {
|
|
268
|
-
/**
|
|
269
|
-
* 部署到服务器的base path,只在远程组件包中生效,需以/开始
|
|
270
|
-
* @example /hotspot
|
|
271
|
-
*/
|
|
272
|
-
base?: string;
|
|
273
|
-
}
|
|
274
|
-
interface WidgetPackageOptions extends LocalPackageUrlInfo {
|
|
275
|
-
name: string;
|
|
276
|
-
version?: string;
|
|
277
|
-
author: string;
|
|
278
|
-
homepage?: string;
|
|
279
|
-
title: LanguageTextMap;
|
|
280
|
-
permissions?: WidgetPermission[];
|
|
281
|
-
description: LanguageTextMap;
|
|
282
|
-
remoteEntry?: string;
|
|
283
|
-
remotePackage?: string;
|
|
284
|
-
remote?: RemotePackageUrlInfo;
|
|
285
|
-
icon?: string;
|
|
286
|
-
lang?: LanguageCode;
|
|
287
|
-
widgets?: Widget[];
|
|
288
|
-
devOptions?: DevOptions;
|
|
289
|
-
}
|
|
290
|
-
declare class WidgetPackage implements RemotePackageUrlInfo {
|
|
291
|
-
/**
|
|
292
|
-
* 组件包名,一般为域名倒写,e.g. com.example
|
|
293
|
-
*/
|
|
294
|
-
readonly name: string;
|
|
295
|
-
/**
|
|
296
|
-
* 组件包版本,可以为空,默认采用package.json里的版本
|
|
297
|
-
* e.g. 1.0.2
|
|
298
|
-
*/
|
|
299
|
-
version?: string;
|
|
300
|
-
/**
|
|
301
|
-
* 组件作者署名
|
|
302
|
-
*/
|
|
303
|
-
readonly author: string;
|
|
304
|
-
/**
|
|
305
|
-
* 组件首页
|
|
306
|
-
*/
|
|
307
|
-
readonly homepage?: string;
|
|
308
|
-
/**
|
|
309
|
-
* 组件描述
|
|
310
|
-
*/
|
|
311
|
-
readonly title: {
|
|
312
|
-
[key: LanguageCode | string]: string;
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* 组件描述
|
|
316
|
-
*/
|
|
317
|
-
readonly description: {
|
|
318
|
-
[key: LanguageCode | string]: string;
|
|
319
|
-
};
|
|
320
|
-
/**
|
|
321
|
-
* 组件入口文件,通常为 index.html
|
|
322
|
-
*/
|
|
323
|
-
entry: string | 'index.html';
|
|
324
|
-
/**
|
|
325
|
-
* 组件包的远程入口地址,
|
|
326
|
-
*/
|
|
327
|
-
remoteEntry?: string;
|
|
328
|
-
readonly remotePackage?: string;
|
|
329
|
-
readonly local?: LocalPackageUrlInfo;
|
|
330
|
-
readonly remote?: RemotePackageUrlInfo;
|
|
331
|
-
/**
|
|
332
|
-
* 组件包图标
|
|
333
|
-
*/
|
|
334
|
-
readonly icon?: string;
|
|
335
|
-
/**
|
|
336
|
-
* Hash路由模式,默认为true
|
|
337
|
-
*/
|
|
338
|
-
readonly hash: boolean;
|
|
339
|
-
/**
|
|
340
|
-
* 可能是网络地址,或者本地路径(解压后的文件夹路径),
|
|
341
|
-
* 网络地址:https://www.bilibili.com
|
|
342
|
-
* 本地地址:file:///C:/Users/neo/Desktop
|
|
343
|
-
* 在测试时。地址通常为: http://127.0.0.1:8080
|
|
344
|
-
*/
|
|
345
|
-
url: string;
|
|
346
|
-
readonly widgets: Widget[];
|
|
347
|
-
readonly pages: Page[];
|
|
348
|
-
devOptions?: DevOptions;
|
|
349
|
-
constructor(options: WidgetPackageOptions);
|
|
350
|
-
static parseJSON(json: string): WidgetPackage;
|
|
351
|
-
static parseObject(obj: any): WidgetPackage;
|
|
352
|
-
/**
|
|
353
|
-
* 获取组件包标题
|
|
354
|
-
* @param lang 语言环境,不传则获取默认语言
|
|
355
|
-
*/
|
|
356
|
-
getTitle(lang?: LanguageCode): string | undefined;
|
|
357
|
-
/**
|
|
358
|
-
* 获取组件包描述
|
|
359
|
-
* @param lang 语言环境,不传则获取默认标题
|
|
360
|
-
*/
|
|
361
|
-
getDescription(lang?: LanguageCode): string | undefined;
|
|
362
|
-
/**
|
|
363
|
-
* 获取组件完整路径
|
|
364
|
-
* 如果url是http链接,直接返回链接
|
|
365
|
-
* 如果是本地组件:file://链接,则返回 url+entry,
|
|
366
|
-
* 如果是远程组件:http://链接,则返回 entry,
|
|
367
|
-
* @example file://C:/users/neo/desktop/index.html#
|
|
368
|
-
* @example file://C:/users/neo/desktop/index.html#
|
|
369
|
-
*/
|
|
370
|
-
getIndexUrl(hash?: boolean): string;
|
|
371
|
-
}
|
|
372
|
-
type DevOptions = {
|
|
373
|
-
folder?: string;
|
|
374
|
-
route?: boolean;
|
|
375
|
-
devUrl?: string;
|
|
376
|
-
remoteEntry?: string;
|
|
272
|
+
interface LocalPackageUrlInfo {
|
|
273
|
+
/**
|
|
274
|
+
* 入口文件,默认为index.html,也可以是/
|
|
275
|
+
* @example remote package: https://rtugeek.gitee.io/hotspot/index.html
|
|
276
|
+
* @example local package: index.html
|
|
277
|
+
*/
|
|
278
|
+
entry?: string;
|
|
279
|
+
/**
|
|
280
|
+
* 是否使用hash路由
|
|
281
|
+
*/
|
|
282
|
+
hash: boolean;
|
|
283
|
+
}
|
|
284
|
+
interface RemotePackageUrlInfo extends LocalPackageUrlInfo {
|
|
285
|
+
/**
|
|
286
|
+
* 部署到服务器的base path,只在远程组件包中生效,需以/开始
|
|
287
|
+
* @example /hotspot
|
|
288
|
+
*/
|
|
289
|
+
base?: string;
|
|
290
|
+
}
|
|
291
|
+
interface WidgetPackageOptions extends LocalPackageUrlInfo {
|
|
292
|
+
name: string;
|
|
293
|
+
version?: string;
|
|
294
|
+
author: string;
|
|
295
|
+
homepage?: string;
|
|
296
|
+
title: LanguageTextMap;
|
|
297
|
+
permissions?: WidgetPermission[];
|
|
298
|
+
description: LanguageTextMap;
|
|
299
|
+
remoteEntry?: string;
|
|
300
|
+
remotePackage?: string;
|
|
301
|
+
remote?: RemotePackageUrlInfo;
|
|
302
|
+
icon?: string;
|
|
303
|
+
lang?: LanguageCode;
|
|
304
|
+
widgets?: Widget[];
|
|
305
|
+
devOptions?: DevOptions;
|
|
306
|
+
}
|
|
307
|
+
declare class WidgetPackage implements RemotePackageUrlInfo {
|
|
308
|
+
/**
|
|
309
|
+
* 组件包名,一般为域名倒写,e.g. com.example
|
|
310
|
+
*/
|
|
311
|
+
readonly name: string;
|
|
312
|
+
/**
|
|
313
|
+
* 组件包版本,可以为空,默认采用package.json里的版本
|
|
314
|
+
* e.g. 1.0.2
|
|
315
|
+
*/
|
|
316
|
+
version?: string;
|
|
317
|
+
/**
|
|
318
|
+
* 组件作者署名
|
|
319
|
+
*/
|
|
320
|
+
readonly author: string;
|
|
321
|
+
/**
|
|
322
|
+
* 组件首页
|
|
323
|
+
*/
|
|
324
|
+
readonly homepage?: string;
|
|
325
|
+
/**
|
|
326
|
+
* 组件描述
|
|
327
|
+
*/
|
|
328
|
+
readonly title: {
|
|
329
|
+
[key: LanguageCode | string]: string;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* 组件描述
|
|
333
|
+
*/
|
|
334
|
+
readonly description: {
|
|
335
|
+
[key: LanguageCode | string]: string;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* 组件入口文件,通常为 index.html
|
|
339
|
+
*/
|
|
340
|
+
entry: string | 'index.html';
|
|
341
|
+
/**
|
|
342
|
+
* 组件包的远程入口地址,
|
|
343
|
+
*/
|
|
344
|
+
remoteEntry?: string;
|
|
345
|
+
readonly remotePackage?: string;
|
|
346
|
+
readonly local?: LocalPackageUrlInfo;
|
|
347
|
+
readonly remote?: RemotePackageUrlInfo;
|
|
348
|
+
/**
|
|
349
|
+
* 组件包图标
|
|
350
|
+
*/
|
|
351
|
+
readonly icon?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Hash路由模式,默认为true
|
|
354
|
+
*/
|
|
355
|
+
readonly hash: boolean;
|
|
356
|
+
/**
|
|
357
|
+
* 可能是网络地址,或者本地路径(解压后的文件夹路径),
|
|
358
|
+
* 网络地址:https://www.bilibili.com
|
|
359
|
+
* 本地地址:file:///C:/Users/neo/Desktop
|
|
360
|
+
* 在测试时。地址通常为: http://127.0.0.1:8080
|
|
361
|
+
*/
|
|
362
|
+
url: string;
|
|
363
|
+
readonly widgets: Widget[];
|
|
364
|
+
readonly pages: Page[];
|
|
365
|
+
devOptions?: DevOptions;
|
|
366
|
+
constructor(options: WidgetPackageOptions);
|
|
367
|
+
static parseJSON(json: string): WidgetPackage;
|
|
368
|
+
static parseObject(obj: any): WidgetPackage;
|
|
369
|
+
/**
|
|
370
|
+
* 获取组件包标题
|
|
371
|
+
* @param lang 语言环境,不传则获取默认语言
|
|
372
|
+
*/
|
|
373
|
+
getTitle(lang?: LanguageCode): string | undefined;
|
|
374
|
+
/**
|
|
375
|
+
* 获取组件包描述
|
|
376
|
+
* @param lang 语言环境,不传则获取默认标题
|
|
377
|
+
*/
|
|
378
|
+
getDescription(lang?: LanguageCode): string | undefined;
|
|
379
|
+
/**
|
|
380
|
+
* 获取组件完整路径
|
|
381
|
+
* 如果url是http链接,直接返回链接
|
|
382
|
+
* 如果是本地组件:file://链接,则返回 url+entry,
|
|
383
|
+
* 如果是远程组件:http://链接,则返回 entry,
|
|
384
|
+
* @example file://C:/users/neo/desktop/index.html#
|
|
385
|
+
* @example file://C:/users/neo/desktop/index.html#
|
|
386
|
+
*/
|
|
387
|
+
getIndexUrl(hash?: boolean): string;
|
|
388
|
+
}
|
|
389
|
+
type DevOptions = {
|
|
390
|
+
folder?: string;
|
|
391
|
+
route?: boolean;
|
|
392
|
+
devUrl?: string;
|
|
393
|
+
remoteEntry?: string;
|
|
377
394
|
};
|
|
378
395
|
|
|
379
|
-
declare class WidgetParams {
|
|
380
|
-
static readonly PARAM_PREFIX = "w_";
|
|
381
|
-
static readonly PARAM_ID = "id";
|
|
382
|
-
static readonly PARAM_WIDTH = "width";
|
|
383
|
-
static readonly PARAM_HEIGHT = "height";
|
|
384
|
-
static readonly PARAM_WIDTH_PX = "width_px";
|
|
385
|
-
static readonly PARAM_HEIGHT_PX = "height_px";
|
|
386
|
-
static readonly PARAM_X = "x";
|
|
387
|
-
static readonly PARAM_Y = "y";
|
|
388
|
-
static readonly PARAM_LANG = "lang";
|
|
389
|
-
static readonly PARAM_THEME = "theme";
|
|
390
|
-
static readonly PARAM_MODE = "mode";
|
|
391
|
-
static readonly PARAM_RADIUS = "radius";
|
|
392
|
-
static readonly PARAM_NAME = "name";
|
|
393
|
-
static readonly PARAM_TITLE = "title";
|
|
394
|
-
static readonly PARAM_PREVIEW = "preview";
|
|
395
|
-
static readonly PARAMS: string[];
|
|
396
|
-
id?: string;
|
|
397
|
-
width?: number;
|
|
398
|
-
widthPx?: number;
|
|
399
|
-
heightPx?: number;
|
|
400
|
-
height?: number;
|
|
401
|
-
x?: number;
|
|
402
|
-
y?: number;
|
|
403
|
-
preview?: boolean;
|
|
404
|
-
lang?: string;
|
|
405
|
-
theme?: ThemeMode;
|
|
406
|
-
mode?: DeployMode;
|
|
407
|
-
radius?: number;
|
|
408
|
-
name?: string;
|
|
409
|
-
title?: string;
|
|
410
|
-
/**
|
|
411
|
-
* 将组件参数转为url参数
|
|
412
|
-
* @param object
|
|
413
|
-
* @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
|
|
414
|
-
*/
|
|
415
|
-
toUrlParams(): URLSearchParams;
|
|
416
|
-
getPersistKey(): string;
|
|
417
|
-
/**
|
|
418
|
-
* 从当前地址解析组件参数:
|
|
419
|
-
* http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
|
|
420
|
-
* =>
|
|
421
|
-
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
422
|
-
*/
|
|
423
|
-
static fromCurrentLocation(): WidgetParams;
|
|
424
|
-
static fromLocation(url: string): WidgetParams;
|
|
425
|
-
private static setValue;
|
|
426
|
-
/**
|
|
427
|
-
* 从对象键值对中初始化组件参数
|
|
428
|
-
* {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
|
|
429
|
-
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
430
|
-
* @param object
|
|
431
|
-
*/
|
|
432
|
-
static fromObject(object: any): WidgetParams;
|
|
433
|
-
}
|
|
434
|
-
declare enum ThemeMode {
|
|
435
|
-
AUTO = "auto",
|
|
436
|
-
LIGHT = "LIGHT",
|
|
437
|
-
DARK = "DARK"
|
|
396
|
+
declare class WidgetParams {
|
|
397
|
+
static readonly PARAM_PREFIX = "w_";
|
|
398
|
+
static readonly PARAM_ID = "id";
|
|
399
|
+
static readonly PARAM_WIDTH = "width";
|
|
400
|
+
static readonly PARAM_HEIGHT = "height";
|
|
401
|
+
static readonly PARAM_WIDTH_PX = "width_px";
|
|
402
|
+
static readonly PARAM_HEIGHT_PX = "height_px";
|
|
403
|
+
static readonly PARAM_X = "x";
|
|
404
|
+
static readonly PARAM_Y = "y";
|
|
405
|
+
static readonly PARAM_LANG = "lang";
|
|
406
|
+
static readonly PARAM_THEME = "theme";
|
|
407
|
+
static readonly PARAM_MODE = "mode";
|
|
408
|
+
static readonly PARAM_RADIUS = "radius";
|
|
409
|
+
static readonly PARAM_NAME = "name";
|
|
410
|
+
static readonly PARAM_TITLE = "title";
|
|
411
|
+
static readonly PARAM_PREVIEW = "preview";
|
|
412
|
+
static readonly PARAMS: string[];
|
|
413
|
+
id?: string;
|
|
414
|
+
width?: number;
|
|
415
|
+
widthPx?: number;
|
|
416
|
+
heightPx?: number;
|
|
417
|
+
height?: number;
|
|
418
|
+
x?: number;
|
|
419
|
+
y?: number;
|
|
420
|
+
preview?: boolean;
|
|
421
|
+
lang?: string;
|
|
422
|
+
theme?: ThemeMode;
|
|
423
|
+
mode?: DeployMode;
|
|
424
|
+
radius?: number;
|
|
425
|
+
name?: string;
|
|
426
|
+
title?: string;
|
|
427
|
+
/**
|
|
428
|
+
* 将组件参数转为url参数
|
|
429
|
+
* @param object
|
|
430
|
+
* @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
|
|
431
|
+
*/
|
|
432
|
+
toUrlParams(): URLSearchParams;
|
|
433
|
+
getPersistKey(): string;
|
|
434
|
+
/**
|
|
435
|
+
* 从当前地址解析组件参数:
|
|
436
|
+
* http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
|
|
437
|
+
* =>
|
|
438
|
+
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
439
|
+
*/
|
|
440
|
+
static fromCurrentLocation(): WidgetParams;
|
|
441
|
+
static fromLocation(url: string): WidgetParams;
|
|
442
|
+
private static setValue;
|
|
443
|
+
/**
|
|
444
|
+
* 从对象键值对中初始化组件参数
|
|
445
|
+
* {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
|
|
446
|
+
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
447
|
+
* @param object
|
|
448
|
+
*/
|
|
449
|
+
static fromObject(object: any): WidgetParams;
|
|
450
|
+
}
|
|
451
|
+
declare enum ThemeMode {
|
|
452
|
+
AUTO = "auto",
|
|
453
|
+
LIGHT = "LIGHT",
|
|
454
|
+
DARK = "DARK"
|
|
438
455
|
}
|
|
439
456
|
|
|
440
|
-
declare abstract class BaseApi<T extends string> {
|
|
441
|
-
abstract getChannel(): string;
|
|
442
|
-
protected invokeMethod(method: T, ...args: any[]): Promise<any>;
|
|
443
|
-
protected invoke(...args: any[]): Promise<any>;
|
|
457
|
+
declare abstract class BaseApi<T extends string> {
|
|
458
|
+
abstract getChannel(): string;
|
|
459
|
+
protected invokeMethod(method: T, ...args: any[]): Promise<any>;
|
|
460
|
+
protected invoke(...args: any[]): Promise<any>;
|
|
444
461
|
}
|
|
445
462
|
|
|
446
|
-
interface IWidgetApi {
|
|
447
|
-
registerWidgets(widgets: Widget[]): Promise<void>;
|
|
448
|
-
registerWidgetPackage(widgetPackage: WidgetPackage): Promise<void>;
|
|
449
|
-
getWidgets(): Promise<Widget[]>;
|
|
450
|
-
getWidget(name: string): Promise<Widget>;
|
|
451
|
-
getWidgetPackage(name: string): Promise<WidgetPackage>;
|
|
452
|
-
getWidgetPackages(): Promise<WidgetPackage[]>;
|
|
453
|
-
getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
454
|
-
getWidgetPackageIndexUrl(packageName: string, hash?: boolean): Promise<string | null>;
|
|
455
|
-
getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
456
|
-
openConfigPage(id: string): Promise<void>;
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
463
|
+
interface IWidgetApi {
|
|
464
|
+
registerWidgets(widgets: Widget[]): Promise<void>;
|
|
465
|
+
registerWidgetPackage(widgetPackage: WidgetPackage): Promise<void>;
|
|
466
|
+
getWidgets(): Promise<Widget[]>;
|
|
467
|
+
getWidget(name: string): Promise<Widget>;
|
|
468
|
+
getWidgetPackage(name: string): Promise<WidgetPackage>;
|
|
469
|
+
getWidgetPackages(): Promise<WidgetPackage[]>;
|
|
470
|
+
getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
471
|
+
getWidgetPackageIndexUrl(packageName: string, hash?: boolean): Promise<string | null>;
|
|
472
|
+
getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
473
|
+
openConfigPage(id: string): Promise<void>;
|
|
474
|
+
openConfigPageByName(name: string): Promise<void>;
|
|
475
|
+
getWidgetPackageUrl(packageName: string): Promise<string | null>;
|
|
476
|
+
}
|
|
477
|
+
type WidgetApiMethods = keyof IWidgetApi;
|
|
478
|
+
declare enum WidgetApiEvent {
|
|
479
|
+
DATA_CHANGED = "event::cn.widgetjs.core.widget.data-changed",
|
|
480
|
+
EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit"
|
|
481
|
+
}
|
|
482
|
+
declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidgetApi {
|
|
483
|
+
getChannel(): string;
|
|
484
|
+
registerWidgets(widgets: Widget[]): Promise<any>;
|
|
485
|
+
registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
|
|
486
|
+
getWidgets(): Promise<Widget[]>;
|
|
487
|
+
openConfigPage(widgetId: string): Promise<any>;
|
|
488
|
+
openConfigPageByName(widgetName: string): Promise<any>;
|
|
489
|
+
getWidgetPackages(): Promise<WidgetPackage[]>;
|
|
490
|
+
/**
|
|
491
|
+
*
|
|
492
|
+
* @param name package name
|
|
493
|
+
*/
|
|
494
|
+
getWidget(name: string): Promise<Widget>;
|
|
495
|
+
/**
|
|
496
|
+
*
|
|
497
|
+
* @param name package name
|
|
498
|
+
*/
|
|
499
|
+
getWidgetPackage(name: string): Promise<WidgetPackage>;
|
|
500
|
+
/**
|
|
501
|
+
* 获取组件配置地址
|
|
502
|
+
* @param widgetName
|
|
503
|
+
*/
|
|
504
|
+
getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
505
|
+
getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
506
|
+
getWidgetPackageIndexUrl(packageName: string, hash?: boolean): Promise<string | null>;
|
|
507
|
+
getWidgetPackageUrl(packageName: string): Promise<string | null>;
|
|
508
|
+
}
|
|
490
509
|
declare const WidgetApi: WidgetApiImpl;
|
|
491
510
|
|
|
492
|
-
interface IAppApi {
|
|
493
|
-
setConfig(key: string, value: string | number | boolean): Promise<void>;
|
|
494
|
-
getConfig(key: string, defaultValue: string | number | boolean): Promise<string | number | boolean>;
|
|
495
|
-
getVersion(): Promise<string>;
|
|
496
|
-
getPreloadPath(): Promise<string>;
|
|
497
|
-
openAddWidgetWindow(): Promise<void>;
|
|
498
|
-
openSettingWindow(): Promise<void>;
|
|
499
|
-
getIconFile(): Promise<string>;
|
|
500
|
-
}
|
|
501
|
-
type AppApiMethods = keyof IAppApi;
|
|
502
|
-
declare enum AppApiEvent {
|
|
503
|
-
CONFIG_CHANGED = "event::cn.widgetjs.core.app.config.changed",
|
|
504
|
-
MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window",
|
|
505
|
-
STOP_MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window.stop"
|
|
506
|
-
}
|
|
507
|
-
declare enum AppApiConstants {
|
|
508
|
-
CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size"
|
|
509
|
-
}
|
|
511
|
+
interface IAppApi {
|
|
512
|
+
setConfig(key: string, value: string | number | boolean): Promise<void>;
|
|
513
|
+
getConfig(key: string, defaultValue: string | number | boolean): Promise<string | number | boolean>;
|
|
514
|
+
getVersion(): Promise<string>;
|
|
515
|
+
getPreloadPath(): Promise<string>;
|
|
516
|
+
openAddWidgetWindow(): Promise<void>;
|
|
517
|
+
openSettingWindow(): Promise<void>;
|
|
518
|
+
getIconFile(): Promise<string>;
|
|
519
|
+
}
|
|
520
|
+
type AppApiMethods = keyof IAppApi;
|
|
521
|
+
declare enum AppApiEvent {
|
|
522
|
+
CONFIG_CHANGED = "event::cn.widgetjs.core.app.config.changed",
|
|
523
|
+
MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window",
|
|
524
|
+
STOP_MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window.stop"
|
|
525
|
+
}
|
|
526
|
+
declare enum AppApiConstants {
|
|
527
|
+
CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size"
|
|
528
|
+
}
|
|
510
529
|
declare const AppApi: IAppApi;
|
|
511
530
|
|
|
512
|
-
interface BroadcastEventOptions {
|
|
513
|
-
event: WidgetApiEvent | AppApiEvent | string;
|
|
514
|
-
/**
|
|
515
|
-
* 发送人,用于标记发送源,一般为组件名,如:com.example.widgets.countdown
|
|
516
|
-
*/
|
|
517
|
-
sender?: string;
|
|
518
|
-
/**
|
|
519
|
-
* 广播事件携带的数据,只支持部分数据类型。
|
|
520
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
|
521
|
-
*/
|
|
522
|
-
payload?: any;
|
|
523
|
-
}
|
|
524
|
-
declare class BroadcastEvent {
|
|
525
|
-
readonly event: string;
|
|
526
|
-
readonly sender?: string;
|
|
527
|
-
payload?: any;
|
|
528
|
-
constructor(options: BroadcastEventOptions);
|
|
531
|
+
interface BroadcastEventOptions {
|
|
532
|
+
event: WidgetApiEvent | AppApiEvent | string;
|
|
533
|
+
/**
|
|
534
|
+
* 发送人,用于标记发送源,一般为组件名,如:com.example.widgets.countdown
|
|
535
|
+
*/
|
|
536
|
+
sender?: string;
|
|
537
|
+
/**
|
|
538
|
+
* 广播事件携带的数据,只支持部分数据类型。
|
|
539
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
|
540
|
+
*/
|
|
541
|
+
payload?: any;
|
|
542
|
+
}
|
|
543
|
+
declare class BroadcastEvent {
|
|
544
|
+
readonly event: string;
|
|
545
|
+
readonly sender?: string;
|
|
546
|
+
payload?: any;
|
|
547
|
+
constructor(options: BroadcastEventOptions);
|
|
529
548
|
}
|
|
530
549
|
|
|
531
|
-
declare enum WebSocketEventType {
|
|
532
|
-
RESISTER_PACKAGE = "ws::cn.widgetjs.core.resister_package"
|
|
533
|
-
}
|
|
534
|
-
declare class WebSocketEvent {
|
|
535
|
-
type: WebSocketEventType;
|
|
536
|
-
payload: any;
|
|
537
|
-
constructor(type: WebSocketEventType, payload: any);
|
|
550
|
+
declare enum WebSocketEventType {
|
|
551
|
+
RESISTER_PACKAGE = "ws::cn.widgetjs.core.resister_package"
|
|
552
|
+
}
|
|
553
|
+
declare class WebSocketEvent {
|
|
554
|
+
type: WebSocketEventType;
|
|
555
|
+
payload: any;
|
|
556
|
+
constructor(type: WebSocketEventType, payload: any);
|
|
538
557
|
}
|
|
539
558
|
|
|
540
|
-
/**
|
|
541
|
-
* 组件配置数据,用于存储组件自定义页面所设置的数据
|
|
542
|
-
*/
|
|
543
|
-
declare class WidgetData {
|
|
544
|
-
/**
|
|
545
|
-
* 组件id
|
|
546
|
-
*/
|
|
547
|
-
id?: string;
|
|
548
|
-
/**
|
|
549
|
-
* 组件名
|
|
550
|
-
*/
|
|
551
|
-
name: string;
|
|
552
|
-
/**
|
|
553
|
-
* 背景颜色
|
|
554
|
-
*/
|
|
555
|
-
backgroundColor?: string;
|
|
556
|
-
/**
|
|
557
|
-
* 文字颜色
|
|
558
|
-
*/
|
|
559
|
-
color?: string;
|
|
560
|
-
/**
|
|
561
|
-
* 字体大小
|
|
562
|
-
*/
|
|
563
|
-
fontSize?: number;
|
|
564
|
-
/**
|
|
565
|
-
* 字体
|
|
566
|
-
*/
|
|
567
|
-
fontFamily?: string;
|
|
568
|
-
/**
|
|
569
|
-
* 圆角半径
|
|
570
|
-
*/
|
|
571
|
-
borderRadius?: number;
|
|
572
|
-
constructor(name: string, id?: string);
|
|
573
|
-
parseJSON(json: {}): void;
|
|
559
|
+
/**
|
|
560
|
+
* 组件配置数据,用于存储组件自定义页面所设置的数据
|
|
561
|
+
*/
|
|
562
|
+
declare class WidgetData {
|
|
563
|
+
/**
|
|
564
|
+
* 组件id
|
|
565
|
+
*/
|
|
566
|
+
id?: string;
|
|
567
|
+
/**
|
|
568
|
+
* 组件名
|
|
569
|
+
*/
|
|
570
|
+
name: string;
|
|
571
|
+
/**
|
|
572
|
+
* 背景颜色
|
|
573
|
+
*/
|
|
574
|
+
backgroundColor?: string;
|
|
575
|
+
/**
|
|
576
|
+
* 文字颜色
|
|
577
|
+
*/
|
|
578
|
+
color?: string;
|
|
579
|
+
/**
|
|
580
|
+
* 字体大小
|
|
581
|
+
*/
|
|
582
|
+
fontSize?: number;
|
|
583
|
+
/**
|
|
584
|
+
* 字体
|
|
585
|
+
*/
|
|
586
|
+
fontFamily?: string;
|
|
587
|
+
/**
|
|
588
|
+
* 圆角半径
|
|
589
|
+
*/
|
|
590
|
+
borderRadius?: number;
|
|
591
|
+
constructor(name: string, id?: string);
|
|
592
|
+
parseJSON(json: {}): void;
|
|
574
593
|
}
|
|
575
594
|
|
|
576
|
-
type NotificationType = "countdown" | "advance-countdown" | "error" | "success" | "warning" | "info" | "reminder" | "url" | "call";
|
|
577
|
-
declare enum NotificationSize {
|
|
578
|
-
SMALL = "small",
|
|
579
|
-
NORMAL = "normal",
|
|
580
|
-
LARGE = "large"
|
|
581
|
-
}
|
|
582
|
-
interface NotificationOption {
|
|
583
|
-
type?: NotificationType;
|
|
584
|
-
title?: string;
|
|
585
|
-
message: string;
|
|
586
|
-
targetTime?: string;
|
|
587
|
-
duration?: number;
|
|
588
|
-
/**
|
|
589
|
-
* 图片名,目前只支持mingcute图标。
|
|
590
|
-
* https://www.mingcute.com/
|
|
591
|
-
*/
|
|
592
|
-
icon?: string;
|
|
593
|
-
color?: string;
|
|
594
|
-
confirmButtonText?: string;
|
|
595
|
-
cancelButtonText?: string;
|
|
596
|
-
cancelBroadcast?: string;
|
|
597
|
-
confirmBroadcast?: string;
|
|
598
|
-
size?: NotificationSize;
|
|
599
|
-
url?: string;
|
|
600
|
-
avatar?: string;
|
|
601
|
-
audio?: string;
|
|
602
|
-
lyric?: string;
|
|
603
|
-
backgroundColor?: string;
|
|
604
|
-
}
|
|
605
|
-
declare class AppNotification {
|
|
606
|
-
type: NotificationType;
|
|
607
|
-
message: string;
|
|
608
|
-
title?: string;
|
|
609
|
-
targetTime?: string;
|
|
610
|
-
duration: number;
|
|
611
|
-
icon?: string;
|
|
612
|
-
color?: string;
|
|
613
|
-
backgroundColor?: string;
|
|
614
|
-
confirmButtonText?: string;
|
|
615
|
-
cancelButtonText?: string;
|
|
616
|
-
cancelBroadcast?: string;
|
|
617
|
-
confirmBroadcast?: string;
|
|
618
|
-
size: NotificationSize;
|
|
619
|
-
url?: string;
|
|
620
|
-
avatar?: string;
|
|
621
|
-
audio?: string;
|
|
622
|
-
lyric?: string;
|
|
623
|
-
createdAt: string;
|
|
624
|
-
constructor(option: NotificationOption);
|
|
595
|
+
type NotificationType = "countdown" | "advance-countdown" | "error" | "success" | "warning" | "info" | "reminder" | "url" | "call";
|
|
596
|
+
declare enum NotificationSize {
|
|
597
|
+
SMALL = "small",
|
|
598
|
+
NORMAL = "normal",
|
|
599
|
+
LARGE = "large"
|
|
600
|
+
}
|
|
601
|
+
interface NotificationOption {
|
|
602
|
+
type?: NotificationType;
|
|
603
|
+
title?: string;
|
|
604
|
+
message: string;
|
|
605
|
+
targetTime?: string;
|
|
606
|
+
duration?: number;
|
|
607
|
+
/**
|
|
608
|
+
* 图片名,目前只支持mingcute图标。
|
|
609
|
+
* https://www.mingcute.com/
|
|
610
|
+
*/
|
|
611
|
+
icon?: string;
|
|
612
|
+
color?: string;
|
|
613
|
+
confirmButtonText?: string;
|
|
614
|
+
cancelButtonText?: string;
|
|
615
|
+
cancelBroadcast?: string;
|
|
616
|
+
confirmBroadcast?: string;
|
|
617
|
+
size?: NotificationSize;
|
|
618
|
+
url?: string;
|
|
619
|
+
avatar?: string;
|
|
620
|
+
audio?: string;
|
|
621
|
+
lyric?: string;
|
|
622
|
+
backgroundColor?: string;
|
|
623
|
+
}
|
|
624
|
+
declare class AppNotification {
|
|
625
|
+
type: NotificationType;
|
|
626
|
+
message: string;
|
|
627
|
+
title?: string;
|
|
628
|
+
targetTime?: string;
|
|
629
|
+
duration: number;
|
|
630
|
+
icon?: string;
|
|
631
|
+
color?: string;
|
|
632
|
+
backgroundColor?: string;
|
|
633
|
+
confirmButtonText?: string;
|
|
634
|
+
cancelButtonText?: string;
|
|
635
|
+
cancelBroadcast?: string;
|
|
636
|
+
confirmBroadcast?: string;
|
|
637
|
+
size: NotificationSize;
|
|
638
|
+
url?: string;
|
|
639
|
+
avatar?: string;
|
|
640
|
+
audio?: string;
|
|
641
|
+
lyric?: string;
|
|
642
|
+
createdAt: string;
|
|
643
|
+
constructor(option: NotificationOption);
|
|
625
644
|
}
|
|
626
645
|
|
|
627
|
-
interface IDeployedPage {
|
|
628
|
-
id: string;
|
|
629
|
-
name: string;
|
|
630
|
-
packageName: string;
|
|
631
|
-
x: number;
|
|
632
|
-
y: number;
|
|
633
|
-
height: number;
|
|
634
|
-
width: number;
|
|
635
|
-
proxy?: string;
|
|
636
|
-
}
|
|
637
|
-
declare class DeployedPage implements IDeployedPage {
|
|
638
|
-
name: string;
|
|
639
|
-
packageName: string;
|
|
640
|
-
x: number;
|
|
641
|
-
y: number;
|
|
642
|
-
height: number;
|
|
643
|
-
width: number;
|
|
644
|
-
proxy?: string;
|
|
645
|
-
id: string;
|
|
646
|
+
interface IDeployedPage {
|
|
647
|
+
id: string;
|
|
648
|
+
name: string;
|
|
649
|
+
packageName: string;
|
|
650
|
+
x: number;
|
|
651
|
+
y: number;
|
|
652
|
+
height: number;
|
|
653
|
+
width: number;
|
|
654
|
+
proxy?: string;
|
|
655
|
+
}
|
|
656
|
+
declare class DeployedPage implements IDeployedPage {
|
|
657
|
+
name: string;
|
|
658
|
+
packageName: string;
|
|
659
|
+
x: number;
|
|
660
|
+
y: number;
|
|
661
|
+
height: number;
|
|
662
|
+
width: number;
|
|
663
|
+
proxy?: string;
|
|
664
|
+
id: string;
|
|
646
665
|
}
|
|
647
666
|
|
|
648
|
-
declare class DeployedWidget extends DeployedPage {
|
|
649
|
-
shortcut?: string;
|
|
650
|
-
deployMode: number;
|
|
651
|
-
isOverlap(): boolean;
|
|
667
|
+
declare class DeployedWidget extends DeployedPage {
|
|
668
|
+
shortcut?: string;
|
|
669
|
+
deployMode: number;
|
|
670
|
+
isOverlap(): boolean;
|
|
652
671
|
}
|
|
653
672
|
|
|
654
|
-
interface Rectangle {
|
|
655
|
-
/**
|
|
656
|
-
* The height of the rectangle (must be an integer).
|
|
657
|
-
*/
|
|
658
|
-
height: number;
|
|
659
|
-
/**
|
|
660
|
-
* The width of the rectangle (must be an integer).
|
|
661
|
-
*/
|
|
662
|
-
width: number;
|
|
663
|
-
/**
|
|
664
|
-
* The x coordinate of the origin of the rectangle (must be an integer).
|
|
665
|
-
*/
|
|
666
|
-
x: number;
|
|
667
|
-
/**
|
|
668
|
-
* The y coordinate of the origin of the rectangle (must be an integer).
|
|
669
|
-
*/
|
|
670
|
-
y: number;
|
|
673
|
+
interface Rectangle {
|
|
674
|
+
/**
|
|
675
|
+
* The height of the rectangle (must be an integer).
|
|
676
|
+
*/
|
|
677
|
+
height: number;
|
|
678
|
+
/**
|
|
679
|
+
* The width of the rectangle (must be an integer).
|
|
680
|
+
*/
|
|
681
|
+
width: number;
|
|
682
|
+
/**
|
|
683
|
+
* The x coordinate of the origin of the rectangle (must be an integer).
|
|
684
|
+
*/
|
|
685
|
+
x: number;
|
|
686
|
+
/**
|
|
687
|
+
* The y coordinate of the origin of the rectangle (must be an integer).
|
|
688
|
+
*/
|
|
689
|
+
y: number;
|
|
671
690
|
}
|
|
672
691
|
|
|
673
|
-
interface Point {
|
|
674
|
-
x: number;
|
|
675
|
-
y: number;
|
|
676
|
-
}
|
|
677
|
-
type Position = {
|
|
678
|
-
x: number;
|
|
679
|
-
y: number;
|
|
680
|
-
};
|
|
681
|
-
declare enum Gravity {
|
|
682
|
-
TOP = "TOP",
|
|
683
|
-
LEFT = "LEFT",
|
|
684
|
-
RIGHT = "RIGHT",
|
|
685
|
-
BOTTOM = "BOTTOM"
|
|
692
|
+
interface Point {
|
|
693
|
+
x: number;
|
|
694
|
+
y: number;
|
|
695
|
+
}
|
|
696
|
+
type Position = {
|
|
697
|
+
x: number;
|
|
698
|
+
y: number;
|
|
699
|
+
};
|
|
700
|
+
declare enum Gravity {
|
|
701
|
+
TOP = "TOP",
|
|
702
|
+
LEFT = "LEFT",
|
|
703
|
+
RIGHT = "RIGHT",
|
|
704
|
+
BOTTOM = "BOTTOM"
|
|
686
705
|
}
|
|
687
706
|
|
|
688
|
-
interface NativeKeyboardEvent {
|
|
689
|
-
name: string;
|
|
690
|
-
keyCode: number;
|
|
691
|
-
scanCode: number;
|
|
692
|
-
isKeyUp: boolean;
|
|
707
|
+
interface NativeKeyboardEvent {
|
|
708
|
+
name: string;
|
|
709
|
+
keyCode: number;
|
|
710
|
+
scanCode: number;
|
|
711
|
+
isKeyUp: boolean;
|
|
693
712
|
}
|
|
694
713
|
|
|
695
|
-
interface AppMouseEvent {
|
|
696
|
-
handled: boolean;
|
|
697
|
-
wheelScrolled: boolean;
|
|
698
|
-
clicked: boolean;
|
|
699
|
-
isMouseButtonDown: boolean;
|
|
700
|
-
isMouseButtonUp: boolean;
|
|
701
|
-
timestamp: number;
|
|
702
|
-
button: number;
|
|
703
|
-
clicks: number;
|
|
704
|
-
x: number;
|
|
705
|
-
y: number;
|
|
706
|
-
delta: number;
|
|
707
|
-
location: string;
|
|
714
|
+
interface AppMouseEvent {
|
|
715
|
+
handled: boolean;
|
|
716
|
+
wheelScrolled: boolean;
|
|
717
|
+
clicked: boolean;
|
|
718
|
+
isMouseButtonDown: boolean;
|
|
719
|
+
isMouseButtonUp: boolean;
|
|
720
|
+
timestamp: number;
|
|
721
|
+
button: number;
|
|
722
|
+
clicks: number;
|
|
723
|
+
x: number;
|
|
724
|
+
y: number;
|
|
725
|
+
delta: number;
|
|
726
|
+
location: string;
|
|
708
727
|
}
|
|
709
728
|
|
|
710
|
-
declare class ElectronUtils {
|
|
711
|
-
static hasElectronApi(): boolean;
|
|
712
|
-
/**
|
|
713
|
-
* 获取ElectronAPI
|
|
714
|
-
* windows api
|
|
715
|
-
*/
|
|
716
|
-
static getAPI(): any;
|
|
717
|
-
static invokeMethod(channel: string, method: string, ...args: any[]): Promise<any>;
|
|
718
|
-
static invoke(channel: string, ...args: any[]): Promise<any>;
|
|
729
|
+
declare class ElectronUtils {
|
|
730
|
+
static hasElectronApi(): boolean;
|
|
731
|
+
/**
|
|
732
|
+
* 获取ElectronAPI
|
|
733
|
+
* windows api
|
|
734
|
+
*/
|
|
735
|
+
static getAPI(): any;
|
|
736
|
+
static invokeMethod(channel: string, method: string, ...args: any[]): Promise<any>;
|
|
737
|
+
static invoke(channel: string, ...args: any[]): Promise<any>;
|
|
719
738
|
}
|
|
720
739
|
|
|
721
|
-
declare class WidgetUrlUtils {
|
|
722
|
-
static getWidgetUrl(widgetUrl: string, widgetPackage: WidgetPackage, widgetParams: WidgetParams): string;
|
|
723
|
-
static getWidgetPackageUrl(url: string, entry: string, hash: boolean): string;
|
|
740
|
+
declare class WidgetUrlUtils {
|
|
741
|
+
static getWidgetUrl(widgetUrl: string, widgetPackage: WidgetPackage, widgetParams: WidgetParams): string;
|
|
742
|
+
static getWidgetPackageUrl(url: string, entry: string, hash: boolean): string;
|
|
724
743
|
}
|
|
725
744
|
|
|
726
|
-
/**
|
|
727
|
-
*
|
|
728
|
-
* param
|
|
729
|
-
*
|
|
730
|
-
* @
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
*
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
* {@link
|
|
756
|
-
*
|
|
757
|
-
* @public
|
|
758
|
-
*/
|
|
759
|
-
type
|
|
760
|
-
/**
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
* @
|
|
764
|
-
*
|
|
765
|
-
* @
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
*
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
* @
|
|
774
|
-
*
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
745
|
+
/**
|
|
746
|
+
* 根据语言环境获取文本
|
|
747
|
+
* @param langMap 对象
|
|
748
|
+
* @param {LanguageCode} langCode 语言环境 例如:zh-CN,en-US
|
|
749
|
+
* @param fallbackToBrowser
|
|
750
|
+
*/
|
|
751
|
+
declare function getTextByLanguageCode(langMap: LanguageTextMap, langCode?: LanguageCode, fallbackToBrowser?: boolean): string | undefined;
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Possible values in normalized {@link LocationQuery}. `null` renders the query
|
|
755
|
+
* param but without an `=`.
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* ```
|
|
759
|
+
* ?isNull&isEmpty=&other=other
|
|
760
|
+
* gives
|
|
761
|
+
* `{ isNull: null, isEmpty: '', other: 'other' }`.
|
|
762
|
+
* ```
|
|
763
|
+
*
|
|
764
|
+
* @internal
|
|
765
|
+
*/
|
|
766
|
+
type LocationQueryValue = string | null;
|
|
767
|
+
/**
|
|
768
|
+
* Possible values when defining a query.
|
|
769
|
+
*
|
|
770
|
+
* @internal
|
|
771
|
+
*/
|
|
772
|
+
type LocationQueryValueRaw = LocationQueryValue | number | undefined;
|
|
773
|
+
/**
|
|
774
|
+
* Normalized query object that appears in {@link RouteLocationNormalized}
|
|
775
|
+
*
|
|
776
|
+
* @public
|
|
777
|
+
*/
|
|
778
|
+
type LocationQuery = Record<string, LocationQueryValue | LocationQueryValue[]>;
|
|
779
|
+
/**
|
|
780
|
+
* Loose {@link LocationQuery} object that can be passed to functions like
|
|
781
|
+
* {@link Router.push} and {@link Router.replace} or anywhere when creating a
|
|
782
|
+
* {@link RouteLocationRaw}
|
|
783
|
+
*
|
|
784
|
+
* @public
|
|
785
|
+
*/
|
|
786
|
+
type LocationQueryRaw = Record<string | number, LocationQueryValueRaw | LocationQueryValueRaw[]>;
|
|
787
|
+
/**
|
|
788
|
+
* Transforms a queryString into a {@link LocationQuery} object. Accept both, a
|
|
789
|
+
* version with the leading `?` and without Should work as URLSearchParams
|
|
790
|
+
* @internal
|
|
791
|
+
*
|
|
792
|
+
* @param search - search string to parse
|
|
793
|
+
* @returns a query object
|
|
794
|
+
*/
|
|
795
|
+
declare function parseQuery(search: string): LocationQuery;
|
|
796
|
+
/**
|
|
797
|
+
* Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
|
|
798
|
+
* doesn't prepend a `?`
|
|
799
|
+
*
|
|
800
|
+
* @internal
|
|
801
|
+
*
|
|
802
|
+
* @param query - query object to stringify
|
|
803
|
+
* @returns string version of the query without the leading `?`
|
|
804
|
+
*/
|
|
778
805
|
declare function stringifyQuery(query: LocationQueryRaw): string;
|
|
779
806
|
|
|
780
|
-
type NormalizeOptions = {
|
|
781
|
-
/**
|
|
782
|
-
@default 'http'
|
|
783
|
-
*/
|
|
784
|
-
defaultProtocol?: string | 'http' | 'https';
|
|
785
|
-
/**
|
|
786
|
-
Prepends `defaultProtocol` to the URL if it's protocol-relative.
|
|
787
|
-
|
|
788
|
-
@default true
|
|
789
|
-
|
|
790
|
-
@example
|
|
791
|
-
```
|
|
792
|
-
normalizeUrl('//sindresorhus.com');
|
|
793
|
-
//=> 'http://sindresorhus.com'
|
|
794
|
-
|
|
795
|
-
normalizeUrl('//sindresorhus.com', {normalizeProtocol: false});
|
|
796
|
-
//=> '//sindresorhus.com'
|
|
797
|
-
```
|
|
798
|
-
*/
|
|
799
|
-
readonly normalizeProtocol?: boolean;
|
|
800
|
-
/**
|
|
801
|
-
Normalizes HTTPS URLs to HTTP.
|
|
802
|
-
|
|
803
|
-
@default false
|
|
804
|
-
|
|
805
|
-
@example
|
|
806
|
-
```
|
|
807
|
-
normalizeUrl('https://sindresorhus.com');
|
|
808
|
-
//=> 'https://sindresorhus.com'
|
|
809
|
-
|
|
810
|
-
normalizeUrl('https://sindresorhus.com', {forceHttp: true});
|
|
811
|
-
//=> 'http://sindresorhus.com'
|
|
812
|
-
```
|
|
813
|
-
*/
|
|
814
|
-
readonly forceHttp?: boolean;
|
|
815
|
-
/**
|
|
816
|
-
Normalizes HTTP URLs to HTTPS.
|
|
817
|
-
|
|
818
|
-
This option cannot be used with the `forceHttp` option at the same time.
|
|
819
|
-
|
|
820
|
-
@default false
|
|
821
|
-
|
|
822
|
-
@example
|
|
823
|
-
```
|
|
824
|
-
normalizeUrl('http://sindresorhus.com');
|
|
825
|
-
//=> 'http://sindresorhus.com'
|
|
826
|
-
|
|
827
|
-
normalizeUrl('http://sindresorhus.com', {forceHttps: true});
|
|
828
|
-
//=> 'https://sindresorhus.com'
|
|
829
|
-
```
|
|
830
|
-
*/
|
|
831
|
-
readonly forceHttps?: boolean;
|
|
832
|
-
/**
|
|
833
|
-
Strip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of a URL.
|
|
834
|
-
|
|
835
|
-
@default true
|
|
836
|
-
|
|
837
|
-
@example
|
|
838
|
-
```
|
|
839
|
-
normalizeUrl('https://user:password@sindresorhus.com');
|
|
840
|
-
//=> 'https://sindresorhus.com'
|
|
841
|
-
|
|
842
|
-
normalizeUrl('https://user:password@sindresorhus.com', {stripAuthentication: false});
|
|
843
|
-
//=> 'https://user:password@sindresorhus.com'
|
|
844
|
-
```
|
|
845
|
-
*/
|
|
846
|
-
readonly stripAuthentication?: boolean;
|
|
847
|
-
/**
|
|
848
|
-
Removes hash from the URL.
|
|
849
|
-
|
|
850
|
-
@default false
|
|
851
|
-
|
|
852
|
-
@example
|
|
853
|
-
```
|
|
854
|
-
normalizeUrl('sindresorhus.com/about.html#contact');
|
|
855
|
-
//=> 'http://sindresorhus.com/about.html#contact'
|
|
856
|
-
|
|
857
|
-
normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
|
|
858
|
-
//=> 'http://sindresorhus.com/about.html'
|
|
859
|
-
```
|
|
860
|
-
*/
|
|
861
|
-
readonly stripHash?: boolean;
|
|
862
|
-
/**
|
|
863
|
-
Remove the protocol from the URL: `http://sindresorhus.com` → `sindresorhus.com`.
|
|
864
|
-
|
|
865
|
-
It will only remove `https://` and `http://` protocols.
|
|
866
|
-
|
|
867
|
-
@default false
|
|
868
|
-
|
|
869
|
-
@example
|
|
870
|
-
```
|
|
871
|
-
normalizeUrl('https://sindresorhus.com');
|
|
872
|
-
//=> 'https://sindresorhus.com'
|
|
873
|
-
|
|
874
|
-
normalizeUrl('sindresorhus.com', {stripProtocol: true});
|
|
875
|
-
//=> 'sindresorhus.com'
|
|
876
|
-
```
|
|
877
|
-
*/
|
|
878
|
-
readonly stripProtocol?: boolean;
|
|
879
|
-
/**
|
|
880
|
-
Strip the [text fragment](https://web.dev/text-fragments/) part of the URL
|
|
881
|
-
|
|
882
|
-
__Note:__ The text fragment will always be removed if the `stripHash` option is set to `true`, as the hash contains the text fragment.
|
|
883
|
-
|
|
884
|
-
@default true
|
|
885
|
-
|
|
886
|
-
@example
|
|
887
|
-
```
|
|
888
|
-
normalizeUrl('http://sindresorhus.com/about.html#:~:text=hello');
|
|
889
|
-
//=> 'http://sindresorhus.com/about.html#'
|
|
890
|
-
|
|
891
|
-
normalizeUrl('http://sindresorhus.com/about.html#section:~:text=hello');
|
|
892
|
-
//=> 'http://sindresorhus.com/about.html#section'
|
|
893
|
-
|
|
894
|
-
normalizeUrl('http://sindresorhus.com/about.html#:~:text=hello', {stripTextFragment: false});
|
|
895
|
-
//=> 'http://sindresorhus.com/about.html#:~:text=hello'
|
|
896
|
-
|
|
897
|
-
normalizeUrl('http://sindresorhus.com/about.html#section:~:text=hello', {stripTextFragment: false});
|
|
898
|
-
//=> 'http://sindresorhus.com/about.html#section:~:text=hello'
|
|
899
|
-
```
|
|
900
|
-
*/
|
|
901
|
-
readonly stripTextFragment?: boolean;
|
|
902
|
-
/**
|
|
903
|
-
Removes `www.` from the URL.
|
|
904
|
-
|
|
905
|
-
@default true
|
|
906
|
-
|
|
907
|
-
@example
|
|
908
|
-
```
|
|
909
|
-
normalizeUrl('http://www.sindresorhus.com');
|
|
910
|
-
//=> 'http://sindresorhus.com'
|
|
911
|
-
|
|
912
|
-
normalizeUrl('http://www.sindresorhus.com', {stripWWW: false});
|
|
913
|
-
//=> 'http://www.sindresorhus.com'
|
|
914
|
-
```
|
|
915
|
-
*/
|
|
916
|
-
readonly stripWWW?: boolean;
|
|
917
|
-
/**
|
|
918
|
-
Removes query parameters that matches any of the provided strings or regexes.
|
|
919
|
-
|
|
920
|
-
@default [/^utm_\w+/i]
|
|
921
|
-
|
|
922
|
-
@example
|
|
923
|
-
```
|
|
924
|
-
normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
|
|
925
|
-
removeQueryParameters: ['ref']
|
|
926
|
-
});
|
|
927
|
-
//=> 'http://sindresorhus.com/?foo=bar'
|
|
928
|
-
```
|
|
929
|
-
|
|
930
|
-
If a boolean is provided, `true` will remove all the query parameters.
|
|
931
|
-
|
|
932
|
-
```
|
|
933
|
-
normalizeUrl('www.sindresorhus.com?foo=bar', {
|
|
934
|
-
removeQueryParameters: true
|
|
935
|
-
});
|
|
936
|
-
//=> 'http://sindresorhus.com'
|
|
937
|
-
```
|
|
938
|
-
|
|
939
|
-
`false` will not remove any query parameter.
|
|
940
|
-
|
|
941
|
-
```
|
|
942
|
-
normalizeUrl('www.sindresorhus.com?foo=bar&utm_medium=test&ref=test_ref', {
|
|
943
|
-
removeQueryParameters: false
|
|
944
|
-
});
|
|
945
|
-
//=> 'http://www.sindresorhus.com/?foo=bar&ref=test_ref&utm_medium=test'
|
|
946
|
-
```
|
|
947
|
-
*/
|
|
948
|
-
readonly removeQueryParameters?: ReadonlyArray<RegExp | string> | boolean;
|
|
949
|
-
/**
|
|
950
|
-
Keeps only query parameters that matches any of the provided strings or regexes.
|
|
951
|
-
|
|
952
|
-
__Note__: It overrides the `removeQueryParameters` option.
|
|
953
|
-
|
|
954
|
-
@default undefined
|
|
955
|
-
|
|
956
|
-
@example
|
|
957
|
-
```
|
|
958
|
-
normalizeUrl('https://sindresorhus.com?foo=bar&ref=unicorn', {
|
|
959
|
-
keepQueryParameters: ['ref']
|
|
960
|
-
});
|
|
961
|
-
//=> 'https://sindresorhus.com/?ref=unicorn'
|
|
962
|
-
```
|
|
963
|
-
*/
|
|
964
|
-
readonly keepQueryParameters?: ReadonlyArray<RegExp | string>;
|
|
965
|
-
/**
|
|
966
|
-
Removes trailing slash.
|
|
967
|
-
|
|
968
|
-
__Note__: Trailing slash is always removed if the URL doesn't have a pathname unless the `removeSingleSlash` option is set to `false`.
|
|
969
|
-
|
|
970
|
-
@default true
|
|
971
|
-
|
|
972
|
-
@example
|
|
973
|
-
```
|
|
974
|
-
normalizeUrl('http://sindresorhus.com/redirect/');
|
|
975
|
-
//=> 'http://sindresorhus.com/redirect'
|
|
976
|
-
|
|
977
|
-
normalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false});
|
|
978
|
-
//=> 'http://sindresorhus.com/redirect/'
|
|
979
|
-
|
|
980
|
-
normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});
|
|
981
|
-
//=> 'http://sindresorhus.com'
|
|
982
|
-
```
|
|
983
|
-
*/
|
|
984
|
-
readonly removeTrailingSlash?: boolean;
|
|
985
|
-
/**
|
|
986
|
-
Remove a sole `/` pathname in the output. This option is independent of `removeTrailingSlash`.
|
|
987
|
-
|
|
988
|
-
@default true
|
|
989
|
-
|
|
990
|
-
@example
|
|
991
|
-
```
|
|
992
|
-
normalizeUrl('https://sindresorhus.com/');
|
|
993
|
-
//=> 'https://sindresorhus.com'
|
|
994
|
-
|
|
995
|
-
normalizeUrl('https://sindresorhus.com/', {removeSingleSlash: false});
|
|
996
|
-
//=> 'https://sindresorhus.com/'
|
|
997
|
-
```
|
|
998
|
-
*/
|
|
999
|
-
readonly removeSingleSlash?: boolean;
|
|
1000
|
-
/**
|
|
1001
|
-
Removes the default directory index file from path that matches any of the provided strings or regexes.
|
|
1002
|
-
When `true`, the regex `/^index\.[a-z]+$/` is used.
|
|
1003
|
-
|
|
1004
|
-
@default false
|
|
1005
|
-
|
|
1006
|
-
@example
|
|
1007
|
-
```
|
|
1008
|
-
normalizeUrl('www.sindresorhus.com/foo/default.php', {
|
|
1009
|
-
removeDirectoryIndex: [/^default\.[a-z]+$/]
|
|
1010
|
-
});
|
|
1011
|
-
//=> 'http://sindresorhus.com/foo'
|
|
1012
|
-
```
|
|
1013
|
-
*/
|
|
1014
|
-
removeDirectoryIndex?: boolean | ReadonlyArray<RegExp | string>;
|
|
1015
|
-
/**
|
|
1016
|
-
Removes an explicit port number from the URL.
|
|
1017
|
-
|
|
1018
|
-
Port 443 is always removed from HTTPS URLs and 80 is always removed from HTTP URLs regardless of this option.
|
|
1019
|
-
|
|
1020
|
-
@default false
|
|
1021
|
-
|
|
1022
|
-
@example
|
|
1023
|
-
```
|
|
1024
|
-
normalizeUrl('sindresorhus.com:123', {
|
|
1025
|
-
removeExplicitPort: true
|
|
1026
|
-
});
|
|
1027
|
-
//=> 'http://sindresorhus.com'
|
|
1028
|
-
```
|
|
1029
|
-
*/
|
|
1030
|
-
readonly removeExplicitPort?: boolean;
|
|
1031
|
-
/**
|
|
1032
|
-
Sorts the query parameters alphabetically by key.
|
|
1033
|
-
|
|
1034
|
-
@default true
|
|
1035
|
-
|
|
1036
|
-
@example
|
|
1037
|
-
```
|
|
1038
|
-
normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
|
|
1039
|
-
sortQueryParameters: false
|
|
1040
|
-
});
|
|
1041
|
-
//=> 'http://sindresorhus.com/?b=two&a=one&c=three'
|
|
1042
|
-
```
|
|
1043
|
-
*/
|
|
1044
|
-
readonly sortQueryParameters?: boolean;
|
|
1045
|
-
};
|
|
807
|
+
type NormalizeOptions = {
|
|
808
|
+
/**
|
|
809
|
+
@default 'http'
|
|
810
|
+
*/
|
|
811
|
+
defaultProtocol?: string | 'http' | 'https';
|
|
812
|
+
/**
|
|
813
|
+
Prepends `defaultProtocol` to the URL if it's protocol-relative.
|
|
814
|
+
|
|
815
|
+
@default true
|
|
816
|
+
|
|
817
|
+
@example
|
|
818
|
+
```
|
|
819
|
+
normalizeUrl('//sindresorhus.com');
|
|
820
|
+
//=> 'http://sindresorhus.com'
|
|
821
|
+
|
|
822
|
+
normalizeUrl('//sindresorhus.com', {normalizeProtocol: false});
|
|
823
|
+
//=> '//sindresorhus.com'
|
|
824
|
+
```
|
|
825
|
+
*/
|
|
826
|
+
readonly normalizeProtocol?: boolean;
|
|
827
|
+
/**
|
|
828
|
+
Normalizes HTTPS URLs to HTTP.
|
|
829
|
+
|
|
830
|
+
@default false
|
|
831
|
+
|
|
832
|
+
@example
|
|
833
|
+
```
|
|
834
|
+
normalizeUrl('https://sindresorhus.com');
|
|
835
|
+
//=> 'https://sindresorhus.com'
|
|
836
|
+
|
|
837
|
+
normalizeUrl('https://sindresorhus.com', {forceHttp: true});
|
|
838
|
+
//=> 'http://sindresorhus.com'
|
|
839
|
+
```
|
|
840
|
+
*/
|
|
841
|
+
readonly forceHttp?: boolean;
|
|
842
|
+
/**
|
|
843
|
+
Normalizes HTTP URLs to HTTPS.
|
|
844
|
+
|
|
845
|
+
This option cannot be used with the `forceHttp` option at the same time.
|
|
846
|
+
|
|
847
|
+
@default false
|
|
848
|
+
|
|
849
|
+
@example
|
|
850
|
+
```
|
|
851
|
+
normalizeUrl('http://sindresorhus.com');
|
|
852
|
+
//=> 'http://sindresorhus.com'
|
|
853
|
+
|
|
854
|
+
normalizeUrl('http://sindresorhus.com', {forceHttps: true});
|
|
855
|
+
//=> 'https://sindresorhus.com'
|
|
856
|
+
```
|
|
857
|
+
*/
|
|
858
|
+
readonly forceHttps?: boolean;
|
|
859
|
+
/**
|
|
860
|
+
Strip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of a URL.
|
|
861
|
+
|
|
862
|
+
@default true
|
|
863
|
+
|
|
864
|
+
@example
|
|
865
|
+
```
|
|
866
|
+
normalizeUrl('https://user:password@sindresorhus.com');
|
|
867
|
+
//=> 'https://sindresorhus.com'
|
|
868
|
+
|
|
869
|
+
normalizeUrl('https://user:password@sindresorhus.com', {stripAuthentication: false});
|
|
870
|
+
//=> 'https://user:password@sindresorhus.com'
|
|
871
|
+
```
|
|
872
|
+
*/
|
|
873
|
+
readonly stripAuthentication?: boolean;
|
|
874
|
+
/**
|
|
875
|
+
Removes hash from the URL.
|
|
876
|
+
|
|
877
|
+
@default false
|
|
878
|
+
|
|
879
|
+
@example
|
|
880
|
+
```
|
|
881
|
+
normalizeUrl('sindresorhus.com/about.html#contact');
|
|
882
|
+
//=> 'http://sindresorhus.com/about.html#contact'
|
|
883
|
+
|
|
884
|
+
normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
|
|
885
|
+
//=> 'http://sindresorhus.com/about.html'
|
|
886
|
+
```
|
|
887
|
+
*/
|
|
888
|
+
readonly stripHash?: boolean;
|
|
889
|
+
/**
|
|
890
|
+
Remove the protocol from the URL: `http://sindresorhus.com` → `sindresorhus.com`.
|
|
891
|
+
|
|
892
|
+
It will only remove `https://` and `http://` protocols.
|
|
893
|
+
|
|
894
|
+
@default false
|
|
895
|
+
|
|
896
|
+
@example
|
|
897
|
+
```
|
|
898
|
+
normalizeUrl('https://sindresorhus.com');
|
|
899
|
+
//=> 'https://sindresorhus.com'
|
|
900
|
+
|
|
901
|
+
normalizeUrl('sindresorhus.com', {stripProtocol: true});
|
|
902
|
+
//=> 'sindresorhus.com'
|
|
903
|
+
```
|
|
904
|
+
*/
|
|
905
|
+
readonly stripProtocol?: boolean;
|
|
906
|
+
/**
|
|
907
|
+
Strip the [text fragment](https://web.dev/text-fragments/) part of the URL
|
|
908
|
+
|
|
909
|
+
__Note:__ The text fragment will always be removed if the `stripHash` option is set to `true`, as the hash contains the text fragment.
|
|
910
|
+
|
|
911
|
+
@default true
|
|
912
|
+
|
|
913
|
+
@example
|
|
914
|
+
```
|
|
915
|
+
normalizeUrl('http://sindresorhus.com/about.html#:~:text=hello');
|
|
916
|
+
//=> 'http://sindresorhus.com/about.html#'
|
|
917
|
+
|
|
918
|
+
normalizeUrl('http://sindresorhus.com/about.html#section:~:text=hello');
|
|
919
|
+
//=> 'http://sindresorhus.com/about.html#section'
|
|
920
|
+
|
|
921
|
+
normalizeUrl('http://sindresorhus.com/about.html#:~:text=hello', {stripTextFragment: false});
|
|
922
|
+
//=> 'http://sindresorhus.com/about.html#:~:text=hello'
|
|
923
|
+
|
|
924
|
+
normalizeUrl('http://sindresorhus.com/about.html#section:~:text=hello', {stripTextFragment: false});
|
|
925
|
+
//=> 'http://sindresorhus.com/about.html#section:~:text=hello'
|
|
926
|
+
```
|
|
927
|
+
*/
|
|
928
|
+
readonly stripTextFragment?: boolean;
|
|
929
|
+
/**
|
|
930
|
+
Removes `www.` from the URL.
|
|
931
|
+
|
|
932
|
+
@default true
|
|
933
|
+
|
|
934
|
+
@example
|
|
935
|
+
```
|
|
936
|
+
normalizeUrl('http://www.sindresorhus.com');
|
|
937
|
+
//=> 'http://sindresorhus.com'
|
|
938
|
+
|
|
939
|
+
normalizeUrl('http://www.sindresorhus.com', {stripWWW: false});
|
|
940
|
+
//=> 'http://www.sindresorhus.com'
|
|
941
|
+
```
|
|
942
|
+
*/
|
|
943
|
+
readonly stripWWW?: boolean;
|
|
944
|
+
/**
|
|
945
|
+
Removes query parameters that matches any of the provided strings or regexes.
|
|
946
|
+
|
|
947
|
+
@default [/^utm_\w+/i]
|
|
948
|
+
|
|
949
|
+
@example
|
|
950
|
+
```
|
|
951
|
+
normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
|
|
952
|
+
removeQueryParameters: ['ref']
|
|
953
|
+
});
|
|
954
|
+
//=> 'http://sindresorhus.com/?foo=bar'
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
If a boolean is provided, `true` will remove all the query parameters.
|
|
958
|
+
|
|
959
|
+
```
|
|
960
|
+
normalizeUrl('www.sindresorhus.com?foo=bar', {
|
|
961
|
+
removeQueryParameters: true
|
|
962
|
+
});
|
|
963
|
+
//=> 'http://sindresorhus.com'
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
`false` will not remove any query parameter.
|
|
967
|
+
|
|
968
|
+
```
|
|
969
|
+
normalizeUrl('www.sindresorhus.com?foo=bar&utm_medium=test&ref=test_ref', {
|
|
970
|
+
removeQueryParameters: false
|
|
971
|
+
});
|
|
972
|
+
//=> 'http://www.sindresorhus.com/?foo=bar&ref=test_ref&utm_medium=test'
|
|
973
|
+
```
|
|
974
|
+
*/
|
|
975
|
+
readonly removeQueryParameters?: ReadonlyArray<RegExp | string> | boolean;
|
|
976
|
+
/**
|
|
977
|
+
Keeps only query parameters that matches any of the provided strings or regexes.
|
|
978
|
+
|
|
979
|
+
__Note__: It overrides the `removeQueryParameters` option.
|
|
980
|
+
|
|
981
|
+
@default undefined
|
|
982
|
+
|
|
983
|
+
@example
|
|
984
|
+
```
|
|
985
|
+
normalizeUrl('https://sindresorhus.com?foo=bar&ref=unicorn', {
|
|
986
|
+
keepQueryParameters: ['ref']
|
|
987
|
+
});
|
|
988
|
+
//=> 'https://sindresorhus.com/?ref=unicorn'
|
|
989
|
+
```
|
|
990
|
+
*/
|
|
991
|
+
readonly keepQueryParameters?: ReadonlyArray<RegExp | string>;
|
|
992
|
+
/**
|
|
993
|
+
Removes trailing slash.
|
|
994
|
+
|
|
995
|
+
__Note__: Trailing slash is always removed if the URL doesn't have a pathname unless the `removeSingleSlash` option is set to `false`.
|
|
996
|
+
|
|
997
|
+
@default true
|
|
998
|
+
|
|
999
|
+
@example
|
|
1000
|
+
```
|
|
1001
|
+
normalizeUrl('http://sindresorhus.com/redirect/');
|
|
1002
|
+
//=> 'http://sindresorhus.com/redirect'
|
|
1003
|
+
|
|
1004
|
+
normalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false});
|
|
1005
|
+
//=> 'http://sindresorhus.com/redirect/'
|
|
1006
|
+
|
|
1007
|
+
normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});
|
|
1008
|
+
//=> 'http://sindresorhus.com'
|
|
1009
|
+
```
|
|
1010
|
+
*/
|
|
1011
|
+
readonly removeTrailingSlash?: boolean;
|
|
1012
|
+
/**
|
|
1013
|
+
Remove a sole `/` pathname in the output. This option is independent of `removeTrailingSlash`.
|
|
1014
|
+
|
|
1015
|
+
@default true
|
|
1016
|
+
|
|
1017
|
+
@example
|
|
1018
|
+
```
|
|
1019
|
+
normalizeUrl('https://sindresorhus.com/');
|
|
1020
|
+
//=> 'https://sindresorhus.com'
|
|
1021
|
+
|
|
1022
|
+
normalizeUrl('https://sindresorhus.com/', {removeSingleSlash: false});
|
|
1023
|
+
//=> 'https://sindresorhus.com/'
|
|
1024
|
+
```
|
|
1025
|
+
*/
|
|
1026
|
+
readonly removeSingleSlash?: boolean;
|
|
1027
|
+
/**
|
|
1028
|
+
Removes the default directory index file from path that matches any of the provided strings or regexes.
|
|
1029
|
+
When `true`, the regex `/^index\.[a-z]+$/` is used.
|
|
1030
|
+
|
|
1031
|
+
@default false
|
|
1032
|
+
|
|
1033
|
+
@example
|
|
1034
|
+
```
|
|
1035
|
+
normalizeUrl('www.sindresorhus.com/foo/default.php', {
|
|
1036
|
+
removeDirectoryIndex: [/^default\.[a-z]+$/]
|
|
1037
|
+
});
|
|
1038
|
+
//=> 'http://sindresorhus.com/foo'
|
|
1039
|
+
```
|
|
1040
|
+
*/
|
|
1041
|
+
removeDirectoryIndex?: boolean | ReadonlyArray<RegExp | string>;
|
|
1042
|
+
/**
|
|
1043
|
+
Removes an explicit port number from the URL.
|
|
1044
|
+
|
|
1045
|
+
Port 443 is always removed from HTTPS URLs and 80 is always removed from HTTP URLs regardless of this option.
|
|
1046
|
+
|
|
1047
|
+
@default false
|
|
1048
|
+
|
|
1049
|
+
@example
|
|
1050
|
+
```
|
|
1051
|
+
normalizeUrl('sindresorhus.com:123', {
|
|
1052
|
+
removeExplicitPort: true
|
|
1053
|
+
});
|
|
1054
|
+
//=> 'http://sindresorhus.com'
|
|
1055
|
+
```
|
|
1056
|
+
*/
|
|
1057
|
+
readonly removeExplicitPort?: boolean;
|
|
1058
|
+
/**
|
|
1059
|
+
Sorts the query parameters alphabetically by key.
|
|
1060
|
+
|
|
1061
|
+
@default true
|
|
1062
|
+
|
|
1063
|
+
@example
|
|
1064
|
+
```
|
|
1065
|
+
normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
|
|
1066
|
+
sortQueryParameters: false
|
|
1067
|
+
});
|
|
1068
|
+
//=> 'http://sindresorhus.com/?b=two&a=one&c=three'
|
|
1069
|
+
```
|
|
1070
|
+
*/
|
|
1071
|
+
readonly sortQueryParameters?: boolean;
|
|
1072
|
+
};
|
|
1046
1073
|
declare function normalizeUrl(urlString: string, options?: NormalizeOptions): string;
|
|
1047
1074
|
|
|
1048
|
-
interface IGridRect {
|
|
1049
|
-
top: number;
|
|
1050
|
-
left: number;
|
|
1051
|
-
width: number;
|
|
1052
|
-
height: number;
|
|
1053
|
-
}
|
|
1054
|
-
declare class GridRect implements IGridRect {
|
|
1055
|
-
top: number;
|
|
1056
|
-
left: number;
|
|
1057
|
-
width: number;
|
|
1058
|
-
height: number;
|
|
1059
|
-
constructor(left: number, top: number, width: number, height: number);
|
|
1060
|
-
get right(): number;
|
|
1061
|
-
get bottom(): number;
|
|
1062
|
-
}
|
|
1063
|
-
declare class GridSystem extends GridRect {
|
|
1064
|
-
cellSize: number;
|
|
1065
|
-
horizontalCellCount: number;
|
|
1066
|
-
verticalCellCount: number;
|
|
1067
|
-
screenWidth: number;
|
|
1068
|
-
screenHeight: number;
|
|
1069
|
-
/**
|
|
1070
|
-
*
|
|
1071
|
-
* @param cellSize
|
|
1072
|
-
* @param padding 至少保留的边距
|
|
1073
|
-
* @param screenWidth
|
|
1074
|
-
* @param screenHeight
|
|
1075
|
-
*/
|
|
1076
|
-
constructor(cellSize: number, padding: number, screenWidth: number, screenHeight: number);
|
|
1077
|
-
/**
|
|
1078
|
-
* 将坐标对齐到网格上
|
|
1079
|
-
* @param x
|
|
1080
|
-
* @param y
|
|
1081
|
-
*/
|
|
1082
|
-
snapPosition(x: number, y: number): number[];
|
|
1083
|
-
snapSize(width: number, height: number): number[];
|
|
1084
|
-
/**
|
|
1085
|
-
* 将矩形对齐到网格上
|
|
1086
|
-
* @param rect
|
|
1087
|
-
* @param minWidth
|
|
1088
|
-
* @param maxWidth
|
|
1089
|
-
* @param minHeight
|
|
1090
|
-
* @param maxHeight
|
|
1091
|
-
*/
|
|
1092
|
-
snapRect(rect: GridRect, minWidth: number, maxWidth: number, minHeight: number, maxHeight: number): IGridRect;
|
|
1093
|
-
private getRangeValue;
|
|
1094
|
-
getWidth(): number;
|
|
1095
|
-
getHeight(): number;
|
|
1075
|
+
interface IGridRect {
|
|
1076
|
+
top: number;
|
|
1077
|
+
left: number;
|
|
1078
|
+
width: number;
|
|
1079
|
+
height: number;
|
|
1080
|
+
}
|
|
1081
|
+
declare class GridRect implements IGridRect {
|
|
1082
|
+
top: number;
|
|
1083
|
+
left: number;
|
|
1084
|
+
width: number;
|
|
1085
|
+
height: number;
|
|
1086
|
+
constructor(left: number, top: number, width: number, height: number);
|
|
1087
|
+
get right(): number;
|
|
1088
|
+
get bottom(): number;
|
|
1089
|
+
}
|
|
1090
|
+
declare class GridSystem extends GridRect {
|
|
1091
|
+
cellSize: number;
|
|
1092
|
+
horizontalCellCount: number;
|
|
1093
|
+
verticalCellCount: number;
|
|
1094
|
+
screenWidth: number;
|
|
1095
|
+
screenHeight: number;
|
|
1096
|
+
/**
|
|
1097
|
+
*
|
|
1098
|
+
* @param cellSize
|
|
1099
|
+
* @param padding 至少保留的边距
|
|
1100
|
+
* @param screenWidth
|
|
1101
|
+
* @param screenHeight
|
|
1102
|
+
*/
|
|
1103
|
+
constructor(cellSize: number, padding: number, screenWidth: number, screenHeight: number);
|
|
1104
|
+
/**
|
|
1105
|
+
* 将坐标对齐到网格上
|
|
1106
|
+
* @param x
|
|
1107
|
+
* @param y
|
|
1108
|
+
*/
|
|
1109
|
+
snapPosition(x: number, y: number): number[];
|
|
1110
|
+
snapSize(width: number, height: number): number[];
|
|
1111
|
+
/**
|
|
1112
|
+
* 将矩形对齐到网格上
|
|
1113
|
+
* @param rect
|
|
1114
|
+
* @param minWidth
|
|
1115
|
+
* @param maxWidth
|
|
1116
|
+
* @param minHeight
|
|
1117
|
+
* @param maxHeight
|
|
1118
|
+
*/
|
|
1119
|
+
snapRect(rect: GridRect, minWidth: number, maxWidth: number, minHeight: number, maxHeight: number): IGridRect;
|
|
1120
|
+
private getRangeValue;
|
|
1121
|
+
getWidth(): number;
|
|
1122
|
+
getHeight(): number;
|
|
1096
1123
|
}
|
|
1097
1124
|
|
|
1098
|
-
declare class ElectronApi {
|
|
1099
|
-
static addIpcListener(key: String, f: Function): Promise<void>;
|
|
1100
|
-
static removeIpcListener(key: String): Promise<void>;
|
|
1125
|
+
declare class ElectronApi {
|
|
1126
|
+
static addIpcListener(key: String, f: Function): Promise<void>;
|
|
1127
|
+
static removeIpcListener(key: String): Promise<void>;
|
|
1101
1128
|
}
|
|
1102
1129
|
|
|
1103
|
-
interface SaveWidgetOption {
|
|
1104
|
-
sendBroadcast?: boolean;
|
|
1105
|
-
id?: string;
|
|
1106
|
-
}
|
|
1107
|
-
interface IWidgetDataApi {
|
|
1108
|
-
findByName<T extends WidgetData>(name: string, type: {
|
|
1109
|
-
new (name: string, id?: string): T;
|
|
1110
|
-
}): Promise<T | undefined>;
|
|
1111
|
-
findByName<T extends WidgetData>(data: T): Promise<T | undefined>;
|
|
1112
|
-
save(data: WidgetData): Promise<string>;
|
|
1113
|
-
getStore(name: string): LocalForage;
|
|
1114
|
-
saveByName<T extends WidgetData>(data: T, options?: SaveWidgetOption): Promise<string>;
|
|
1115
|
-
find<T extends WidgetData>(name: string, id: string, type: {
|
|
1116
|
-
new (name: string, id?: string): T;
|
|
1117
|
-
}): Promise<T | undefined>;
|
|
1118
|
-
}
|
|
1119
|
-
type WidgetDataApiMethods = keyof IWidgetDataApi;
|
|
1130
|
+
interface SaveWidgetOption {
|
|
1131
|
+
sendBroadcast?: boolean;
|
|
1132
|
+
id?: string;
|
|
1133
|
+
}
|
|
1134
|
+
interface IWidgetDataApi {
|
|
1135
|
+
findByName<T extends WidgetData>(name: string, type: {
|
|
1136
|
+
new (name: string, id?: string): T;
|
|
1137
|
+
}): Promise<T | undefined>;
|
|
1138
|
+
findByName<T extends WidgetData>(data: T): Promise<T | undefined>;
|
|
1139
|
+
save(data: WidgetData, options?: SaveWidgetOption): Promise<string>;
|
|
1140
|
+
getStore(name: string): LocalForage;
|
|
1141
|
+
saveByName<T extends WidgetData>(data: T, options?: SaveWidgetOption): Promise<string>;
|
|
1142
|
+
find<T extends WidgetData>(name: string, id: string, type: {
|
|
1143
|
+
new (name: string, id?: string): T;
|
|
1144
|
+
}): Promise<T | undefined>;
|
|
1145
|
+
}
|
|
1146
|
+
type WidgetDataApiMethods = keyof IWidgetDataApi;
|
|
1120
1147
|
declare const WidgetDataApi: IWidgetDataApi;
|
|
1121
1148
|
|
|
1122
|
-
interface IBrowserWindowApi {
|
|
1123
|
-
setIgnoreMouseEvent(ignore: boolean): Promise<void>;
|
|
1124
|
-
show(): Promise<void>;
|
|
1125
|
-
hide(): Promise<void>;
|
|
1126
|
-
close(): Promise<void>;
|
|
1127
|
-
showInactive(): Promise<void>;
|
|
1128
|
-
center(): Promise<void>;
|
|
1129
|
-
startDraggingWindow(): Promise<void>;
|
|
1130
|
-
minimize(): Promise<void>;
|
|
1131
|
-
restore(): Promise<void>;
|
|
1132
|
-
isMinimized(): Promise<boolean>;
|
|
1133
|
-
isMaximized(): Promise<boolean>;
|
|
1134
|
-
maximize(): Promise<void>;
|
|
1135
|
-
stopDraggingWindow(): Promise<void>;
|
|
1136
|
-
setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
|
|
1137
|
-
isAlwaysOnTop(): Promise<boolean>;
|
|
1138
|
-
openUrl(url: string, option?: OpenUrlOptions): Promise<void>;
|
|
1139
|
-
moveTop(): Promise<void>;
|
|
1140
|
-
unmaximize(): Promise<void>;
|
|
1141
|
-
reload(): Promise<void>;
|
|
1142
|
-
setSize(width: number, height: number, animate?: boolean): Promise<void>;
|
|
1143
|
-
openDevTools(): Promise<void>;
|
|
1144
|
-
setPosition(options: SetPositionOptions): Promise<void>;
|
|
1145
|
-
getPosition(): Promise<Position>;
|
|
1146
|
-
blur(): Promise<void>;
|
|
1147
|
-
focus(): Promise<void>;
|
|
1148
|
-
setResizable(resizable: boolean): Promise<void>;
|
|
1149
|
-
setMovable(movable: boolean): Promise<void>;
|
|
1150
|
-
getBounds(): Promise<Rectangle>;
|
|
1151
|
-
setBounds(bounds: Partial<Rectangle>, animate: boolean): Promise<void>;
|
|
1152
|
-
alignToScreen(align: AlignPosition): Promise<void>;
|
|
1153
|
-
existsByUrl(url: string): Promise<boolean>;
|
|
1154
|
-
getMaximumSize(): Promise<number[]>;
|
|
1155
|
-
getMinimumSize(): Promise<number[]>;
|
|
1156
|
-
setMaximumSize(width: number, height: number): Promise<void>;
|
|
1157
|
-
setMinimumSize(width: number, height: number): Promise<void>;
|
|
1158
|
-
setZoomLevel(level: number): Promise<void>;
|
|
1159
|
-
setZoomFactor(factor: number): Promise<void>;
|
|
1160
|
-
isFocused(): Promise<boolean>;
|
|
1161
|
-
}
|
|
1162
|
-
type BrowserWindowApiMethods = keyof IBrowserWindowApi;
|
|
1163
|
-
type AlignPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
1164
|
-
interface OpenUrlOptions {
|
|
1165
|
-
partition?: string;
|
|
1166
|
-
external?: boolean;
|
|
1167
|
-
}
|
|
1168
|
-
interface SetPositionOptions {
|
|
1169
|
-
x?: number;
|
|
1170
|
-
y?: number;
|
|
1171
|
-
/**
|
|
1172
|
-
* 只有在 macOS 上有效
|
|
1173
|
-
*/
|
|
1174
|
-
animation?: boolean;
|
|
1175
|
-
}
|
|
1176
|
-
declare enum BrowserWindowApiEvent {
|
|
1177
|
-
BLUR = "event::cn.widgetjs.core.browser-window.blur",
|
|
1178
|
-
MOVED = "event::cn.widgetjs.core.browser-window.moved",
|
|
1179
|
-
FOCUS = "event::cn.widgetjs.core.browser-window.focus",
|
|
1180
|
-
SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.snap_to_edge",
|
|
1181
|
-
RESIZED = "event::cn.widgetjs.core.browser-window.resized",
|
|
1182
|
-
CANCEL_SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge"
|
|
1183
|
-
}
|
|
1184
|
-
interface SetupOptions {
|
|
1185
|
-
width: number;
|
|
1186
|
-
height: number;
|
|
1187
|
-
minWidth?: number;
|
|
1188
|
-
minHeight?: number;
|
|
1189
|
-
maxWidth?: number;
|
|
1190
|
-
maxHeight?: number;
|
|
1191
|
-
resizable?: boolean;
|
|
1192
|
-
movable?: boolean;
|
|
1193
|
-
center?: boolean;
|
|
1194
|
-
alwaysOnTop?: boolean;
|
|
1195
|
-
}
|
|
1196
|
-
declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> implements IBrowserWindowApi {
|
|
1197
|
-
getChannel(): string;
|
|
1198
|
-
setIgnoreMouseEvent(ignore: boolean): Promise<void>;
|
|
1199
|
-
show(): Promise<void>;
|
|
1200
|
-
showInactive(): Promise<void>;
|
|
1201
|
-
hide(): Promise<void>;
|
|
1202
|
-
center(): Promise<void>;
|
|
1203
|
-
setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
|
|
1204
|
-
isAlwaysOnTop(): Promise<boolean>;
|
|
1205
|
-
openUrl(url: string, option?: OpenUrlOptions): Promise<void>;
|
|
1206
|
-
moveTop(): Promise<void>;
|
|
1207
|
-
openDevTools(): Promise<void>;
|
|
1208
|
-
setPosition(options: SetPositionOptions): Promise<void>;
|
|
1209
|
-
getPosition(): Promise<Position>;
|
|
1210
|
-
blur(): Promise<any>;
|
|
1211
|
-
focus(): Promise<any>;
|
|
1212
|
-
/**
|
|
1213
|
-
* 设置窗口是否可以拉伸
|
|
1214
|
-
* @param resizable
|
|
1215
|
-
*/
|
|
1216
|
-
setResizable(resizable: boolean): Promise<any>;
|
|
1217
|
-
getBounds(): Promise<Rectangle>;
|
|
1218
|
-
setBounds(bounds: Partial<Rectangle>, animate?: boolean): Promise<void>;
|
|
1219
|
-
alignToScreen(align: AlignPosition): Promise<any>;
|
|
1220
|
-
startDraggingWindow(): Promise<any>;
|
|
1221
|
-
stopDraggingWindow(): Promise<any>;
|
|
1222
|
-
/**
|
|
1223
|
-
* 通过url检测窗口是否存在
|
|
1224
|
-
* @param url
|
|
1225
|
-
*/
|
|
1226
|
-
existsByUrl(url: string): Promise<boolean>;
|
|
1227
|
-
getMaximumSize(): Promise<number[]>;
|
|
1228
|
-
minimize(): Promise<void>;
|
|
1229
|
-
maximize(): Promise<void>;
|
|
1230
|
-
isMaximized(): Promise<boolean>;
|
|
1231
|
-
isMinimized(): Promise<boolean>;
|
|
1232
|
-
restore(): Promise<void>;
|
|
1233
|
-
unmaximize(): Promise<void>;
|
|
1234
|
-
setZoomLevel(level: number): Promise<void>;
|
|
1235
|
-
reload(): Promise<void>;
|
|
1236
|
-
setMovable(movable: boolean): Promise<void>;
|
|
1237
|
-
setSize(width: number, height: number, animate?: boolean): Promise<void>;
|
|
1238
|
-
isFocused(): Promise<boolean>;
|
|
1239
|
-
setMaximumSize(width: number, height: number): Promise<void>;
|
|
1240
|
-
setMinimumSize(width: number, height: number): Promise<void>;
|
|
1241
|
-
getMinimumSize(): Promise<number[]>;
|
|
1242
|
-
close(): Promise<void>;
|
|
1243
|
-
setZoomFactor(factor: number): Promise<void>;
|
|
1244
|
-
setup(options: SetupOptions): Promise<void>;
|
|
1245
|
-
}
|
|
1149
|
+
interface IBrowserWindowApi {
|
|
1150
|
+
setIgnoreMouseEvent(ignore: boolean): Promise<void>;
|
|
1151
|
+
show(): Promise<void>;
|
|
1152
|
+
hide(): Promise<void>;
|
|
1153
|
+
close(): Promise<void>;
|
|
1154
|
+
showInactive(): Promise<void>;
|
|
1155
|
+
center(): Promise<void>;
|
|
1156
|
+
startDraggingWindow(): Promise<void>;
|
|
1157
|
+
minimize(): Promise<void>;
|
|
1158
|
+
restore(): Promise<void>;
|
|
1159
|
+
isMinimized(): Promise<boolean>;
|
|
1160
|
+
isMaximized(): Promise<boolean>;
|
|
1161
|
+
maximize(): Promise<void>;
|
|
1162
|
+
stopDraggingWindow(): Promise<void>;
|
|
1163
|
+
setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
|
|
1164
|
+
isAlwaysOnTop(): Promise<boolean>;
|
|
1165
|
+
openUrl(url: string, option?: OpenUrlOptions): Promise<void>;
|
|
1166
|
+
moveTop(): Promise<void>;
|
|
1167
|
+
unmaximize(): Promise<void>;
|
|
1168
|
+
reload(): Promise<void>;
|
|
1169
|
+
setSize(width: number, height: number, animate?: boolean): Promise<void>;
|
|
1170
|
+
openDevTools(): Promise<void>;
|
|
1171
|
+
setPosition(options: SetPositionOptions): Promise<void>;
|
|
1172
|
+
getPosition(): Promise<Position>;
|
|
1173
|
+
blur(): Promise<void>;
|
|
1174
|
+
focus(): Promise<void>;
|
|
1175
|
+
setResizable(resizable: boolean): Promise<void>;
|
|
1176
|
+
setMovable(movable: boolean): Promise<void>;
|
|
1177
|
+
getBounds(): Promise<Rectangle>;
|
|
1178
|
+
setBounds(bounds: Partial<Rectangle>, animate: boolean): Promise<void>;
|
|
1179
|
+
alignToScreen(align: AlignPosition): Promise<void>;
|
|
1180
|
+
existsByUrl(url: string): Promise<boolean>;
|
|
1181
|
+
getMaximumSize(): Promise<number[]>;
|
|
1182
|
+
getMinimumSize(): Promise<number[]>;
|
|
1183
|
+
setMaximumSize(width: number, height: number): Promise<void>;
|
|
1184
|
+
setMinimumSize(width: number, height: number): Promise<void>;
|
|
1185
|
+
setZoomLevel(level: number): Promise<void>;
|
|
1186
|
+
setZoomFactor(factor: number): Promise<void>;
|
|
1187
|
+
isFocused(): Promise<boolean>;
|
|
1188
|
+
}
|
|
1189
|
+
type BrowserWindowApiMethods = keyof IBrowserWindowApi;
|
|
1190
|
+
type AlignPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
1191
|
+
interface OpenUrlOptions {
|
|
1192
|
+
partition?: string;
|
|
1193
|
+
external?: boolean;
|
|
1194
|
+
}
|
|
1195
|
+
interface SetPositionOptions {
|
|
1196
|
+
x?: number;
|
|
1197
|
+
y?: number;
|
|
1198
|
+
/**
|
|
1199
|
+
* 只有在 macOS 上有效
|
|
1200
|
+
*/
|
|
1201
|
+
animation?: boolean;
|
|
1202
|
+
}
|
|
1203
|
+
declare enum BrowserWindowApiEvent {
|
|
1204
|
+
BLUR = "event::cn.widgetjs.core.browser-window.blur",
|
|
1205
|
+
MOVED = "event::cn.widgetjs.core.browser-window.moved",
|
|
1206
|
+
FOCUS = "event::cn.widgetjs.core.browser-window.focus",
|
|
1207
|
+
SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.snap_to_edge",
|
|
1208
|
+
RESIZED = "event::cn.widgetjs.core.browser-window.resized",
|
|
1209
|
+
CANCEL_SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge"
|
|
1210
|
+
}
|
|
1211
|
+
interface SetupOptions {
|
|
1212
|
+
width: number;
|
|
1213
|
+
height: number;
|
|
1214
|
+
minWidth?: number;
|
|
1215
|
+
minHeight?: number;
|
|
1216
|
+
maxWidth?: number;
|
|
1217
|
+
maxHeight?: number;
|
|
1218
|
+
resizable?: boolean;
|
|
1219
|
+
movable?: boolean;
|
|
1220
|
+
center?: boolean;
|
|
1221
|
+
alwaysOnTop?: boolean;
|
|
1222
|
+
}
|
|
1223
|
+
declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> implements IBrowserWindowApi {
|
|
1224
|
+
getChannel(): string;
|
|
1225
|
+
setIgnoreMouseEvent(ignore: boolean): Promise<void>;
|
|
1226
|
+
show(): Promise<void>;
|
|
1227
|
+
showInactive(): Promise<void>;
|
|
1228
|
+
hide(): Promise<void>;
|
|
1229
|
+
center(): Promise<void>;
|
|
1230
|
+
setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
|
|
1231
|
+
isAlwaysOnTop(): Promise<boolean>;
|
|
1232
|
+
openUrl(url: string, option?: OpenUrlOptions): Promise<void>;
|
|
1233
|
+
moveTop(): Promise<void>;
|
|
1234
|
+
openDevTools(): Promise<void>;
|
|
1235
|
+
setPosition(options: SetPositionOptions): Promise<void>;
|
|
1236
|
+
getPosition(): Promise<Position>;
|
|
1237
|
+
blur(): Promise<any>;
|
|
1238
|
+
focus(): Promise<any>;
|
|
1239
|
+
/**
|
|
1240
|
+
* 设置窗口是否可以拉伸
|
|
1241
|
+
* @param resizable
|
|
1242
|
+
*/
|
|
1243
|
+
setResizable(resizable: boolean): Promise<any>;
|
|
1244
|
+
getBounds(): Promise<Rectangle>;
|
|
1245
|
+
setBounds(bounds: Partial<Rectangle>, animate?: boolean): Promise<void>;
|
|
1246
|
+
alignToScreen(align: AlignPosition): Promise<any>;
|
|
1247
|
+
startDraggingWindow(): Promise<any>;
|
|
1248
|
+
stopDraggingWindow(): Promise<any>;
|
|
1249
|
+
/**
|
|
1250
|
+
* 通过url检测窗口是否存在
|
|
1251
|
+
* @param url
|
|
1252
|
+
*/
|
|
1253
|
+
existsByUrl(url: string): Promise<boolean>;
|
|
1254
|
+
getMaximumSize(): Promise<number[]>;
|
|
1255
|
+
minimize(): Promise<void>;
|
|
1256
|
+
maximize(): Promise<void>;
|
|
1257
|
+
isMaximized(): Promise<boolean>;
|
|
1258
|
+
isMinimized(): Promise<boolean>;
|
|
1259
|
+
restore(): Promise<void>;
|
|
1260
|
+
unmaximize(): Promise<void>;
|
|
1261
|
+
setZoomLevel(level: number): Promise<void>;
|
|
1262
|
+
reload(): Promise<void>;
|
|
1263
|
+
setMovable(movable: boolean): Promise<void>;
|
|
1264
|
+
setSize(width: number, height: number, animate?: boolean): Promise<void>;
|
|
1265
|
+
isFocused(): Promise<boolean>;
|
|
1266
|
+
setMaximumSize(width: number, height: number): Promise<void>;
|
|
1267
|
+
setMinimumSize(width: number, height: number): Promise<void>;
|
|
1268
|
+
getMinimumSize(): Promise<number[]>;
|
|
1269
|
+
close(): Promise<void>;
|
|
1270
|
+
setZoomFactor(factor: number): Promise<void>;
|
|
1271
|
+
setup(options: SetupOptions): Promise<void>;
|
|
1272
|
+
}
|
|
1246
1273
|
declare const BrowserWindowApi: BrowserWindowApiImpl;
|
|
1247
1274
|
|
|
1248
|
-
interface INotificationApi {
|
|
1249
|
-
send(notification: AppNotification): Promise<void>;
|
|
1250
|
-
hide(): Promise<void>;
|
|
1251
|
-
}
|
|
1252
|
-
type NotificationApiMethods = keyof INotificationApi;
|
|
1253
|
-
declare enum NotificationApiEvent {
|
|
1254
|
-
CONFIRM = "event::cn.widgetjs.core.notification.confirm",
|
|
1255
|
-
CANCEL = "event::cn.widgetjs.core.notification.cancel",
|
|
1256
|
-
HIDE = "event::cn.widgetjs.core.notification.hide"
|
|
1257
|
-
}
|
|
1258
|
-
declare class NotificationApiImpl extends BaseApi<NotificationApiMethods> implements INotificationApi {
|
|
1259
|
-
/**
|
|
1260
|
-
* 来电
|
|
1261
|
-
* @param avatar 头像地址
|
|
1262
|
-
* @param audio 音频地址
|
|
1263
|
-
* @param title 标题文件
|
|
1264
|
-
* @param message 初始消息
|
|
1265
|
-
* @param lyric 歌词字符串
|
|
1266
|
-
*/
|
|
1267
|
-
call(avatar: string, audio: string, title: string, message: string, lyric: string): Promise<void>;
|
|
1268
|
-
send(notification: AppNotification): Promise<any>;
|
|
1269
|
-
reminder(title: string, message: string, icon: string, cancelButtonText: string, confirmButtonText: string, cancelBroadcast: string, confirmBroadcast: string, duration?: number): Promise<any>;
|
|
1270
|
-
advanceCountdown(message: string, targetTime: string, title?: string): Promise<any>;
|
|
1271
|
-
countdown(message: string, targetTime: string): Promise<void>;
|
|
1272
|
-
success(message: string, duration?: number): Promise<void>;
|
|
1273
|
-
error(message: string, duration?: number): Promise<void>;
|
|
1274
|
-
warning(message: string, duration?: number): Promise<void>;
|
|
1275
|
-
info(message: string, duration?: number): Promise<void>;
|
|
1276
|
-
/**
|
|
1277
|
-
* 隐藏通知
|
|
1278
|
-
*/
|
|
1279
|
-
hide(): Promise<void>;
|
|
1280
|
-
getChannel(): string;
|
|
1281
|
-
}
|
|
1275
|
+
interface INotificationApi {
|
|
1276
|
+
send(notification: AppNotification): Promise<void>;
|
|
1277
|
+
hide(): Promise<void>;
|
|
1278
|
+
}
|
|
1279
|
+
type NotificationApiMethods = keyof INotificationApi;
|
|
1280
|
+
declare enum NotificationApiEvent {
|
|
1281
|
+
CONFIRM = "event::cn.widgetjs.core.notification.confirm",
|
|
1282
|
+
CANCEL = "event::cn.widgetjs.core.notification.cancel",
|
|
1283
|
+
HIDE = "event::cn.widgetjs.core.notification.hide"
|
|
1284
|
+
}
|
|
1285
|
+
declare class NotificationApiImpl extends BaseApi<NotificationApiMethods> implements INotificationApi {
|
|
1286
|
+
/**
|
|
1287
|
+
* 来电
|
|
1288
|
+
* @param avatar 头像地址
|
|
1289
|
+
* @param audio 音频地址
|
|
1290
|
+
* @param title 标题文件
|
|
1291
|
+
* @param message 初始消息
|
|
1292
|
+
* @param lyric 歌词字符串
|
|
1293
|
+
*/
|
|
1294
|
+
call(avatar: string, audio: string, title: string, message: string, lyric: string): Promise<void>;
|
|
1295
|
+
send(notification: AppNotification): Promise<any>;
|
|
1296
|
+
reminder(title: string, message: string, icon: string, cancelButtonText: string, confirmButtonText: string, cancelBroadcast: string, confirmBroadcast: string, duration?: number): Promise<any>;
|
|
1297
|
+
advanceCountdown(message: string, targetTime: string, title?: string): Promise<any>;
|
|
1298
|
+
countdown(message: string, targetTime: string): Promise<void>;
|
|
1299
|
+
success(message: string, duration?: number): Promise<void>;
|
|
1300
|
+
error(message: string, duration?: number): Promise<void>;
|
|
1301
|
+
warning(message: string, duration?: number): Promise<void>;
|
|
1302
|
+
info(message: string, duration?: number): Promise<void>;
|
|
1303
|
+
/**
|
|
1304
|
+
* 隐藏通知
|
|
1305
|
+
*/
|
|
1306
|
+
hide(): Promise<void>;
|
|
1307
|
+
getChannel(): string;
|
|
1308
|
+
}
|
|
1282
1309
|
declare const NotificationApi: NotificationApiImpl;
|
|
1283
1310
|
|
|
1284
|
-
interface IDeployedWidgetApi {
|
|
1285
|
-
removeDeployedWidget(id: string): Promise<void>;
|
|
1286
|
-
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1287
|
-
getDeployedWidgets(): Promise<DeployedWidget[]>;
|
|
1288
|
-
openDevTools(id: string): Promise<void>;
|
|
1289
|
-
openConfigPage(id: string): Promise<void>;
|
|
1290
|
-
registerActiveShortcut(id: string, shortcut: string): Promise<boolean>;
|
|
1291
|
-
setProxy(id: string, proxy: string): Promise<boolean>;
|
|
1292
|
-
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
1293
|
-
addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
|
|
1294
|
-
}
|
|
1295
|
-
type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
|
|
1296
|
-
declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
|
|
1297
|
-
getChannel(): string;
|
|
1298
|
-
/**
|
|
1299
|
-
* 移除组件
|
|
1300
|
-
* @param id
|
|
1301
|
-
*/
|
|
1302
|
-
removeDeployedWidget(id: string): Promise<any>;
|
|
1303
|
-
addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
|
|
1304
|
-
/**
|
|
1305
|
-
* 通过组件名移除已添加的组件
|
|
1306
|
-
* @param name 组件名
|
|
1307
|
-
*/
|
|
1308
|
-
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1309
|
-
/**
|
|
1310
|
-
* 获取已添加的组件
|
|
1311
|
-
* @param name 组件名,可以不传
|
|
1312
|
-
*/
|
|
1313
|
-
getDeployedWidgets(name?: string): Promise<DeployedWidget[]>;
|
|
1314
|
-
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
1315
|
-
/**
|
|
1316
|
-
* Opens the dev tools for a widget with the specified ID.
|
|
1317
|
-
*
|
|
1318
|
-
* @param {string} widgetId - The ID of the widget to open the dev tools for.
|
|
1319
|
-
* @return {Promise} A Promise that resolves when the dev tools are opened.
|
|
1320
|
-
*/
|
|
1321
|
-
openDevTools(widgetId: string): Promise<any>;
|
|
1322
|
-
openConfigPage(widgetId: string, params?: WidgetParams): Promise<any>;
|
|
1323
|
-
/**
|
|
1324
|
-
* 注册激活、呼出、置顶组件快捷键
|
|
1325
|
-
* @param widgetId 组件id
|
|
1326
|
-
* @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
|
|
1327
|
-
* https://www.electronjs.org/docs/latest/api/accelerator
|
|
1328
|
-
*/
|
|
1329
|
-
registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
|
|
1330
|
-
setProxy(widgetId: string, proxy: string): Promise<boolean>;
|
|
1331
|
-
}
|
|
1311
|
+
interface IDeployedWidgetApi {
|
|
1312
|
+
removeDeployedWidget(id: string): Promise<void>;
|
|
1313
|
+
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1314
|
+
getDeployedWidgets(): Promise<DeployedWidget[]>;
|
|
1315
|
+
openDevTools(id: string): Promise<void>;
|
|
1316
|
+
openConfigPage(id: string): Promise<void>;
|
|
1317
|
+
registerActiveShortcut(id: string, shortcut: string): Promise<boolean>;
|
|
1318
|
+
setProxy(id: string, proxy: string): Promise<boolean>;
|
|
1319
|
+
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
1320
|
+
addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
|
|
1321
|
+
}
|
|
1322
|
+
type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
|
|
1323
|
+
declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
|
|
1324
|
+
getChannel(): string;
|
|
1325
|
+
/**
|
|
1326
|
+
* 移除组件
|
|
1327
|
+
* @param id
|
|
1328
|
+
*/
|
|
1329
|
+
removeDeployedWidget(id: string): Promise<any>;
|
|
1330
|
+
addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
|
|
1331
|
+
/**
|
|
1332
|
+
* 通过组件名移除已添加的组件
|
|
1333
|
+
* @param name 组件名
|
|
1334
|
+
*/
|
|
1335
|
+
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1336
|
+
/**
|
|
1337
|
+
* 获取已添加的组件
|
|
1338
|
+
* @param name 组件名,可以不传
|
|
1339
|
+
*/
|
|
1340
|
+
getDeployedWidgets(name?: string): Promise<DeployedWidget[]>;
|
|
1341
|
+
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
1342
|
+
/**
|
|
1343
|
+
* Opens the dev tools for a widget with the specified ID.
|
|
1344
|
+
*
|
|
1345
|
+
* @param {string} widgetId - The ID of the widget to open the dev tools for.
|
|
1346
|
+
* @return {Promise} A Promise that resolves when the dev tools are opened.
|
|
1347
|
+
*/
|
|
1348
|
+
openDevTools(widgetId: string): Promise<any>;
|
|
1349
|
+
openConfigPage(widgetId: string, params?: WidgetParams): Promise<any>;
|
|
1350
|
+
/**
|
|
1351
|
+
* 注册激活、呼出、置顶组件快捷键
|
|
1352
|
+
* @param widgetId 组件id
|
|
1353
|
+
* @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
|
|
1354
|
+
* https://www.electronjs.org/docs/latest/api/accelerator
|
|
1355
|
+
*/
|
|
1356
|
+
registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
|
|
1357
|
+
setProxy(widgetId: string, proxy: string): Promise<boolean>;
|
|
1358
|
+
}
|
|
1332
1359
|
declare const DeployedWidgetApi: DeployedWidgetApiImpl;
|
|
1333
1360
|
|
|
1334
|
-
interface IDeviceApi {
|
|
1335
|
-
getCursorScreenPoint(): Promise<Point>;
|
|
1336
|
-
isAllKeyReleased(): Promise<boolean>;
|
|
1337
|
-
}
|
|
1338
|
-
type DeviceApiMethods = keyof IDeviceApi;
|
|
1361
|
+
interface IDeviceApi {
|
|
1362
|
+
getCursorScreenPoint(): Promise<Point>;
|
|
1363
|
+
isAllKeyReleased(): Promise<boolean>;
|
|
1364
|
+
}
|
|
1365
|
+
type DeviceApiMethods = keyof IDeviceApi;
|
|
1339
1366
|
declare const DeviceApi: IDeviceApi;
|
|
1340
1367
|
|
|
1341
|
-
declare enum Channel {
|
|
1342
|
-
NOTIFICATION = "channel::cn.widgetjs.core.notification",
|
|
1343
|
-
BROWSER_WINDOW = "channel::cn.widgetjs.core.browser_window",
|
|
1344
|
-
BROADCAST = "channel::cn.widgetjs.core.broadcast",
|
|
1345
|
-
WIDGET = "channel::cn.widgetjs.core.widget",
|
|
1346
|
-
HOSTED_WIDGET = "channel::cn.widgetjs.core.hosted_widget",
|
|
1347
|
-
APP = "channel::cn.widgetjs.core.app",
|
|
1348
|
-
DIALOG = "channel::cn.widgetjs.core.dialog",
|
|
1349
|
-
CLIPBOARD = "channel::cn.widgetjs.core.clipboard",
|
|
1350
|
-
FILE = "channel::cn.widgetjs.core.file",
|
|
1351
|
-
SCREEN = "channel::cn.widgetjs.core.screen",
|
|
1352
|
-
SHORTCUT = "channel::cn.widgetjs.core.shortcut",
|
|
1353
|
-
LOG = "channel::cn.widgetjs.core.log",
|
|
1354
|
-
DEVICE = "channel::cn.widgetjs.core.device",
|
|
1355
|
-
MOUSE = "channel::cn.widgetjs.core.mouse",
|
|
1356
|
-
KEYBOARD = "channel::cn.widgetjs.core.keyboard",
|
|
1357
|
-
STORE = "channel::cn.widgetjs.core.store"
|
|
1368
|
+
declare enum Channel {
|
|
1369
|
+
NOTIFICATION = "channel::cn.widgetjs.core.notification",
|
|
1370
|
+
BROWSER_WINDOW = "channel::cn.widgetjs.core.browser_window",
|
|
1371
|
+
BROADCAST = "channel::cn.widgetjs.core.broadcast",
|
|
1372
|
+
WIDGET = "channel::cn.widgetjs.core.widget",
|
|
1373
|
+
HOSTED_WIDGET = "channel::cn.widgetjs.core.hosted_widget",
|
|
1374
|
+
APP = "channel::cn.widgetjs.core.app",
|
|
1375
|
+
DIALOG = "channel::cn.widgetjs.core.dialog",
|
|
1376
|
+
CLIPBOARD = "channel::cn.widgetjs.core.clipboard",
|
|
1377
|
+
FILE = "channel::cn.widgetjs.core.file",
|
|
1378
|
+
SCREEN = "channel::cn.widgetjs.core.screen",
|
|
1379
|
+
SHORTCUT = "channel::cn.widgetjs.core.shortcut",
|
|
1380
|
+
LOG = "channel::cn.widgetjs.core.log",
|
|
1381
|
+
DEVICE = "channel::cn.widgetjs.core.device",
|
|
1382
|
+
MOUSE = "channel::cn.widgetjs.core.mouse",
|
|
1383
|
+
KEYBOARD = "channel::cn.widgetjs.core.keyboard",
|
|
1384
|
+
STORE = "channel::cn.widgetjs.core.store"
|
|
1358
1385
|
}
|
|
1359
1386
|
|
|
1360
|
-
interface IClipboardApi {
|
|
1361
|
-
getSelectedText(): Promise<string | undefined>;
|
|
1362
|
-
getText(): Promise<string | undefined>;
|
|
1363
|
-
}
|
|
1364
|
-
type ClipboardApiMethods = keyof IClipboardApi;
|
|
1365
|
-
declare enum ClipboardApiEvent {
|
|
1366
|
-
CHANGED = "clipboard-changed"
|
|
1367
|
-
}
|
|
1387
|
+
interface IClipboardApi {
|
|
1388
|
+
getSelectedText(): Promise<string | undefined>;
|
|
1389
|
+
getText(): Promise<string | undefined>;
|
|
1390
|
+
}
|
|
1391
|
+
type ClipboardApiMethods = keyof IClipboardApi;
|
|
1392
|
+
declare enum ClipboardApiEvent {
|
|
1393
|
+
CHANGED = "clipboard-changed"
|
|
1394
|
+
}
|
|
1368
1395
|
declare const ClipboardApi: IClipboardApi;
|
|
1369
1396
|
|
|
1370
|
-
declare class ApiConstants {
|
|
1371
|
-
static readonly CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
|
|
1372
|
-
static readonly CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
|
|
1373
|
-
static readonly CONFIG_DEBUG_MODE = "cn.widgetjs.config.debug";
|
|
1374
|
-
static readonly CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size";
|
|
1375
|
-
static readonly SHORTCUT_PIN_DESKTOP_WIDGETS = "cn.widgetjs.config.shortcut.pin_desktop_widgets";
|
|
1397
|
+
declare class ApiConstants {
|
|
1398
|
+
static readonly CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
|
|
1399
|
+
static readonly CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
|
|
1400
|
+
static readonly CONFIG_DEBUG_MODE = "cn.widgetjs.config.debug";
|
|
1401
|
+
static readonly CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size";
|
|
1402
|
+
static readonly SHORTCUT_PIN_DESKTOP_WIDGETS = "cn.widgetjs.config.shortcut.pin_desktop_widgets";
|
|
1376
1403
|
}
|
|
1377
1404
|
|
|
1378
|
-
interface IShortcutApi {
|
|
1379
|
-
register(shortcut: string): void;
|
|
1380
|
-
unregister(shortcut: string): void;
|
|
1381
|
-
}
|
|
1382
|
-
type ShortcutApiMethods = keyof IShortcutApi;
|
|
1383
|
-
declare enum ShortcutApiEvent {
|
|
1384
|
-
TRIGGERED = "channel::cn.widgetjs.core.shortcut.triggered"
|
|
1385
|
-
}
|
|
1405
|
+
interface IShortcutApi {
|
|
1406
|
+
register(shortcut: string): void;
|
|
1407
|
+
unregister(shortcut: string): void;
|
|
1408
|
+
}
|
|
1409
|
+
type ShortcutApiMethods = keyof IShortcutApi;
|
|
1410
|
+
declare enum ShortcutApiEvent {
|
|
1411
|
+
TRIGGERED = "channel::cn.widgetjs.core.shortcut.triggered"
|
|
1412
|
+
}
|
|
1386
1413
|
declare const ShortcutApi: IShortcutApi;
|
|
1387
1414
|
|
|
1388
|
-
type BroadcastEventType = WidgetApiEvent | BrowserWindowApiEvent | ShortcutApiEvent | ClipboardApiEvent | string;
|
|
1389
|
-
interface IBroadcastApi {
|
|
1390
|
-
send(event: BroadcastEvent): Promise<void>;
|
|
1391
|
-
register(...event: BroadcastEventType[]): Promise<void>;
|
|
1392
|
-
unregister(...event: BroadcastEventType[]): Promise<void>;
|
|
1393
|
-
}
|
|
1394
|
-
type BroadcastApiMethods = keyof IBroadcastApi;
|
|
1415
|
+
type BroadcastEventType = WidgetApiEvent | BrowserWindowApiEvent | ShortcutApiEvent | ClipboardApiEvent | string;
|
|
1416
|
+
interface IBroadcastApi {
|
|
1417
|
+
send(event: BroadcastEvent): Promise<void>;
|
|
1418
|
+
register(...event: BroadcastEventType[]): Promise<void>;
|
|
1419
|
+
unregister(...event: BroadcastEventType[]): Promise<void>;
|
|
1420
|
+
}
|
|
1421
|
+
type BroadcastApiMethods = keyof IBroadcastApi;
|
|
1395
1422
|
declare const BroadcastApi: IBroadcastApi;
|
|
1396
1423
|
|
|
1397
|
-
interface IDialogApi {
|
|
1398
|
-
pickFile(extensions?: string[]): Promise<string | undefined>;
|
|
1399
|
-
pickFolder(): Promise<string | undefined>;
|
|
1400
|
-
}
|
|
1401
|
-
type DialogApiMethods = keyof IDialogApi;
|
|
1424
|
+
interface IDialogApi {
|
|
1425
|
+
pickFile(extensions?: string[]): Promise<string | undefined>;
|
|
1426
|
+
pickFolder(): Promise<string | undefined>;
|
|
1427
|
+
}
|
|
1428
|
+
type DialogApiMethods = keyof IDialogApi;
|
|
1402
1429
|
declare const DialogApi: IDialogApi;
|
|
1403
1430
|
|
|
1404
|
-
type BaseType = string | number | boolean;
|
|
1405
|
-
interface IStoreApi {
|
|
1406
|
-
get<T extends BaseType>(key: string, defaultValue?: T): Promise<T | null>;
|
|
1407
|
-
set(key: string, value: BaseType | object): Promise<string>;
|
|
1408
|
-
getObject<T>(key: string, defaultValue?: T): Promise<T | undefined>;
|
|
1409
|
-
delete(key: string): Promise<void>;
|
|
1410
|
-
}
|
|
1411
|
-
type StoreApiMethods = keyof IStoreApi;
|
|
1431
|
+
type BaseType = string | number | boolean;
|
|
1432
|
+
interface IStoreApi {
|
|
1433
|
+
get<T extends BaseType>(key: string, defaultValue?: T): Promise<T | null>;
|
|
1434
|
+
set(key: string, value: BaseType | object): Promise<string>;
|
|
1435
|
+
getObject<T>(key: string, defaultValue?: T): Promise<T | undefined>;
|
|
1436
|
+
delete(key: string): Promise<void>;
|
|
1437
|
+
}
|
|
1438
|
+
type StoreApiMethods = keyof IStoreApi;
|
|
1412
1439
|
declare const StoreApi: IStoreApi;
|
|
1413
1440
|
|
|
1414
|
-
interface ILogApi {
|
|
1415
|
-
info(...data: any[]): void;
|
|
1416
|
-
error(...data: any[]): void;
|
|
1417
|
-
warn(...data: any[]): void;
|
|
1418
|
-
log(...data: any[]): void;
|
|
1419
|
-
json(data: any): void;
|
|
1420
|
-
}
|
|
1421
|
-
type LogApiMethods = keyof ILogApi;
|
|
1441
|
+
interface ILogApi {
|
|
1442
|
+
info(...data: any[]): void;
|
|
1443
|
+
error(...data: any[]): void;
|
|
1444
|
+
warn(...data: any[]): void;
|
|
1445
|
+
log(...data: any[]): void;
|
|
1446
|
+
json(data: any): void;
|
|
1447
|
+
}
|
|
1448
|
+
type LogApiMethods = keyof ILogApi;
|
|
1422
1449
|
declare const LogApi: ILogApi;
|
|
1423
1450
|
|
|
1424
|
-
interface ReadDirOptions {
|
|
1425
|
-
ignoreDir?: boolean;
|
|
1426
|
-
traverseDir?: boolean;
|
|
1427
|
-
}
|
|
1428
|
-
interface IFileApi {
|
|
1429
|
-
readDirectory(path: string, options?: ReadDirOptions): Promise<string[]>;
|
|
1430
|
-
isDirectory(filePath: string): Promise<boolean>;
|
|
1431
|
-
getFileType(filePath: string): Promise<FileTypeResult>;
|
|
1432
|
-
}
|
|
1433
|
-
type FileApiMethods = keyof IFileApi;
|
|
1451
|
+
interface ReadDirOptions {
|
|
1452
|
+
ignoreDir?: boolean;
|
|
1453
|
+
traverseDir?: boolean;
|
|
1454
|
+
}
|
|
1455
|
+
interface IFileApi {
|
|
1456
|
+
readDirectory(path: string, options?: ReadDirOptions): Promise<string[]>;
|
|
1457
|
+
isDirectory(filePath: string): Promise<boolean>;
|
|
1458
|
+
getFileType(filePath: string): Promise<FileTypeResult>;
|
|
1459
|
+
}
|
|
1460
|
+
type FileApiMethods = keyof IFileApi;
|
|
1434
1461
|
declare const FileApi: IFileApi;
|
|
1435
1462
|
|
|
1436
|
-
export { AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, AppApiMethods, AppMouseEvent, AppNotification, BaseApi, BroadcastApi, BroadcastApiMethods, BroadcastEvent, BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, BrowserWindowApiMethods, Channel, ClipboardApi, ClipboardApiEvent, ClipboardApiMethods, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, DeployedWidgetApiMethods, DevOptions, DeviceApi, DeviceApiMethods, DialogApi, DialogApiMethods, ElectronApi, ElectronUtils, FileApi, FileApiMethods, Gravity, GridRect, GridSystem, HostedMode, IGridRect, IPage, IPageOptions, IWidgetDataApi, IWidgetOptions, IWindowSize, LanguageCode, LanguageTextMap, LocalPackageUrlInfo, LocationQuery, LocationQueryRaw, LocationQueryValue, LocationQueryValueRaw, LogApi, LogApiMethods, MetaInfo, NativeKeyboardEvent, NormalizeOptions, NotificationApi, NotificationApiEvent, NotificationApiMethods, NotificationOption, NotificationSize, NotificationType, OpenUrlOptions, Page, Point, Position, ReadDirOptions, Rectangle, RemotePackageUrlInfo, SaveWidgetOption, SetPositionOptions, ShortcutApi, ShortcutApiEvent, ShortcutApiMethods, StoreApi, StoreApiMethods, ThemeMode, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, WidgetApiMethods, WidgetData, WidgetDataApi, WidgetDataApiMethods, WidgetKeyword, WidgetPackage, WidgetPackageOptions, WidgetParams, WidgetPermission, WidgetUrlUtils, normalizeUrl, parseQuery, stringifyQuery };
|
|
1463
|
+
export { AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, AppApiMethods, AppMouseEvent, AppNotification, BaseApi, BroadcastApi, BroadcastApiMethods, BroadcastEvent, BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, BrowserWindowApiMethods, Channel, ClipboardApi, ClipboardApiEvent, ClipboardApiMethods, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, DeployedWidgetApiMethods, DevOptions, DeviceApi, DeviceApiMethods, DialogApi, DialogApiMethods, ElectronApi, ElectronUtils, FileApi, FileApiMethods, Gravity, GridRect, GridSystem, HostedMode, IGridRect, IPage, IPageOptions, IWidgetDataApi, IWidgetOptions, IWindowSize, LanguageCode, LanguageTextMap, LocalPackageUrlInfo, LocationQuery, LocationQueryRaw, LocationQueryValue, LocationQueryValueRaw, LogApi, LogApiMethods, MetaInfo, NativeKeyboardEvent, NormalizeOptions, NotificationApi, NotificationApiEvent, NotificationApiMethods, NotificationOption, NotificationSize, NotificationType, OpenUrlOptions, Page, Point, Position, ReadDirOptions, Rectangle, RemotePackageUrlInfo, SaveWidgetOption, SetPositionOptions, ShortcutApi, ShortcutApiEvent, ShortcutApiMethods, StoreApi, StoreApiMethods, ThemeMode, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, WidgetApiMethods, WidgetData, WidgetDataApi, WidgetDataApiMethods, WidgetKeyword, WidgetPackage, WidgetPackageOptions, WidgetParams, WidgetPermission, WidgetRoute, WidgetUrlUtils, getTextByLanguageCode, normalizeUrl, parseQuery, stringifyQuery };
|