@widget-js/core 0.7.10 → 0.10.6

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.d.ts CHANGED
@@ -1,1436 +1,1464 @@
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 MetaInfo = {
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
- interface IWidgetOptions extends IWindowSize, IPageOptions {
213
- supportDeployMode?: DeployMode;
214
- configPagePath?: string;
215
- previewImage: string;
216
- description: LanguageTextMap;
217
- keywords: WidgetKeyword[];
218
- }
219
- declare class Widget extends Page {
220
- readonly previewImage: string;
221
- readonly supportDeployMode: number;
222
- /**
223
- * 配置页面路径,没有则不能修改
224
- */
225
- readonly configPagePath?: string;
226
- constructor(options: IWidgetOptions);
227
- static parseJSON(json: string): Widget;
228
- static parseObject(obj: any): Widget;
229
- /**
230
- * 是否支持悬浮窗
231
- */
232
- isSupportOverlap(): boolean;
233
- isSupportBackground(): boolean;
234
- /**
235
- * 是否支持普通模式
236
- */
237
- isSupportNormal(): boolean;
238
- isConfigurable(): boolean;
239
- }
240
- declare enum WidgetKeyword {
241
- RECOMMEND = "recommend",
242
- TOOLS = "tools",
243
- EFFICIENCY = "efficiency",
244
- PICTURE = "picture",
245
- LIFE = "life",
246
- SHORTCUT = "shortcut",
247
- COUNTDOWN = "countdown",
248
- TIMER = "timer",
249
- INFO = "info",
250
- DASHBOARD = "dashboard"
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
- type WidgetPermission = 'keyboard' | 'mouse' | 'clipboard' | 'notification' | 'storage' | 'network' | 'cpu' | 'system-info';
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
+ getUrl(path: string, hash?: boolean): string;
389
+ }
390
+ type DevOptions = {
391
+ folder?: string;
392
+ route?: boolean;
393
+ devUrl?: string;
394
+ remoteEntry?: string;
377
395
  };
378
396
 
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"
397
+ declare class WidgetParams {
398
+ static readonly PARAM_PREFIX = "w_";
399
+ static readonly PARAM_ID = "id";
400
+ static readonly PARAM_WIDTH = "width";
401
+ static readonly PARAM_HEIGHT = "height";
402
+ static readonly PARAM_WIDTH_PX = "width_px";
403
+ static readonly PARAM_HEIGHT_PX = "height_px";
404
+ static readonly PARAM_X = "x";
405
+ static readonly PARAM_Y = "y";
406
+ static readonly PARAM_LANG = "lang";
407
+ static readonly PARAM_THEME = "theme";
408
+ static readonly PARAM_MODE = "mode";
409
+ static readonly PARAM_RADIUS = "radius";
410
+ static readonly PARAM_NAME = "name";
411
+ static readonly PARAM_TITLE = "title";
412
+ static readonly PARAM_PREVIEW = "preview";
413
+ static readonly PARAMS: string[];
414
+ id?: string;
415
+ width?: number;
416
+ widthPx?: number;
417
+ heightPx?: number;
418
+ height?: number;
419
+ x?: number;
420
+ y?: number;
421
+ preview?: boolean;
422
+ lang?: string;
423
+ theme?: ThemeMode;
424
+ mode?: DeployMode;
425
+ radius?: number;
426
+ name?: string;
427
+ title?: string;
428
+ /**
429
+ * 将组件参数转为url参数
430
+ * @param object
431
+ * @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
432
+ */
433
+ toUrlParams(): URLSearchParams;
434
+ getPersistKey(): string;
435
+ /**
436
+ * 从当前地址解析组件参数:
437
+ * http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
438
+ * =>
439
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
440
+ */
441
+ static fromCurrentLocation(): WidgetParams;
442
+ static fromLocation(url: string): WidgetParams;
443
+ private static setValue;
444
+ /**
445
+ * 从对象键值对中初始化组件参数
446
+ * {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
447
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
448
+ * @param object
449
+ */
450
+ static fromObject(object: any): WidgetParams;
451
+ }
452
+ declare enum ThemeMode {
453
+ AUTO = "auto",
454
+ LIGHT = "LIGHT",
455
+ DARK = "DARK"
438
456
  }
439
457
 
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>;
458
+ declare abstract class BaseApi<T extends string> {
459
+ abstract getChannel(): string;
460
+ protected invokeMethod(method: T, ...args: any[]): Promise<any>;
461
+ protected invoke(...args: any[]): Promise<any>;
444
462
  }
445
463
 
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
- getWidgetPackageUrl(packageName: string): Promise<string | null>;
458
- }
459
- type WidgetApiMethods = keyof IWidgetApi;
460
- declare enum WidgetApiEvent {
461
- DATA_CHANGED = "event::cn.widgetjs.core.widget.data-changed",
462
- EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit"
463
- }
464
- declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidgetApi {
465
- getChannel(): string;
466
- registerWidgets(widgets: Widget[]): Promise<any>;
467
- registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
468
- getWidgets(): Promise<Widget[]>;
469
- openConfigPage(widgetId: string): Promise<any>;
470
- getWidgetPackages(): Promise<WidgetPackage[]>;
471
- /**
472
- *
473
- * @param name package name
474
- */
475
- getWidget(name: string): Promise<Widget>;
476
- /**
477
- *
478
- * @param name package name
479
- */
480
- getWidgetPackage(name: string): Promise<WidgetPackage>;
481
- /**
482
- * 获取组件配置地址
483
- * @param widgetName
484
- */
485
- getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
486
- getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
487
- getWidgetPackageIndexUrl(packageName: string, hash?: boolean): Promise<string | null>;
488
- getWidgetPackageUrl(packageName: string): Promise<string | null>;
489
- }
464
+ interface IWidgetApi {
465
+ registerWidgets(widgets: Widget[]): Promise<void>;
466
+ registerWidgetPackage(widgetPackage: WidgetPackage): Promise<void>;
467
+ getWidgets(): Promise<Widget[]>;
468
+ getWidget(name: string): Promise<Widget>;
469
+ getWidgetPackage(name: string): Promise<WidgetPackage>;
470
+ getWidgetPackages(): Promise<WidgetPackage[]>;
471
+ getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
472
+ getWidgetPackageIndexUrl(packageName: string, hash?: boolean): Promise<string | null>;
473
+ getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
474
+ openConfigPage(id: string): Promise<void>;
475
+ openConfigPageByName(name: string): Promise<void>;
476
+ getWidgetPackageUrl(packageName: string): Promise<string | null>;
477
+ }
478
+ type WidgetApiMethods = keyof IWidgetApi;
479
+ declare enum WidgetApiEvent {
480
+ DATA_CHANGED = "event::cn.widgetjs.core.widget.data-changed",
481
+ EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit"
482
+ }
483
+ declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidgetApi {
484
+ getChannel(): string;
485
+ registerWidgets(widgets: Widget[]): Promise<any>;
486
+ registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
487
+ getWidgets(): Promise<Widget[]>;
488
+ openConfigPage(widgetId: string): Promise<any>;
489
+ openConfigPageByName(widgetName: string): Promise<any>;
490
+ getWidgetPackages(): Promise<WidgetPackage[]>;
491
+ /**
492
+ *
493
+ * @param name package name
494
+ */
495
+ getWidget(name: string): Promise<Widget>;
496
+ /**
497
+ *
498
+ * @param name package name
499
+ */
500
+ getWidgetPackage(name: string): Promise<WidgetPackage>;
501
+ /**
502
+ * 获取组件配置地址
503
+ * @param widgetName
504
+ */
505
+ getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
506
+ getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
507
+ getWidgetPackageIndexUrl(packageName: string, hash?: boolean): Promise<string | null>;
508
+ getWidgetPackageUrl(packageName: string): Promise<string | null>;
509
+ }
490
510
  declare const WidgetApi: WidgetApiImpl;
491
511
 
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
- }
512
+ interface IAppApi {
513
+ setConfig(key: string, value: string | number | boolean): Promise<void>;
514
+ getConfig(key: string, defaultValue: string | number | boolean): Promise<string | number | boolean>;
515
+ getVersion(): Promise<string>;
516
+ getPreloadPath(): Promise<string>;
517
+ openAddWidgetWindow(): Promise<void>;
518
+ openSettingWindow(): Promise<void>;
519
+ getIconFile(): Promise<string>;
520
+ }
521
+ type AppApiMethods = keyof IAppApi;
522
+ declare enum AppApiEvent {
523
+ CONFIG_CHANGED = "event::cn.widgetjs.core.app.config.changed",
524
+ MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window",
525
+ STOP_MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window.stop"
526
+ }
527
+ declare enum AppApiConstants {
528
+ CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size"
529
+ }
510
530
  declare const AppApi: IAppApi;
511
531
 
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);
532
+ interface BroadcastEventOptions {
533
+ event: WidgetApiEvent | AppApiEvent | string;
534
+ /**
535
+ * 发送人,用于标记发送源,一般为组件名,如:com.example.widgets.countdown
536
+ */
537
+ sender?: string;
538
+ /**
539
+ * 广播事件携带的数据,只支持部分数据类型。
540
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
541
+ */
542
+ payload?: any;
543
+ }
544
+ declare class BroadcastEvent {
545
+ readonly event: string;
546
+ readonly sender?: string;
547
+ payload?: any;
548
+ constructor(options: BroadcastEventOptions);
529
549
  }
530
550
 
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);
551
+ declare enum WebSocketEventType {
552
+ RESISTER_PACKAGE = "ws::cn.widgetjs.core.resister_package"
553
+ }
554
+ declare class WebSocketEvent {
555
+ type: WebSocketEventType;
556
+ payload: any;
557
+ constructor(type: WebSocketEventType, payload: any);
538
558
  }
539
559
 
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;
560
+ /**
561
+ * 组件配置数据,用于存储组件自定义页面所设置的数据
562
+ */
563
+ declare class WidgetData {
564
+ /**
565
+ * 组件id
566
+ */
567
+ id?: string;
568
+ /**
569
+ * 组件名
570
+ */
571
+ name: string;
572
+ /**
573
+ * 背景颜色
574
+ */
575
+ backgroundColor?: string;
576
+ /**
577
+ * 文字颜色
578
+ */
579
+ color?: string;
580
+ /**
581
+ * 字体大小
582
+ */
583
+ fontSize?: number;
584
+ /**
585
+ * 字体
586
+ */
587
+ fontFamily?: string;
588
+ /**
589
+ * 圆角半径
590
+ */
591
+ borderRadius?: number;
592
+ constructor(name: string, id?: string);
593
+ parseJSON(json: {}): void;
574
594
  }
575
595
 
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);
596
+ type NotificationType = "countdown" | "advance-countdown" | "error" | "success" | "warning" | "info" | "reminder" | "url" | "call";
597
+ declare enum NotificationSize {
598
+ SMALL = "small",
599
+ NORMAL = "normal",
600
+ LARGE = "large"
601
+ }
602
+ interface NotificationOption {
603
+ type?: NotificationType;
604
+ title?: string;
605
+ message: string;
606
+ targetTime?: string;
607
+ duration?: number;
608
+ /**
609
+ * 图片名,目前只支持mingcute图标。
610
+ * https://www.mingcute.com/
611
+ */
612
+ icon?: string;
613
+ color?: 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
+ backgroundColor?: string;
624
+ }
625
+ declare class AppNotification {
626
+ type: NotificationType;
627
+ message: string;
628
+ title?: string;
629
+ targetTime?: string;
630
+ duration: number;
631
+ icon?: string;
632
+ color?: string;
633
+ backgroundColor?: string;
634
+ confirmButtonText?: string;
635
+ cancelButtonText?: string;
636
+ cancelBroadcast?: string;
637
+ confirmBroadcast?: string;
638
+ size: NotificationSize;
639
+ url?: string;
640
+ avatar?: string;
641
+ audio?: string;
642
+ lyric?: string;
643
+ createdAt: string;
644
+ constructor(option: NotificationOption);
625
645
  }
626
646
 
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;
647
+ interface IDeployedPage {
648
+ id: string;
649
+ name: string;
650
+ packageName: string;
651
+ x: number;
652
+ y: number;
653
+ height: number;
654
+ width: number;
655
+ proxy?: string;
656
+ }
657
+ declare class DeployedPage implements IDeployedPage {
658
+ name: string;
659
+ packageName: string;
660
+ x: number;
661
+ y: number;
662
+ height: number;
663
+ width: number;
664
+ proxy?: string;
665
+ id: string;
646
666
  }
647
667
 
648
- declare class DeployedWidget extends DeployedPage {
649
- shortcut?: string;
650
- deployMode: number;
651
- isOverlap(): boolean;
668
+ declare class DeployedWidget extends DeployedPage {
669
+ shortcut?: string;
670
+ deployMode: number;
671
+ isOverlap(): boolean;
652
672
  }
653
673
 
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;
674
+ interface Rectangle {
675
+ /**
676
+ * The height of the rectangle (must be an integer).
677
+ */
678
+ height: number;
679
+ /**
680
+ * The width of the rectangle (must be an integer).
681
+ */
682
+ width: number;
683
+ /**
684
+ * The x coordinate of the origin of the rectangle (must be an integer).
685
+ */
686
+ x: number;
687
+ /**
688
+ * The y coordinate of the origin of the rectangle (must be an integer).
689
+ */
690
+ y: number;
671
691
  }
672
692
 
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"
693
+ interface Point {
694
+ x: number;
695
+ y: number;
696
+ }
697
+ type Position = {
698
+ x: number;
699
+ y: number;
700
+ };
701
+ declare enum Gravity {
702
+ TOP = "TOP",
703
+ LEFT = "LEFT",
704
+ RIGHT = "RIGHT",
705
+ BOTTOM = "BOTTOM"
686
706
  }
687
707
 
688
- interface NativeKeyboardEvent {
689
- name: string;
690
- keyCode: number;
691
- scanCode: number;
692
- isKeyUp: boolean;
708
+ interface NativeKeyboardEvent {
709
+ name: string;
710
+ keyCode: number;
711
+ scanCode: number;
712
+ isKeyUp: boolean;
693
713
  }
694
714
 
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;
715
+ interface AppMouseEvent {
716
+ handled: boolean;
717
+ wheelScrolled: boolean;
718
+ clicked: boolean;
719
+ isMouseButtonDown: boolean;
720
+ isMouseButtonUp: boolean;
721
+ timestamp: number;
722
+ button: number;
723
+ clicks: number;
724
+ x: number;
725
+ y: number;
726
+ delta: number;
727
+ location: string;
708
728
  }
709
729
 
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>;
730
+ declare class ElectronUtils {
731
+ static hasElectronApi(): boolean;
732
+ /**
733
+ * 获取ElectronAPI
734
+ * windows api
735
+ */
736
+ static getAPI(): any;
737
+ static invokeMethod(channel: string, method: string, ...args: any[]): Promise<any>;
738
+ static invoke(channel: string, ...args: any[]): Promise<any>;
719
739
  }
720
740
 
721
- declare class WidgetUrlUtils {
722
- static getWidgetUrl(widgetUrl: string, widgetPackage: WidgetPackage, widgetParams: WidgetParams): string;
723
- static getWidgetPackageUrl(url: string, entry: string, hash: boolean): string;
741
+ declare class WidgetUrlUtils {
742
+ static getWidgetUrl(widgetUrl: string, widgetPackage: WidgetPackage, widgetParams: WidgetParams): string;
743
+ static getWidgetPackageUrl(url: string, entry: string, hash: boolean, path?: string): string;
724
744
  }
725
745
 
726
- /**
727
- * Possible values in normalized {@link LocationQuery}. `null` renders the query
728
- * param but without an `=`.
729
- *
730
- * @example
731
- * ```
732
- * ?isNull&isEmpty=&other=other
733
- * gives
734
- * `{ isNull: null, isEmpty: '', other: 'other' }`.
735
- * ```
736
- *
737
- * @internal
738
- */
739
- type LocationQueryValue = string | null;
740
- /**
741
- * Possible values when defining a query.
742
- *
743
- * @internal
744
- */
745
- type LocationQueryValueRaw = LocationQueryValue | number | undefined;
746
- /**
747
- * Normalized query object that appears in {@link RouteLocationNormalized}
748
- *
749
- * @public
750
- */
751
- type LocationQuery = Record<string, LocationQueryValue | LocationQueryValue[]>;
752
- /**
753
- * Loose {@link LocationQuery} object that can be passed to functions like
754
- * {@link Router.push} and {@link Router.replace} or anywhere when creating a
755
- * {@link RouteLocationRaw}
756
- *
757
- * @public
758
- */
759
- type LocationQueryRaw = Record<string | number, LocationQueryValueRaw | LocationQueryValueRaw[]>;
760
- /**
761
- * Transforms a queryString into a {@link LocationQuery} object. Accept both, a
762
- * version with the leading `?` and without Should work as URLSearchParams
763
- * @internal
764
- *
765
- * @param search - search string to parse
766
- * @returns a query object
767
- */
768
- declare function parseQuery(search: string): LocationQuery;
769
- /**
770
- * Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
771
- * doesn't prepend a `?`
772
- *
773
- * @internal
774
- *
775
- * @param query - query object to stringify
776
- * @returns string version of the query without the leading `?`
777
- */
746
+ /**
747
+ * 根据语言环境获取文本
748
+ * @param langMap 对象
749
+ * @param {LanguageCode} langCode 语言环境 例如:zh-CN,en-US
750
+ * @param fallbackToBrowser
751
+ */
752
+ declare function getTextByLanguageCode(langMap: LanguageTextMap, langCode?: LanguageCode, fallbackToBrowser?: boolean): string | undefined;
753
+
754
+ /**
755
+ * Possible values in normalized {@link LocationQuery}. `null` renders the query
756
+ * param but without an `=`.
757
+ *
758
+ * @example
759
+ * ```
760
+ * ?isNull&isEmpty=&other=other
761
+ * gives
762
+ * `{ isNull: null, isEmpty: '', other: 'other' }`.
763
+ * ```
764
+ *
765
+ * @internal
766
+ */
767
+ type LocationQueryValue = string | null;
768
+ /**
769
+ * Possible values when defining a query.
770
+ *
771
+ * @internal
772
+ */
773
+ type LocationQueryValueRaw = LocationQueryValue | number | undefined;
774
+ /**
775
+ * Normalized query object that appears in {@link RouteLocationNormalized}
776
+ *
777
+ * @public
778
+ */
779
+ type LocationQuery = Record<string, LocationQueryValue | LocationQueryValue[]>;
780
+ /**
781
+ * Loose {@link LocationQuery} object that can be passed to functions like
782
+ * {@link Router.push} and {@link Router.replace} or anywhere when creating a
783
+ * {@link RouteLocationRaw}
784
+ *
785
+ * @public
786
+ */
787
+ type LocationQueryRaw = Record<string | number, LocationQueryValueRaw | LocationQueryValueRaw[]>;
788
+ /**
789
+ * Transforms a queryString into a {@link LocationQuery} object. Accept both, a
790
+ * version with the leading `?` and without Should work as URLSearchParams
791
+ * @internal
792
+ *
793
+ * @param search - search string to parse
794
+ * @returns a query object
795
+ */
796
+ declare function parseQuery(search: string): LocationQuery;
797
+ /**
798
+ * Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
799
+ * doesn't prepend a `?`
800
+ *
801
+ * @internal
802
+ *
803
+ * @param query - query object to stringify
804
+ * @returns string version of the query without the leading `?`
805
+ */
778
806
  declare function stringifyQuery(query: LocationQueryRaw): string;
779
807
 
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
- };
808
+ type NormalizeOptions = {
809
+ /**
810
+ @default 'http'
811
+ */
812
+ defaultProtocol?: string | 'http' | 'https';
813
+ /**
814
+ Prepends `defaultProtocol` to the URL if it's protocol-relative.
815
+
816
+ @default true
817
+
818
+ @example
819
+ ```
820
+ normalizeUrl('//sindresorhus.com');
821
+ //=> 'http://sindresorhus.com'
822
+
823
+ normalizeUrl('//sindresorhus.com', {normalizeProtocol: false});
824
+ //=> '//sindresorhus.com'
825
+ ```
826
+ */
827
+ readonly normalizeProtocol?: boolean;
828
+ /**
829
+ Normalizes HTTPS URLs to HTTP.
830
+
831
+ @default false
832
+
833
+ @example
834
+ ```
835
+ normalizeUrl('https://sindresorhus.com');
836
+ //=> 'https://sindresorhus.com'
837
+
838
+ normalizeUrl('https://sindresorhus.com', {forceHttp: true});
839
+ //=> 'http://sindresorhus.com'
840
+ ```
841
+ */
842
+ readonly forceHttp?: boolean;
843
+ /**
844
+ Normalizes HTTP URLs to HTTPS.
845
+
846
+ This option cannot be used with the `forceHttp` option at the same time.
847
+
848
+ @default false
849
+
850
+ @example
851
+ ```
852
+ normalizeUrl('http://sindresorhus.com');
853
+ //=> 'http://sindresorhus.com'
854
+
855
+ normalizeUrl('http://sindresorhus.com', {forceHttps: true});
856
+ //=> 'https://sindresorhus.com'
857
+ ```
858
+ */
859
+ readonly forceHttps?: boolean;
860
+ /**
861
+ Strip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of a URL.
862
+
863
+ @default true
864
+
865
+ @example
866
+ ```
867
+ normalizeUrl('https://user:password@sindresorhus.com');
868
+ //=> 'https://sindresorhus.com'
869
+
870
+ normalizeUrl('https://user:password@sindresorhus.com', {stripAuthentication: false});
871
+ //=> 'https://user:password@sindresorhus.com'
872
+ ```
873
+ */
874
+ readonly stripAuthentication?: boolean;
875
+ /**
876
+ Removes hash from the URL.
877
+
878
+ @default false
879
+
880
+ @example
881
+ ```
882
+ normalizeUrl('sindresorhus.com/about.html#contact');
883
+ //=> 'http://sindresorhus.com/about.html#contact'
884
+
885
+ normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
886
+ //=> 'http://sindresorhus.com/about.html'
887
+ ```
888
+ */
889
+ readonly stripHash?: boolean;
890
+ /**
891
+ Remove the protocol from the URL: `http://sindresorhus.com` → `sindresorhus.com`.
892
+
893
+ It will only remove `https://` and `http://` protocols.
894
+
895
+ @default false
896
+
897
+ @example
898
+ ```
899
+ normalizeUrl('https://sindresorhus.com');
900
+ //=> 'https://sindresorhus.com'
901
+
902
+ normalizeUrl('sindresorhus.com', {stripProtocol: true});
903
+ //=> 'sindresorhus.com'
904
+ ```
905
+ */
906
+ readonly stripProtocol?: boolean;
907
+ /**
908
+ Strip the [text fragment](https://web.dev/text-fragments/) part of the URL
909
+
910
+ __Note:__ The text fragment will always be removed if the `stripHash` option is set to `true`, as the hash contains the text fragment.
911
+
912
+ @default true
913
+
914
+ @example
915
+ ```
916
+ normalizeUrl('http://sindresorhus.com/about.html#:~:text=hello');
917
+ //=> 'http://sindresorhus.com/about.html#'
918
+
919
+ normalizeUrl('http://sindresorhus.com/about.html#section:~:text=hello');
920
+ //=> 'http://sindresorhus.com/about.html#section'
921
+
922
+ normalizeUrl('http://sindresorhus.com/about.html#:~:text=hello', {stripTextFragment: false});
923
+ //=> 'http://sindresorhus.com/about.html#:~:text=hello'
924
+
925
+ normalizeUrl('http://sindresorhus.com/about.html#section:~:text=hello', {stripTextFragment: false});
926
+ //=> 'http://sindresorhus.com/about.html#section:~:text=hello'
927
+ ```
928
+ */
929
+ readonly stripTextFragment?: boolean;
930
+ /**
931
+ Removes `www.` from the URL.
932
+
933
+ @default true
934
+
935
+ @example
936
+ ```
937
+ normalizeUrl('http://www.sindresorhus.com');
938
+ //=> 'http://sindresorhus.com'
939
+
940
+ normalizeUrl('http://www.sindresorhus.com', {stripWWW: false});
941
+ //=> 'http://www.sindresorhus.com'
942
+ ```
943
+ */
944
+ readonly stripWWW?: boolean;
945
+ /**
946
+ Removes query parameters that matches any of the provided strings or regexes.
947
+
948
+ @default [/^utm_\w+/i]
949
+
950
+ @example
951
+ ```
952
+ normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
953
+ removeQueryParameters: ['ref']
954
+ });
955
+ //=> 'http://sindresorhus.com/?foo=bar'
956
+ ```
957
+
958
+ If a boolean is provided, `true` will remove all the query parameters.
959
+
960
+ ```
961
+ normalizeUrl('www.sindresorhus.com?foo=bar', {
962
+ removeQueryParameters: true
963
+ });
964
+ //=> 'http://sindresorhus.com'
965
+ ```
966
+
967
+ `false` will not remove any query parameter.
968
+
969
+ ```
970
+ normalizeUrl('www.sindresorhus.com?foo=bar&utm_medium=test&ref=test_ref', {
971
+ removeQueryParameters: false
972
+ });
973
+ //=> 'http://www.sindresorhus.com/?foo=bar&ref=test_ref&utm_medium=test'
974
+ ```
975
+ */
976
+ readonly removeQueryParameters?: ReadonlyArray<RegExp | string> | boolean;
977
+ /**
978
+ Keeps only query parameters that matches any of the provided strings or regexes.
979
+
980
+ __Note__: It overrides the `removeQueryParameters` option.
981
+
982
+ @default undefined
983
+
984
+ @example
985
+ ```
986
+ normalizeUrl('https://sindresorhus.com?foo=bar&ref=unicorn', {
987
+ keepQueryParameters: ['ref']
988
+ });
989
+ //=> 'https://sindresorhus.com/?ref=unicorn'
990
+ ```
991
+ */
992
+ readonly keepQueryParameters?: ReadonlyArray<RegExp | string>;
993
+ /**
994
+ Removes trailing slash.
995
+
996
+ __Note__: Trailing slash is always removed if the URL doesn't have a pathname unless the `removeSingleSlash` option is set to `false`.
997
+
998
+ @default true
999
+
1000
+ @example
1001
+ ```
1002
+ normalizeUrl('http://sindresorhus.com/redirect/');
1003
+ //=> 'http://sindresorhus.com/redirect'
1004
+
1005
+ normalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false});
1006
+ //=> 'http://sindresorhus.com/redirect/'
1007
+
1008
+ normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});
1009
+ //=> 'http://sindresorhus.com'
1010
+ ```
1011
+ */
1012
+ readonly removeTrailingSlash?: boolean;
1013
+ /**
1014
+ Remove a sole `/` pathname in the output. This option is independent of `removeTrailingSlash`.
1015
+
1016
+ @default true
1017
+
1018
+ @example
1019
+ ```
1020
+ normalizeUrl('https://sindresorhus.com/');
1021
+ //=> 'https://sindresorhus.com'
1022
+
1023
+ normalizeUrl('https://sindresorhus.com/', {removeSingleSlash: false});
1024
+ //=> 'https://sindresorhus.com/'
1025
+ ```
1026
+ */
1027
+ readonly removeSingleSlash?: boolean;
1028
+ /**
1029
+ Removes the default directory index file from path that matches any of the provided strings or regexes.
1030
+ When `true`, the regex `/^index\.[a-z]+$/` is used.
1031
+
1032
+ @default false
1033
+
1034
+ @example
1035
+ ```
1036
+ normalizeUrl('www.sindresorhus.com/foo/default.php', {
1037
+ removeDirectoryIndex: [/^default\.[a-z]+$/]
1038
+ });
1039
+ //=> 'http://sindresorhus.com/foo'
1040
+ ```
1041
+ */
1042
+ removeDirectoryIndex?: boolean | ReadonlyArray<RegExp | string>;
1043
+ /**
1044
+ Removes an explicit port number from the URL.
1045
+
1046
+ Port 443 is always removed from HTTPS URLs and 80 is always removed from HTTP URLs regardless of this option.
1047
+
1048
+ @default false
1049
+
1050
+ @example
1051
+ ```
1052
+ normalizeUrl('sindresorhus.com:123', {
1053
+ removeExplicitPort: true
1054
+ });
1055
+ //=> 'http://sindresorhus.com'
1056
+ ```
1057
+ */
1058
+ readonly removeExplicitPort?: boolean;
1059
+ /**
1060
+ Sorts the query parameters alphabetically by key.
1061
+
1062
+ @default true
1063
+
1064
+ @example
1065
+ ```
1066
+ normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
1067
+ sortQueryParameters: false
1068
+ });
1069
+ //=> 'http://sindresorhus.com/?b=two&a=one&c=three'
1070
+ ```
1071
+ */
1072
+ readonly sortQueryParameters?: boolean;
1073
+ };
1046
1074
  declare function normalizeUrl(urlString: string, options?: NormalizeOptions): string;
1047
1075
 
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;
1076
+ interface IGridRect {
1077
+ top: number;
1078
+ left: number;
1079
+ width: number;
1080
+ height: number;
1081
+ }
1082
+ declare class GridRect implements IGridRect {
1083
+ top: number;
1084
+ left: number;
1085
+ width: number;
1086
+ height: number;
1087
+ constructor(left: number, top: number, width: number, height: number);
1088
+ get right(): number;
1089
+ get bottom(): number;
1090
+ }
1091
+ declare class GridSystem extends GridRect {
1092
+ cellSize: number;
1093
+ horizontalCellCount: number;
1094
+ verticalCellCount: number;
1095
+ screenWidth: number;
1096
+ screenHeight: number;
1097
+ /**
1098
+ *
1099
+ * @param cellSize
1100
+ * @param padding 至少保留的边距
1101
+ * @param screenWidth
1102
+ * @param screenHeight
1103
+ */
1104
+ constructor(cellSize: number, padding: number, screenWidth: number, screenHeight: number);
1105
+ /**
1106
+ * 将坐标对齐到网格上
1107
+ * @param x
1108
+ * @param y
1109
+ */
1110
+ snapPosition(x: number, y: number): number[];
1111
+ snapSize(width: number, height: number): number[];
1112
+ /**
1113
+ * 将矩形对齐到网格上
1114
+ * @param rect
1115
+ * @param minWidth
1116
+ * @param maxWidth
1117
+ * @param minHeight
1118
+ * @param maxHeight
1119
+ */
1120
+ snapRect(rect: GridRect, minWidth: number, maxWidth: number, minHeight: number, maxHeight: number): IGridRect;
1121
+ private getRangeValue;
1122
+ getWidth(): number;
1123
+ getHeight(): number;
1096
1124
  }
1097
1125
 
1098
- declare class ElectronApi {
1099
- static addIpcListener(key: String, f: Function): Promise<void>;
1100
- static removeIpcListener(key: String): Promise<void>;
1126
+ declare class ElectronApi {
1127
+ static addIpcListener(key: String, f: Function): Promise<void>;
1128
+ static removeIpcListener(key: String): Promise<void>;
1101
1129
  }
1102
1130
 
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;
1131
+ interface SaveWidgetOption {
1132
+ sendBroadcast?: boolean;
1133
+ id?: string;
1134
+ }
1135
+ interface IWidgetDataApi {
1136
+ findByName<T extends WidgetData>(name: string, type: {
1137
+ new (name: string, id?: string): T;
1138
+ }): Promise<T | undefined>;
1139
+ findByName<T extends WidgetData>(data: T): Promise<T | undefined>;
1140
+ save(data: WidgetData, options?: SaveWidgetOption): Promise<string>;
1141
+ getStore(name: string): LocalForage;
1142
+ saveByName<T extends WidgetData>(data: T, options?: SaveWidgetOption): Promise<string>;
1143
+ find<T extends WidgetData>(name: string, id: string, type: {
1144
+ new (name: string, id?: string): T;
1145
+ }): Promise<T | undefined>;
1146
+ }
1147
+ type WidgetDataApiMethods = keyof IWidgetDataApi;
1120
1148
  declare const WidgetDataApi: IWidgetDataApi;
1121
1149
 
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
- }
1150
+ interface IBrowserWindowApi {
1151
+ setIgnoreMouseEvent(ignore: boolean): Promise<void>;
1152
+ show(): Promise<void>;
1153
+ hide(): Promise<void>;
1154
+ close(): Promise<void>;
1155
+ showInactive(): Promise<void>;
1156
+ center(): Promise<void>;
1157
+ startDraggingWindow(): Promise<void>;
1158
+ minimize(): Promise<void>;
1159
+ restore(): Promise<void>;
1160
+ isMinimized(): Promise<boolean>;
1161
+ isMaximized(): Promise<boolean>;
1162
+ maximize(): Promise<void>;
1163
+ stopDraggingWindow(): Promise<void>;
1164
+ setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
1165
+ isAlwaysOnTop(): Promise<boolean>;
1166
+ openUrl(url: string, option?: OpenUrlOptions): Promise<void>;
1167
+ moveTop(): Promise<void>;
1168
+ unmaximize(): Promise<void>;
1169
+ reload(): Promise<void>;
1170
+ setSize(width: number, height: number, animate?: boolean): Promise<void>;
1171
+ openDevTools(): Promise<void>;
1172
+ setPosition(options: SetPositionOptions): Promise<void>;
1173
+ getPosition(): Promise<Position>;
1174
+ blur(): Promise<void>;
1175
+ focus(): Promise<void>;
1176
+ setResizable(resizable: boolean): Promise<void>;
1177
+ setMovable(movable: boolean): Promise<void>;
1178
+ getBounds(): Promise<Rectangle>;
1179
+ setBounds(bounds: Partial<Rectangle>, animate: boolean): Promise<void>;
1180
+ alignToScreen(align: AlignPosition): Promise<void>;
1181
+ existsByUrl(url: string): Promise<boolean>;
1182
+ getMaximumSize(): Promise<number[]>;
1183
+ getMinimumSize(): Promise<number[]>;
1184
+ setMaximumSize(width: number, height: number): Promise<void>;
1185
+ setMinimumSize(width: number, height: number): Promise<void>;
1186
+ setZoomLevel(level: number): Promise<void>;
1187
+ setZoomFactor(factor: number): Promise<void>;
1188
+ isFocused(): Promise<boolean>;
1189
+ }
1190
+ type BrowserWindowApiMethods = keyof IBrowserWindowApi;
1191
+ type AlignPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
1192
+ interface OpenUrlOptions {
1193
+ partition?: string;
1194
+ external?: boolean;
1195
+ }
1196
+ interface SetPositionOptions {
1197
+ x?: number;
1198
+ y?: number;
1199
+ /**
1200
+ * 只有在 macOS 上有效
1201
+ */
1202
+ animation?: boolean;
1203
+ }
1204
+ declare enum BrowserWindowApiEvent {
1205
+ BLUR = "event::cn.widgetjs.core.browser-window.blur",
1206
+ MOVED = "event::cn.widgetjs.core.browser-window.moved",
1207
+ FOCUS = "event::cn.widgetjs.core.browser-window.focus",
1208
+ SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.snap_to_edge",
1209
+ RESIZED = "event::cn.widgetjs.core.browser-window.resized",
1210
+ CANCEL_SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge"
1211
+ }
1212
+ interface SetupOptions {
1213
+ width: number;
1214
+ height: number;
1215
+ minWidth?: number;
1216
+ minHeight?: number;
1217
+ maxWidth?: number;
1218
+ maxHeight?: number;
1219
+ resizable?: boolean;
1220
+ movable?: boolean;
1221
+ center?: boolean;
1222
+ alwaysOnTop?: boolean;
1223
+ }
1224
+ declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> implements IBrowserWindowApi {
1225
+ getChannel(): string;
1226
+ setIgnoreMouseEvent(ignore: boolean): Promise<void>;
1227
+ show(): Promise<void>;
1228
+ showInactive(): Promise<void>;
1229
+ hide(): Promise<void>;
1230
+ center(): Promise<void>;
1231
+ setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
1232
+ isAlwaysOnTop(): Promise<boolean>;
1233
+ openUrl(url: string, option?: OpenUrlOptions): Promise<void>;
1234
+ moveTop(): Promise<void>;
1235
+ openDevTools(): Promise<void>;
1236
+ setPosition(options: SetPositionOptions): Promise<void>;
1237
+ getPosition(): Promise<Position>;
1238
+ blur(): Promise<any>;
1239
+ focus(): Promise<any>;
1240
+ /**
1241
+ * 设置窗口是否可以拉伸
1242
+ * @param resizable
1243
+ */
1244
+ setResizable(resizable: boolean): Promise<any>;
1245
+ getBounds(): Promise<Rectangle>;
1246
+ setBounds(bounds: Partial<Rectangle>, animate?: boolean): Promise<void>;
1247
+ alignToScreen(align: AlignPosition): Promise<any>;
1248
+ startDraggingWindow(): Promise<any>;
1249
+ stopDraggingWindow(): Promise<any>;
1250
+ /**
1251
+ * 通过url检测窗口是否存在
1252
+ * @param url
1253
+ */
1254
+ existsByUrl(url: string): Promise<boolean>;
1255
+ getMaximumSize(): Promise<number[]>;
1256
+ minimize(): Promise<void>;
1257
+ maximize(): Promise<void>;
1258
+ isMaximized(): Promise<boolean>;
1259
+ isMinimized(): Promise<boolean>;
1260
+ restore(): Promise<void>;
1261
+ unmaximize(): Promise<void>;
1262
+ setZoomLevel(level: number): Promise<void>;
1263
+ reload(): Promise<void>;
1264
+ setMovable(movable: boolean): Promise<void>;
1265
+ setSize(width: number, height: number, animate?: boolean): Promise<void>;
1266
+ isFocused(): Promise<boolean>;
1267
+ setMaximumSize(width: number, height: number): Promise<void>;
1268
+ setMinimumSize(width: number, height: number): Promise<void>;
1269
+ getMinimumSize(): Promise<number[]>;
1270
+ close(): Promise<void>;
1271
+ setZoomFactor(factor: number): Promise<void>;
1272
+ setup(options: SetupOptions): Promise<void>;
1273
+ }
1246
1274
  declare const BrowserWindowApi: BrowserWindowApiImpl;
1247
1275
 
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
- }
1276
+ interface INotificationApi {
1277
+ send(notification: AppNotification): Promise<void>;
1278
+ hide(): Promise<void>;
1279
+ }
1280
+ type NotificationApiMethods = keyof INotificationApi;
1281
+ declare enum NotificationApiEvent {
1282
+ CONFIRM = "event::cn.widgetjs.core.notification.confirm",
1283
+ CANCEL = "event::cn.widgetjs.core.notification.cancel",
1284
+ HIDE = "event::cn.widgetjs.core.notification.hide"
1285
+ }
1286
+ declare class NotificationApiImpl extends BaseApi<NotificationApiMethods> implements INotificationApi {
1287
+ /**
1288
+ * 来电
1289
+ * @param avatar 头像地址
1290
+ * @param audio 音频地址
1291
+ * @param title 标题文件
1292
+ * @param message 初始消息
1293
+ * @param lyric 歌词字符串
1294
+ */
1295
+ call(avatar: string, audio: string, title: string, message: string, lyric: string): Promise<void>;
1296
+ send(notification: AppNotification): Promise<any>;
1297
+ reminder(title: string, message: string, icon: string, cancelButtonText: string, confirmButtonText: string, cancelBroadcast: string, confirmBroadcast: string, duration?: number): Promise<any>;
1298
+ advanceCountdown(message: string, targetTime: string, title?: string): Promise<any>;
1299
+ countdown(message: string, targetTime: string): Promise<void>;
1300
+ success(message: string, duration?: number): Promise<void>;
1301
+ error(message: string, duration?: number): Promise<void>;
1302
+ warning(message: string, duration?: number): Promise<void>;
1303
+ info(message: string, duration?: number): Promise<void>;
1304
+ /**
1305
+ * 隐藏通知
1306
+ */
1307
+ hide(): Promise<void>;
1308
+ getChannel(): string;
1309
+ }
1282
1310
  declare const NotificationApi: NotificationApiImpl;
1283
1311
 
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
- }
1312
+ interface IDeployedWidgetApi {
1313
+ removeDeployedWidget(id: string): Promise<void>;
1314
+ removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
1315
+ getDeployedWidgets(): Promise<DeployedWidget[]>;
1316
+ openDevTools(id: string): Promise<void>;
1317
+ openConfigPage(id: string): Promise<void>;
1318
+ registerActiveShortcut(id: string, shortcut: string): Promise<boolean>;
1319
+ setProxy(id: string, proxy: string): Promise<boolean>;
1320
+ getDeployedWidget(id: string): Promise<DeployedWidget>;
1321
+ addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
1322
+ }
1323
+ type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
1324
+ declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
1325
+ getChannel(): string;
1326
+ /**
1327
+ * 移除组件
1328
+ * @param id
1329
+ */
1330
+ removeDeployedWidget(id: string): Promise<any>;
1331
+ addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
1332
+ /**
1333
+ * 通过组件名移除已添加的组件
1334
+ * @param name 组件名
1335
+ */
1336
+ removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
1337
+ /**
1338
+ * 获取已添加的组件
1339
+ * @param name 组件名,可以不传
1340
+ */
1341
+ getDeployedWidgets(name?: string): Promise<DeployedWidget[]>;
1342
+ getDeployedWidget(id: string): Promise<DeployedWidget>;
1343
+ /**
1344
+ * Opens the dev tools for a widget with the specified ID.
1345
+ *
1346
+ * @param {string} widgetId - The ID of the widget to open the dev tools for.
1347
+ * @return {Promise} A Promise that resolves when the dev tools are opened.
1348
+ */
1349
+ openDevTools(widgetId: string): Promise<any>;
1350
+ openConfigPage(widgetId: string, params?: WidgetParams): Promise<any>;
1351
+ /**
1352
+ * 注册激活、呼出、置顶组件快捷键
1353
+ * @param widgetId 组件id
1354
+ * @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
1355
+ * https://www.electronjs.org/docs/latest/api/accelerator
1356
+ */
1357
+ registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
1358
+ setProxy(widgetId: string, proxy: string): Promise<boolean>;
1359
+ }
1332
1360
  declare const DeployedWidgetApi: DeployedWidgetApiImpl;
1333
1361
 
1334
- interface IDeviceApi {
1335
- getCursorScreenPoint(): Promise<Point>;
1336
- isAllKeyReleased(): Promise<boolean>;
1337
- }
1338
- type DeviceApiMethods = keyof IDeviceApi;
1362
+ interface IDeviceApi {
1363
+ getCursorScreenPoint(): Promise<Point>;
1364
+ isAllKeyReleased(): Promise<boolean>;
1365
+ }
1366
+ type DeviceApiMethods = keyof IDeviceApi;
1339
1367
  declare const DeviceApi: IDeviceApi;
1340
1368
 
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"
1369
+ declare enum Channel {
1370
+ NOTIFICATION = "channel::cn.widgetjs.core.notification",
1371
+ BROWSER_WINDOW = "channel::cn.widgetjs.core.browser_window",
1372
+ BROADCAST = "channel::cn.widgetjs.core.broadcast",
1373
+ WIDGET = "channel::cn.widgetjs.core.widget",
1374
+ HOSTED_WIDGET = "channel::cn.widgetjs.core.hosted_widget",
1375
+ APP = "channel::cn.widgetjs.core.app",
1376
+ DIALOG = "channel::cn.widgetjs.core.dialog",
1377
+ CLIPBOARD = "channel::cn.widgetjs.core.clipboard",
1378
+ FILE = "channel::cn.widgetjs.core.file",
1379
+ SCREEN = "channel::cn.widgetjs.core.screen",
1380
+ SHORTCUT = "channel::cn.widgetjs.core.shortcut",
1381
+ LOG = "channel::cn.widgetjs.core.log",
1382
+ DEVICE = "channel::cn.widgetjs.core.device",
1383
+ MOUSE = "channel::cn.widgetjs.core.mouse",
1384
+ KEYBOARD = "channel::cn.widgetjs.core.keyboard",
1385
+ STORE = "channel::cn.widgetjs.core.store"
1358
1386
  }
1359
1387
 
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
- }
1388
+ interface IClipboardApi {
1389
+ getSelectedText(): Promise<string | undefined>;
1390
+ getText(): Promise<string | undefined>;
1391
+ }
1392
+ type ClipboardApiMethods = keyof IClipboardApi;
1393
+ declare enum ClipboardApiEvent {
1394
+ CHANGED = "clipboard-changed"
1395
+ }
1368
1396
  declare const ClipboardApi: IClipboardApi;
1369
1397
 
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";
1398
+ declare class ApiConstants {
1399
+ static readonly CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
1400
+ static readonly CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
1401
+ static readonly CONFIG_DEBUG_MODE = "cn.widgetjs.config.debug";
1402
+ static readonly CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size";
1403
+ static readonly SHORTCUT_PIN_DESKTOP_WIDGETS = "cn.widgetjs.config.shortcut.pin_desktop_widgets";
1376
1404
  }
1377
1405
 
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
- }
1406
+ interface IShortcutApi {
1407
+ register(shortcut: string): void;
1408
+ unregister(shortcut: string): void;
1409
+ }
1410
+ type ShortcutApiMethods = keyof IShortcutApi;
1411
+ declare enum ShortcutApiEvent {
1412
+ TRIGGERED = "channel::cn.widgetjs.core.shortcut.triggered"
1413
+ }
1386
1414
  declare const ShortcutApi: IShortcutApi;
1387
1415
 
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;
1416
+ type BroadcastEventType = WidgetApiEvent | BrowserWindowApiEvent | ShortcutApiEvent | ClipboardApiEvent | string;
1417
+ interface IBroadcastApi {
1418
+ send(event: BroadcastEvent): Promise<void>;
1419
+ register(...event: BroadcastEventType[]): Promise<void>;
1420
+ unregister(...event: BroadcastEventType[]): Promise<void>;
1421
+ }
1422
+ type BroadcastApiMethods = keyof IBroadcastApi;
1395
1423
  declare const BroadcastApi: IBroadcastApi;
1396
1424
 
1397
- interface IDialogApi {
1398
- pickFile(extensions?: string[]): Promise<string | undefined>;
1399
- pickFolder(): Promise<string | undefined>;
1400
- }
1401
- type DialogApiMethods = keyof IDialogApi;
1425
+ interface IDialogApi {
1426
+ pickFile(extensions?: string[]): Promise<string | undefined>;
1427
+ pickFolder(): Promise<string | undefined>;
1428
+ }
1429
+ type DialogApiMethods = keyof IDialogApi;
1402
1430
  declare const DialogApi: IDialogApi;
1403
1431
 
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;
1432
+ type BaseType = string | number | boolean;
1433
+ interface IStoreApi {
1434
+ get<T extends BaseType>(key: string, defaultValue?: T): Promise<T | null>;
1435
+ set(key: string, value: BaseType | object): Promise<string>;
1436
+ getObject<T>(key: string, defaultValue?: T): Promise<T | undefined>;
1437
+ delete(key: string): Promise<void>;
1438
+ }
1439
+ type StoreApiMethods = keyof IStoreApi;
1412
1440
  declare const StoreApi: IStoreApi;
1413
1441
 
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;
1442
+ interface ILogApi {
1443
+ info(...data: any[]): void;
1444
+ error(...data: any[]): void;
1445
+ warn(...data: any[]): void;
1446
+ log(...data: any[]): void;
1447
+ json(data: any): void;
1448
+ }
1449
+ type LogApiMethods = keyof ILogApi;
1422
1450
  declare const LogApi: ILogApi;
1423
1451
 
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;
1452
+ interface ReadDirOptions {
1453
+ ignoreDir?: boolean;
1454
+ traverseDir?: boolean;
1455
+ }
1456
+ interface IFileApi {
1457
+ readDirectory(path: string, options?: ReadDirOptions): Promise<string[]>;
1458
+ isDirectory(filePath: string): Promise<boolean>;
1459
+ getFileType(filePath: string): Promise<FileTypeResult>;
1460
+ }
1461
+ type FileApiMethods = keyof IFileApi;
1434
1462
  declare const FileApi: IFileApi;
1435
1463
 
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 };
1464
+ 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 };