@widget-js/core 24.1.1-beta.86 → 24.1.1-beta.88

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
@@ -3,6 +3,287 @@ import { FileTypeResult } from 'file-type';
3
3
  import { FormatEnum, ColourspaceEnum, Channels, LevelMetadata } from 'sharp';
4
4
  import { AuthSession, AuthUser } from '@supabase/supabase-js';
5
5
 
6
+ type NotificationType = 'countdown' | 'advance-countdown' | 'error' | 'success' | 'warning' | 'info' | 'reminder' | 'url' | 'call';
7
+ declare enum NotificationSize {
8
+ SMALL = "small",
9
+ NORMAL = "normal",
10
+ LARGE = "large"
11
+ }
12
+ interface CountdownNotificationOption extends InfoNotificationOption {
13
+ targetTime?: string;
14
+ }
15
+ interface InfoNotificationOption {
16
+ message: string;
17
+ duration?: number;
18
+ /**
19
+ * 图片名,目前只支持mingcute图标。
20
+ * https://www.mingcute.com/
21
+ */
22
+ icon?: string;
23
+ color?: string;
24
+ size?: NotificationSize;
25
+ backgroundColor?: string;
26
+ }
27
+ interface CallNotificationOption extends InfoNotificationOption {
28
+ lyric?: string;
29
+ audio?: string;
30
+ avatar?: string;
31
+ }
32
+ interface ReminderNotificationOption extends InfoNotificationOption {
33
+ confirmButtonText?: string;
34
+ cancelButtonText?: string;
35
+ title?: string;
36
+ cancelBroadcast?: string;
37
+ confirmBroadcast?: string;
38
+ }
39
+ interface NotificationOption extends InfoNotificationOption, ReminderNotificationOption, CountdownNotificationOption, CallNotificationOption {
40
+ type?: NotificationType;
41
+ }
42
+ declare class AppNotification {
43
+ type: NotificationType;
44
+ message: string;
45
+ title?: string;
46
+ targetTime?: string;
47
+ /**
48
+ * 持续时间,单位毫秒
49
+ */
50
+ duration: number;
51
+ /**
52
+ * IconPark图标
53
+ * @example close-one
54
+ * @see [IconPark](https://iconpark.oceanengine.com/official)
55
+ */
56
+ icon?: string;
57
+ color?: string;
58
+ backgroundColor?: string;
59
+ confirmButtonText?: string;
60
+ cancelButtonText?: string;
61
+ cancelBroadcast?: string;
62
+ confirmBroadcast?: string;
63
+ size: NotificationSize;
64
+ url?: string;
65
+ avatar?: string;
66
+ audio?: string;
67
+ lyric?: string;
68
+ createdAt: string;
69
+ constructor(option: NotificationOption);
70
+ }
71
+ declare class AppReminderNotification extends AppNotification {
72
+ constructor(option: ReminderNotificationOption);
73
+ }
74
+
75
+ interface ThemeColors {
76
+ background: string;
77
+ foreground: string;
78
+ card: string;
79
+ cardForeground: string;
80
+ popover: string;
81
+ popoverForeground: string;
82
+ primary: string;
83
+ primaryForeground: string;
84
+ secondary: string;
85
+ secondaryForeground: string;
86
+ muted: string;
87
+ mutedForeground: string;
88
+ accent: string;
89
+ accentForeground: string;
90
+ destructive: string;
91
+ destructiveForeground: string;
92
+ border: string;
93
+ input: string;
94
+ ring: string;
95
+ shadow: string;
96
+ innerShadow: string;
97
+ }
98
+ interface ThemeRadius {
99
+ sm: string;
100
+ md: string;
101
+ lg: string;
102
+ full: string;
103
+ }
104
+ interface ThemeTypography {
105
+ fontFamily: string;
106
+ fontSize: string;
107
+ }
108
+ interface ThemeShadow {
109
+ sm: ThemeBoxShadow;
110
+ md: ThemeBoxShadow;
111
+ lg: ThemeBoxShadow;
112
+ }
113
+ interface ThemeBoxShadow {
114
+ offsetX: string;
115
+ offsetY: string;
116
+ blur: string;
117
+ }
118
+ interface IAppTheme {
119
+ useGlobalTheme?: boolean;
120
+ mode?: 'light' | 'dark';
121
+ colors: ThemeColors;
122
+ radius: ThemeRadius;
123
+ typography: ThemeTypography;
124
+ shadow: ThemeShadow;
125
+ spacing?: string;
126
+ }
127
+ type DeepPartial<T> = T extends object ? {
128
+ [P in keyof T]?: DeepPartial<T[P]>;
129
+ } : T;
130
+ declare const DefaultThemeDark: IAppTheme;
131
+ declare const DefaultThemeLight: IAppTheme;
132
+ declare const DefaultTheme: IAppTheme;
133
+ declare class AppTheme implements IAppTheme {
134
+ useGlobalTheme?: boolean;
135
+ mode?: 'light' | 'dark';
136
+ colors: ThemeColors;
137
+ radius: ThemeRadius;
138
+ typography: ThemeTypography;
139
+ shadow: ThemeShadow;
140
+ spacing?: string;
141
+ constructor(options?: DeepPartial<IAppTheme> | string);
142
+ static fromJSON(json: string): AppTheme;
143
+ /**
144
+ * 兼容 V1 版本的 CSS 变量
145
+ */
146
+ toLegacyCSSVariables(prefix?: string): Record<string, string>;
147
+ /**
148
+ * flatten tokens → CSS variables
149
+ */
150
+ toCSSVariables(prefix?: string): Record<string, string>;
151
+ toCSS(selector?: string): string;
152
+ injectCSS(el?: HTMLElement): void;
153
+ removeCSS(el?: HTMLElement): void;
154
+ /**
155
+ * 支持主题切换(light/dark)
156
+ */
157
+ setMode(mode: 'light' | 'dark'): void;
158
+ copy(partial?: DeepPartial<IAppTheme>): AppTheme;
159
+ static fromCSS(css: string): AppTheme;
160
+ }
161
+
162
+ interface IDeployedPage {
163
+ id: string;
164
+ name: string;
165
+ packageName: string;
166
+ x: number;
167
+ y: number;
168
+ height: number;
169
+ width: number;
170
+ proxy?: string;
171
+ isIgnoreMouseEvents?: boolean;
172
+ }
173
+ declare class DeployedPage implements IDeployedPage {
174
+ name: string;
175
+ packageName: string;
176
+ x: number;
177
+ y: number;
178
+ height: number;
179
+ width: number;
180
+ proxy?: string;
181
+ id: string;
182
+ isIgnoreMouseEvents?: boolean;
183
+ }
184
+
185
+ declare class DeployedWidget extends DeployedPage {
186
+ shortcut?: string;
187
+ deployMode: number;
188
+ isOverlap(): boolean;
189
+ }
190
+
191
+ /**
192
+ * @deprecated use DeployedMode instead
193
+ */
194
+ declare enum HostedMode {
195
+ NORMAL = 1,
196
+ /**
197
+ * 悬浮窗
198
+ */
199
+ OVERLAP = 16,
200
+ WALLPAPER = 256,
201
+ SCREEN = 4096,
202
+ BACKGROUND = 65536,
203
+ /**
204
+ * 页面
205
+ */
206
+ PAGE = 1048576,
207
+ ALL = 1118481
208
+ }
209
+ declare enum DeployMode {
210
+ /**
211
+ * 桌面组件,默认
212
+ */
213
+ NORMAL = 1,
214
+ /**
215
+ * 悬浮窗
216
+ */
217
+ OVERLAP = 16,
218
+ /**
219
+ * 后台组件,没有界面,一般在后台执行定时任务
220
+ */
221
+ BACKGROUND = 65536,
222
+ /**
223
+ * System tray
224
+ */
225
+ TRAY = 256,
226
+ /**
227
+ * 全部支持
228
+ */
229
+ ALL = 1118481
230
+ }
231
+
232
+ interface AppMouseEvent {
233
+ handled: boolean;
234
+ wheelScrolled: boolean;
235
+ clicked: boolean;
236
+ isMouseButtonDown: boolean;
237
+ isMouseButtonUp: boolean;
238
+ timestamp: number;
239
+ button: number;
240
+ clicks: number;
241
+ x: number;
242
+ y: number;
243
+ delta: number;
244
+ location: string;
245
+ }
246
+
247
+ declare class ApiConstants {
248
+ static readonly CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
249
+ static readonly CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
250
+ static readonly CONFIG_DEBUG_MODE = "cn.widgetjs.config.debug";
251
+ static readonly CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size";
252
+ static readonly SHORTCUT_PIN_DESKTOP_WIDGETS = "cn.widgetjs.config.shortcut.pin_desktop_widgets";
253
+ }
254
+ declare class AppEvent {
255
+ static readonly LANGUAGE_CHANGED = "event::cn.widgetjs.core.app.language.changed";
256
+ }
257
+ declare class AppConfig {
258
+ static readonly LANGUAGE = "cn.widgetjs.config.app.language";
259
+ static readonly LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
260
+ }
261
+
262
+ interface AiConfig {
263
+ id: string;
264
+ model: string;
265
+ apiKey: string;
266
+ apiBaseUrl: string;
267
+ }
268
+ interface IAiApi {
269
+ addConfig: (config: AiConfig) => Promise<AiConfig>;
270
+ deleteConfig: (id: string) => Promise<void>;
271
+ updateConfig: (config: AiConfig) => Promise<void>;
272
+ getConfigList: () => Promise<AiConfig[]>;
273
+ setConfigList: (configs: AiConfig[]) => Promise<void>;
274
+ getConfig: (id: string) => Promise<AiConfig | undefined>;
275
+ }
276
+ /**
277
+ * AiApiEvent
278
+ */
279
+ declare enum AiApiEvent {
280
+ /**
281
+ * 配置更新事件
282
+ */
283
+ CONFIG_UPDATED = "channel::cn.widgetjs.core.ai.config.updated"
284
+ }
285
+ type AiApiMethods = keyof IAiApi;
286
+
6
287
  interface Language {
7
288
  baseName: string;
8
289
  language: string;
@@ -74,204 +355,35 @@ type LanguageTextMap = {
74
355
  [key in LanguageCode]?: string;
75
356
  };
76
357
 
77
- declare class ElectronApi {
78
- static addIpcListener(key: string, f: Function): Promise<void>;
79
- static removeIpcListener(key: string): Promise<void>;
80
- }
81
-
82
- interface IWidgetTheme {
358
+ /**
359
+ * 设置窗口位置的选项
360
+ */
361
+ interface BrowserWindowOptions {
83
362
  /**
84
- * 是否使用全局主题,
85
- * 默认true
363
+ * 分区
364
+ * @deprecated
86
365
  */
87
- useGlobalTheme?: boolean;
88
- borderRadius?: CSS.Properties['borderRadius'];
89
- backgroundColor?: CSS.Properties['color'];
366
+ partition?: string;
90
367
  /**
91
- * 背景边框颜色
368
+ * 是否使用外部浏览器打开
92
369
  */
93
- backgroundBorderColor?: CSS.Properties['color'];
94
- backgroundBoxShadowColor?: CSS.Properties['color'];
95
- fontSize?: CSS.Properties['fontSize'];
96
- dividerColor?: CSS.Properties['color'];
370
+ external?: boolean;
97
371
  /**
98
- * 主色调
372
+ * Window's width in pixels. Default is `800`.
99
373
  */
100
- primaryColor?: CSS.Properties['color'];
374
+ width?: number;
101
375
  /**
102
- * 文字颜色
376
+ * Window's height in pixels. Default is `600`.
103
377
  */
104
- color?: CSS.Properties['color'];
105
- fontFamily?: CSS.Properties['fontFamily'];
106
- shadowColor?: CSS.Properties['color'];
107
- padding?: CSS.Properties['padding'];
108
- borderColor?: CSS.Properties['borderColor'];
109
- }
110
- type WidgetThemeProperty = keyof IWidgetTheme;
111
- declare class WidgetTheme implements IWidgetTheme {
112
- borderRadius?: CSS.Properties['borderRadius'];
113
- backgroundColor?: CSS.Properties['color'];
114
- fontSize?: CSS.Properties['fontSize'];
115
- dividerColor?: CSS.Properties['color'];
378
+ height?: number;
116
379
  /**
117
- * 主色调
380
+ * (**required** if y is used) Window's left offset from screen. Default is to
381
+ * center the window.
118
382
  */
119
- primaryColor?: CSS.Properties['color'];
120
- backgroundBorderColor?: CSS.Properties['color'];
121
- backgroundBoxShadowColor?: CSS.Properties['color'];
383
+ x?: number;
122
384
  /**
123
- * 文字颜色
124
- */
125
- color?: CSS.Properties['color'];
126
- fontFamily?: CSS.Properties['fontFamily'];
127
- shadowColor?: CSS.Properties['color'];
128
- padding?: CSS.Properties['padding'];
129
- borderColor?: CSS.Properties['borderColor'];
130
- useGlobalTheme?: boolean;
131
- constructor(options?: IWidgetTheme | string);
132
- static fromJSON(json: string): WidgetTheme;
133
- /**
134
- * Injects the style properties as css variable.
135
- * @param selector default is 'body'
136
- */
137
- toCSS(selector?: string): string;
138
- /**
139
- * Injects the style properties as css variable.
140
- * @param rootElement The rootElement to inject the css.
141
- * @remarks Only works in a browser environment.
142
- */
143
- injectCSS(rootElement?: HTMLElement): void;
144
- removeCSS(rootElement?: HTMLElement): void;
145
- copy(options?: IWidgetTheme): WidgetTheme;
146
- /**
147
- * Gets the style properties from the widget's style object.
148
- * @returns A record representing CSS custom variable and their values.
149
- */
150
- toCSSVariable(): Record<string, string>;
151
- toCSSProperties(): Record<string, string>;
152
- static fromCSS(css: string): WidgetTheme;
153
- }
154
- type WidgetThemeKey = keyof WidgetTheme;
155
- /**
156
- * Widget default theme, this object is immutable. Clone it before use.
157
- */
158
- declare const DefaultWidgetTheme: WidgetTheme;
159
-
160
- /**
161
- * 组件配置数据,用于存储组件自定义页面所设置的数据
162
- * @deprecated
163
- */
164
- declare class WidgetData {
165
- /**
166
- * 组件id
167
- */
168
- id?: string;
169
- /**
170
- * 组件名
171
- */
172
- name: string;
173
- /**
174
- * 背景颜色
175
- * @deprecated
176
- */
177
- backgroundColor?: string;
178
- /**
179
- * 文字颜色
180
- * @deprecated
181
- */
182
- color?: string;
183
- /**
184
- * 字体大小
185
- * @deprecated
186
- */
187
- fontSize?: number;
188
- /**
189
- * 字体
190
- * @deprecated
191
- */
192
- fontFamily?: string;
193
- /**
194
- * 圆角半径
195
- * @deprecated
196
- */
197
- borderRadius?: number;
198
- /**
199
- * 组件样式
200
- * @deprecated
201
- */
202
- theme: WidgetTheme;
203
- constructor(name: string, id?: string);
204
- parseJSON(json: any): void;
205
- /**
206
- * Gets the style properties from the widget's style object.
207
- * @returns A record representing CSS custom properties and their values.
208
- */
209
- getThemeProperties(): Record<string, string>;
210
- /**
211
- * Injects the style properties as css variable.
212
- * @remarks Only works in a browser environment.
213
- */
214
- injectThemeProperties(): void;
215
- }
216
-
217
- interface SaveWidgetOption {
218
- sendBroadcast?: boolean;
219
- id?: string;
220
- storeName?: string;
221
- }
222
- /**
223
- * 用户处理浏览器数据,只在浏览器环境下有用
224
- * @deprecated
225
- */
226
- interface IWidgetDataApi {
227
- findByName: (<T extends WidgetData>(name: string, type: {
228
- new (name: string, id?: string): T;
229
- }) => Promise<T | undefined>) & (<T extends WidgetData>(data: T) => Promise<T | undefined>);
230
- save: (data: WidgetData, options?: SaveWidgetOption) => Promise<string>;
231
- /**
232
- * 获取组件 LocalForage 存储实例
233
- * @param widgetName 组件名
234
- * @param storeName 存储名
235
- * @see https://localforage.docschina.org/
236
- */
237
- getStore: (widgetName: string, storeName?: string) => LocalForage;
238
- saveByName: <T extends WidgetData>(data: T, options?: SaveWidgetOption) => Promise<string>;
239
- find: <T extends WidgetData>(name: string, id: string, type: {
240
- new (name: string, id?: string): T;
241
- }) => Promise<T | undefined>;
242
- }
243
- type WidgetDataApiMethods = keyof IWidgetDataApi;
244
- declare const WidgetDataApi: IWidgetDataApi;
245
-
246
- /**
247
- * 设置窗口位置的选项
248
- */
249
- interface BrowserWindowOptions {
250
- /**
251
- * 分区
252
- * @deprecated
253
- */
254
- partition?: string;
255
- /**
256
- * 是否使用外部浏览器打开
257
- */
258
- external?: boolean;
259
- /**
260
- * Window's width in pixels. Default is `800`.
261
- */
262
- width?: number;
263
- /**
264
- * Window's height in pixels. Default is `600`.
265
- */
266
- height?: number;
267
- /**
268
- * (**required** if y is used) Window's left offset from screen. Default is to
269
- * center the window.
270
- */
271
- x?: number;
272
- /**
273
- * (**required** if x is used) Window's top offset from screen. Default is to
274
- * center the window.
385
+ * (**required** if x is used) Window's top offset from screen. Default is to
386
+ * center the window.
275
387
  */
276
388
  y?: number;
277
389
  /**
@@ -488,1030 +600,651 @@ interface AppRuntimeInfo {
488
600
  systemName: string;
489
601
  }
490
602
 
491
- declare abstract class BaseApi<T extends string> {
492
- abstract getChannel(): string;
493
- protected invokeMethod(method: T, ...args: any[]): Promise<any>;
494
- protected invoke(...args: any[]): Promise<any>;
495
- }
496
-
603
+ type AppRoutes = '/widget/search' | '/widget/package' | '/setting/common' | '/setting/theme' | '/setting/ai' | '/setting/proxy' | '/setting/info' | '/user/profile';
497
604
  /**
498
- * BrowserWindowApi 接口定义了一系列用于控制窗口的方法,这些方法提供了窗口的显示、隐藏、移动、调整大小等功能
499
- * @remarks 注意:桌面类型组件不支持窗口移动、调整大小、最大化、最小化等操作
605
+ * AppApi 接口定义了与应用程序相关的一系列方法。这些方法提供了应用程序配置管理、版本信息获取、路径获取以及应用内置窗口操作等功能。
606
+ * @see [Electron API App](https://www.electronjs.org/docs/latest/api/app)
500
607
  */
501
- interface IBrowserWindowApi {
608
+ interface IAppApi {
502
609
  /**
503
- * 设置是否忽略鼠标事件
504
- * @param ignore boolean
610
+ * 设置配置
611
+ * @param key string
612
+ * @param value string | number | boolean
505
613
  */
506
- setIgnoreMouseEvent: (ignore: boolean) => Promise<void>;
614
+ setConfig: (key: string | AppApiConstants, value: string | number | boolean) => Promise<any>;
507
615
  /**
508
- * 显示窗口
616
+ * 获取配置
617
+ * @param key
618
+ * @param defaultValue
619
+ * @return Promise<string | number | boolean>
509
620
  */
510
- show: () => Promise<void>;
621
+ getConfig: <T extends string | number | boolean>(key: string | AppApiConstants, defaultValue: T) => Promise<T>;
511
622
  /**
512
- * 设置窗口是否有阴影
513
- * @param hasShadow boolean
623
+ * 获取版本信息
624
+ * @param type string - 可选。指定要获取的版本类型。
625
+ * <ol>
626
+ * <li>`app`: Get app's version with Semantic Versioning format.
627
+ * The version is different from Microsoft store's version.
628
+ * For example, if the app's version is `24.1.1`, Microsoft store's version will be `24.1.1.0`</li>
629
+ * <li>`electron`: 获取 Electron 框架的版本。</li>
630
+ * <li>`chrome`: 获取 Electron 使用的 Chromium 版本。</li>
631
+ * <li>`node`: 获取 Node.js 的版本。</li>
632
+ * <li>`v8`: 获取 V8 引擎的版本。</li>
633
+ * </ol>
634
+ * @return Promise<string>
514
635
  */
515
- setHasShadow: (hasShadow: boolean) => Promise<void>;
636
+ getVersion: (type?: 'app' | 'electron' | 'chrome' | 'node' | 'v8') => Promise<string>;
516
637
  /**
517
- * 隐藏窗口
638
+ * Get App's runtime info (e.g. app name, os/electron/node version, etc.)
518
639
  */
519
- hide: () => Promise<void>;
640
+ getRuntimeInfo: () => Promise<AppRuntimeInfo>;
520
641
  /**
521
- * 关闭窗口
642
+ * 获取Preload JS路径
643
+ * @see [Using Preload Scripts](https://www.electronjs.org/docs/latest/tutorial/tutorial-preload)
644
+ * @return Promise<string>
522
645
  */
523
- close: () => Promise<void>;
646
+ getPreloadPath: () => Promise<string>;
524
647
  /**
525
- * 以不激活窗口的方式显示窗口
648
+ * 获取应用安装路径
649
+ * @return Promise<string>
526
650
  */
527
- showInactive: () => Promise<void>;
651
+ getAppPath: () => Promise<string>;
528
652
  /**
529
- * 将窗口居中
653
+ * Open the app's add/search widget window
654
+ * @deprecated Use `showAppWindow('/widget/add', options)` instead, which is more flexible and supports custom routes.
530
655
  */
531
- center: () => Promise<void>;
656
+ openAddWidgetWindow: () => Promise<void>;
532
657
  /**
533
- * 最小化窗口
658
+ * Show a new window with specified route and options
659
+ * support routes:
660
+ * /user/profile
661
+ * /auth/register
662
+ *
663
+ * @param route
664
+ * @param options
534
665
  */
535
- minimize: () => Promise<void>;
666
+ showAppWindow: (route: string | AppRoutes, options?: BrowserWindowOptions) => Promise<void>;
536
667
  /**
537
- * 还原窗口
668
+ * Open the app's setting window
669
+ * @deprecated Use `showAppWindow('/setting/common', options)` instead, which is more flexible and supports custom routes.
538
670
  */
539
- restore: () => Promise<void>;
671
+ openSettingWindow: () => Promise<void>;
540
672
  /**
541
- * 窗口是否最小后
542
- * @return Promise<boolean>
673
+ * Open the app's update window
674
+ * @deprecated Use `showAppWindow('/widget/info', options)` instead, which is more flexible and supports custom routes.
543
675
  */
544
- isMinimized: () => Promise<boolean>;
676
+ openCheckUpdateWindow: () => Promise<void>;
545
677
  /**
546
- * 检查窗口是否最大化
547
- * @return Promise<boolean>
678
+ * open the app's widget manager window
679
+ * @deprecated Use `showAppWindow('/widget/search', options)` instead, which is more flexible and supports custom routes.
548
680
  */
549
- isMaximized: () => Promise<boolean>;
681
+ openWidgetManagerWindow: () => Promise<void>;
550
682
  /**
551
- * 检查窗口是否可见
552
- * @return Promise<boolean>
683
+ * @deprecated Use `showAppWindow('/widget/package', options)` instead, which is more flexible and supports custom routes.
553
684
  */
554
- isVisible: () => Promise<boolean>;
685
+ openWidgetPackageManagerWindow: () => Promise<void>;
555
686
  /**
556
- * 检查窗口是否可调整大小
557
- * @since 24.1.1-beta.6
558
- * @return Promise<boolean>
687
+ * Open the app's runtime info window
688
+ * @deprecated Use `showAppWindow('/setting/info', options)` instead, which is more flexible and supports custom routes.
559
689
  */
560
- isResizable: () => Promise<boolean>;
690
+ openRuntimeInfoWindow: () => Promise<void>;
561
691
  /**
562
- * 最大化窗口
692
+ * Get the app's icon file path
693
+ * @return Promise<string>
563
694
  */
564
- maximize: () => Promise<void>;
695
+ getIconFile: () => Promise<string>;
565
696
  /**
566
- * 停止拖动窗口
567
- */
568
- stopDraggingWindow: () => Promise<void>;
569
- /**
570
- * 开始拖动窗口
697
+ * Check if the app is running as Windows Store app (appx)
698
+ * @return Promise<boolean>
571
699
  */
572
- startDraggingWindow: () => Promise<void>;
700
+ isWindowsStore: () => Promise<boolean>;
573
701
  /**
574
- * 检查窗口是否正在拖动
575
- * @return Promise<boolean>
702
+ * Get app's language, if user has not set, return `navigator.language`
576
703
  */
577
- isDraggingWindow: () => Promise<boolean>;
704
+ getLanguageCode: () => Promise<string>;
578
705
  /**
579
- * 设置窗口是否总在最前
580
- * @param alwaysOnTop boolean
706
+ * Set app's language
707
+ * @param code
581
708
  */
582
- setAlwaysOnTop: (alwaysOnTop: boolean) => Promise<void>;
709
+ setLanguageCode: (code: LanguageCode) => Promise<void>;
583
710
  /**
584
- * 检查窗口是否总在最前
585
- * @return Promise<boolean>
711
+ * Set app's global proxy settings, set empty string to disable proxy
712
+ * @param config
713
+ * @example
714
+ * ```typescript
715
+ * AppApi.setProxy({
716
+ * proxyRules:'socks5://127.0.0.1:7890'
717
+ * })
718
+ * ```
586
719
  */
587
- isAlwaysOnTop: () => Promise<boolean>;
720
+ setProxy: (config: ProxyConfig) => Promise<void>;
721
+ getProxy: () => Promise<ProxyConfig>;
588
722
  /**
589
- * 打开指定的 URL
590
- * @param url string 要打开的 URL
591
- * @param option OpenUrlOptions - 可选参数,用于配置 URL 打开的方式
723
+ * Set app's global theme CSS
724
+ * @param css
592
725
  */
593
- openUrl: (url: string, option?: BrowserWindowOptions) => Promise<void>;
726
+ setThemeCSS: (css: string) => Promise<void>;
594
727
  /**
595
- * 将窗口置于最前
728
+ * Get the app's global theme CSS
729
+ * @return Promise<string> If the theme CSS is not set, return empty string
596
730
  */
597
- moveTop: () => Promise<void>;
731
+ getThemeCSS: () => Promise<string>;
598
732
  /**
599
- * 取消最大化窗口
733
+ * enable/disable developer mode
600
734
  */
601
- unmaximize: () => Promise<void>;
735
+ setDevMode: (enable: boolean) => Promise<void>;
602
736
  /**
603
- * 重新加载窗口
737
+ * get developer mode is enabled
604
738
  */
605
- reload: () => Promise<void>;
739
+ getDevMode: () => Promise<boolean>;
606
740
  /**
607
- * 设置窗口大小
608
- * @param width boolean - 窗口宽度
609
- * @param height boolean - 窗口高度
610
- * @param animate boolean - 是否使用动画(可选)
741
+ * Get the app's desktop grid system cell size
611
742
  */
612
- setSize: (width: number, height: number, animate?: boolean) => Promise<void>;
743
+ getGridCellSize: () => Promise<number>;
613
744
  /**
614
- * 获取窗口大小
615
- * @since 24.1.1-beta.6
616
- * @returns Promise<number[]>
745
+ * Set the app's desktop grid system cell size
746
+ * @param size
617
747
  */
618
- getSize: () => Promise<number[]>;
748
+ setGridCellSize: (size: number) => Promise<void>;
619
749
  /**
620
- * 打开开发者工具
750
+ * exit application
621
751
  */
622
- openDevTools: () => Promise<void>;
752
+ exit: () => Promise<void>;
753
+ }
754
+ type AppApiMethods = keyof IAppApi;
755
+ /**
756
+ * AppApiEvent
757
+ */
758
+ declare enum AppApiEvent {
623
759
  /**
624
- * 设置窗口位置
625
- * @param {SetPositionOptions} options - 配置窗口位置的选项
760
+ * 应用设置变更时触发
626
761
  */
627
- setPosition: (options: SetPositionOptions) => Promise<void>;
762
+ CONFIG_CHANGED = "event::cn.widgetjs.core.app.config.changed",
628
763
  /**
629
- * 获取窗口位置
630
- * @returns {Promise<Position>} 返回一个 Promise,解析为窗口的位置
764
+ * 桌面组件网格窗口移动时触发
631
765
  */
632
- getPosition: () => Promise<Position>;
766
+ MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window",
633
767
  /**
634
- * 使窗口失去焦点
768
+ * 桌面组件网格窗口停止移动时触发
635
769
  */
636
- blur: () => Promise<void>;
770
+ STOP_MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window.stop",
637
771
  /**
638
- * 聚焦窗口
772
+ * 应用代理发生变化
639
773
  */
640
- focus: () => Promise<void>;
774
+ PROXY_CHANGED = "event::cn.widgetjs.core.app.proxy.changed",
641
775
  /**
642
- * 设置窗口是否可调整大小
643
- * @param resizable boolean - 是否可调整大小
776
+ * 应用语言发生变化
644
777
  */
645
- setResizable: (resizable: boolean) => Promise<void>;
778
+ LANGUAGE_CHANGED = "event::cn.widgetjs.core.app.language.changed"
779
+ }
780
+ /**
781
+ * AppApiConstants
782
+ */
783
+ declare enum AppApiConstants {
646
784
  /**
647
- * 设置窗口是否可移动
648
- * @param movable boolean - 是否可移动
785
+ * 桌面组件网格大小
649
786
  */
650
- setMovable: (movable: boolean) => Promise<void>;
787
+ CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size",
651
788
  /**
652
- * 获取窗口边界
653
- * @returns Promise<Rectangle>
789
+ * 应用主题CSS设置
654
790
  */
655
- getBounds: () => Promise<Rectangle>;
791
+ CONFIG_WIDGET_THEME_CSS = "cn.widgetjs.config.widget.theme.css",
656
792
  /**
657
- * 设置窗口边界
658
- * @param {Partial<Rectangle>} bounds - 窗口的边界矩形
659
- * @param {boolean} animate - 是否启用动画
793
+ * 应用全局代理设置
660
794
  */
661
- setBounds: (bounds: Partial<Rectangle>, animate: boolean) => Promise<void>;
795
+ CONFIG_PROXY = "cn.widgetjs.config.app.proxy",
796
+ CONFIG_DEV_MODE = "cn.widgetjs.config.app.dev.mode",
662
797
  /**
663
- * 将窗口对齐到当前屏幕
664
- * @param align string 对齐位置
665
- * <ol>
666
- * <li>'top-left'</li>
667
- * <li>'top-center'</li>
668
- * <li>'top-right'</li>
669
- * <li>'bottom-left'</li>
670
- * <li>'bottom-center'</li>
671
- * <li>'bottom-right'</li>
672
- * </ol>
798
+ * 应用语言设置
673
799
  */
674
- alignToScreen: (align: AlignPosition) => Promise<void>;
800
+ CONFIG_LANGUAGE = "cn.widgetjs.config.app.language"
801
+ }
802
+
803
+ type WidgetPermission = 'keyboard' | 'mouse' | 'clipboard' | 'notification' | 'storage' | 'network' | 'cpu' | 'system-info';
804
+
805
+ interface MetaInfo {
806
+ [key: string]: string | number | boolean;
807
+ }
808
+ interface IWindowSize {
809
+ width: number;
810
+ height: number;
811
+ maxWidth?: number;
812
+ maxHeight?: number;
813
+ minWidth?: number;
814
+ minHeight?: number;
815
+ }
816
+ interface IPageOptions extends IWindowSize {
817
+ name: string;
675
818
  /**
676
- * 检查指定 URL 是否存在
677
- * @param {string} url - 要检查的 URL
678
- * @return Promise<boolean>
819
+ * 当showInSearch为true时,此项必填
679
820
  */
680
- existsByUrl: (url: string) => Promise<boolean>;
821
+ title: LanguageTextMap;
681
822
  /**
682
- * 获取窗口的最大尺寸
683
- * @returns {Promise<number[]>} 返回一个 Promise,解析为一个数组,包含窗口的最大宽度和高度
823
+ * 当showInSearch为true时,此项必填
684
824
  */
685
- getMaximumSize: () => Promise<number[]>;
825
+ description?: LanguageTextMap;
686
826
  /**
687
- * 获取窗口的最小尺寸
688
- * @returns {Promise<number[]>} 返回一个 Promise,解析为一个数组,包含窗口的最小宽度和高度
827
+ * 当showInSearch为true时,此项必填
689
828
  */
690
- getMinimumSize: () => Promise<number[]>;
829
+ keywords?: WidgetKeyword[];
830
+ lang: LanguageCode;
831
+ packageName?: string;
832
+ icon?: string;
691
833
  /**
692
- * 设置窗口的最大尺寸
693
- * @param {number} width - 最大宽度
694
- * @param {number} height - 最大高度
834
+ * 当showInSearch为true时,此项必填
695
835
  */
696
- setMaximumSize: (width: number, height: number) => Promise<void>;
836
+ previewImage?: string;
697
837
  /**
698
- * 设置窗口的最小尺寸
699
- * @param {number} width - 最大宽度
700
- * @param {number} height - 最大高度
838
+ * 是否在搜索中显示
701
839
  */
702
- setMinimumSize: (width: number, height: number) => Promise<void>;
840
+ showInSearch?: boolean;
703
841
  /**
704
- * 更改缩放等级 原始尺寸为 0,每升高或将顶代表缩放20%,大和小限制默认分区为 300% 和 50% 缩放公式为 scale := 1.2 ^ level.
705
- * @param level number - 缩放等级,默认为 0
842
+ * 悬浮窗模式 是否可移动
843
+ * @deprecated
706
844
  */
707
- setZoomLevel: (level: number) => Promise<void>;
845
+ movable?: boolean;
708
846
  /**
709
- * 更改缩放倍数 缩放系数是缩放百分比除以 100,即 300% = 3.0
710
- * @param factor Double - 缩放系数,默认为 1.0
711
- * @remarks 系数必须大于0.0
847
+ * @deprecated
712
848
  */
713
- setZoomFactor: (factor: number) => Promise<void>;
849
+ resizable?: boolean;
714
850
  /**
715
- * Set the proxy config for window. All requests will be sent through the proxy server.
716
- * Proxy config will be lost once the window is closed. If you want to set a persistent proxy for widget window, use `DeployWidgetApi.setProxy` instead.
717
- * @remarks All links will be disconnected after setting, it is best to refresh the page (window.location.reload())
718
- * @param config
719
- * @example
720
- * ```typescript
721
- * BrowserWindowApi.setProxy({
722
- * proxyRules:'socks5://127.0.0.1:7890'
723
- * })
724
- * ```
851
+ * @deprecated
725
852
  */
726
- setProxy: (config: ProxyConfig) => Promise<void>;
727
- getProxy: () => Promise<ProxyConfig | undefined>;
853
+ backgroundThrottling?: boolean;
854
+ security?: boolean;
728
855
  /**
729
- * @return Promise<boolean>
856
+ * @deprecated
730
857
  */
731
- isFocused: () => Promise<boolean>;
858
+ webviewTag?: boolean;
859
+ path: string;
732
860
  /**
733
- * A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.
734
- * The window should not be activated through programmatic access or via keyboard navigation by accessible technology, such as Narrator.
735
- * @see [Extended Window Styles](https://learn.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles)
861
+ * 是否只能添加一次
736
862
  */
737
- setNoActivate: () => Promise<void>;
863
+ singleton?: boolean;
864
+ permissions?: WidgetPermission[];
865
+ meta?: MetaInfo;
866
+ broadcastChannels?: string[];
867
+ }
868
+ interface IPage {
869
+ readonly name: string;
738
870
  /**
739
- * Controls whether or not this window's WebContents will throttle animations and timers when the page becomes backgrounded. This also affects the Page Visibility API.
740
- * @param enabled
741
- * @see https://www.electronjs.org/docs/latest/api/web-contents#contentssetbackgroundthrottlingallowed
871
+ * 窗口标题,显示在界面上的,
872
+ * https://zh.m.wikipedia.org/zh-hans/ISO_639-1
742
873
  */
743
- setBackgroundThrottling: (enabled: boolean) => Promise<void>;
744
- getBackgroundThrottling: () => Promise<boolean>;
874
+ readonly title: LanguageTextMap;
875
+ readonly permissions: WidgetPermission[];
876
+ readonly webviewTag: boolean;
745
877
  /**
746
- * Makes the window not show in the taskbar.
747
- * @param boolean
878
+ * 窗口介绍
748
879
  */
749
- setSkipTaskbar: (boolean: boolean) => Promise<void>;
750
- }
751
-
752
- type BrowserWindowApiMethods = keyof IBrowserWindowApi;
753
- type AlignPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
754
- interface SetPositionOptions {
755
- x?: number;
756
- y?: number;
880
+ readonly description: LanguageTextMap;
881
+ readonly keywords: WidgetKeyword[];
757
882
  /**
758
- * Only works on macOS
883
+ * 组件默认语言
759
884
  */
760
- animation?: boolean;
761
- }
762
- declare enum BrowserWindowApiEvent {
763
- BLUR = "event::cn.widgetjs.core.browser-window.blur",
764
- MOVED = "event::cn.widgetjs.core.browser-window.moved",
765
- FOCUS = "event::cn.widgetjs.core.browser-window.focus",
766
- CLOSE = "event::cn.widgetjs.core.browser-window.close",
767
- SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.snap_to_edge",
768
- RESIZED = "event::cn.widgetjs.core.browser-window.resized",
769
- CANCEL_SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge"
770
- }
771
- interface SetupOptions {
772
- width: number;
773
- height: number;
774
- minWidth?: number;
775
- minHeight?: number;
776
- maxWidth?: number;
777
- maxHeight?: number;
778
- resizable?: boolean;
779
- movable?: boolean;
780
- center?: boolean;
781
- alwaysOnTop?: boolean;
782
- x?: number;
783
- y?: number;
784
- skipTaskbar?: boolean;
785
- }
786
- declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> implements IBrowserWindowApi {
787
- getProxy(): Promise<ProxyConfig | undefined>;
788
- setBackgroundThrottling(enabled: boolean): Promise<void>;
789
- getBackgroundThrottling(): Promise<boolean>;
790
- isResizable(): Promise<boolean>;
791
- setHasShadow(hasShadow: boolean): Promise<void>;
792
- isDraggingWindow(): Promise<boolean>;
793
- setNoActivate(): Promise<void>;
794
- isVisible(): Promise<boolean>;
795
- getChannel(): string;
796
- setIgnoreMouseEvent(ignore: boolean): Promise<void>;
797
- show(): Promise<void>;
798
- showInactive(): Promise<void>;
799
- hide(): Promise<void>;
800
- center(): Promise<void>;
801
- setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
802
- isAlwaysOnTop(): Promise<boolean>;
803
- openUrl(url: string, option?: BrowserWindowOptions): Promise<void>;
804
- moveTop(): Promise<void>;
805
- openDevTools(): Promise<void>;
806
- setPosition(options: SetPositionOptions): Promise<void>;
807
- getPosition(): Promise<Position>;
808
- blur(): Promise<any>;
809
- focus(): Promise<any>;
810
- /**
811
- * 设置窗口是否可以拉伸
812
- * @param resizable
813
- */
814
- setResizable(resizable: boolean): Promise<any>;
815
- getBounds(): Promise<Rectangle>;
816
- setBounds(bounds: Partial<Rectangle>, animate?: boolean): Promise<void>;
817
- alignToScreen(align: AlignPosition): Promise<any>;
818
- startDraggingWindow(): Promise<any>;
819
- stopDraggingWindow(): Promise<any>;
820
- /**
821
- * 通过url检测窗口是否存在
822
- * @param url
823
- */
824
- existsByUrl(url: string): Promise<boolean>;
825
- getMaximumSize(): Promise<number[]>;
826
- minimize(): Promise<void>;
827
- maximize(): Promise<void>;
828
- isMaximized(): Promise<boolean>;
829
- isMinimized(): Promise<boolean>;
830
- restore(): Promise<void>;
831
- unmaximize(): Promise<void>;
832
- setZoomLevel(level: number): Promise<void>;
833
- reload(): Promise<void>;
834
- setMovable(movable: boolean): Promise<void>;
835
- setSize(width: number, height: number, animate?: boolean): Promise<void>;
836
- isFocused(): Promise<boolean>;
837
- setMaximumSize(width: number, height: number): Promise<void>;
838
- setMinimumSize(width: number, height: number): Promise<void>;
839
- getMinimumSize(): Promise<number[]>;
840
- close(): Promise<void>;
841
- setZoomFactor(factor: number): Promise<void>;
842
- setup(options: SetupOptions): Promise<void>;
843
- setProxy(config: Electron.Config): Promise<void>;
844
- getSize(): Promise<number[]>;
845
- setSkipTaskbar(skip: boolean): Promise<void>;
846
- }
847
- declare const BrowserWindowApi: BrowserWindowApiImpl;
848
-
849
- type NotificationType = 'countdown' | 'advance-countdown' | 'error' | 'success' | 'warning' | 'info' | 'reminder' | 'url' | 'call';
850
- declare enum NotificationSize {
851
- SMALL = "small",
852
- NORMAL = "normal",
853
- LARGE = "large"
854
- }
855
- interface CountdownNotificationOption extends InfoNotificationOption {
856
- targetTime?: string;
857
- }
858
- interface InfoNotificationOption {
859
- message: string;
860
- duration?: number;
861
- /**
862
- * 图片名,目前只支持mingcute图标。
863
- * https://www.mingcute.com/
864
- */
865
- icon?: string;
866
- color?: string;
867
- size?: NotificationSize;
868
- backgroundColor?: string;
869
- }
870
- interface CallNotificationOption extends InfoNotificationOption {
871
- lyric?: string;
872
- audio?: string;
873
- avatar?: string;
874
- }
875
- interface ReminderNotificationOption extends InfoNotificationOption {
876
- confirmButtonText?: string;
877
- cancelButtonText?: string;
878
- title?: string;
879
- cancelBroadcast?: string;
880
- confirmBroadcast?: string;
881
- }
882
- interface NotificationOption extends InfoNotificationOption, ReminderNotificationOption, CountdownNotificationOption, CallNotificationOption {
883
- type?: NotificationType;
884
- }
885
- declare class AppNotification {
886
- type: NotificationType;
887
- message: string;
888
- title?: string;
889
- targetTime?: string;
890
- /**
891
- * 持续时间,单位毫秒
892
- */
893
- duration: number;
894
- /**
895
- * IconPark图标
896
- * @example close-one
897
- * @see [IconPark](https://iconpark.oceanengine.com/official)
898
- */
899
- icon?: string;
900
- color?: string;
901
- backgroundColor?: string;
902
- confirmButtonText?: string;
903
- cancelButtonText?: string;
904
- cancelBroadcast?: string;
905
- confirmBroadcast?: string;
906
- size: NotificationSize;
907
- url?: string;
908
- avatar?: string;
909
- audio?: string;
910
- lyric?: string;
911
- createdAt: string;
912
- constructor(option: NotificationOption);
913
- }
914
- declare class AppReminderNotification extends AppNotification {
915
- constructor(option: ReminderNotificationOption);
916
- }
917
-
918
- /**
919
- * NotificationApi提供了发送通知的能力
920
- */
921
- interface INotificationApi {
922
- /**
923
- * 发送自定义通知
924
- * @param notification
925
- */
926
- send: (notification: AppNotification) => Promise<void>;
927
- /**
928
- * 隐藏通知
929
- */
930
- hide: () => Promise<void>;
931
- /**
932
- * @param message string
933
- * @param duration number 持续时间,单位毫秒,默认5000
934
- */
935
- success: (message: string, duration?: number) => Promise<void>;
936
- /**
937
- * @param message string
938
- * @param duration number 持续时间,单位毫秒,默认5000
939
- */
940
- error: (message: string, duration?: number) => Promise<void>;
941
- /**
942
- * @param message string
943
- * @param duration number 持续时间,单位毫秒,默认5000
944
- */
945
- warning: (message: string, duration?: number) => Promise<void>;
946
- /**
947
- * @param message string
948
- * @param duration number 持续时间,单位毫秒,默认5000
949
- */
950
- info: (message: string, duration?: number) => Promise<void>;
951
- reminder: (option: ReminderNotificationOption) => Promise<void>;
952
- }
953
-
954
- type NotificationApiMethods = keyof INotificationApi;
955
- declare enum NotificationApiEvent {
956
- CONFIRM = "event::cn.widgetjs.core.notification.confirm",
957
- CANCEL = "event::cn.widgetjs.core.notification.cancel",
958
- HIDE = "event::cn.widgetjs.core.notification.hide"
959
- }
960
- declare class NotificationApiImpl extends BaseApi<NotificationApiMethods> implements INotificationApi {
961
- /**
962
- * 来电
963
- * @param avatar 头像地址
964
- * @param audio 音频地址
965
- * @param title 标题文件
966
- * @param message 初始消息
967
- * @param lyric 歌词字符串
968
- */
969
- call(avatar: string, audio: string, title: string, message: string, lyric: string): Promise<void>;
970
- send(notification: AppNotification): Promise<any>;
971
- reminder(option: ReminderNotificationOption): Promise<any>;
972
- advanceCountdown(message: string, targetTime: string, title?: string): Promise<any>;
973
- countdown(message: string, targetTime: string): Promise<void>;
974
- success(message: string, duration?: number): Promise<void>;
975
- error(message: string, duration?: number): Promise<void>;
976
- warning(message: string, duration?: number): Promise<void>;
977
- info(message: string, duration?: number): Promise<void>;
978
- /**
979
- * 隐藏通知
980
- */
981
- hide(): Promise<void>;
982
- getChannel(): string;
983
- }
984
- declare const NotificationApi: NotificationApiImpl;
985
-
986
- /**
987
- * @deprecated use DeployedMode instead
988
- */
989
- declare enum HostedMode {
990
- NORMAL = 1,
991
- /**
992
- * 悬浮窗
993
- */
994
- OVERLAP = 16,
995
- WALLPAPER = 256,
996
- SCREEN = 4096,
997
- BACKGROUND = 65536,
998
- /**
999
- * 页面
1000
- */
1001
- PAGE = 1048576,
1002
- ALL = 1118481
1003
- }
1004
- declare enum DeployMode {
1005
- /**
1006
- * 桌面组件,默认
1007
- */
1008
- NORMAL = 1,
1009
- /**
1010
- * 悬浮窗
1011
- */
1012
- OVERLAP = 16,
1013
- /**
1014
- * 后台组件,没有界面,一般在后台执行定时任务
1015
- */
1016
- BACKGROUND = 65536,
1017
- /**
1018
- * System tray
1019
- */
1020
- TRAY = 256,
1021
- /**
1022
- * 全部支持
1023
- */
1024
- ALL = 1118481
1025
- }
1026
-
1027
- declare class WidgetParams {
1028
- static readonly PARAM_PREFIX = "w_";
1029
- static readonly PARAM_ID = "id";
1030
- static readonly PARAM_LANG = "lang";
1031
- static readonly PARAM_THEME = "theme";
1032
- static readonly PARAM_MODE = "mode";
1033
- static readonly PARAM_NAME = "name";
1034
- static readonly PARAM_TITLE = "title";
1035
- static readonly PARAM_PREVIEW = "preview";
1036
- static readonly PARAMS: string[];
1037
- id?: string;
1038
- width?: number;
1039
- widthPx?: number;
1040
- heightPx?: number;
1041
- height?: number;
1042
- x?: number;
1043
- y?: number;
1044
- preview?: boolean;
1045
- lang?: string;
1046
- theme?: ThemeMode;
1047
- mode?: DeployMode;
1048
- radius?: number;
1049
- name?: string;
1050
- title?: string;
1051
- /**
1052
- * 将组件参数转为url参数
1053
- * @param object
1054
- * @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
1055
- */
1056
- toUrlParams(): URLSearchParams;
1057
- getPersistKey(): string;
1058
- /**
1059
- * 从当前地址解析组件参数:
1060
- * http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
1061
- * =>
1062
- * {width:2,height:2,id:21,width_px:156,height_px:156}
1063
- */
1064
- static fromCurrentLocation(): WidgetParams;
1065
- static fromLocation(url: string): WidgetParams;
1066
- private static setValue;
1067
- /**
1068
- * 从对象键值对中初始化组件参数
1069
- * {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
1070
- * {width:2,height:2,id:21,width_px:156,height_px:156}
1071
- * @param object
1072
- */
1073
- static fromObject(object: any): WidgetParams;
1074
- }
1075
- declare enum ThemeMode {
1076
- AUTO = "auto",
1077
- LIGHT = "LIGHT",
1078
- DARK = "DARK"
1079
- }
1080
-
1081
- interface IDeployedPage {
1082
- id: string;
1083
- name: string;
1084
- packageName: string;
1085
- x: number;
1086
- y: number;
1087
- height: number;
1088
- width: number;
1089
- proxy?: string;
1090
- isIgnoreMouseEvents?: boolean;
1091
- }
1092
- declare class DeployedPage implements IDeployedPage {
1093
- name: string;
1094
- packageName: string;
1095
- x: number;
1096
- y: number;
1097
- height: number;
1098
- width: number;
1099
- proxy?: string;
1100
- id: string;
1101
- isIgnoreMouseEvents?: boolean;
1102
- }
1103
-
1104
- declare class DeployedWidget extends DeployedPage {
1105
- shortcut?: string;
1106
- deployMode: number;
1107
- isOverlap(): boolean;
1108
- }
1109
-
1110
- /**
1111
- * DeployedWidgetApi provides methods for managing deployed widgets within the application.
1112
- * It allows for the removal, retrieval, and configuration of deployed widgets,
1113
- * as well as the ability to manipulate their settings and behavior.
1114
- * @remarks
1115
- */
1116
- interface IDeployedWidgetApi {
1117
- removeDeployedWidget: (id?: string) => Promise<void>;
1118
- removeDeployedWidgetByName: (name: string) => Promise<DeployedWidget[]>;
1119
- getDeployedWidgets: () => Promise<DeployedWidget[]>;
1120
- openDevTools: (id: string) => Promise<void>;
1121
- /**
1122
- * @deprecated 使用WidgetApi.openConfigPage代替
1123
- * @param id
1124
- */
1125
- openConfigPage: (id?: string, params?: WidgetParams) => Promise<void>;
1126
- registerActiveShortcut: (id: string, shortcut: string) => Promise<boolean>;
1127
- /**
1128
- * Set proxy for the widget, this will reload the widget after setting the proxy.
1129
- * @param id
1130
- * @param proxy
1131
- */
1132
- setProxy: (id: string, proxy: string) => Promise<boolean>;
1133
- getDeployedWidget: (id: string) => Promise<DeployedWidget>;
1134
- /**
1135
- * Adds a new widget with the specified options.
1136
- * If in browser environment, it will open widget://widgetjs.cn/widget?packageUrl=xxx&name=xxx&package
1137
- * @param options - The options for the widget to be added.
1138
- * @returns A promise that resolves with an array of added widgets.
1139
- */
1140
- addWidget: (options: AddWidgetOption) => Promise<Widget[]>;
1141
- }
1142
-
1143
- interface AddWidgetOption {
1144
- widgetName: string;
1145
- widgetTitle?: string;
1146
- deployMode: DeployMode;
1147
- packageJsonUrl?: string;
1148
- hostname?: string;
1149
- }
1150
- type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
1151
- declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
1152
- getChannel(): string;
1153
- /**
1154
- * 移除组件
1155
- * @param id
1156
- */
1157
- removeDeployedWidget(id?: string): Promise<any>;
1158
- addWidget(options: AddWidgetOption): Promise<Widget[]>;
1159
- /**
1160
- * 通过组件名移除已添加的组件
1161
- * @param name 组件名
1162
- */
1163
- removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
1164
- /**
1165
- * 获取已添加的组件
1166
- * @param name 组件名,可以不传
1167
- */
1168
- getDeployedWidgets(name?: string): Promise<DeployedWidget[]>;
1169
- getDeployedWidget(id: string): Promise<DeployedWidget>;
1170
- /**
1171
- * Opens the dev tools for a widget with the specified ID.
1172
- *
1173
- * @param {string} widgetId - The ID of the widget to open the dev tools for.
1174
- * @return {Promise} A Promise that resolves when the dev tools are opened.
1175
- */
1176
- openDevTools(widgetId: string): Promise<any>;
1177
- openConfigPage(widgetId?: string, params?: WidgetParams): Promise<any>;
1178
- /**
1179
- * 注册激活、呼出、置顶组件快捷键
1180
- * @param widgetId 组件id
1181
- * @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
1182
- * https://www.electronjs.org/docs/latest/api/accelerator
1183
- */
1184
- registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
1185
- setProxy(widgetId: string, proxy: string): Promise<boolean>;
1186
- }
1187
- declare const DeployedWidgetApi: DeployedWidgetApiImpl;
1188
-
1189
- type AppRoutes = '/widget/search' | '/widget/package' | '/setting/common' | '/setting/theme' | '/setting/ai' | '/setting/proxy' | '/setting/info' | '/user/profile';
1190
- /**
1191
- * AppApi 接口定义了与应用程序相关的一系列方法。这些方法提供了应用程序配置管理、版本信息获取、路径获取以及应用内置窗口操作等功能。
1192
- * @see [Electron API App](https://www.electronjs.org/docs/latest/api/app)
1193
- */
1194
- interface IAppApi {
1195
- /**
1196
- * 设置配置
1197
- * @param key string
1198
- * @param value string | number | boolean
1199
- */
1200
- setConfig: (key: string | AppApiConstants, value: string | number | boolean) => Promise<any>;
1201
- /**
1202
- * 获取配置
1203
- * @param key
1204
- * @param defaultValue
1205
- * @return Promise<string | number | boolean>
1206
- */
1207
- getConfig: <T extends string | number | boolean>(key: string | AppApiConstants, defaultValue: T) => Promise<T>;
1208
- /**
1209
- * 获取版本信息
1210
- * @param type string - 可选。指定要获取的版本类型。
1211
- * <ol>
1212
- * <li>`app`: Get app's version with Semantic Versioning format.
1213
- * The version is different from Microsoft store's version.
1214
- * For example, if the app's version is `24.1.1`, Microsoft store's version will be `24.1.1.0`</li>
1215
- * <li>`electron`: 获取 Electron 框架的版本。</li>
1216
- * <li>`chrome`: 获取 Electron 使用的 Chromium 版本。</li>
1217
- * <li>`node`: 获取 Node.js 的版本。</li>
1218
- * <li>`v8`: 获取 V8 引擎的版本。</li>
1219
- * </ol>
1220
- * @return Promise<string>
1221
- */
1222
- getVersion: (type?: 'app' | 'electron' | 'chrome' | 'node' | 'v8') => Promise<string>;
1223
- /**
1224
- * Get App's runtime info (e.g. app name, os/electron/node version, etc.)
1225
- */
1226
- getRuntimeInfo: () => Promise<AppRuntimeInfo>;
1227
- /**
1228
- * 获取Preload JS路径
1229
- * @see [Using Preload Scripts](https://www.electronjs.org/docs/latest/tutorial/tutorial-preload)
1230
- * @return Promise<string>
1231
- */
1232
- getPreloadPath: () => Promise<string>;
1233
- /**
1234
- * 获取应用安装路径
1235
- * @return Promise<string>
1236
- */
1237
- getAppPath: () => Promise<string>;
1238
- /**
1239
- * Open the app's add/search widget window
1240
- * @deprecated Use `showAppWindow('/widget/add', options)` instead, which is more flexible and supports custom routes.
1241
- */
1242
- openAddWidgetWindow: () => Promise<void>;
1243
- /**
1244
- * Show a new window with specified route and options
1245
- * support routes:
1246
- * /user/profile
1247
- * /auth/register
1248
- *
1249
- * @param route
1250
- * @param options
1251
- */
1252
- showAppWindow: (route: string | AppRoutes, options?: BrowserWindowOptions) => Promise<void>;
1253
- /**
1254
- * Open the app's setting window
1255
- * @deprecated Use `showAppWindow('/setting/common', options)` instead, which is more flexible and supports custom routes.
1256
- */
1257
- openSettingWindow: () => Promise<void>;
1258
- /**
1259
- * Open the app's update window
1260
- * @deprecated Use `showAppWindow('/widget/info', options)` instead, which is more flexible and supports custom routes.
1261
- */
1262
- openCheckUpdateWindow: () => Promise<void>;
1263
- /**
1264
- * open the app's widget manager window
1265
- * @deprecated Use `showAppWindow('/widget/search', options)` instead, which is more flexible and supports custom routes.
1266
- */
1267
- openWidgetManagerWindow: () => Promise<void>;
885
+ readonly lang: LanguageCode;
886
+ readonly width: number;
887
+ packageName?: string | null;
888
+ readonly height: number;
889
+ readonly maxWidth: number;
890
+ readonly maxHeight: number;
891
+ readonly minWidth: number;
892
+ readonly minHeight: number;
893
+ readonly movable: boolean;
894
+ readonly singleton: boolean;
895
+ readonly resizable: boolean;
896
+ readonly path: string;
897
+ readonly meta: {
898
+ [key: string]: string | number | boolean;
899
+ };
900
+ readonly backgroundThrottling: boolean;
1268
901
  /**
1269
- * @deprecated Use `showAppWindow('/widget/package', options)` instead, which is more flexible and supports custom routes.
902
+ * 预览图片,可以是GIF
1270
903
  */
1271
- openWidgetPackageManagerWindow: () => Promise<void>;
904
+ readonly previewImage?: string;
905
+ }
906
+ declare class Page implements IPage {
1272
907
  /**
1273
- * Open the app's runtime info window
1274
- * @deprecated Use `showAppWindow('/setting/info', options)` instead, which is more flexible and supports custom routes.
908
+ * 页面名称,名称必须以包名开头,如果以.开头,会自动加上包名<br>
909
+ * 假设包名为`example.com`,以下两种写法等价
910
+ * @example example.com.countdown
911
+ * @example .countdown
1275
912
  */
1276
- openRuntimeInfoWindow: () => Promise<void>;
913
+ name: string;
1277
914
  /**
1278
- * Get the app's icon file path
1279
- * @return Promise<string>
915
+ * 窗口标题,显示在界面上的,
916
+ * @see https://zh.m.wikipedia.org/zh-hans/ISO_639-1
1280
917
  */
1281
- getIconFile: () => Promise<string>;
918
+ readonly title: LanguageTextMap;
1282
919
  /**
1283
- * Check if the app is running as Windows Store app (appx)
1284
- * @return Promise<boolean>
920
+ * 窗口介绍
1285
921
  */
1286
- isWindowsStore: () => Promise<boolean>;
922
+ readonly description: LanguageTextMap;
923
+ readonly keywords: WidgetKeyword[];
924
+ readonly security: boolean;
925
+ readonly permissions: WidgetPermission[];
1287
926
  /**
1288
- * Get app's language, if user has not set, return `navigator.language`
927
+ * 组件默认语言
1289
928
  */
1290
- getLanguageCode: () => Promise<string>;
929
+ readonly lang: LanguageCode;
930
+ readonly width: number;
931
+ packageName?: string | null;
932
+ readonly height: number;
933
+ readonly maxWidth: number;
1291
934
  /**
1292
- * Set app's language
1293
- * @param code
935
+ * @deprecated
1294
936
  */
1295
- setLanguageCode: (code: LanguageCode) => Promise<void>;
937
+ readonly webviewTag: boolean;
938
+ readonly maxHeight: number;
939
+ readonly minWidth: number;
940
+ readonly minHeight: number;
941
+ readonly movable: boolean;
942
+ readonly singleton: boolean;
943
+ readonly resizable: boolean;
944
+ readonly path: string;
945
+ readonly icon?: string;
946
+ readonly meta: MetaInfo;
947
+ readonly backgroundThrottling: boolean;
1296
948
  /**
1297
- * Set app's global proxy settings, set empty string to disable proxy
1298
- * @param config
1299
- * @example
1300
- * ```typescript
1301
- * AppApi.setProxy({
1302
- * proxyRules:'socks5://127.0.0.1:7890'
1303
- * })
1304
- * ```
949
+ * 预览图片,可以是GIF
1305
950
  */
1306
- setProxy: (config: ProxyConfig) => Promise<void>;
1307
- getProxy: () => Promise<ProxyConfig>;
951
+ readonly previewImage?: string;
952
+ constructor(options: IPageOptions);
1308
953
  /**
1309
- * Set app's global theme CSS
1310
- * @param css
954
+ * 获取组件标题
955
+ * @param lang 语言环境,不传则获取默认语言
1311
956
  */
1312
- setThemeCSS: (css: string) => Promise<void>;
957
+ getTitle(lang?: LanguageCode): string | undefined;
1313
958
  /**
1314
- * Get the app's global theme CSS
1315
- * @return Promise<string> If the theme CSS is not set, return empty string
959
+ * 获取组件描述
960
+ * @param lang 语言环境,不传则获取默认标题
1316
961
  */
1317
- getThemeCSS: () => Promise<string>;
962
+ getDescription(lang?: LanguageCode): string | undefined;
963
+ static parseJSON(json: string): Page;
964
+ static parseObject(obj: any): Page;
965
+ isResizable(): boolean;
966
+ }
967
+
968
+ type SocialType = 'qq' | 'wechat' | 'qq-group' | 'discord' | 'telegram' | 'tiktok' | 'douyin' | 'youtube' | 'instagram' | 'twitter' | 'facebook' | 'kuaishou' | 'bilibili' | 'github' | 'email' | 'gitee' | 'homepage';
969
+ declare class SocialInfo {
970
+ content: string;
971
+ name: SocialType;
972
+ constructor(name: SocialType, content: string);
973
+ }
974
+ interface SocialLink {
975
+ name: SocialType;
976
+ link: string;
977
+ }
978
+
979
+ /**
980
+ * @see [Web Manifest Categories]https://developer.mozilla.org/en-US/docs/Web/Manifest/categories
981
+ * @see [W3C Categories](https://github.com/w3c/manifest/wiki/Categories)
982
+ */
983
+ type Category = 'news' | 'photo' | 'productivity' | 'social' | 'utilities' | 'weather'
984
+ /**
985
+ * @deprecated
986
+ */
987
+ | 'calendar' | 'fun'
988
+ /**
989
+ * @deprecated
990
+ */
991
+ | 'countdown' | 'time' | 'finance' | 'ai';
992
+
993
+ interface IWidgetOptions extends IWindowSize, IPageOptions {
994
+ supportDeployMode?: DeployMode;
995
+ configPagePath?: string;
1318
996
  /**
1319
- * enable/disable developer mode
997
+ * 如果为true,组件将不会添加到组件包中
1320
998
  */
1321
- setDevMode: (enable: boolean) => Promise<void>;
999
+ disabled?: boolean;
1000
+ previewImage: string;
1322
1001
  /**
1323
- * get developer mode is enabled
1002
+ * whether the widget data can be synchronized
1324
1003
  */
1325
- getDevMode: () => Promise<boolean>;
1004
+ synchronizable?: boolean;
1005
+ categories?: Category[];
1326
1006
  /**
1327
- * Get the app's desktop grid system cell size
1007
+ * 组件包所需的App版本
1328
1008
  */
1329
- getGridCellSize: () => Promise<number>;
1009
+ requiredAppVersion?: string;
1010
+ description: LanguageTextMap;
1011
+ keywords: WidgetKeyword[];
1330
1012
  /**
1331
- * Set the app's desktop grid system cell size
1332
- * @param size
1013
+ * @deprecated
1333
1014
  */
1334
- setGridCellSize: (size: number) => Promise<void>;
1015
+ routes?: WidgetRoute[];
1335
1016
  /**
1336
- * exit application
1017
+ * 一般用于填写教程链接
1337
1018
  */
1338
- exit: () => Promise<void>;
1019
+ socialLinks?: SocialLink[];
1020
+ browserWindowOptions?: Pick<BrowserWindowOptions, 'backgroundThrottling'>;
1021
+ trayOptions?: TrayWidgetOptions;
1022
+ }
1023
+ interface IBackgroundWidgetOptions extends Omit<IWidgetOptions, 'width' | 'height'> {
1024
+ width?: number;
1025
+ height?: number;
1026
+ browserWindowOptions?: BrowserWindowOptions;
1339
1027
  }
1340
- type AppApiMethods = keyof IAppApi;
1341
1028
  /**
1342
- * AppApiEvent
1029
+ * @deprecated
1343
1030
  */
1344
- declare enum AppApiEvent {
1031
+ interface WidgetRoute {
1032
+ url: string;
1033
+ name: string;
1034
+ }
1035
+ interface TrayWidgetOptions {
1036
+ closeOnBlur?: boolean;
1037
+ hideOnBlur?: boolean;
1038
+ }
1039
+ declare class Widget extends Page {
1040
+ readonly previewImage: string;
1041
+ readonly categories?: Category[];
1042
+ readonly supportDeployMode: number;
1043
+ readonly trayOptions?: TrayWidgetOptions;
1345
1044
  /**
1346
- * 应用设置变更时触发
1045
+ * 组件包所需的App版本
1347
1046
  */
1348
- CONFIG_CHANGED = "event::cn.widgetjs.core.app.config.changed",
1047
+ readonly requiredAppVersion?: string;
1349
1048
  /**
1350
- * 桌面组件网格窗口移动时触发
1049
+ * 如果为true,组件将不会添加到组件包中
1351
1050
  */
1352
- MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window",
1051
+ readonly disabled?: boolean;
1052
+ readonly synchronizable?: boolean;
1353
1053
  /**
1354
- * 桌面组件网格窗口停止移动时触发
1054
+ * 配置页面路径,没有则不能修改
1355
1055
  */
1356
- STOP_MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window.stop",
1056
+ readonly configPagePath?: string;
1357
1057
  /**
1358
- * 应用代理发生变化
1058
+ * @deprecated
1359
1059
  */
1360
- PROXY_CHANGED = "event::cn.widgetjs.core.app.proxy.changed",
1060
+ readonly routes: WidgetRoute[];
1061
+ protected browserWindowOptions?: BrowserWindowOptions;
1062
+ readonly socialLinks?: SocialLink[];
1063
+ constructor(options: IWidgetOptions);
1064
+ static parseJSON(json: string): Widget;
1065
+ static parseObject(obj: any): Widget;
1361
1066
  /**
1362
- * 应用语言发生变化
1067
+ * 是否支持悬浮窗
1363
1068
  */
1364
- LANGUAGE_CHANGED = "event::cn.widgetjs.core.app.language.changed"
1365
- }
1366
- /**
1367
- * AppApiConstants
1368
- */
1369
- declare enum AppApiConstants {
1069
+ isSupportOverlap(): boolean;
1070
+ isSupportBackground(): boolean;
1071
+ isSupportTray(): boolean;
1370
1072
  /**
1371
- * 桌面组件网格大小
1073
+ * 是否支持普通模式
1372
1074
  */
1373
- CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size",
1075
+ isSupportNormal(): boolean;
1076
+ isConfigurable(): boolean;
1077
+ }
1078
+ declare class BackgroundWidget extends Widget {
1079
+ constructor(options: IBackgroundWidgetOptions);
1080
+ }
1081
+ declare enum WidgetKeyword {
1082
+ RECOMMEND = "recommend",
1083
+ TOOLS = "tools",
1084
+ EFFICIENCY = "efficiency",
1085
+ PICTURE = "picture",
1086
+ LIFE = "life",
1087
+ SHORTCUT = "shortcut",
1088
+ COUNTDOWN = "countdown",
1089
+ TIMER = "timer",
1090
+ INFO = "info",
1091
+ DASHBOARD = "dashboard"
1092
+ }
1093
+
1094
+ declare class WidgetParams {
1095
+ static readonly PARAM_PREFIX = "w_";
1096
+ static readonly PARAM_ID = "id";
1097
+ static readonly PARAM_LANG = "lang";
1098
+ static readonly PARAM_THEME = "theme";
1099
+ static readonly PARAM_MODE = "mode";
1100
+ static readonly PARAM_NAME = "name";
1101
+ static readonly PARAM_TITLE = "title";
1102
+ static readonly PARAM_PREVIEW = "preview";
1103
+ static readonly PARAMS: string[];
1104
+ id?: string;
1105
+ width?: number;
1106
+ widthPx?: number;
1107
+ heightPx?: number;
1108
+ height?: number;
1109
+ x?: number;
1110
+ y?: number;
1111
+ preview?: boolean;
1112
+ lang?: string;
1113
+ theme?: ThemeMode;
1114
+ mode?: DeployMode;
1115
+ radius?: number;
1116
+ name?: string;
1117
+ title?: string;
1374
1118
  /**
1375
- * 应用主题CSS设置
1119
+ * 将组件参数转为url参数
1120
+ * @param object
1121
+ * @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
1376
1122
  */
1377
- CONFIG_WIDGET_THEME_CSS = "cn.widgetjs.config.widget.theme.css",
1123
+ toUrlParams(): URLSearchParams;
1124
+ getPersistKey(): string;
1378
1125
  /**
1379
- * 应用全局代理设置
1126
+ * 从当前地址解析组件参数:
1127
+ * http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
1128
+ * =>
1129
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
1380
1130
  */
1381
- CONFIG_PROXY = "cn.widgetjs.config.app.proxy",
1382
- CONFIG_DEV_MODE = "cn.widgetjs.config.app.dev.mode",
1131
+ static fromCurrentLocation(): WidgetParams;
1132
+ static fromLocation(url: string): WidgetParams;
1133
+ private static setValue;
1383
1134
  /**
1384
- * 应用语言设置
1135
+ * 从对象键值对中初始化组件参数
1136
+ * {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
1137
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
1138
+ * @param object
1385
1139
  */
1386
- CONFIG_LANGUAGE = "cn.widgetjs.config.app.language"
1140
+ static fromObject(object: any): WidgetParams;
1141
+ }
1142
+ declare enum ThemeMode {
1143
+ AUTO = "auto",
1144
+ LIGHT = "LIGHT",
1145
+ DARK = "DARK"
1387
1146
  }
1388
1147
 
1389
- /**
1390
- * DialogApi 提供文件、文件夹选择功能
1391
- */
1392
- interface IDialogApi {
1393
- /**
1394
- * 选取单个文件
1395
- * @param extensions 允许的文件后缀格式,如:["txt","docx","gif"]
1396
- */
1397
- pickFile: (extensions?: string[]) => Promise<string | undefined>;
1398
- /**
1399
- * 选取文件夹
1400
- */
1401
- pickFolder: () => Promise<string | undefined>;
1148
+ declare abstract class BaseApi<T extends string> {
1149
+ abstract getChannel(): string;
1150
+ protected invokeMethod(method: T, ...args: any[]): Promise<any>;
1151
+ protected invoke(...args: any[]): Promise<any>;
1402
1152
  }
1403
- type DialogApiMethods = keyof IDialogApi;
1404
1153
 
1405
- /**
1406
- * WidgetPackageApi 提供了组件包的升级、获取、安装等功能
1407
- */
1408
- interface IWidgetPackageApi {
1409
- /**
1410
- * 升级组件包
1411
- * @param packageName 组件包名称
1412
- * @param remoteUrlInfo
1413
- */
1414
- upgrade: (packageName: string, remoteUrlInfo: RemotePackageUrlInfo) => Promise<void>;
1415
- /**
1416
- * 获取组件包的首页url信息
1417
- * @param packageName
1418
- */
1419
- getIndexUrl: (packageName: string) => Promise<string | null>;
1420
- /**
1421
- * 获取组件包入口url信息
1422
- * @param packageName
1423
- */
1424
- getEntryUrl: (packageName: string) => Promise<string | null>;
1425
- /**
1426
- * 通过包名获取组件包信息
1427
- * @param name
1428
- */
1429
- getPackage: (name: string) => Promise<WidgetPackage | undefined>;
1154
+ interface AddWidgetOption {
1155
+ widgetName: string;
1156
+ widgetTitle?: string;
1157
+ deployMode: DeployMode;
1158
+ packageJsonUrl?: string;
1159
+ hostname?: string;
1160
+ }
1161
+ type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
1162
+ declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
1163
+ getChannel(): string;
1430
1164
  /**
1431
- * 获取已经安装的组件包
1165
+ * 移除组件
1166
+ * @param id
1432
1167
  */
1433
- getPackages: () => Promise<WidgetPackage[]>;
1168
+ removeDeployedWidget(id?: string): Promise<any>;
1169
+ addWidget(options: AddWidgetOption): Promise<Widget[]>;
1170
+ createDesktopShortcut(widgetName: string): Promise<boolean>;
1434
1171
  /**
1435
- * Install a widget package, if the package is a string, it will be treated as a path or http url to install the widget.zip file.
1436
- * @param widgetPackage
1172
+ * 通过组件名移除已添加的组件
1173
+ * @param name 组件名
1437
1174
  */
1438
- install: (widgetPackage: WidgetPackage | string) => Promise<void>;
1175
+ removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
1439
1176
  /**
1440
- * Uninstall a widget package by package name.
1441
- * @param packageName
1442
- * @param clearData Whether to clear the data of the widget package, default is false.
1177
+ * 获取已添加的组件
1178
+ * @param name 组件名,可以不传
1443
1179
  */
1444
- uninstall: (widgetPackage: WidgetPackage | string, clearData?: boolean) => Promise<void>;
1445
- }
1446
- type WidgetPackageApiMethods = keyof IWidgetPackageApi;
1447
- /**
1448
- * WidgetPackageApiEvent
1449
- */
1450
- declare enum WidgetPackageApiEvent {
1180
+ getDeployedWidgets(name?: string): Promise<DeployedWidget[]>;
1181
+ getDeployedWidget(id: string): Promise<DeployedWidget>;
1451
1182
  /**
1452
- * 组件包升级事件
1183
+ * Opens the dev tools for a widget with the specified ID.
1184
+ *
1185
+ * @param {string} widgetId - The ID of the widget to open the dev tools for.
1186
+ * @return {Promise} A Promise that resolves when the dev tools are opened.
1453
1187
  */
1454
- PACKAGE_UPGRADE = "event::cn.widgetjs.core.widget.package.upgraded",
1188
+ openDevTools(widgetId: string): Promise<any>;
1189
+ openConfigPage(widgetId?: string, params?: WidgetParams): Promise<any>;
1455
1190
  /**
1456
- * 组件包安装事件
1191
+ * 注册激活、呼出、置顶组件快捷键
1192
+ * @param widgetId 组件id
1193
+ * @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
1194
+ * https://www.electronjs.org/docs/latest/api/accelerator
1457
1195
  */
1458
- PACKAGE_INSTALLED = "event::cn.widgetjs.core.widget.package.installed"
1459
- }
1460
-
1461
- /**
1462
- * LogApi提供了日志输出的方法,日志会保存在用户的`当前用户名/文档/桌面组件/logs/日期/组件包名.log`文件中
1463
- */
1464
- interface ILogApi {
1465
- info: (...data: any[]) => void;
1466
- error: (...data: any[]) => void;
1467
- warn: (...data: any[]) => void;
1468
- log: (...data: any[]) => void;
1469
- json: (data: any) => void;
1196
+ registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
1197
+ setProxy(widgetId: string, proxy: string): Promise<boolean>;
1470
1198
  }
1471
- type LogApiMethods = keyof ILogApi;
1199
+ declare const DeployedWidgetApi: DeployedWidgetApiImpl;
1472
1200
 
1473
1201
  /**
1474
- * ProcessApi 提供进程信息获取功能
1202
+ * DeployedWidgetApi provides methods for managing deployed widgets within the application.
1203
+ * It allows for the removal, retrieval, and configuration of deployed widgets,
1204
+ * as well as the ability to manipulate their settings and behavior.
1205
+ * @remarks
1475
1206
  */
1476
- interface IProcessApi {
1477
- getBlinkMemoryInfo: () => Promise<Electron.BlinkMemoryInfo>;
1478
- getHeapStatistics: () => Promise<Electron.HeapStatistics>;
1207
+ interface IDeployedWidgetApi {
1208
+ removeDeployedWidget: (id?: string) => Promise<void>;
1209
+ removeDeployedWidgetByName: (name: string) => Promise<DeployedWidget[]>;
1210
+ getDeployedWidgets: () => Promise<DeployedWidget[]>;
1211
+ openDevTools: (id: string) => Promise<void>;
1479
1212
  /**
1480
- * 获取系统版本信息
1481
- * @example '10.0.17763'
1213
+ * @deprecated 使用WidgetApi.openConfigPage代替
1214
+ * @param id
1482
1215
  */
1483
- getSystemVersion: () => Promise<string>;
1216
+ openConfigPage: (id?: string, params?: WidgetParams) => Promise<void>;
1217
+ registerActiveShortcut: (id: string, shortcut: string) => Promise<boolean>;
1484
1218
  /**
1485
- * 获取当前应用内存信息
1219
+ * Set proxy for the widget, this will reload the widget after setting the proxy.
1220
+ * @param id
1221
+ * @param proxy
1486
1222
  */
1487
- getProcessMemoryInfo: () => Promise<Electron.ProcessMemoryInfo>;
1488
- }
1489
- type ProcessApiMethods = keyof IProcessApi;
1490
-
1491
- /**
1492
- * MouseApi
1493
- */
1494
- interface IMouseApi {
1223
+ setProxy: (id: string, proxy: string) => Promise<boolean>;
1224
+ getDeployedWidget: (id: string) => Promise<DeployedWidget>;
1495
1225
  /**
1496
- * Create a mouse screen edge hotspot, usually used for edge-hiding windows.
1497
- * @param rect
1226
+ * Adds a new widget with the specified options.
1227
+ * If in browser environment, it will open widget://widgetjs.cn/widget?packageUrl=xxx&name=xxx&package
1228
+ * @param options - The options for the widget to be added.
1229
+ * @returns A promise that resolves with an array of added widgets.
1498
1230
  */
1499
- createHotspot: (rect: Rectangle) => Promise<void>;
1231
+ addWidget: (options: AddWidgetOption) => Promise<Widget[]>;
1500
1232
  /**
1501
- * Remove the mouse screen edge hotspot.
1233
+ * 创建桌面快捷方式
1234
+ * @param widgetName 组件名
1235
+ * @returns 成功返回 true,否则返回 false
1502
1236
  */
1503
- removeHotspot: () => Promise<void>;
1237
+ createDesktopShortcut: (widgetName: string) => Promise<boolean>;
1504
1238
  }
1505
1239
  /**
1506
- * SystemApiEvent
1240
+ * AiApiEvent
1507
1241
  */
1508
- declare enum MouseApiEvent {
1242
+ declare enum DeployedWidgetApiEvent {
1509
1243
  /**
1510
- * Triggered when the mouse enters the hotspot area.
1244
+ * 第二实例启动事件
1511
1245
  */
1512
- HOTSPOT_ACTIVE = "event::cn.widgetjs.core.mouse.hotspot.active"
1246
+ SECOND_INSTANCE = "channel::cn.widgetjs.core.deployed_widget.second_instance"
1513
1247
  }
1514
- type MouseApiMethods = keyof IMouseApi;
1515
1248
 
1516
1249
  /**
1517
1250
  * @see https://electronjs.org/docs/api/structures/size
@@ -1670,6 +1403,22 @@ interface IDeviceApi {
1670
1403
  isCapsLockOn: () => Promise<boolean>;
1671
1404
  }
1672
1405
 
1406
+ /**
1407
+ * DialogApi 提供文件、文件夹选择功能
1408
+ */
1409
+ interface IDialogApi {
1410
+ /**
1411
+ * 选取单个文件
1412
+ * @param extensions 允许的文件后缀格式,如:["txt","docx","gif"]
1413
+ */
1414
+ pickFile: (extensions?: string[]) => Promise<string | undefined>;
1415
+ /**
1416
+ * 选取文件夹
1417
+ */
1418
+ pickFolder: () => Promise<string | undefined>;
1419
+ }
1420
+ type DialogApiMethods = keyof IDialogApi;
1421
+
1673
1422
  interface Metadata {
1674
1423
  /** Number value of the EXIF Orientation header, if present */
1675
1424
  orientation?: number | undefined;
@@ -2834,13 +2583,68 @@ interface IFileApi {
2834
2583
  *
2835
2584
  * @param path
2836
2585
  */
2837
- openPath: (path: string) => Promise<void>;
2586
+ openPath: (path: string) => Promise<void>;
2587
+ /**
2588
+ *
2589
+ * @param path path to the item to be moved to the trash.
2590
+ */
2591
+ trashItem: (path: string) => Promise<void>;
2592
+ }
2593
+
2594
+ /**
2595
+ * LogApi提供了日志输出的方法,日志会保存在用户的`当前用户名/文档/桌面组件/logs/日期/组件包名.log`文件中
2596
+ */
2597
+ interface ILogApi {
2598
+ info: (...data: any[]) => void;
2599
+ error: (...data: any[]) => void;
2600
+ warn: (...data: any[]) => void;
2601
+ log: (...data: any[]) => void;
2602
+ json: (data: any) => void;
2603
+ }
2604
+ type LogApiMethods = keyof ILogApi;
2605
+
2606
+ /**
2607
+ * MouseApi
2608
+ */
2609
+ interface IMouseApi {
2610
+ /**
2611
+ * Create a mouse screen edge hotspot, usually used for edge-hiding windows.
2612
+ * @param rect
2613
+ */
2614
+ createHotspot: (rect: Rectangle) => Promise<void>;
2615
+ /**
2616
+ * Remove the mouse screen edge hotspot.
2617
+ */
2618
+ removeHotspot: () => Promise<void>;
2619
+ }
2620
+ /**
2621
+ * SystemApiEvent
2622
+ */
2623
+ declare enum MouseApiEvent {
2624
+ /**
2625
+ * Triggered when the mouse enters the hotspot area.
2626
+ */
2627
+ HOTSPOT_ACTIVE = "event::cn.widgetjs.core.mouse.hotspot.active"
2628
+ }
2629
+ type MouseApiMethods = keyof IMouseApi;
2630
+
2631
+ /**
2632
+ * ProcessApi 提供进程信息获取功能
2633
+ */
2634
+ interface IProcessApi {
2635
+ getBlinkMemoryInfo: () => Promise<Electron.BlinkMemoryInfo>;
2636
+ getHeapStatistics: () => Promise<Electron.HeapStatistics>;
2637
+ /**
2638
+ * 获取系统版本信息
2639
+ * @example '10.0.17763'
2640
+ */
2641
+ getSystemVersion: () => Promise<string>;
2838
2642
  /**
2839
- *
2840
- * @param path path to the item to be moved to the trash.
2643
+ * 获取当前应用内存信息
2841
2644
  */
2842
- trashItem: (path: string) => Promise<void>;
2645
+ getProcessMemoryInfo: () => Promise<Electron.ProcessMemoryInfo>;
2843
2646
  }
2647
+ type ProcessApiMethods = keyof IProcessApi;
2844
2648
 
2845
2649
  /**
2846
2650
  * MenuApi 接口定义了一系列用于控制窗口的方法,这些方法提供了窗口的显示、隐藏、移动、调整大小等功能
@@ -2966,776 +2770,1044 @@ interface DisplayBalloonOptions {
2966
2770
  /**
2967
2771
  * Do not play the associated sound. Default is `false`. Maps to `NIIF_NOSOUND`.
2968
2772
  */
2969
- noSound?: boolean;
2773
+ noSound?: boolean;
2774
+ /**
2775
+ * Do not display the balloon notification if the current user is in "quiet time".
2776
+ * Default is `false`. Maps to `NIIF_RESPECT_QUIET_TIME`.
2777
+ */
2778
+ respectQuietTime?: boolean;
2779
+ }
2780
+ /**
2781
+ * ITrayApi
2782
+ *
2783
+ * API for interacting with the native system tray / status bar icon.
2784
+ * All methods return a Promise and should be awaited in callers where timing matters.
2785
+ */
2786
+ interface ITrayApi {
2787
+ /**
2788
+ * Create or update the tray icon with given options.
2789
+ * Resolves once the native tray object is created/updated.
2790
+ * @param options AddTrayOptions - image and optional tooltip
2791
+ */
2792
+ setTray: (options: AddTrayOptions) => Promise<void>;
2793
+ /**
2794
+ * Remove the tray icon and free native resources.
2795
+ * Resolves when the tray has been removed.
2796
+ */
2797
+ removeTray: () => Promise<void>;
2798
+ /**
2799
+ * Displays a balloon notification.
2800
+ * @param options DisplayBalloonOptions
2801
+ */
2802
+ displayBalloon: (options: DisplayBalloonOptions) => Promise<void>;
2803
+ /**
2804
+ * Removes a balloon notification.
2805
+ */
2806
+ removeBalloon: () => Promise<void>;
2807
+ /**
2808
+ * Set the context menu for the tray icon.
2809
+ * Replaces any previously set menu.
2810
+ * @param menus Array of WidgetMenuItem describing the menu structure
2811
+ */
2812
+ setContextMenu: (menus: WidgetMenuItem[]) => Promise<void>;
2813
+ /**
2814
+ * Close any open context menu for the tray (if supported by the platform).
2815
+ */
2816
+ closeContextMenu: () => Promise<void>;
2817
+ /**
2818
+ * Programmatically pop up a context menu at the optional screen position.
2819
+ * On some platforms the position may be ignored.
2820
+ * @param menus menu items to show
2821
+ * @param position optional screen point where the menu should appear
2822
+ */
2823
+ popUpContextMenu: (menus: WidgetMenuItem[], position?: Point) => Promise<void>;
2824
+ /**
2825
+ * Returns whether the underlying native tray object has been destroyed.
2826
+ * Useful to check before calling other tray methods.
2827
+ */
2828
+ isDestroyed: () => Promise<boolean>;
2829
+ /**
2830
+ * Get the bounds of the tray icon on screen.
2831
+ * Returns a Rectangle when available, or `null` if the bounds cannot be determined
2832
+ * on the current platform or if the tray is not present.
2833
+ */
2834
+ getBounds: () => Promise<Rectangle | null>;
2835
+ /**
2836
+ * Bring the application to the foreground or focus the window associated with the tray.
2837
+ * Exact behavior depends on platform and application window state.
2838
+ */
2839
+ focus: () => Promise<void>;
2840
+ }
2841
+ /**
2842
+ * TrayApiEvent
2843
+ *
2844
+ * Events emitted from the tray icon. Channels are stable strings used for internal
2845
+ * event routing; subscribers should listen to these channels to react to user
2846
+ * interactions with the tray icon.
2847
+ */
2848
+ declare enum TrayApiEvent {
2849
+ /**
2850
+ * Emitted when the tray icon is clicked (usually left-button click).
2851
+ * Channel: 'channel::cn.widgetjs.core.tray.click'
2852
+ */
2853
+ CLICK = "channel::cn.widgetjs.core.tray.click",
2854
+ /**
2855
+ * Emitted when the tray icon receives a right-button click.
2856
+ * Channel: 'channel::cn.widgetjs.core.tray.right-click'
2857
+ */
2858
+ RIGHT_CLICK = "channel::cn.widgetjs.core.tray.right-click",
2859
+ /**
2860
+ * Emitted when the tray icon receives a middle-button click (if supported).
2861
+ * Channel: 'channel::cn.widgetjs.core.tray.middle-click'
2862
+ */
2863
+ MIDDLE_CLICK = "channel::cn.widgetjs.core.tray.middle-click",
2864
+ /**
2865
+ * Emitted when the mouse pointer enters the tray icon area (hover start).
2866
+ * Channel: 'channel::cn.widgetjs.core.tray.mouse-enter'
2867
+ */
2868
+ MOUSE_ENTER = "channel::cn.widgetjs.core.tray.mouse-enter",
2869
+ /**
2870
+ * Emitted when the mouse pointer leaves the tray icon area (hover end).
2871
+ * Channel: 'channel::cn.widgetjs.core.tray.mouse-leave'
2872
+ */
2873
+ MOUSE_LEAVE = "channel::cn.widgetjs.core.tray.mouse-leave"
2874
+ }
2875
+ type TrayApiMethods = keyof ITrayApi;
2876
+
2877
+ interface IUserApi {
2878
+ /**
2879
+ * Login with user info.
2880
+ * @param token
2881
+ */
2882
+ login: (session: AuthSession) => Promise<void>;
2883
+ /**
2884
+ * Clear user auth token and user info.
2885
+ */
2886
+ logout: () => Promise<void>;
2887
+ /**
2888
+ * Get current logged in user info. If no user is logged in, return null.
2889
+ */
2890
+ getUser: () => Promise<AuthUser | null>;
2891
+ updateSession: (session: AuthSession) => Promise<void>;
2892
+ getSession: () => Promise<AuthSession | null>;
2893
+ updateUser: (user: AuthUser) => Promise<void>;
2894
+ }
2895
+ /**
2896
+ * ShortcutApiEvent
2897
+ */
2898
+ declare enum UserApiEvent {
2899
+ /**
2900
+ * 快捷键触发事件
2901
+ */
2902
+ USER_UPDATED = "channel::cn.widgetjs.core.user.updated",
2903
+ SIGNED_OUT = "channel::cn.widgetjs.core.user.signed.out",
2904
+ SIGNED_IN = "channel::cn.widgetjs.core.user.signed.in",
2905
+ TOKEN_REFRESHED = "channel::cn.widgetjs.core.user.token.refreshed"
2906
+ }
2907
+ type UserApiMethods = keyof IUserApi;
2908
+
2909
+ /**
2910
+ * WidgetPackageApi 提供了组件包的升级、获取、安装等功能
2911
+ */
2912
+ interface IWidgetPackageApi {
2913
+ /**
2914
+ * 升级组件包
2915
+ * @param packageName 组件包名称
2916
+ * @param remoteUrlInfo
2917
+ */
2918
+ upgrade: (packageName: string, remoteUrlInfo: RemotePackageUrlInfo) => Promise<void>;
2919
+ /**
2920
+ * 获取组件包的首页url信息
2921
+ * @param packageName
2922
+ */
2923
+ getIndexUrl: (packageName: string) => Promise<string | null>;
2924
+ /**
2925
+ * 获取组件包入口url信息
2926
+ * @param packageName
2927
+ */
2928
+ getEntryUrl: (packageName: string) => Promise<string | null>;
2929
+ /**
2930
+ * 通过包名获取组件包信息
2931
+ * @param name
2932
+ */
2933
+ getPackage: (name: string) => Promise<WidgetPackage | undefined>;
2934
+ /**
2935
+ * 获取已经安装的组件包
2936
+ */
2937
+ getPackages: () => Promise<WidgetPackage[]>;
2938
+ /**
2939
+ * Install a widget package, if the package is a string, it will be treated as a path or http url to install the widget.zip file.
2940
+ * @param widgetPackage
2941
+ */
2942
+ install: (widgetPackage: WidgetPackage | string) => Promise<void>;
2943
+ /**
2944
+ * Uninstall a widget package by package name.
2945
+ * @param packageName
2946
+ * @param clearData Whether to clear the data of the widget package, default is false.
2947
+ */
2948
+ uninstall: (widgetPackage: WidgetPackage | string, clearData?: boolean) => Promise<void>;
2949
+ }
2950
+ type WidgetPackageApiMethods = keyof IWidgetPackageApi;
2951
+ /**
2952
+ * WidgetPackageApiEvent
2953
+ */
2954
+ declare enum WidgetPackageApiEvent {
2955
+ /**
2956
+ * 组件包升级事件
2957
+ */
2958
+ PACKAGE_UPGRADE = "event::cn.widgetjs.core.widget.package.upgraded",
2959
+ /**
2960
+ * 组件包安装事件
2961
+ */
2962
+ PACKAGE_INSTALLED = "event::cn.widgetjs.core.widget.package.installed"
2963
+ }
2964
+
2965
+ declare const AppApi: IAppApi;
2966
+
2967
+ /**
2968
+ * WidgetApi 接口定义了一系列用于控制组件的方法,这些方法提供了组件的注册、升级、获取、打开设置页面、重新加载等功能
2969
+ */
2970
+ interface IWidgetApi {
2971
+ /**
2972
+ * 注册组件
2973
+ * @param widgets
2974
+ */
2975
+ registerWidgets: (widgets: Widget[]) => Promise<void>;
2976
+ /**
2977
+ * @deprecated
2978
+ */
2979
+ registerWidgetPackage: (widgetPackage: WidgetPackage) => Promise<void>;
2980
+ /**
2981
+ * ignore mouse events
2982
+ * @param widgetId
2983
+ * @param ignore
2984
+ */
2985
+ setIgnoreMouseEvents: (widgetId: string, ignore: boolean) => Promise<void>;
2986
+ /**
2987
+ * Check if the widget is ignoring mouse events.
2988
+ * @param widgetId
2989
+ */
2990
+ isIgnoreMouseEvents: (widgetId?: string) => Promise<boolean>;
2991
+ /**
2992
+ * 设置组件是否可以左键拖动
2993
+ * @param draggable boolean true-启用左键拖动 false-禁用左键拖动
2994
+ * @remarks 注意:只对悬浮窗组件(DeployMode.OVERLAP)有效
2995
+ */
2996
+ setMouseDraggable: (draggable: boolean) => Promise<void>;
2997
+ /**
2998
+ * 升级组件包
2999
+ * @param packageName 组件包名
3000
+ */
3001
+ upgradePackage: (packageName: string) => Promise<void>;
3002
+ /**
3003
+ * 获取所有组件
3004
+ * @return Promise<Widget[]>
3005
+ */
3006
+ getWidgets: () => Promise<Widget[]>;
3007
+ /**
3008
+ * 通过组件名称获取组件
3009
+ * @param name string 组件名
3010
+ * @return Promise<Widget>
3011
+ */
3012
+ getWidget: (name: string) => Promise<Widget>;
3013
+ /**
3014
+ * @param name
3015
+ * @deprecated
3016
+ */
3017
+ getWidgetPackage: (name: string) => Promise<WidgetPackage | undefined>;
3018
+ /**
3019
+ * @deprecated
3020
+ */
3021
+ getWidgetPackages: () => Promise<WidgetPackage[]>;
2970
3022
  /**
2971
- * Do not display the balloon notification if the current user is in "quiet time".
2972
- * Default is `false`. Maps to `NIIF_RESPECT_QUIET_TIME`.
3023
+ * 打开组件设置页面
3024
+ * @param id string 组件id
2973
3025
  */
2974
- respectQuietTime?: boolean;
2975
- }
2976
- /**
2977
- * ITrayApi
2978
- *
2979
- * API for interacting with the native system tray / status bar icon.
2980
- * All methods return a Promise and should be awaited in callers where timing matters.
2981
- */
2982
- interface ITrayApi {
3026
+ openConfigPage: (id?: string) => Promise<void>;
2983
3027
  /**
2984
- * Create or update the tray icon with given options.
2985
- * Resolves once the native tray object is created/updated.
2986
- * @param options AddTrayOptions - image and optional tooltip
3028
+ * @param name
2987
3029
  */
2988
- setTray: (options: AddTrayOptions) => Promise<void>;
3030
+ openConfigPageByName: (name: string) => Promise<void>;
2989
3031
  /**
2990
- * Remove the tray icon and free native resources.
2991
- * Resolves when the tray has been removed.
3032
+ * 重新加载组件
2992
3033
  */
2993
- removeTray: () => Promise<void>;
3034
+ reload: (id?: string) => Promise<void>;
2994
3035
  /**
2995
- * Displays a balloon notification.
2996
- * @param options DisplayBalloonOptions
3036
+ *
3037
+ * @param packageName
3038
+ * @deprecated
2997
3039
  */
2998
- displayBalloon: (options: DisplayBalloonOptions) => Promise<void>;
3040
+ getWidgetPackageUrl: (packageName: string) => Promise<string | null>;
3041
+ restartWidgets: (mode?: DeployMode) => Promise<void>;
3042
+ updateSyncInfo: () => Promise<void>;
3043
+ getSyncInfo: (widgetName?: string) => Promise<WidgetSyncInfo | null>;
3044
+ }
3045
+
3046
+ interface LocalPackageUrlInfo {
2999
3047
  /**
3000
- * Removes a balloon notification.
3048
+ * 入口文件,默认为index.html,也可以是/
3049
+ * @example remote package: https://rtugeek.gitee.io/hotspot/index.html
3050
+ * @example local package: index.html
3051
+ * @deprecated use entryFile instead
3001
3052
  */
3002
- removeBalloon: () => Promise<void>;
3053
+ entry?: string;
3003
3054
  /**
3004
- * Set the context menu for the tray icon.
3005
- * Replaces any previously set menu.
3006
- * @param menus Array of WidgetMenuItem describing the menu structure
3055
+ * 需以 / 开头
3056
+ * @example /index.html
3007
3057
  */
3008
- setContextMenu: (menus: WidgetMenuItem[]) => Promise<void>;
3058
+ entryFile?: string;
3009
3059
  /**
3010
- * Close any open context menu for the tray (if supported by the platform).
3060
+ * 是否使用hash路由
3011
3061
  */
3012
- closeContextMenu: () => Promise<void>;
3062
+ hash?: boolean;
3063
+ }
3064
+ interface RemotePackageUrlInfo extends LocalPackageUrlInfo {
3013
3065
  /**
3014
- * Programmatically pop up a context menu at the optional screen position.
3015
- * On some platforms the position may be ignored.
3016
- * @param menus menu items to show
3017
- * @param position optional screen point where the menu should appear
3066
+ * 部署到服务器的base path,只在远程组件包中生效,需以/开始
3067
+ * @example /hotspot
3018
3068
  */
3019
- popUpContextMenu: (menus: WidgetMenuItem[], position?: Point) => Promise<void>;
3069
+ base?: string;
3020
3070
  /**
3021
- * Returns whether the underlying native tray object has been destroyed.
3022
- * Useful to check before calling other tray methods.
3071
+ * 域名地址,不带协议
3072
+ * @example widgetjs.cn
3023
3073
  */
3024
- isDestroyed: () => Promise<boolean>;
3074
+ hostname: string;
3075
+ }
3076
+ interface WidgetPackageOptions extends LocalPackageUrlInfo {
3077
+ name: string;
3078
+ version?: string;
3079
+ author: string;
3080
+ homepage?: string;
3081
+ title: LanguageTextMap;
3082
+ permissions?: WidgetPermission[];
3083
+ description: LanguageTextMap;
3084
+ zipUrl?: string;
3025
3085
  /**
3026
- * Get the bounds of the tray icon on screen.
3027
- * Returns a Rectangle when available, or `null` if the bounds cannot be determined
3028
- * on the current platform or if the tray is not present.
3086
+ * 远程组件包入口文件
3087
+ * @deprecated
3029
3088
  */
3030
- getBounds: () => Promise<Rectangle | null>;
3089
+ remoteEntry?: string;
3031
3090
  /**
3032
- * Bring the application to the foreground or focus the window associated with the tray.
3033
- * Exact behavior depends on platform and application window state.
3091
+ * @deprecated
3034
3092
  */
3035
- focus: () => Promise<void>;
3036
- }
3037
- /**
3038
- * TrayApiEvent
3039
- *
3040
- * Events emitted from the tray icon. Channels are stable strings used for internal
3041
- * event routing; subscribers should listen to these channels to react to user
3042
- * interactions with the tray icon.
3043
- */
3044
- declare enum TrayApiEvent {
3093
+ remotePackage?: string;
3094
+ remote?: RemotePackageUrlInfo;
3095
+ icon?: string;
3096
+ lang?: LanguageCode;
3097
+ widgets?: Widget[];
3045
3098
  /**
3046
- * Emitted when the tray icon is clicked (usually left-button click).
3047
- * Channel: 'channel::cn.widgetjs.core.tray.click'
3099
+ * 是否处于开发模式
3048
3100
  */
3049
- CLICK = "channel::cn.widgetjs.core.tray.click",
3101
+ development?: boolean;
3102
+ devOptions?: DevOptions;
3103
+ requiredAppVersion?: string;
3050
3104
  /**
3051
- * Emitted when the tray icon receives a right-button click.
3052
- * Channel: 'channel::cn.widgetjs.core.tray.right-click'
3105
+ * social links, generally used for tutorial links or source code
3053
3106
  */
3054
- RIGHT_CLICK = "channel::cn.widgetjs.core.tray.right-click",
3107
+ socialLinks?: SocialLink[];
3108
+ }
3109
+ declare class WidgetPackage implements Omit<RemotePackageUrlInfo, 'hostname'> {
3055
3110
  /**
3056
- * Emitted when the tray icon receives a middle-button click (if supported).
3057
- * Channel: 'channel::cn.widgetjs.core.tray.middle-click'
3111
+ * 组件包名,一般为域名倒写,e.g. com.example
3058
3112
  */
3059
- MIDDLE_CLICK = "channel::cn.widgetjs.core.tray.middle-click",
3113
+ readonly name: string;
3060
3114
  /**
3061
- * Emitted when the mouse pointer enters the tray icon area (hover start).
3062
- * Channel: 'channel::cn.widgetjs.core.tray.mouse-enter'
3115
+ * 组件包版本,可以为空,默认采用package.json里的版本
3116
+ * e.g. 1.0.2
3063
3117
  */
3064
- MOUSE_ENTER = "channel::cn.widgetjs.core.tray.mouse-enter",
3118
+ version?: string;
3065
3119
  /**
3066
- * Emitted when the mouse pointer leaves the tray icon area (hover end).
3067
- * Channel: 'channel::cn.widgetjs.core.tray.mouse-leave'
3120
+ * 组件包所需的App版本
3068
3121
  */
3069
- MOUSE_LEAVE = "channel::cn.widgetjs.core.tray.mouse-leave"
3070
- }
3071
- type TrayApiMethods = keyof ITrayApi;
3072
-
3073
- interface IUserApi {
3122
+ requiredAppVersion?: string;
3074
3123
  /**
3075
- * Login with user info.
3076
- * @param token
3124
+ * 组件作者署名
3077
3125
  */
3078
- login: (session: AuthSession) => Promise<void>;
3126
+ readonly author: string;
3127
+ development?: boolean;
3079
3128
  /**
3080
- * Clear user auth token and user info.
3129
+ * 组件首页
3081
3130
  */
3082
- logout: () => Promise<void>;
3131
+ readonly homepage?: string;
3083
3132
  /**
3084
- * Get current logged in user info. If no user is logged in, return null.
3133
+ * 组件描述
3085
3134
  */
3086
- getUser: () => Promise<AuthUser | null>;
3087
- updateSession: (session: AuthSession) => Promise<void>;
3088
- getSession: () => Promise<AuthSession | null>;
3089
- updateUser: (user: AuthUser) => Promise<void>;
3090
- }
3091
- /**
3092
- * ShortcutApiEvent
3093
- */
3094
- declare enum UserApiEvent {
3135
+ readonly title: {
3136
+ [key: LanguageCode | string]: string;
3137
+ };
3095
3138
  /**
3096
- * 快捷键触发事件
3139
+ * 组件描述
3097
3140
  */
3098
- USER_UPDATED = "channel::cn.widgetjs.core.user.updated",
3099
- SIGNED_OUT = "channel::cn.widgetjs.core.user.signed.out",
3100
- SIGNED_IN = "channel::cn.widgetjs.core.user.signed.in",
3101
- TOKEN_REFRESHED = "channel::cn.widgetjs.core.user.token.refreshed"
3102
- }
3103
- type UserApiMethods = keyof IUserApi;
3104
-
3105
- interface AiConfig {
3106
- id: string;
3107
- model: string;
3108
- apiKey: string;
3109
- apiBaseUrl: string;
3110
- }
3111
- interface IAiApi {
3112
- addConfig(config: AiConfig): Promise<AiConfig>;
3113
- deleteConfig(id: string): Promise<void>;
3114
- updateConfig(config: AiConfig): Promise<void>;
3115
- getConfigList(): Promise<AiConfig[]>;
3116
- setConfigList(configs: AiConfig[]): Promise<void>;
3117
- getConfig(id: string): Promise<AiConfig | undefined>;
3118
- }
3119
- /**
3120
- * AiApiEvent
3121
- */
3122
- declare enum AiApiEvent {
3141
+ readonly description: {
3142
+ [key: LanguageCode | string]: string;
3143
+ };
3123
3144
  /**
3124
- * 配置更新事件
3145
+ * 本地组件入口文件,通常为 index.html
3125
3146
  */
3126
- CONFIG_UPDATED = "channel::cn.widgetjs.core.ai.config.updated"
3127
- }
3128
- type AiApiMethods = keyof IAiApi;
3129
-
3130
- type DeviceApiMethods = keyof IDeviceApi;
3131
- declare const DeviceApi: IDeviceApi;
3132
-
3133
- declare enum Channel {
3134
- NOTIFICATION = "channel::cn.widgetjs.core.notification",
3135
- BROWSER_WINDOW = "channel::cn.widgetjs.core.browser_window",
3136
- BROADCAST = "channel::cn.widgetjs.core.broadcast",
3137
- WIDGET = "channel::cn.widgetjs.core.widget",
3138
- WIDGET_PACKAGE = "channel::cn.widgetjs.core.widget.package",
3139
- DEPLOYED_WIDGET = "channel::cn.widgetjs.core.deployed_widget",
3140
- APP = "channel::cn.widgetjs.core.app",
3141
- SYSTEM = "channel::cn.widgetjs.core.system",
3142
- DIALOG = "channel::cn.widgetjs.core.dialog",
3143
- HTTP = "channel::cn.widgetjs.core.http",
3144
- CLIPBOARD = "channel::cn.widgetjs.core.clipboard",
3145
- FILE = "channel::cn.widgetjs.core.file",
3146
- SCREEN = "channel::cn.widgetjs.core.screen",
3147
- MENU = "channel::cn.widgetjs.core.menu",
3148
- SHORTCUT = "channel::cn.widgetjs.core.shortcut",
3149
- LOG = "channel::cn.widgetjs.core.log",
3150
- DEVICE = "channel::cn.widgetjs.core.device",
3151
- MOUSE = "channel::cn.widgetjs.core.mouse",
3152
- KEYBOARD = "channel::cn.widgetjs.core.keyboard",
3147
+ entry: string | 'index.html';
3153
3148
  /**
3149
+ * 远程组件包入口文件
3154
3150
  * @deprecated
3155
3151
  */
3156
- STORE = "channel::cn.widgetjs.core.store",
3157
- STORAGE = "channel::cn.widgetjs.core.storage",
3158
- PROCESS = "channel::cn.widgetjs.core.process",
3159
- USER = "channel::cn.widgetjs.core.user",
3160
- TRAY = "channel::cn.widgetjs.core.tray",
3161
- AI = "channel::cn.widgetjs.core.ai"
3162
- }
3163
-
3164
- interface IClipboardApi {
3165
- getSelectedText(): Promise<string | undefined>;
3166
- getText(): Promise<string | undefined>;
3167
- writeText(text: string): Promise<void>;
3168
- }
3169
- type ClipboardApiMethods = keyof IClipboardApi;
3170
- declare enum ClipboardApiEvent {
3171
- CHANGED = "clipboard-changed"
3172
- }
3173
- declare const ClipboardApi: IClipboardApi;
3174
-
3175
- type WidgetPermission = 'keyboard' | 'mouse' | 'clipboard' | 'notification' | 'storage' | 'network' | 'cpu' | 'system-info';
3176
-
3177
- interface MetaInfo {
3178
- [key: string]: string | number | boolean;
3179
- }
3180
- interface IWindowSize {
3181
- width: number;
3182
- height: number;
3183
- maxWidth?: number;
3184
- maxHeight?: number;
3185
- minWidth?: number;
3186
- minHeight?: number;
3187
- }
3188
- interface IPageOptions extends IWindowSize {
3189
- name: string;
3152
+ remoteEntry?: string;
3190
3153
  /**
3191
- * 当showInSearch为true时,此项必填
3154
+ * 组件包json文件路径
3155
+ * @deprecated
3156
+ * @example https://rtugeek.gitee.io/hotspot/widget.json
3192
3157
  */
3193
- title: LanguageTextMap;
3158
+ readonly remotePackage?: string;
3159
+ readonly local?: LocalPackageUrlInfo;
3160
+ readonly remote?: RemotePackageUrlInfo;
3194
3161
  /**
3195
- * 当showInSearch为true时,此项必填
3162
+ * zip package url, used for downloading the package
3196
3163
  */
3197
- description?: LanguageTextMap;
3164
+ zipUrl?: string;
3198
3165
  /**
3199
- * 当showInSearch为true时,此项必填
3166
+ * 组件包图标
3200
3167
  */
3201
- keywords?: WidgetKeyword[];
3202
- lang: LanguageCode;
3203
- packageName?: string;
3204
- icon?: string;
3168
+ readonly icon?: string;
3205
3169
  /**
3206
- * 当showInSearch为true时,此项必填
3170
+ * Hash路由模式,默认为true
3207
3171
  */
3208
- previewImage?: string;
3172
+ readonly hash: boolean;
3209
3173
  /**
3210
- * 是否在搜索中显示
3174
+ * 可能是网络地址,或者本地路径(解压后的文件夹路径),
3175
+ * 网络地址:https://www.bilibili.com
3176
+ * 本地地址:file:///C:/Users/neo/Desktop
3177
+ * 在测试时。地址通常为: http://127.0.0.1:8080
3211
3178
  */
3212
- showInSearch?: boolean;
3179
+ url: string;
3180
+ readonly widgets: Widget[];
3181
+ readonly pages: Page[];
3182
+ devOptions?: DevOptions;
3183
+ constructor(options: WidgetPackageOptions);
3184
+ static parseJSON(json: string): WidgetPackage;
3185
+ static parseObject(obj: any): WidgetPackage;
3213
3186
  /**
3214
- * 悬浮窗模式 是否可移动
3215
- * @deprecated
3187
+ * 获取组件包标题
3188
+ * @param lang 语言环境,不传则获取默认语言
3216
3189
  */
3217
- movable?: boolean;
3190
+ getTitle(lang?: LanguageCode): string | undefined;
3218
3191
  /**
3219
- * @deprecated
3192
+ * 获取组件包描述
3193
+ * @param lang 语言环境,不传则获取默认标题
3220
3194
  */
3221
- resizable?: boolean;
3195
+ getDescription(lang?: LanguageCode): string | undefined;
3196
+ }
3197
+ interface DevOptions {
3198
+ folder?: string;
3199
+ route?: boolean;
3200
+ devUrl?: string;
3201
+ remoteEntry?: string;
3202
+ }
3203
+
3204
+ type WidgetApiMethods = keyof IWidgetApi;
3205
+ declare enum WidgetApiEvent {
3206
+ DATA_CHANGED = "event::cn.widgetjs.core.widget.data-changed",
3207
+ EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit",
3208
+ PACKAGE_UPGRADE = "event::cn.widgetjs.core.widget.package.upgraded",
3209
+ PACKAGE_INSTALLED = "event::cn.widgetjs.core.widget.package.installed"
3210
+ }
3211
+ declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidgetApi {
3212
+ getSyncInfo(widgetName?: string): Promise<WidgetSyncInfo | null>;
3213
+ updateSyncInfo(): Promise<void>;
3214
+ reload(id?: string): Promise<void>;
3215
+ getChannel(): string;
3216
+ registerWidgets(widgets: Widget[]): Promise<any>;
3217
+ registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
3218
+ getWidgets(): Promise<Widget[]>;
3219
+ openConfigPage(widgetId?: string): Promise<any>;
3220
+ openConfigPageByName(widgetName: string): Promise<any>;
3222
3221
  /**
3223
3222
  * @deprecated
3224
3223
  */
3225
- backgroundThrottling?: boolean;
3226
- security?: boolean;
3224
+ getWidgetPackages(): Promise<WidgetPackage[]>;
3227
3225
  /**
3228
- * @deprecated
3226
+ *
3227
+ * @param name package name
3229
3228
  */
3230
- webviewTag?: boolean;
3231
- path: string;
3229
+ getWidget(name: string): Promise<Widget>;
3232
3230
  /**
3233
- * 是否只能添加一次
3231
+ * @param name package name
3232
+ * @deprecated
3234
3233
  */
3235
- singleton?: boolean;
3236
- permissions?: WidgetPermission[];
3237
- meta?: MetaInfo;
3238
- broadcastChannels?: string[];
3239
- }
3240
- interface IPage {
3241
- readonly name: string;
3234
+ getWidgetPackage(name: string): Promise<WidgetPackage | undefined>;
3235
+ getWidgetPackageUrl(packageName: string): Promise<string | null>;
3236
+ upgradePackage(packageName: string): Promise<void>;
3242
3237
  /**
3243
- * 窗口标题,显示在界面上的,
3244
- * https://zh.m.wikipedia.org/zh-hans/ISO_639-1
3238
+ * 阻止拖动窗口,只能用于悬浮窗口 DeployMode.OVERLAP
3239
+ * @param draggable
3245
3240
  */
3246
- readonly title: LanguageTextMap;
3247
- readonly permissions: WidgetPermission[];
3248
- readonly webviewTag: boolean;
3241
+ setMouseDraggable(draggable: boolean): Promise<void>;
3242
+ isIgnoreMouseEvents(widgetId: string | undefined): Promise<boolean>;
3243
+ setIgnoreMouseEvents(widgetId: string, ignore: boolean): Promise<void>;
3244
+ restartWidgets(mode?: DeployMode): Promise<void>;
3245
+ }
3246
+ declare const WidgetApi: WidgetApiImpl;
3247
+
3248
+ /**
3249
+ * ShortcutApi 提供了注册快捷键的能力,当快捷键被触发时,会发送广播事件 {@link BroadcastEvent}
3250
+ */
3251
+ interface IShortcutApi {
3249
3252
  /**
3250
- * 窗口介绍
3253
+ * 注册快捷键, 如果注册成功, 触发快捷键时,会发送广播事件 {@link BroadcastEvent}
3254
+ * @see [Electron Accelerator](https://www.electronjs.org/docs/latest/api/accelerator)
3255
+ * @param shortcut string
3256
+ * @return Promise<boolean> true 注册成功,false 注册失败
3257
+ * @example
3258
+ * ```typescript
3259
+ * //Meta 通常为windows键
3260
+ * ShortcutApi.register('Ctrl+Meta+Y')
3261
+ * ```
3251
3262
  */
3252
- readonly description: LanguageTextMap;
3253
- readonly keywords: WidgetKeyword[];
3263
+ register: (shortcut: string) => Promise<boolean>;
3254
3264
  /**
3255
- * 组件默认语言
3265
+ * 注销快捷键
3266
+ * @param shortcut string
3267
+ * @example
3268
+ * ```typescript
3269
+ * //Meta 通常为windows键
3270
+ * ShortcutApi.unregister('Ctrl+Meta+Y')
3271
+ * ```
3256
3272
  */
3257
- readonly lang: LanguageCode;
3258
- readonly width: number;
3259
- packageName?: string | null;
3260
- readonly height: number;
3261
- readonly maxWidth: number;
3262
- readonly maxHeight: number;
3263
- readonly minWidth: number;
3264
- readonly minHeight: number;
3265
- readonly movable: boolean;
3266
- readonly singleton: boolean;
3267
- readonly resizable: boolean;
3268
- readonly path: string;
3269
- readonly meta: {
3270
- [key: string]: string | number | boolean;
3271
- };
3272
- readonly backgroundThrottling: boolean;
3273
+ unregister: (shortcut: string) => void;
3274
+ }
3275
+ /**
3276
+ * ShortcutApiEvent
3277
+ */
3278
+ declare enum ShortcutApiEvent {
3273
3279
  /**
3274
- * 预览图片,可以是GIF
3280
+ * 快捷键触发事件
3275
3281
  */
3276
- readonly previewImage?: string;
3282
+ TRIGGERED = "channel::cn.widgetjs.core.shortcut.triggered"
3277
3283
  }
3278
- declare class Page implements IPage {
3284
+
3285
+ type ShortcutApiMethods = keyof IShortcutApi;
3286
+ declare const ShortcutApi: IShortcutApi;
3287
+
3288
+ interface IClipboardApi {
3289
+ getSelectedText(): Promise<string | undefined>;
3290
+ getText(): Promise<string | undefined>;
3291
+ writeText(text: string): Promise<void>;
3292
+ }
3293
+ type ClipboardApiMethods = keyof IClipboardApi;
3294
+ declare enum ClipboardApiEvent {
3295
+ CHANGED = "clipboard-changed"
3296
+ }
3297
+ declare const ClipboardApi: IClipboardApi;
3298
+
3299
+ /**
3300
+ * BrowserWindowApi 接口定义了一系列用于控制窗口的方法,这些方法提供了窗口的显示、隐藏、移动、调整大小等功能
3301
+ * @remarks 注意:桌面类型组件不支持窗口移动、调整大小、最大化、最小化等操作
3302
+ */
3303
+ interface IBrowserWindowApi {
3279
3304
  /**
3280
- * 页面名称,名称必须以包名开头,如果以.开头,会自动加上包名<br>
3281
- * 假设包名为`example.com`,以下两种写法等价
3282
- * @example example.com.countdown
3283
- * @example .countdown
3305
+ * 设置是否忽略鼠标事件
3306
+ * @param ignore boolean
3284
3307
  */
3285
- name: string;
3308
+ setIgnoreMouseEvent: (ignore: boolean) => Promise<void>;
3286
3309
  /**
3287
- * 窗口标题,显示在界面上的,
3288
- * @see https://zh.m.wikipedia.org/zh-hans/ISO_639-1
3310
+ * 显示窗口
3289
3311
  */
3290
- readonly title: LanguageTextMap;
3312
+ show: () => Promise<void>;
3291
3313
  /**
3292
- * 窗口介绍
3314
+ * 设置窗口是否有阴影
3315
+ * @param hasShadow boolean
3293
3316
  */
3294
- readonly description: LanguageTextMap;
3295
- readonly keywords: WidgetKeyword[];
3296
- readonly security: boolean;
3297
- readonly permissions: WidgetPermission[];
3317
+ setHasShadow: (hasShadow: boolean) => Promise<void>;
3298
3318
  /**
3299
- * 组件默认语言
3319
+ * 隐藏窗口
3300
3320
  */
3301
- readonly lang: LanguageCode;
3302
- readonly width: number;
3303
- packageName?: string | null;
3304
- readonly height: number;
3305
- readonly maxWidth: number;
3321
+ hide: () => Promise<void>;
3306
3322
  /**
3307
- * @deprecated
3323
+ * 关闭窗口
3308
3324
  */
3309
- readonly webviewTag: boolean;
3310
- readonly maxHeight: number;
3311
- readonly minWidth: number;
3312
- readonly minHeight: number;
3313
- readonly movable: boolean;
3314
- readonly singleton: boolean;
3315
- readonly resizable: boolean;
3316
- readonly path: string;
3317
- readonly icon?: string;
3318
- readonly meta: MetaInfo;
3319
- readonly backgroundThrottling: boolean;
3325
+ close: () => Promise<void>;
3320
3326
  /**
3321
- * 预览图片,可以是GIF
3327
+ * 以不激活窗口的方式显示窗口
3322
3328
  */
3323
- readonly previewImage?: string;
3324
- constructor(options: IPageOptions);
3329
+ showInactive: () => Promise<void>;
3325
3330
  /**
3326
- * 获取组件标题
3327
- * @param lang 语言环境,不传则获取默认语言
3331
+ * 将窗口居中
3328
3332
  */
3329
- getTitle(lang?: LanguageCode): string | undefined;
3333
+ center: () => Promise<void>;
3330
3334
  /**
3331
- * 获取组件描述
3332
- * @param lang 语言环境,不传则获取默认标题
3335
+ * 最小化窗口
3333
3336
  */
3334
- getDescription(lang?: LanguageCode): string | undefined;
3335
- static parseJSON(json: string): Page;
3336
- static parseObject(obj: any): Page;
3337
- isResizable(): boolean;
3338
- }
3339
-
3340
- type SocialType = 'qq' | 'wechat' | 'qq-group' | 'discord' | 'telegram' | 'tiktok' | 'douyin' | 'youtube' | 'instagram' | 'twitter' | 'facebook' | 'kuaishou' | 'bilibili' | 'github' | 'email' | 'gitee' | 'homepage';
3341
- declare class SocialInfo {
3342
- content: string;
3343
- name: SocialType;
3344
- constructor(name: SocialType, content: string);
3345
- }
3346
- interface SocialLink {
3347
- name: SocialType;
3348
- link: string;
3349
- }
3350
-
3351
- interface LocalPackageUrlInfo {
3337
+ minimize: () => Promise<void>;
3352
3338
  /**
3353
- * 入口文件,默认为index.html,也可以是/
3354
- * @example remote package: https://rtugeek.gitee.io/hotspot/index.html
3355
- * @example local package: index.html
3356
- * @deprecated use entryFile instead
3339
+ * 还原窗口
3357
3340
  */
3358
- entry?: string;
3341
+ restore: () => Promise<void>;
3359
3342
  /**
3360
- * 需以 / 开头
3361
- * @example /index.html
3343
+ * 窗口是否最小后
3344
+ * @return Promise<boolean>
3362
3345
  */
3363
- entryFile?: string;
3346
+ isMinimized: () => Promise<boolean>;
3364
3347
  /**
3365
- * 是否使用hash路由
3348
+ * 检查窗口是否最大化
3349
+ * @return Promise<boolean>
3366
3350
  */
3367
- hash?: boolean;
3368
- }
3369
- interface RemotePackageUrlInfo extends LocalPackageUrlInfo {
3351
+ isMaximized: () => Promise<boolean>;
3370
3352
  /**
3371
- * 部署到服务器的base path,只在远程组件包中生效,需以/开始
3372
- * @example /hotspot
3353
+ * 检查窗口是否可见
3354
+ * @return Promise<boolean>
3373
3355
  */
3374
- base?: string;
3356
+ isVisible: () => Promise<boolean>;
3375
3357
  /**
3376
- * 域名地址,不带协议
3377
- * @example widgetjs.cn
3358
+ * 检查窗口是否可调整大小
3359
+ * @since 24.1.1-beta.6
3360
+ * @return Promise<boolean>
3378
3361
  */
3379
- hostname: string;
3380
- }
3381
- interface WidgetPackageOptions extends LocalPackageUrlInfo {
3382
- name: string;
3383
- version?: string;
3384
- author: string;
3385
- homepage?: string;
3386
- title: LanguageTextMap;
3387
- permissions?: WidgetPermission[];
3388
- description: LanguageTextMap;
3389
- zipUrl?: string;
3362
+ isResizable: () => Promise<boolean>;
3390
3363
  /**
3391
- * 远程组件包入口文件
3392
- * @deprecated
3364
+ * 最大化窗口
3393
3365
  */
3394
- remoteEntry?: string;
3366
+ maximize: () => Promise<void>;
3395
3367
  /**
3396
- * @deprecated
3368
+ * 停止拖动窗口
3397
3369
  */
3398
- remotePackage?: string;
3399
- remote?: RemotePackageUrlInfo;
3400
- icon?: string;
3401
- lang?: LanguageCode;
3402
- widgets?: Widget[];
3370
+ stopDraggingWindow: () => Promise<void>;
3403
3371
  /**
3404
- * 是否处于开发模式
3372
+ * 开始拖动窗口
3405
3373
  */
3406
- development?: boolean;
3407
- devOptions?: DevOptions;
3408
- requiredAppVersion?: string;
3374
+ startDraggingWindow: () => Promise<void>;
3409
3375
  /**
3410
- * social links, generally used for tutorial links or source code
3376
+ * 检查窗口是否正在拖动
3377
+ * @return Promise<boolean>
3411
3378
  */
3412
- socialLinks?: SocialLink[];
3413
- }
3414
- declare class WidgetPackage implements Omit<RemotePackageUrlInfo, 'hostname'> {
3379
+ isDraggingWindow: () => Promise<boolean>;
3415
3380
  /**
3416
- * 组件包名,一般为域名倒写,e.g. com.example
3381
+ * 设置窗口是否总在最前
3382
+ * @param alwaysOnTop boolean
3417
3383
  */
3418
- readonly name: string;
3384
+ setAlwaysOnTop: (alwaysOnTop: boolean) => Promise<void>;
3419
3385
  /**
3420
- * 组件包版本,可以为空,默认采用package.json里的版本
3421
- * e.g. 1.0.2
3386
+ * 检查窗口是否总在最前
3387
+ * @return Promise<boolean>
3422
3388
  */
3423
- version?: string;
3389
+ isAlwaysOnTop: () => Promise<boolean>;
3424
3390
  /**
3425
- * 组件包所需的App版本
3391
+ * 打开指定的 URL
3392
+ * @param url string 要打开的 URL
3393
+ * @param option OpenUrlOptions - 可选参数,用于配置 URL 打开的方式
3426
3394
  */
3427
- requiredAppVersion?: string;
3395
+ openUrl: (url: string, option?: BrowserWindowOptions) => Promise<void>;
3428
3396
  /**
3429
- * 组件作者署名
3397
+ * 将窗口置于最前
3430
3398
  */
3431
- readonly author: string;
3432
- development?: boolean;
3399
+ moveTop: () => Promise<void>;
3433
3400
  /**
3434
- * 组件首页
3401
+ * 取消最大化窗口
3435
3402
  */
3436
- readonly homepage?: string;
3403
+ unmaximize: () => Promise<void>;
3437
3404
  /**
3438
- * 组件描述
3405
+ * 重新加载窗口
3439
3406
  */
3440
- readonly title: {
3441
- [key: LanguageCode | string]: string;
3442
- };
3407
+ reload: () => Promise<void>;
3443
3408
  /**
3444
- * 组件描述
3409
+ * 设置窗口大小
3410
+ * @param width boolean - 窗口宽度
3411
+ * @param height boolean - 窗口高度
3412
+ * @param animate boolean - 是否使用动画(可选)
3445
3413
  */
3446
- readonly description: {
3447
- [key: LanguageCode | string]: string;
3448
- };
3414
+ setSize: (width: number, height: number, animate?: boolean) => Promise<void>;
3449
3415
  /**
3450
- * 本地组件入口文件,通常为 index.html
3416
+ * 获取窗口大小
3417
+ * @since 24.1.1-beta.6
3418
+ * @returns Promise<number[]>
3451
3419
  */
3452
- entry: string | 'index.html';
3420
+ getSize: () => Promise<number[]>;
3453
3421
  /**
3454
- * 远程组件包入口文件
3455
- * @deprecated
3422
+ * 打开开发者工具
3456
3423
  */
3457
- remoteEntry?: string;
3424
+ openDevTools: () => Promise<void>;
3458
3425
  /**
3459
- * 组件包json文件路径
3460
- * @deprecated
3461
- * @example https://rtugeek.gitee.io/hotspot/widget.json
3426
+ * 设置窗口位置
3427
+ * @param {SetPositionOptions} options - 配置窗口位置的选项
3462
3428
  */
3463
- readonly remotePackage?: string;
3464
- readonly local?: LocalPackageUrlInfo;
3465
- readonly remote?: RemotePackageUrlInfo;
3429
+ setPosition: (options: SetPositionOptions) => Promise<void>;
3466
3430
  /**
3467
- * zip package url, used for downloading the package
3431
+ * 获取窗口位置
3432
+ * @returns {Promise<Position>} 返回一个 Promise,解析为窗口的位置
3468
3433
  */
3469
- zipUrl?: string;
3434
+ getPosition: () => Promise<Position>;
3470
3435
  /**
3471
- * 组件包图标
3436
+ * 使窗口失去焦点
3472
3437
  */
3473
- readonly icon?: string;
3438
+ blur: () => Promise<void>;
3474
3439
  /**
3475
- * Hash路由模式,默认为true
3440
+ * 聚焦窗口
3476
3441
  */
3477
- readonly hash: boolean;
3442
+ focus: () => Promise<void>;
3478
3443
  /**
3479
- * 可能是网络地址,或者本地路径(解压后的文件夹路径),
3480
- * 网络地址:https://www.bilibili.com
3481
- * 本地地址:file:///C:/Users/neo/Desktop
3482
- * 在测试时。地址通常为: http://127.0.0.1:8080
3444
+ * 设置窗口是否可调整大小
3445
+ * @param resizable boolean - 是否可调整大小
3483
3446
  */
3484
- url: string;
3485
- readonly widgets: Widget[];
3486
- readonly pages: Page[];
3487
- devOptions?: DevOptions;
3488
- constructor(options: WidgetPackageOptions);
3489
- static parseJSON(json: string): WidgetPackage;
3490
- static parseObject(obj: any): WidgetPackage;
3447
+ setResizable: (resizable: boolean) => Promise<void>;
3491
3448
  /**
3492
- * 获取组件包标题
3493
- * @param lang 语言环境,不传则获取默认语言
3449
+ * 设置窗口是否可移动
3450
+ * @param movable boolean - 是否可移动
3494
3451
  */
3495
- getTitle(lang?: LanguageCode): string | undefined;
3452
+ setMovable: (movable: boolean) => Promise<void>;
3496
3453
  /**
3497
- * 获取组件包描述
3498
- * @param lang 语言环境,不传则获取默认标题
3454
+ * 获取窗口边界
3455
+ * @returns Promise<Rectangle>
3499
3456
  */
3500
- getDescription(lang?: LanguageCode): string | undefined;
3501
- }
3502
- interface DevOptions {
3503
- folder?: string;
3504
- route?: boolean;
3505
- devUrl?: string;
3506
- remoteEntry?: string;
3507
- }
3508
-
3509
- /**
3510
- * WidgetApi 接口定义了一系列用于控制组件的方法,这些方法提供了组件的注册、升级、获取、打开设置页面、重新加载等功能
3511
- */
3512
- interface IWidgetApi {
3457
+ getBounds: () => Promise<Rectangle>;
3513
3458
  /**
3514
- * 注册组件
3515
- * @param widgets
3459
+ * 设置窗口边界
3460
+ * @param {Partial<Rectangle>} bounds - 窗口的边界矩形
3461
+ * @param {boolean} animate - 是否启用动画
3516
3462
  */
3517
- registerWidgets: (widgets: Widget[]) => Promise<void>;
3463
+ setBounds: (bounds: Partial<Rectangle>, animate: boolean) => Promise<void>;
3518
3464
  /**
3519
- * @deprecated
3465
+ * 将窗口对齐到当前屏幕
3466
+ * @param align string 对齐位置
3467
+ * <ol>
3468
+ * <li>'top-left'</li>
3469
+ * <li>'top-center'</li>
3470
+ * <li>'top-right'</li>
3471
+ * <li>'bottom-left'</li>
3472
+ * <li>'bottom-center'</li>
3473
+ * <li>'bottom-right'</li>
3474
+ * </ol>
3520
3475
  */
3521
- registerWidgetPackage: (widgetPackage: WidgetPackage) => Promise<void>;
3476
+ alignToScreen: (align: AlignPosition) => Promise<void>;
3522
3477
  /**
3523
- * ignore mouse events
3524
- * @param widgetId
3525
- * @param ignore
3478
+ * 检查指定 URL 是否存在
3479
+ * @param {string} url - 要检查的 URL
3480
+ * @return Promise<boolean>
3526
3481
  */
3527
- setIgnoreMouseEvents: (widgetId: string, ignore: boolean) => Promise<void>;
3482
+ existsByUrl: (url: string) => Promise<boolean>;
3528
3483
  /**
3529
- * Check if the widget is ignoring mouse events.
3530
- * @param widgetId
3484
+ * 获取窗口的最大尺寸
3485
+ * @returns {Promise<number[]>} 返回一个 Promise,解析为一个数组,包含窗口的最大宽度和高度
3531
3486
  */
3532
- isIgnoreMouseEvents: (widgetId?: string) => Promise<boolean>;
3487
+ getMaximumSize: () => Promise<number[]>;
3533
3488
  /**
3534
- * 设置组件是否可以左键拖动
3535
- * @param draggable boolean true-启用左键拖动 false-禁用左键拖动
3536
- * @remarks 注意:只对悬浮窗组件(DeployMode.OVERLAP)有效
3489
+ * 获取窗口的最小尺寸
3490
+ * @returns {Promise<number[]>} 返回一个 Promise,解析为一个数组,包含窗口的最小宽度和高度
3537
3491
  */
3538
- setMouseDraggable: (draggable: boolean) => Promise<void>;
3492
+ getMinimumSize: () => Promise<number[]>;
3539
3493
  /**
3540
- * 升级组件包
3541
- * @param packageName 组件包名
3494
+ * 设置窗口的最大尺寸
3495
+ * @param {number} width - 最大宽度
3496
+ * @param {number} height - 最大高度
3542
3497
  */
3543
- upgradePackage: (packageName: string) => Promise<void>;
3498
+ setMaximumSize: (width: number, height: number) => Promise<void>;
3544
3499
  /**
3545
- * 获取所有组件
3546
- * @return Promise<Widget[]>
3500
+ * 设置窗口的最小尺寸
3501
+ * @param {number} width - 最大宽度
3502
+ * @param {number} height - 最大高度
3503
+ */
3504
+ setMinimumSize: (width: number, height: number) => Promise<void>;
3505
+ /**
3506
+ * 更改缩放等级 原始尺寸为 0,每升高或将顶代表缩放20%,大和小限制默认分区为 300% 和 50% 缩放公式为 scale := 1.2 ^ level.
3507
+ * @param level number - 缩放等级,默认为 0
3508
+ */
3509
+ setZoomLevel: (level: number) => Promise<void>;
3510
+ /**
3511
+ * 更改缩放倍数 缩放系数是缩放百分比除以 100,即 300% = 3.0
3512
+ * @param factor Double - 缩放系数,默认为 1.0
3513
+ * @remarks 系数必须大于0.0
3514
+ */
3515
+ setZoomFactor: (factor: number) => Promise<void>;
3516
+ /**
3517
+ * Set the proxy config for window. All requests will be sent through the proxy server.
3518
+ * Proxy config will be lost once the window is closed. If you want to set a persistent proxy for widget window, use `DeployWidgetApi.setProxy` instead.
3519
+ * @remarks All links will be disconnected after setting, it is best to refresh the page (window.location.reload())
3520
+ * @param config
3521
+ * @example
3522
+ * ```typescript
3523
+ * BrowserWindowApi.setProxy({
3524
+ * proxyRules:'socks5://127.0.0.1:7890'
3525
+ * })
3526
+ * ```
3547
3527
  */
3548
- getWidgets: () => Promise<Widget[]>;
3528
+ setProxy: (config: ProxyConfig) => Promise<void>;
3529
+ getProxy: () => Promise<ProxyConfig | undefined>;
3549
3530
  /**
3550
- * 通过组件名称获取组件
3551
- * @param name string 组件名
3552
- * @return Promise<Widget>
3531
+ * @return Promise<boolean>
3553
3532
  */
3554
- getWidget: (name: string) => Promise<Widget>;
3533
+ isFocused: () => Promise<boolean>;
3555
3534
  /**
3556
- * @param name
3557
- * @deprecated
3535
+ * A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.
3536
+ * The window should not be activated through programmatic access or via keyboard navigation by accessible technology, such as Narrator.
3537
+ * @see [Extended Window Styles](https://learn.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles)
3558
3538
  */
3559
- getWidgetPackage: (name: string) => Promise<WidgetPackage | undefined>;
3539
+ setNoActivate: () => Promise<void>;
3560
3540
  /**
3561
- * @deprecated
3541
+ * Controls whether or not this window's WebContents will throttle animations and timers when the page becomes backgrounded. This also affects the Page Visibility API.
3542
+ * @param enabled
3543
+ * @see https://www.electronjs.org/docs/latest/api/web-contents#contentssetbackgroundthrottlingallowed
3562
3544
  */
3563
- getWidgetPackages: () => Promise<WidgetPackage[]>;
3545
+ setBackgroundThrottling: (enabled: boolean) => Promise<void>;
3546
+ getBackgroundThrottling: () => Promise<boolean>;
3564
3547
  /**
3565
- * 打开组件设置页面
3566
- * @param id string 组件id
3548
+ * Makes the window not show in the taskbar.
3549
+ * @param boolean
3567
3550
  */
3568
- openConfigPage: (id?: string) => Promise<void>;
3551
+ setSkipTaskbar: (boolean: boolean) => Promise<void>;
3552
+ }
3553
+
3554
+ type BrowserWindowApiMethods = keyof IBrowserWindowApi;
3555
+ type AlignPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
3556
+ interface SetPositionOptions {
3557
+ x?: number;
3558
+ y?: number;
3569
3559
  /**
3570
- * @param name
3560
+ * Only works on macOS
3571
3561
  */
3572
- openConfigPageByName: (name: string) => Promise<void>;
3562
+ animation?: boolean;
3563
+ }
3564
+ declare enum BrowserWindowApiEvent {
3565
+ BLUR = "event::cn.widgetjs.core.browser-window.blur",
3566
+ MOVED = "event::cn.widgetjs.core.browser-window.moved",
3567
+ FOCUS = "event::cn.widgetjs.core.browser-window.focus",
3568
+ CLOSE = "event::cn.widgetjs.core.browser-window.close",
3569
+ SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.snap_to_edge",
3570
+ RESIZED = "event::cn.widgetjs.core.browser-window.resized",
3571
+ CANCEL_SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge"
3572
+ }
3573
+ interface SetupOptions {
3574
+ width: number;
3575
+ height: number;
3576
+ minWidth?: number;
3577
+ minHeight?: number;
3578
+ maxWidth?: number;
3579
+ maxHeight?: number;
3580
+ resizable?: boolean;
3581
+ movable?: boolean;
3582
+ center?: boolean;
3583
+ alwaysOnTop?: boolean;
3584
+ x?: number;
3585
+ y?: number;
3586
+ skipTaskbar?: boolean;
3587
+ }
3588
+ declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> implements IBrowserWindowApi {
3589
+ getProxy(): Promise<ProxyConfig | undefined>;
3590
+ setBackgroundThrottling(enabled: boolean): Promise<void>;
3591
+ getBackgroundThrottling(): Promise<boolean>;
3592
+ isResizable(): Promise<boolean>;
3593
+ setHasShadow(hasShadow: boolean): Promise<void>;
3594
+ isDraggingWindow(): Promise<boolean>;
3595
+ setNoActivate(): Promise<void>;
3596
+ isVisible(): Promise<boolean>;
3597
+ getChannel(): string;
3598
+ setIgnoreMouseEvent(ignore: boolean): Promise<void>;
3599
+ show(): Promise<void>;
3600
+ showInactive(): Promise<void>;
3601
+ hide(): Promise<void>;
3602
+ center(): Promise<void>;
3603
+ setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
3604
+ isAlwaysOnTop(): Promise<boolean>;
3605
+ openUrl(url: string, option?: BrowserWindowOptions): Promise<void>;
3606
+ moveTop(): Promise<void>;
3607
+ openDevTools(): Promise<void>;
3608
+ setPosition(options: SetPositionOptions): Promise<void>;
3609
+ getPosition(): Promise<Position>;
3610
+ blur(): Promise<any>;
3611
+ focus(): Promise<any>;
3573
3612
  /**
3574
- * 重新加载组件
3613
+ * 设置窗口是否可以拉伸
3614
+ * @param resizable
3575
3615
  */
3576
- reload: (id?: string) => Promise<void>;
3616
+ setResizable(resizable: boolean): Promise<any>;
3617
+ getBounds(): Promise<Rectangle>;
3618
+ setBounds(bounds: Partial<Rectangle>, animate?: boolean): Promise<void>;
3619
+ alignToScreen(align: AlignPosition): Promise<any>;
3620
+ startDraggingWindow(): Promise<any>;
3621
+ stopDraggingWindow(): Promise<any>;
3577
3622
  /**
3578
- *
3579
- * @param packageName
3580
- * @deprecated
3623
+ * 通过url检测窗口是否存在
3624
+ * @param url
3581
3625
  */
3582
- getWidgetPackageUrl: (packageName: string) => Promise<string | null>;
3583
- restartWidgets: (mode?: DeployMode) => Promise<void>;
3584
- updateSyncInfo: () => Promise<void>;
3585
- getSyncInfo: (widgetName?: string) => Promise<WidgetSyncInfo | null>;
3626
+ existsByUrl(url: string): Promise<boolean>;
3627
+ getMaximumSize(): Promise<number[]>;
3628
+ minimize(): Promise<void>;
3629
+ maximize(): Promise<void>;
3630
+ isMaximized(): Promise<boolean>;
3631
+ isMinimized(): Promise<boolean>;
3632
+ restore(): Promise<void>;
3633
+ unmaximize(): Promise<void>;
3634
+ setZoomLevel(level: number): Promise<void>;
3635
+ reload(): Promise<void>;
3636
+ setMovable(movable: boolean): Promise<void>;
3637
+ setSize(width: number, height: number, animate?: boolean): Promise<void>;
3638
+ isFocused(): Promise<boolean>;
3639
+ setMaximumSize(width: number, height: number): Promise<void>;
3640
+ setMinimumSize(width: number, height: number): Promise<void>;
3641
+ getMinimumSize(): Promise<number[]>;
3642
+ close(): Promise<void>;
3643
+ setZoomFactor(factor: number): Promise<void>;
3644
+ setup(options: SetupOptions): Promise<void>;
3645
+ setProxy(config: Electron.Config): Promise<void>;
3646
+ getSize(): Promise<number[]>;
3647
+ setSkipTaskbar(skip: boolean): Promise<void>;
3586
3648
  }
3649
+ declare const BrowserWindowApi: BrowserWindowApiImpl;
3587
3650
 
3588
- type WidgetApiMethods = keyof IWidgetApi;
3589
- declare enum WidgetApiEvent {
3590
- DATA_CHANGED = "event::cn.widgetjs.core.widget.data-changed",
3591
- EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit",
3592
- PACKAGE_UPGRADE = "event::cn.widgetjs.core.widget.package.upgraded",
3593
- PACKAGE_INSTALLED = "event::cn.widgetjs.core.widget.package.installed"
3594
- }
3595
- declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidgetApi {
3596
- getSyncInfo(widgetName?: string): Promise<WidgetSyncInfo | null>;
3597
- updateSyncInfo(): Promise<void>;
3598
- reload(id?: string): Promise<void>;
3599
- getChannel(): string;
3600
- registerWidgets(widgets: Widget[]): Promise<any>;
3601
- registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
3602
- getWidgets(): Promise<Widget[]>;
3603
- openConfigPage(widgetId?: string): Promise<any>;
3604
- openConfigPageByName(widgetName: string): Promise<any>;
3651
+ /**
3652
+ * BroadcastApi provides the ability to send and listen to broadcast events,
3653
+ * typically used for component packages to listen for system or application events,
3654
+ * or for communication and data transfer between component packages.
3655
+ */
3656
+ interface IBroadcastApi {
3605
3657
  /**
3606
- * @deprecated
3658
+ * send broadcast event
3659
+ * @param event
3607
3660
  */
3608
- getWidgetPackages(): Promise<WidgetPackage[]>;
3661
+ send: (event: BroadcastEvent) => Promise<void>;
3609
3662
  /**
3610
- *
3611
- * @param name package name
3663
+ * register listener for broadcast event
3664
+ * @param event
3612
3665
  */
3613
- getWidget(name: string): Promise<Widget>;
3666
+ register: (...event: BroadcastEventType[]) => Promise<void>;
3614
3667
  /**
3615
- * @param name package name
3616
- * @deprecated
3668
+ * Unregister broadcast event
3669
+ * @param event
3617
3670
  */
3618
- getWidgetPackage(name: string): Promise<WidgetPackage | undefined>;
3619
- getWidgetPackageUrl(packageName: string): Promise<string | null>;
3620
- upgradePackage(packageName: string): Promise<void>;
3671
+ unregister: (...event: BroadcastEventType[]) => Promise<void>;
3672
+ }
3673
+
3674
+ type BroadcastEventType = string | WidgetApiEvent | BrowserWindowApiEvent | ShortcutApiEvent | ClipboardApiEvent | MouseApiEvent;
3675
+ type BroadcastApiMethods = keyof IBroadcastApi;
3676
+ declare const BroadcastApi: IBroadcastApi;
3677
+
3678
+ declare enum Channel {
3679
+ NOTIFICATION = "channel::cn.widgetjs.core.notification",
3680
+ BROWSER_WINDOW = "channel::cn.widgetjs.core.browser_window",
3681
+ BROADCAST = "channel::cn.widgetjs.core.broadcast",
3682
+ WIDGET = "channel::cn.widgetjs.core.widget",
3683
+ WIDGET_PACKAGE = "channel::cn.widgetjs.core.widget.package",
3684
+ DEPLOYED_WIDGET = "channel::cn.widgetjs.core.deployed_widget",
3685
+ APP = "channel::cn.widgetjs.core.app",
3686
+ SYSTEM = "channel::cn.widgetjs.core.system",
3687
+ DIALOG = "channel::cn.widgetjs.core.dialog",
3688
+ HTTP = "channel::cn.widgetjs.core.http",
3689
+ CLIPBOARD = "channel::cn.widgetjs.core.clipboard",
3690
+ FILE = "channel::cn.widgetjs.core.file",
3691
+ SCREEN = "channel::cn.widgetjs.core.screen",
3692
+ MENU = "channel::cn.widgetjs.core.menu",
3693
+ SHORTCUT = "channel::cn.widgetjs.core.shortcut",
3694
+ LOG = "channel::cn.widgetjs.core.log",
3695
+ DEVICE = "channel::cn.widgetjs.core.device",
3696
+ MOUSE = "channel::cn.widgetjs.core.mouse",
3697
+ KEYBOARD = "channel::cn.widgetjs.core.keyboard",
3621
3698
  /**
3622
- * 阻止拖动窗口,只能用于悬浮窗口 DeployMode.OVERLAP
3623
- * @param draggable
3699
+ * @deprecated
3624
3700
  */
3625
- setMouseDraggable(draggable: boolean): Promise<void>;
3626
- isIgnoreMouseEvents(widgetId: string | undefined): Promise<boolean>;
3627
- setIgnoreMouseEvents(widgetId: string, ignore: boolean): Promise<void>;
3628
- restartWidgets(mode?: DeployMode): Promise<void>;
3701
+ STORE = "channel::cn.widgetjs.core.store",
3702
+ STORAGE = "channel::cn.widgetjs.core.storage",
3703
+ PROCESS = "channel::cn.widgetjs.core.process",
3704
+ USER = "channel::cn.widgetjs.core.user",
3705
+ TRAY = "channel::cn.widgetjs.core.tray",
3706
+ AI = "channel::cn.widgetjs.core.ai"
3629
3707
  }
3630
- declare const WidgetApi: WidgetApiImpl;
3631
3708
 
3632
- declare class ApiConstants {
3633
- static readonly CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
3634
- static readonly CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
3635
- static readonly CONFIG_DEBUG_MODE = "cn.widgetjs.config.debug";
3636
- static readonly CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size";
3637
- static readonly SHORTCUT_PIN_DESKTOP_WIDGETS = "cn.widgetjs.config.shortcut.pin_desktop_widgets";
3638
- }
3639
- declare class AppEvent {
3640
- static readonly LANGUAGE_CHANGED = "event::cn.widgetjs.core.app.language.changed";
3709
+ type DeviceApiMethods = keyof IDeviceApi;
3710
+ declare const DeviceApi: IDeviceApi;
3711
+
3712
+ declare const DialogApi: IDialogApi;
3713
+
3714
+ declare class ElectronApi {
3715
+ static addIpcListener(key: string, f: Function): Promise<void>;
3716
+ static removeIpcListener(key: string): Promise<void>;
3641
3717
  }
3642
- declare class AppConfig {
3643
- static readonly LANGUAGE = "cn.widgetjs.config.app.language";
3644
- static readonly LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
3718
+
3719
+ interface IHttpApi {
3720
+ /**
3721
+ * Simple HTTP GET request
3722
+ * @param url
3723
+ * @param params
3724
+ */
3725
+ get: (url: string, params?: Record<string, any>) => Promise<string>;
3726
+ /**
3727
+ * Simple HTTP POST request
3728
+ * @param url
3729
+ * @param params
3730
+ */
3731
+ post: (url: string, data?: Record<string, any>) => Promise<string>;
3645
3732
  }
3733
+ type HttpApiMethods = keyof IHttpApi;
3734
+
3735
+ declare const HttpApi: IHttpApi;
3736
+
3737
+ declare const LogApi: ILogApi;
3738
+
3739
+ declare const MouseApi: IMouseApi;
3646
3740
 
3647
3741
  /**
3648
- * ShortcutApi 提供了注册快捷键的能力,当快捷键被触发时,会发送广播事件 {@link BroadcastEvent}
3742
+ * NotificationApi提供了发送通知的能力
3649
3743
  */
3650
- interface IShortcutApi {
3744
+ interface INotificationApi {
3651
3745
  /**
3652
- * 注册快捷键, 如果注册成功, 触发快捷键时,会发送广播事件 {@link BroadcastEvent}
3653
- * @see [Electron Accelerator](https://www.electronjs.org/docs/latest/api/accelerator)
3654
- * @param shortcut string
3655
- * @return Promise<boolean> true 注册成功,false 注册失败
3656
- * @example
3657
- * ```typescript
3658
- * //Meta 通常为windows键
3659
- * ShortcutApi.register('Ctrl+Meta+Y')
3660
- * ```
3746
+ * 发送自定义通知
3747
+ * @param notification
3661
3748
  */
3662
- register: (shortcut: string) => Promise<boolean>;
3749
+ send: (notification: AppNotification) => Promise<void>;
3663
3750
  /**
3664
- * 注销快捷键
3665
- * @param shortcut string
3666
- * @example
3667
- * ```typescript
3668
- * //Meta 通常为windows键
3669
- * ShortcutApi.unregister('Ctrl+Meta+Y')
3670
- * ```
3751
+ * 隐藏通知
3671
3752
  */
3672
- unregister: (shortcut: string) => void;
3673
- }
3674
- /**
3675
- * ShortcutApiEvent
3676
- */
3677
- declare enum ShortcutApiEvent {
3753
+ hide: () => Promise<void>;
3678
3754
  /**
3679
- * 快捷键触发事件
3755
+ * @param message string
3756
+ * @param duration number 持续时间,单位毫秒,默认5000
3680
3757
  */
3681
- TRIGGERED = "channel::cn.widgetjs.core.shortcut.triggered"
3682
- }
3683
-
3684
- type ShortcutApiMethods = keyof IShortcutApi;
3685
- declare const ShortcutApi: IShortcutApi;
3686
-
3687
- interface BroadcastEventOptions {
3688
- event: WidgetApiEvent | AppApiEvent | string;
3758
+ success: (message: string, duration?: number) => Promise<void>;
3689
3759
  /**
3690
- * 发送人,用于标记发送源,一般为组件名,如:com.example.widgets.countdown
3760
+ * @param message string
3761
+ * @param duration number 持续时间,单位毫秒,默认5000
3691
3762
  */
3692
- sender?: string;
3763
+ error: (message: string, duration?: number) => Promise<void>;
3693
3764
  /**
3694
- * 广播事件携带的数据,只支持部分数据类型。
3695
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
3765
+ * @param message string
3766
+ * @param duration number 持续时间,单位毫秒,默认5000
3696
3767
  */
3697
- payload?: any;
3698
- }
3699
- declare class BroadcastEvent {
3700
- readonly event: string;
3701
- readonly sender?: string;
3702
- payload?: any;
3703
- constructor(options: BroadcastEventOptions);
3704
- }
3705
-
3706
- /**
3707
- * BroadcastApi provides the ability to send and listen to broadcast events,
3708
- * typically used for component packages to listen for system or application events,
3709
- * or for communication and data transfer between component packages.
3710
- */
3711
- interface IBroadcastApi {
3768
+ warning: (message: string, duration?: number) => Promise<void>;
3712
3769
  /**
3713
- * send broadcast event
3714
- * @param event
3770
+ * @param message string
3771
+ * @param duration number 持续时间,单位毫秒,默认5000
3715
3772
  */
3716
- send: (event: BroadcastEvent) => Promise<void>;
3773
+ info: (message: string, duration?: number) => Promise<void>;
3774
+ reminder: (option: ReminderNotificationOption) => Promise<void>;
3775
+ }
3776
+
3777
+ type NotificationApiMethods = keyof INotificationApi;
3778
+ declare enum NotificationApiEvent {
3779
+ CONFIRM = "event::cn.widgetjs.core.notification.confirm",
3780
+ CANCEL = "event::cn.widgetjs.core.notification.cancel",
3781
+ HIDE = "event::cn.widgetjs.core.notification.hide"
3782
+ }
3783
+ declare class NotificationApiImpl extends BaseApi<NotificationApiMethods> implements INotificationApi {
3717
3784
  /**
3718
- * register listener for broadcast event
3719
- * @param event
3785
+ * 来电
3786
+ * @param avatar 头像地址
3787
+ * @param audio 音频地址
3788
+ * @param title 标题文件
3789
+ * @param message 初始消息
3790
+ * @param lyric 歌词字符串
3720
3791
  */
3721
- register: (...event: BroadcastEventType[]) => Promise<void>;
3792
+ call(avatar: string, audio: string, title: string, message: string, lyric: string): Promise<void>;
3793
+ send(notification: AppNotification): Promise<any>;
3794
+ reminder(option: ReminderNotificationOption): Promise<any>;
3795
+ advanceCountdown(message: string, targetTime: string, title?: string): Promise<any>;
3796
+ countdown(message: string, targetTime: string): Promise<void>;
3797
+ success(message: string, duration?: number): Promise<void>;
3798
+ error(message: string, duration?: number): Promise<void>;
3799
+ warning(message: string, duration?: number): Promise<void>;
3800
+ info(message: string, duration?: number): Promise<void>;
3722
3801
  /**
3723
- * Unregister broadcast event
3724
- * @param event
3802
+ * 隐藏通知
3725
3803
  */
3726
- unregister: (...event: BroadcastEventType[]) => Promise<void>;
3804
+ hide(): Promise<void>;
3805
+ getChannel(): string;
3727
3806
  }
3728
-
3729
- type BroadcastEventType = string | WidgetApiEvent | BrowserWindowApiEvent | ShortcutApiEvent | ClipboardApiEvent | MouseApiEvent;
3730
- type BroadcastApiMethods = keyof IBroadcastApi;
3731
- declare const BroadcastApi: IBroadcastApi;
3807
+ declare const NotificationApi: NotificationApiImpl;
3732
3808
 
3733
3809
  declare const ProcessApi: IProcessApi;
3734
3810
 
3735
- declare const AppApi: IAppApi;
3736
-
3737
- declare const DialogApi: IDialogApi;
3738
-
3739
3811
  type BaseType = string | number | boolean;
3740
3812
  /**
3741
3813
  * StorageApi 接口定义了用于存储和检索数据的方法,包括加密和解密功能。
@@ -3802,54 +3874,226 @@ declare const StorageApi: IStorageApi;
3802
3874
  */
3803
3875
  declare const StoreApi: IStoreApi;
3804
3876
 
3805
- declare const LogApi: ILogApi;
3806
-
3807
3877
  /**
3808
3878
  *
3809
3879
  * SystemApi provides functionality for retrieving system information or interacting with the system.
3810
3880
  */
3811
3881
  interface ISystemApi {
3812
3882
  /**
3813
- * Get system wallpaper absolute path
3883
+ * Get system wallpaper absolute path
3884
+ */
3885
+ getWallpaper: () => Promise<string>;
3886
+ /**
3887
+ * Get system information based on the provided valuesObject. The valuesObject can contain specific keys to retrieve certain information.
3888
+ * @param valuesObject
3889
+ * @see https://systeminformation.io/general.html
3890
+ */
3891
+ getInfo: (valuesObject: any) => Promise<any>;
3892
+ /**
3893
+ * Get system uptime in seconds
3894
+ * @return Promise<number>
3895
+ */
3896
+ getUptime: () => Promise<number>;
3897
+ /**
3898
+ * Launches the full product details page (PDP) for a product at Microsoft Store.
3899
+ * @see https://learn.microsoft.com/en-us/windows/apps/develop/launch/launch-store-app
3900
+ * @param storeId
3901
+ */
3902
+ launchStoreDetailsPage: (storeId?: string) => Promise<void>;
3903
+ /**
3904
+ * @see https://learn.microsoft.com/en-us/windows/apps/develop/launch/launch-settings-app
3905
+ * @param uri Use this URI scheme to launch the Windows Settings app to specific settings pages.
3906
+ * @example ms-settings:defaultapps
3907
+ * @example ms-settings:startupapps
3908
+ */
3909
+ launchWindowsSettings: (uri: string) => Promise<void>;
3910
+ }
3911
+ /**
3912
+ * SystemApiEvent
3913
+ */
3914
+ declare enum SystemApiEvent {
3915
+ /**
3916
+ * Date changed event
3917
+ */
3918
+ DATE_CHANGED = "event::cn.widgetjs.core.sys.date.changed"
3919
+ }
3920
+
3921
+ type SystemApiMethods = keyof ISystemApi;
3922
+ declare const SystemApi: ISystemApi;
3923
+
3924
+ declare const TrayApi: ITrayApi;
3925
+
3926
+ declare const UserApi: IUserApi;
3927
+
3928
+ /**
3929
+ * @deprecated 已迁移到 AppTheme
3930
+ */
3931
+ interface IWidgetTheme {
3932
+ /**
3933
+ * 是否使用全局主题,
3934
+ * 默认true
3935
+ */
3936
+ useGlobalTheme?: boolean;
3937
+ borderRadius?: CSS.Properties['borderRadius'];
3938
+ backgroundColor?: CSS.Properties['color'];
3939
+ /**
3940
+ * 背景边框颜色
3941
+ */
3942
+ backgroundBorderColor?: CSS.Properties['color'];
3943
+ backgroundBoxShadowColor?: CSS.Properties['color'];
3944
+ fontSize?: CSS.Properties['fontSize'];
3945
+ dividerColor?: CSS.Properties['color'];
3946
+ /**
3947
+ * 主色调
3948
+ */
3949
+ primaryColor?: CSS.Properties['color'];
3950
+ /**
3951
+ * 文字颜色
3952
+ */
3953
+ color?: CSS.Properties['color'];
3954
+ fontFamily?: CSS.Properties['fontFamily'];
3955
+ shadowColor?: CSS.Properties['color'];
3956
+ padding?: CSS.Properties['padding'];
3957
+ borderColor?: CSS.Properties['borderColor'];
3958
+ }
3959
+ type WidgetThemeProperty = keyof IWidgetTheme;
3960
+ /**
3961
+ * @deprecated 已迁移到 AppTheme
3962
+ */
3963
+ declare class WidgetTheme implements IWidgetTheme {
3964
+ borderRadius?: CSS.Properties['borderRadius'];
3965
+ backgroundColor?: CSS.Properties['color'];
3966
+ fontSize?: CSS.Properties['fontSize'];
3967
+ dividerColor?: CSS.Properties['color'];
3968
+ /**
3969
+ * 主色调
3970
+ */
3971
+ primaryColor?: CSS.Properties['color'];
3972
+ backgroundBorderColor?: CSS.Properties['color'];
3973
+ backgroundBoxShadowColor?: CSS.Properties['color'];
3974
+ /**
3975
+ * 文字颜色
3976
+ */
3977
+ color?: CSS.Properties['color'];
3978
+ fontFamily?: CSS.Properties['fontFamily'];
3979
+ shadowColor?: CSS.Properties['color'];
3980
+ padding?: CSS.Properties['padding'];
3981
+ borderColor?: CSS.Properties['borderColor'];
3982
+ useGlobalTheme?: boolean;
3983
+ constructor(options?: IWidgetTheme | string);
3984
+ static fromJSON(json: string): WidgetTheme;
3985
+ /**
3986
+ * Injects the style properties as css variable.
3987
+ * @param selector default is 'body'
3988
+ */
3989
+ toCSS(selector?: string): string;
3990
+ /**
3991
+ * Injects the style properties as css variable.
3992
+ * @param rootElement The rootElement to inject the css.
3993
+ * @remarks Only works in a browser environment.
3994
+ */
3995
+ injectCSS(rootElement?: HTMLElement): void;
3996
+ removeCSS(rootElement?: HTMLElement): void;
3997
+ copy(options?: IWidgetTheme): WidgetTheme;
3998
+ /**
3999
+ * Gets the style properties from the widget's style object.
4000
+ * @returns A record representing CSS custom variable and their values.
4001
+ */
4002
+ toCSSVariable(): Record<string, string>;
4003
+ toCSSProperties(): Record<string, string>;
4004
+ static fromCSS(css: string): WidgetTheme;
4005
+ }
4006
+ type WidgetThemeKey = keyof WidgetTheme;
4007
+ /**
4008
+ * Widget default theme, this object is immutable. Clone it before use.
4009
+ */
4010
+ declare const DefaultWidgetTheme: WidgetTheme;
4011
+
4012
+ /**
4013
+ * 组件配置数据,用于存储组件自定义页面所设置的数据
4014
+ * @deprecated
4015
+ */
4016
+ declare class WidgetData {
4017
+ /**
4018
+ * 组件id
4019
+ */
4020
+ id?: string;
4021
+ /**
4022
+ * 组件名
3814
4023
  */
3815
- getWallpaper: () => Promise<string>;
4024
+ name: string;
3816
4025
  /**
3817
- * Get system information based on the provided valuesObject. The valuesObject can contain specific keys to retrieve certain information.
3818
- * @param valuesObject
3819
- * @see https://systeminformation.io/general.html
4026
+ * 背景颜色
4027
+ * @deprecated
3820
4028
  */
3821
- getInfo: (valuesObject: any) => Promise<any>;
4029
+ backgroundColor?: string;
3822
4030
  /**
3823
- * Get system uptime in seconds
3824
- * @return Promise<number>
4031
+ * 文字颜色
4032
+ * @deprecated
3825
4033
  */
3826
- getUptime: () => Promise<number>;
4034
+ color?: string;
3827
4035
  /**
3828
- * Launches the full product details page (PDP) for a product at Microsoft Store.
3829
- * @see https://learn.microsoft.com/en-us/windows/apps/develop/launch/launch-store-app
3830
- * @param storeId
4036
+ * 字体大小
4037
+ * @deprecated
3831
4038
  */
3832
- launchStoreDetailsPage: (storeId?: string) => Promise<void>;
4039
+ fontSize?: number;
3833
4040
  /**
3834
- * @see https://learn.microsoft.com/en-us/windows/apps/develop/launch/launch-settings-app
3835
- * @param uri Use this URI scheme to launch the Windows Settings app to specific settings pages.
3836
- * @example ms-settings:defaultapps
3837
- * @example ms-settings:startupapps
4041
+ * 字体
4042
+ * @deprecated
3838
4043
  */
3839
- launchWindowsSettings: (uri: string) => Promise<void>;
4044
+ fontFamily?: string;
4045
+ /**
4046
+ * 圆角半径
4047
+ * @deprecated
4048
+ */
4049
+ borderRadius?: number;
4050
+ /**
4051
+ * 组件样式
4052
+ * @deprecated
4053
+ */
4054
+ theme: WidgetTheme;
4055
+ constructor(name: string, id?: string);
4056
+ parseJSON(json: any): void;
4057
+ /**
4058
+ * Gets the style properties from the widget's style object.
4059
+ * @returns A record representing CSS custom properties and their values.
4060
+ */
4061
+ getThemeProperties(): Record<string, string>;
4062
+ /**
4063
+ * Injects the style properties as css variable.
4064
+ * @remarks Only works in a browser environment.
4065
+ */
4066
+ injectThemeProperties(): void;
4067
+ }
4068
+
4069
+ interface SaveWidgetOption {
4070
+ sendBroadcast?: boolean;
4071
+ id?: string;
4072
+ storeName?: string;
3840
4073
  }
3841
4074
  /**
3842
- * SystemApiEvent
4075
+ * 用户处理浏览器数据,只在浏览器环境下有用
4076
+ * @deprecated
3843
4077
  */
3844
- declare enum SystemApiEvent {
4078
+ interface IWidgetDataApi {
4079
+ findByName: (<T extends WidgetData>(name: string, type: {
4080
+ new (name: string, id?: string): T;
4081
+ }) => Promise<T | undefined>) & (<T extends WidgetData>(data: T) => Promise<T | undefined>);
4082
+ save: (data: WidgetData, options?: SaveWidgetOption) => Promise<string>;
3845
4083
  /**
3846
- * Date changed event
4084
+ * 获取组件 LocalForage 存储实例
4085
+ * @param widgetName 组件名
4086
+ * @param storeName 存储名
4087
+ * @see https://localforage.docschina.org/
3847
4088
  */
3848
- DATE_CHANGED = "event::cn.widgetjs.core.sys.date.changed"
4089
+ getStore: (widgetName: string, storeName?: string) => LocalForage;
4090
+ saveByName: <T extends WidgetData>(data: T, options?: SaveWidgetOption) => Promise<string>;
4091
+ find: <T extends WidgetData>(name: string, id: string, type: {
4092
+ new (name: string, id?: string): T;
4093
+ }) => Promise<T | undefined>;
3849
4094
  }
3850
-
3851
- type SystemApiMethods = keyof ISystemApi;
3852
- declare const SystemApi: ISystemApi;
4095
+ type WidgetDataApiMethods = keyof IWidgetDataApi;
4096
+ declare const WidgetDataApi: IWidgetDataApi;
3853
4097
 
3854
4098
  declare class WidgetPackageApiImpl extends BaseApi<WidgetPackageApiMethods> implements IWidgetPackageApi {
3855
4099
  getChannel(): string;
@@ -3867,145 +4111,30 @@ declare class WidgetPackageApiImpl extends BaseApi<WidgetPackageApiMethods> impl
3867
4111
  }
3868
4112
  declare const WidgetPackageApi: WidgetPackageApiImpl;
3869
4113
 
3870
- declare const MouseApi: IMouseApi;
3871
-
3872
- interface IHttpApi {
3873
- /**
3874
- * Simple HTTP GET request
3875
- * @param url
3876
- * @param params
3877
- */
3878
- get: (url: string, params?: Record<string, any>) => Promise<string>;
3879
- /**
3880
- * Simple HTTP POST request
3881
- * @param url
3882
- * @param params
3883
- */
3884
- post: (url: string, data?: Record<string, any>) => Promise<string>;
3885
- }
3886
- type HttpApiMethods = keyof IHttpApi;
3887
-
3888
- declare const HttpApi: IHttpApi;
3889
-
3890
- declare const UserApi: IUserApi;
3891
-
3892
- declare const TrayApi: ITrayApi;
3893
-
3894
- declare const AiApi: IAiApi;
3895
-
3896
- /**
3897
- * @see [Web Manifest Categories]https://developer.mozilla.org/en-US/docs/Web/Manifest/categories
3898
- * @see [W3C Categories](https://github.com/w3c/manifest/wiki/Categories)
3899
- */
3900
- type Category = 'news' | 'photo' | 'productivity' | 'social' | 'utilities' | 'weather'
3901
- /**
3902
- * @deprecated
3903
- */
3904
- | 'calendar' | 'fun'
3905
- /**
3906
- * @deprecated
3907
- */
3908
- | 'countdown' | 'time' | 'finance' | 'ai';
3909
-
3910
- interface IWidgetOptions extends IWindowSize, IPageOptions {
3911
- supportDeployMode?: DeployMode;
3912
- configPagePath?: string;
3913
- /**
3914
- * 如果为true,组件将不会添加到组件包中
3915
- */
3916
- disabled?: boolean;
3917
- previewImage: string;
3918
- /**
3919
- * whether the widget data can be synchronized
3920
- */
3921
- synchronizable?: boolean;
3922
- categories?: Category[];
3923
- /**
3924
- * 组件包所需的App版本
3925
- */
3926
- requiredAppVersion?: string;
3927
- description: LanguageTextMap;
3928
- keywords: WidgetKeyword[];
4114
+ interface BroadcastEventOptions {
4115
+ event: WidgetApiEvent | AppApiEvent | string;
3929
4116
  /**
3930
- * @deprecated
4117
+ * 发送人,用于标记发送源,一般为组件名,如:com.example.widgets.countdown
3931
4118
  */
3932
- routes?: WidgetRoute[];
4119
+ sender?: string;
3933
4120
  /**
3934
- * 一般用于填写教程链接
4121
+ * 广播事件携带的数据,只支持部分数据类型。
4122
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
3935
4123
  */
3936
- socialLinks?: SocialLink[];
3937
- browserWindowOptions?: Pick<BrowserWindowOptions, 'backgroundThrottling'>;
3938
- trayOptions?: TrayWidgetOptions;
4124
+ payload?: any;
3939
4125
  }
3940
- interface IBackgroundWidgetOptions extends Omit<IWidgetOptions, 'width' | 'height'> {
3941
- width?: number;
3942
- height?: number;
3943
- browserWindowOptions?: BrowserWindowOptions;
4126
+ declare class BroadcastEvent {
4127
+ readonly event: string;
4128
+ readonly sender?: string;
4129
+ payload?: any;
4130
+ constructor(options: BroadcastEventOptions);
3944
4131
  }
3945
- /**
3946
- * @deprecated
3947
- */
3948
- interface WidgetRoute {
3949
- url: string;
4132
+
4133
+ interface NativeKeyboardEvent {
3950
4134
  name: string;
3951
- }
3952
- interface TrayWidgetOptions {
3953
- closeOnBlur?: boolean;
3954
- hideOnBlur?: boolean;
3955
- }
3956
- declare class Widget extends Page {
3957
- readonly previewImage: string;
3958
- readonly categories?: Category[];
3959
- readonly supportDeployMode: number;
3960
- readonly trayOptions?: TrayWidgetOptions;
3961
- /**
3962
- * 组件包所需的App版本
3963
- */
3964
- readonly requiredAppVersion?: string;
3965
- /**
3966
- * 如果为true,组件将不会添加到组件包中
3967
- */
3968
- readonly disabled?: boolean;
3969
- readonly synchronizable?: boolean;
3970
- /**
3971
- * 配置页面路径,没有则不能修改
3972
- */
3973
- readonly configPagePath?: string;
3974
- /**
3975
- * @deprecated
3976
- */
3977
- readonly routes: WidgetRoute[];
3978
- protected browserWindowOptions?: BrowserWindowOptions;
3979
- readonly socialLinks?: SocialLink[];
3980
- constructor(options: IWidgetOptions);
3981
- static parseJSON(json: string): Widget;
3982
- static parseObject(obj: any): Widget;
3983
- /**
3984
- * 是否支持悬浮窗
3985
- */
3986
- isSupportOverlap(): boolean;
3987
- isSupportBackground(): boolean;
3988
- isSupportTray(): boolean;
3989
- /**
3990
- * 是否支持普通模式
3991
- */
3992
- isSupportNormal(): boolean;
3993
- isConfigurable(): boolean;
3994
- }
3995
- declare class BackgroundWidget extends Widget {
3996
- constructor(options: IBackgroundWidgetOptions);
3997
- }
3998
- declare enum WidgetKeyword {
3999
- RECOMMEND = "recommend",
4000
- TOOLS = "tools",
4001
- EFFICIENCY = "efficiency",
4002
- PICTURE = "picture",
4003
- LIFE = "life",
4004
- SHORTCUT = "shortcut",
4005
- COUNTDOWN = "countdown",
4006
- TIMER = "timer",
4007
- INFO = "info",
4008
- DASHBOARD = "dashboard"
4135
+ keyCode: number;
4136
+ scanCode: number;
4137
+ isKeyUp: boolean;
4009
4138
  }
4010
4139
 
4011
4140
  declare enum WebSocketEventType {
@@ -4017,28 +4146,6 @@ declare class WebSocketEvent {
4017
4146
  constructor(type: WebSocketEventType, payload: any);
4018
4147
  }
4019
4148
 
4020
- interface NativeKeyboardEvent {
4021
- name: string;
4022
- keyCode: number;
4023
- scanCode: number;
4024
- isKeyUp: boolean;
4025
- }
4026
-
4027
- interface AppMouseEvent {
4028
- handled: boolean;
4029
- wheelScrolled: boolean;
4030
- clicked: boolean;
4031
- isMouseButtonDown: boolean;
4032
- isMouseButtonUp: boolean;
4033
- timestamp: number;
4034
- button: number;
4035
- clicks: number;
4036
- x: number;
4037
- y: number;
4038
- delta: number;
4039
- location: string;
4040
- }
4041
-
4042
4149
  interface WidgetSyncInfo {
4043
4150
  widgetName: string;
4044
4151
  latestSyncTime: Date;
@@ -4491,4 +4598,4 @@ declare class GridSystem extends GridRect {
4491
4598
  getHeight(): number;
4492
4599
  }
4493
4600
 
4494
- export { type AddTrayOptions, type AddWidgetOption, AiApi, AiApiEvent, type AiApiMethods, type AiConfig, type AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, type AppApiMethods, AppConfig, AppEvent, type AppMouseEvent, AppNotification, AppReminderNotification, type AppRoutes, type AppRuntimeInfo, type AudioData, BackgroundWidget, BaseApi, type BaseboardData, type BatteryData, type BiosData, type BlockDevicesData, type BluetoothDeviceData, BroadcastApi, type BroadcastApiMethods, BroadcastEvent, type BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, type BrowserWindowApiMethods, type BrowserWindowOptions, type CallNotificationOption, type Category, Channel, type ChassisData, ClipboardApi, ClipboardApiEvent, type ClipboardApiMethods, type CountdownNotificationOption, type CpuCacheData, type CpuCurrentSpeedData, type CpuData, type CpuTemperatureData, type CurrentLoadCpuData, type CurrentLoadData, DefaultWidgetTheme, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, type DeployedWidgetApiMethods, type DevOptions, DeviceApi, type DeviceApiMethods, DialogApi, type DialogApiMethods, type DiskLayoutData, type DisksIoData, type Display, type DisplayBalloonOptions, type DockerContainerData, type DockerContainerMountData, type DockerContainerProcessData, type DockerContainerStatsData, type DockerImageData, type DockerInfoData, type DockerVolumeData, type DownloadUrlOptions, type DynamicData, ElectronApi, ElectronUtils, FileApi, type FileApiMethods, type FsOpenFilesData, type FsSizeData, type FsStatsData, type GraphicsControllerData, type GraphicsData, type GraphicsDisplayData, Gravity, GridRect, GridSystem, HostedMode, HttpApi, type HttpApiMethods, type IAiApi, type IAppApi, type IBackgroundWidgetOptions, type IDeviceApi, type IDialogApi, type IFileApi, type IGridRect, type ILogApi, type IMouseApi, type IPage, type IPageOptions, type IProcessApi, type ITrayApi, type IUserApi, type IWidgetDataApi, type IWidgetOptions, type IWidgetPackageApi, type IWidgetTheme, type IWindowSize, type InetChecksiteData, type InfoNotificationOption, type Language, type LanguageCode, LanguageMap, type LanguageTextMap, LanguageUtils, type LocalPackageUrlInfo, type LocationQuery, type LocationQueryRaw, type LocationQueryValue, type LocationQueryValueRaw, LogApi, type LogApiMethods, type MemData, type MemLayoutData, MenuApi, MenuApiEvent, type MenuApiMethods, type MetaInfo, type Metadata, MouseApi, MouseApiEvent, type MouseApiMethods, type NativeKeyboardEvent, type NetworkConnectionsData, type NetworkInterfacesData, type NetworkStatsData, type NormalizeOptions, NotificationApi, NotificationApiEvent, type NotificationApiMethods, type NotificationOption, NotificationSize, type NotificationType, type OsData, Page, type Point, type Position, type PrinterData, ProcessApi, type ProcessApiMethods, type ProcessesData, type ProcessesProcessData, type ProcessesProcessLoadData, type ProxyConfig, type RaspberryRevisionData, type ReadDirOptions, type Rectangle, type ReminderNotificationOption, type RemotePackageUrlInfo, type SaveWidgetOption, type ServicesData, type SetPositionOptions, ShortcutApi, ShortcutApiEvent, type ShortcutApiMethods, type ShortcutDetails, type ShowMenuOption, type Size, type SmartData, SocialInfo, type SocialLink, type SocialType, type StaticData, StorageApi, type StorageApiMethods, StoreApi, type StoreApiMethods, SystemApi, SystemApiEvent, type SystemApiMethods, type SystemData, type SystemFile, type SystemInfoMethods, type SystemInfoResultMap, ThemeMode, type TimeData, TrayApi, TrayApiEvent, type TrayApiMethods, type TrayWidgetOptions, type UsbData, UserApi, UserApiEvent, type UserApiMethods, type UserData, type UuidData, type VboxInfoData, type VersionData, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, type WidgetApiMethods, WidgetData, WidgetDataApi, type WidgetDataApiMethods, WidgetKeyword, type WidgetMenuItem, WidgetPackage, WidgetPackageApi, WidgetPackageApiEvent, type WidgetPackageApiMethods, type WidgetPackageOptions, WidgetPackageUtils, WidgetParams, type WidgetPermission, type WidgetRoute, type WidgetSyncInfo, WidgetTheme, type WidgetThemeKey, type WidgetThemeProperty, WidgetUtils, type WifiConnectionData, type WifiInterfaceData, type WifiNetworkData, delay, normalizeUrl, parseQuery, stringifyQuery };
4601
+ export { type AddTrayOptions, type AddWidgetOption, AiApiEvent, type AiApiMethods, type AiConfig, type AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, type AppApiMethods, AppConfig, AppEvent, type AppMouseEvent, AppNotification, AppReminderNotification, type AppRoutes, type AppRuntimeInfo, AppTheme, type AudioData, BackgroundWidget, BaseApi, type BaseboardData, type BatteryData, type BiosData, type BlockDevicesData, type BluetoothDeviceData, BroadcastApi, type BroadcastApiMethods, BroadcastEvent, type BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, type BrowserWindowApiMethods, type BrowserWindowOptions, type CallNotificationOption, type Category, Channel, type ChassisData, ClipboardApi, ClipboardApiEvent, type ClipboardApiMethods, type CountdownNotificationOption, type CpuCacheData, type CpuCurrentSpeedData, type CpuData, type CpuTemperatureData, type CurrentLoadCpuData, type CurrentLoadData, type DeepPartial, DefaultTheme, DefaultThemeDark, DefaultThemeLight, DefaultWidgetTheme, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, DeployedWidgetApiEvent, type DeployedWidgetApiMethods, type DevOptions, DeviceApi, type DeviceApiMethods, DialogApi, type DialogApiMethods, type DiskLayoutData, type DisksIoData, type Display, type DisplayBalloonOptions, type DockerContainerData, type DockerContainerMountData, type DockerContainerProcessData, type DockerContainerStatsData, type DockerImageData, type DockerInfoData, type DockerVolumeData, type DownloadUrlOptions, type DynamicData, ElectronApi, ElectronUtils, FileApi, type FileApiMethods, type FsOpenFilesData, type FsSizeData, type FsStatsData, type GraphicsControllerData, type GraphicsData, type GraphicsDisplayData, Gravity, GridRect, GridSystem, HostedMode, HttpApi, type HttpApiMethods, type IAiApi, type IAppApi, type IAppTheme, type IBackgroundWidgetOptions, type IDeployedWidgetApi, type IDeviceApi, type IDialogApi, type IFileApi, type IGridRect, type ILogApi, type IMouseApi, type IPage, type IPageOptions, type IProcessApi, type ITrayApi, type IUserApi, type IWidgetDataApi, type IWidgetOptions, type IWidgetPackageApi, type IWidgetTheme, type IWindowSize, type InetChecksiteData, type InfoNotificationOption, type Language, type LanguageCode, LanguageMap, type LanguageTextMap, LanguageUtils, type LocalPackageUrlInfo, type LocationQuery, type LocationQueryRaw, type LocationQueryValue, type LocationQueryValueRaw, LogApi, type LogApiMethods, type MemData, type MemLayoutData, MenuApi, MenuApiEvent, type MenuApiMethods, type MetaInfo, type Metadata, MouseApi, MouseApiEvent, type MouseApiMethods, type NativeKeyboardEvent, type NetworkConnectionsData, type NetworkInterfacesData, type NetworkStatsData, type NormalizeOptions, NotificationApi, NotificationApiEvent, type NotificationApiMethods, type NotificationOption, NotificationSize, type NotificationType, type OsData, Page, type Point, type Position, type PrinterData, ProcessApi, type ProcessApiMethods, type ProcessesData, type ProcessesProcessData, type ProcessesProcessLoadData, type ProxyConfig, type RaspberryRevisionData, type ReadDirOptions, type Rectangle, type ReminderNotificationOption, type RemotePackageUrlInfo, type SaveWidgetOption, type ServicesData, type SetPositionOptions, ShortcutApi, ShortcutApiEvent, type ShortcutApiMethods, type ShortcutDetails, type ShowMenuOption, type Size, type SmartData, SocialInfo, type SocialLink, type SocialType, type StaticData, StorageApi, type StorageApiMethods, StoreApi, type StoreApiMethods, SystemApi, SystemApiEvent, type SystemApiMethods, type SystemData, type SystemFile, type SystemInfoMethods, type SystemInfoResultMap, type ThemeBoxShadow, type ThemeColors, ThemeMode, type ThemeRadius, type ThemeShadow, type ThemeTypography, type TimeData, TrayApi, TrayApiEvent, type TrayApiMethods, type TrayWidgetOptions, type UsbData, UserApi, UserApiEvent, type UserApiMethods, type UserData, type UuidData, type VboxInfoData, type VersionData, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, type WidgetApiMethods, WidgetData, WidgetDataApi, type WidgetDataApiMethods, WidgetKeyword, type WidgetMenuItem, WidgetPackage, WidgetPackageApi, WidgetPackageApiEvent, type WidgetPackageApiMethods, type WidgetPackageOptions, WidgetPackageUtils, WidgetParams, type WidgetPermission, type WidgetRoute, type WidgetSyncInfo, WidgetTheme, type WidgetThemeKey, type WidgetThemeProperty, WidgetUtils, type WifiConnectionData, type WifiInterfaceData, type WifiNetworkData, delay, normalizeUrl, parseQuery, stringifyQuery };