@widget-js/core 0.7.2 → 0.7.4

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