@widget-js/core 0.1.31 → 0.5.12
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/cjs/api/AppApi.js +24 -21
- package/dist/cjs/api/BaseApi.js +13 -0
- package/dist/cjs/api/BroadcastApi.js +14 -13
- package/dist/cjs/api/BrowserWindowApi.js +55 -72
- package/dist/cjs/api/Channel.js +1 -1
- package/dist/cjs/api/ClipboardApi.js +16 -11
- package/dist/cjs/api/DeviceApi.js +12 -9
- package/dist/cjs/api/DialogApi.js +8 -6
- package/dist/cjs/api/HostedWidgetApi.js +27 -36
- package/dist/cjs/api/LogApi.js +14 -10
- package/dist/cjs/api/NotificationApi.js +52 -74
- package/dist/cjs/api/ShortcutApi.js +23 -0
- package/dist/cjs/api/WidgetApi.js +29 -69
- package/dist/cjs/{repository/WidgetDataRepository.js → api/WidgetDataApi.js} +19 -10
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/lang/LanguageCode.js +34 -0
- package/dist/cjs/model/Widget.js +4 -4
- package/dist/cjs/model/WidgetPackage.js +49 -2
- package/dist/cjs/model/event/BroadcastEvent.js +4 -8
- package/dist/cjs/model/msic/graphics.js +2 -0
- package/dist/cjs/utils/ElectronUtils.js +5 -1
- package/dist/cjs/utils/LanguageUtils.js +36 -0
- package/dist/esm/api/AppApi.js +23 -20
- package/dist/esm/api/BaseApi.js +9 -0
- package/dist/esm/api/BroadcastApi.js +13 -12
- package/dist/esm/api/BrowserWindowApi.js +53 -71
- package/dist/esm/api/Channel.js +1 -1
- package/dist/esm/api/ClipboardApi.js +15 -10
- package/dist/esm/api/DeviceApi.js +11 -8
- package/dist/esm/api/DialogApi.js +9 -6
- package/dist/esm/api/HostedWidgetApi.js +26 -35
- package/dist/esm/api/LogApi.js +15 -10
- package/dist/esm/api/NotificationApi.js +51 -73
- package/dist/esm/api/ShortcutApi.js +19 -0
- package/dist/esm/api/WidgetApi.js +28 -65
- package/dist/esm/{repository/WidgetDataRepository.js → api/WidgetDataApi.js} +17 -8
- package/dist/esm/index.js +3 -2
- package/dist/esm/lang/LanguageCode.js +33 -0
- package/dist/esm/model/Widget.js +4 -4
- package/dist/esm/model/WidgetPackage.js +49 -2
- package/dist/esm/model/event/BroadcastEvent.js +4 -8
- package/dist/esm/model/msic/graphics.js +1 -0
- package/dist/esm/utils/ElectronUtils.js +5 -1
- package/dist/esm/utils/LanguageUtils.js +32 -0
- package/dist/types/api/AppApi.d.ts +23 -13
- package/dist/types/api/BaseApi.d.ts +5 -0
- package/dist/types/api/BroadcastApi.d.ts +19 -4
- package/dist/types/api/BrowserWindowApi.d.ts +56 -52
- package/dist/types/api/Channel.d.ts +1 -1
- package/dist/types/api/ClipboardApi.d.ts +9 -5
- package/dist/types/api/DeviceApi.d.ts +13 -9
- package/dist/types/api/DialogApi.d.ts +5 -7
- package/dist/types/api/HostedWidgetApi.d.ts +28 -18
- package/dist/types/api/LogApi.d.ts +8 -5
- package/dist/types/api/NotificationApi.d.ts +26 -16
- package/dist/types/api/ShortcutApi.d.ts +10 -0
- package/dist/types/api/WidgetApi.d.ts +31 -33
- package/dist/types/{repository/WidgetDataRepository.d.ts → api/WidgetDataApi.d.ts} +7 -2
- package/dist/types/index.d.ts +3 -2
- package/dist/types/lang/LanguageCode.d.ts +40 -0
- package/dist/types/model/Widget.d.ts +7 -9
- package/dist/types/model/WidgetPackage.d.ts +55 -12
- package/dist/types/model/event/BroadcastEvent.d.ts +14 -10
- package/dist/types/model/msic/graphics.d.ts +8 -0
- package/dist/types/utils/ElectronUtils.d.ts +2 -1
- package/dist/types/utils/LanguageUtils.d.ts +8 -0
- package/dist/umd/index.js +1 -1
- package/package.json +4 -2
- package/dist/cjs/api/GlobalShortcutApi.js +0 -29
- package/dist/esm/api/GlobalShortcutApi.js +0 -25
- package/dist/types/api/GlobalShortcutApi.d.ts +0 -14
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { BroadcastEvent } from "../model/event/BroadcastEvent";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
import { WidgetApiEvent } from "./WidgetApi";
|
|
4
|
+
import { ShortcutApiEvent } from "./ShortcutApi";
|
|
5
|
+
import { ClipboardApiEvent } from "./ClipboardApi";
|
|
6
|
+
import { BrowserWindowApiEvent } from "./BrowserWindowApi";
|
|
7
|
+
type BroadcastEventType = WidgetApiEvent | BrowserWindowApiEvent | ShortcutApiEvent | ClipboardApiEvent | string;
|
|
8
|
+
interface IBroadcastApi {
|
|
9
|
+
send(event: BroadcastEvent): Promise<void>;
|
|
10
|
+
register(...event: BroadcastEventType[]): Promise<void>;
|
|
11
|
+
unregister(...event: BroadcastEventType[]): Promise<void>;
|
|
6
12
|
}
|
|
13
|
+
type BroadcastApiMethods = keyof IBroadcastApi;
|
|
14
|
+
export declare class BroadcastApiImpl extends BaseApi<BroadcastApiMethods> implements IBroadcastApi {
|
|
15
|
+
send(event: BroadcastEvent): Promise<void>;
|
|
16
|
+
register(...event: BroadcastEventType[]): Promise<void>;
|
|
17
|
+
unregister(...event: BroadcastEventType[]): Promise<void>;
|
|
18
|
+
getChannel(): string;
|
|
19
|
+
}
|
|
20
|
+
declare const BroadcastApi: IBroadcastApi;
|
|
21
|
+
export { BroadcastApi, BroadcastApiMethods, BroadcastEventType };
|
|
@@ -1,68 +1,72 @@
|
|
|
1
1
|
import { Rectangle } from "../model/interface/Rectangle";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
2
|
+
import { Position } from "../model/msic/graphics";
|
|
3
|
+
import { BaseApi } from "./BaseApi";
|
|
4
|
+
interface IBrowserWindowApi {
|
|
5
|
+
setIgnoreMouseEvent(ignore: boolean): Promise<void>;
|
|
6
|
+
show(): Promise<void>;
|
|
7
|
+
hide(): Promise<void>;
|
|
8
|
+
showInactive(): Promise<void>;
|
|
9
|
+
center(): Promise<void>;
|
|
10
|
+
startDraggingWindow(): Promise<void>;
|
|
11
|
+
stopDraggingWindow(): Promise<void>;
|
|
12
|
+
setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
|
|
13
|
+
isAlwaysOnTop(): Promise<boolean>;
|
|
14
|
+
openUrl(url: string): Promise<void>;
|
|
15
|
+
moveTop(): Promise<void>;
|
|
16
|
+
openDevTools(): Promise<void>;
|
|
17
|
+
setPosition(x: number, y: number, animation: boolean): Promise<void>;
|
|
18
|
+
getPosition(): Promise<Position>;
|
|
19
|
+
blur(): Promise<void>;
|
|
20
|
+
focus(): Promise<void>;
|
|
21
|
+
setResizable(resizable: boolean): Promise<void>;
|
|
22
|
+
getBounds(): Promise<Rectangle>;
|
|
23
|
+
setBounds(bounds: Partial<Rectangle>, animate: boolean): Promise<void>;
|
|
24
|
+
alignToScreen(align: AlignPosition): Promise<void>;
|
|
25
|
+
existsByUrl(url: string): Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
type BrowserWindowApiMethods = keyof IBrowserWindowApi;
|
|
28
|
+
type AlignPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
29
|
+
declare enum BrowserWindowApiEvent {
|
|
30
|
+
BLUR = "event::cn.widgetjs.core.browser-window.blur",
|
|
31
|
+
FOCUS = "event::cn.widgetjs.core.browser-window.focus"
|
|
32
|
+
}
|
|
33
|
+
export declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> implements IBrowserWindowApi {
|
|
34
|
+
getChannel(): string;
|
|
35
|
+
setIgnoreMouseEvent(ignore: boolean): Promise<void>;
|
|
36
|
+
show(): Promise<void>;
|
|
37
|
+
showInactive(): Promise<void>;
|
|
38
|
+
hide(): Promise<void>;
|
|
39
|
+
center(): Promise<void>;
|
|
40
|
+
setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
|
|
41
|
+
isAlwaysOnTop(): Promise<boolean>;
|
|
42
|
+
openUrl(url: string): Promise<void>;
|
|
43
|
+
moveTop(): Promise<void>;
|
|
44
|
+
openDevTools(): Promise<void>;
|
|
43
45
|
/**
|
|
44
46
|
* 设置窗口位置
|
|
45
47
|
* @param x
|
|
46
48
|
* @param y
|
|
47
49
|
* @param animation 动画只在mac系统有效
|
|
48
50
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
setPosition(x: number, y: number, animation: boolean): Promise<void>;
|
|
52
|
+
getPosition(): Promise<Position>;
|
|
53
|
+
blur(): Promise<any>;
|
|
54
|
+
focus(): Promise<any>;
|
|
53
55
|
/**
|
|
54
56
|
* 设置窗口是否可以拉伸
|
|
55
57
|
* @param resizable
|
|
56
58
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
setResizable(resizable: boolean): Promise<any>;
|
|
60
|
+
getBounds(): Promise<Rectangle>;
|
|
61
|
+
setBounds(bounds: Partial<Rectangle>, animate?: boolean): Promise<void>;
|
|
62
|
+
alignToScreen(align: AlignPosition): Promise<any>;
|
|
63
|
+
startDraggingWindow(): Promise<any>;
|
|
64
|
+
stopDraggingWindow(): Promise<any>;
|
|
63
65
|
/**
|
|
64
66
|
* 通过url检测窗口是否存在
|
|
65
67
|
* @param url
|
|
66
68
|
*/
|
|
67
|
-
|
|
69
|
+
existsByUrl(url: string): Promise<boolean>;
|
|
68
70
|
}
|
|
71
|
+
declare const BrowserWindowApi: BrowserWindowApiImpl;
|
|
72
|
+
export { BrowserWindowApi, BrowserWindowApiMethods, BrowserWindowApiEvent, AlignPosition };
|
|
@@ -11,6 +11,6 @@ export declare enum Channel {
|
|
|
11
11
|
SHORTCUT = "channel::cn.widgetjs.core.shortcut",
|
|
12
12
|
LOG = "channel::cn.widgetjs.core.log",
|
|
13
13
|
DEVICE = "channel::cn.widgetjs.core.device",
|
|
14
|
-
|
|
14
|
+
MOUSE = "channel::cn.widgetjs.core.mouse",
|
|
15
15
|
KEYBOARD = "channel::cn.widgetjs.core.keyboard"
|
|
16
16
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
static getSelectedText(): Promise<string | undefined>;
|
|
5
|
-
static getText(): Promise<string | undefined>;
|
|
1
|
+
interface IClipboardApi {
|
|
2
|
+
getSelectedText(): Promise<string | undefined>;
|
|
3
|
+
getText(): Promise<string | undefined>;
|
|
6
4
|
}
|
|
5
|
+
type ClipboardApiMethods = keyof IClipboardApi;
|
|
6
|
+
declare enum ClipboardApiEvent {
|
|
7
|
+
CHANGED = "clipboard-changed"
|
|
8
|
+
}
|
|
9
|
+
declare const ClipboardApi: IClipboardApi;
|
|
10
|
+
export { ClipboardApi, ClipboardApiMethods, ClipboardApiEvent };
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BaseApi } from "./BaseApi";
|
|
2
|
+
import { Point } from "../model/msic/graphics";
|
|
3
|
+
interface IDeviceApi {
|
|
4
|
+
getCursorScreenPoint(): Promise<Point>;
|
|
5
|
+
isAllKeyReleased(): Promise<boolean>;
|
|
6
|
+
}
|
|
7
|
+
type DeviceApiMethods = keyof IDeviceApi;
|
|
8
|
+
export declare class DeviceApiImpl extends BaseApi<DeviceApiMethods> implements IDeviceApi {
|
|
4
9
|
/**
|
|
5
10
|
* 获取当前鼠标位置
|
|
6
11
|
*/
|
|
7
|
-
|
|
12
|
+
getCursorScreenPoint(): Promise<Point>;
|
|
8
13
|
/**
|
|
9
14
|
* 判断是否所有按键都已经释放
|
|
10
15
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export interface Point {
|
|
14
|
-
x: number;
|
|
15
|
-
y: number;
|
|
16
|
+
isAllKeyReleased(): Promise<boolean>;
|
|
17
|
+
getChannel(): string;
|
|
16
18
|
}
|
|
19
|
+
declare const DeviceApi: IDeviceApi;
|
|
20
|
+
export { DeviceApi, DeviceApiMethods };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 选取单个文件
|
|
5
|
-
* @param extensions 允许的文件后缀格式,如:["txt","docx","gif"]
|
|
6
|
-
*/
|
|
7
|
-
static pickFile(extensions?: string[]): Promise<string | undefined>;
|
|
1
|
+
interface IDialogApi {
|
|
2
|
+
pickFile(extensions?: string[]): Promise<string | undefined>;
|
|
8
3
|
}
|
|
4
|
+
type DialogApiMethods = keyof IDialogApi;
|
|
5
|
+
declare const DialogApi: IDialogApi;
|
|
6
|
+
export { DialogApiMethods, DialogApi, };
|
|
@@ -1,45 +1,55 @@
|
|
|
1
1
|
import { HostedWidget } from "../model/HostedWidget";
|
|
2
2
|
import { WidgetParams } from "../model/WidgetParams";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { BaseApi } from "./BaseApi";
|
|
4
|
+
import { HostedMode } from '../model/HostedMode';
|
|
5
|
+
import { Widget } from '../model/Widget';
|
|
6
|
+
interface IHostedWidgetApi {
|
|
7
|
+
removeHostedWidget(id: string): Promise<void>;
|
|
8
|
+
removeHostedWidgetByName(name: string): Promise<HostedWidget[]>;
|
|
9
|
+
getHostedWidgets(): Promise<HostedWidget[]>;
|
|
10
|
+
openDevTools(id: string): Promise<void>;
|
|
11
|
+
openConfigRoute(id: string): Promise<void>;
|
|
12
|
+
registerActiveShortcut(id: string, shortcut: string): Promise<boolean>;
|
|
13
|
+
setProxy(id: string, proxy: string): Promise<boolean>;
|
|
14
|
+
getHostedWidget(id: string): Promise<HostedWidget>;
|
|
15
|
+
addWidget(widgetName: string, hostMode: HostedMode): Promise<Widget[]>;
|
|
16
|
+
}
|
|
17
|
+
type HostedWidgetApiMethods = keyof IHostedWidgetApi;
|
|
18
|
+
export declare class HostedWidgetApiImpl extends BaseApi<HostedWidgetApiMethods> implements IHostedWidgetApi {
|
|
19
|
+
getChannel(): string;
|
|
13
20
|
/**
|
|
14
21
|
* 移除组件
|
|
15
22
|
* @param id
|
|
16
23
|
*/
|
|
17
|
-
|
|
24
|
+
removeHostedWidget(id: string): Promise<any>;
|
|
25
|
+
addWidget(widgetName: string, hostMode: HostedMode): Promise<Widget[]>;
|
|
18
26
|
/**
|
|
19
27
|
* 通过组件名移除已添加的组件
|
|
20
28
|
* @param name 组件名
|
|
21
29
|
*/
|
|
22
|
-
|
|
30
|
+
removeHostedWidgetByName(name: string): Promise<HostedWidget[]>;
|
|
23
31
|
/**
|
|
24
32
|
* 获取已添加的组件
|
|
25
33
|
* @param name 组件名,可以不传
|
|
26
34
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
getHostedWidgets(name?: string): Promise<HostedWidget[]>;
|
|
36
|
+
getHostedWidget(id: string): Promise<HostedWidget>;
|
|
29
37
|
/**
|
|
30
38
|
* Opens the dev tools for a widget with the specified ID.
|
|
31
39
|
*
|
|
32
40
|
* @param {string} widgetId - The ID of the widget to open the dev tools for.
|
|
33
41
|
* @return {Promise} A Promise that resolves when the dev tools are opened.
|
|
34
42
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
openDevTools(widgetId: string): Promise<any>;
|
|
44
|
+
openConfigRoute(widgetId: string, params?: WidgetParams): Promise<any>;
|
|
37
45
|
/**
|
|
38
46
|
* 注册激活、呼出、置顶组件快捷键
|
|
39
47
|
* @param widgetId 组件id
|
|
40
48
|
* @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
|
|
41
49
|
* https://www.electronjs.org/docs/latest/api/accelerator
|
|
42
50
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
|
|
52
|
+
setProxy(widgetId: string, proxy: string): Promise<boolean>;
|
|
45
53
|
}
|
|
54
|
+
declare const HostedWidgetApi: HostedWidgetApiImpl;
|
|
55
|
+
export { HostedWidgetApi, HostedWidgetApiMethods };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
interface ILogApi {
|
|
2
|
+
info(...data: any[]): void;
|
|
3
|
+
error(...data: any[]): void;
|
|
4
|
+
warn(...data: any[]): void;
|
|
5
|
+
log(...data: any[]): void;
|
|
6
6
|
}
|
|
7
|
+
type LogApiMethods = keyof ILogApi;
|
|
8
|
+
declare const LogApi: ILogApi;
|
|
9
|
+
export { LogApi, LogApiMethods };
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import { AppNotification
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { AppNotification } from "../model/AppNotification";
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
interface INotificationApi {
|
|
4
|
+
send(notification: AppNotification): Promise<void>;
|
|
5
|
+
hide(): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
type NotificationApiMethods = keyof INotificationApi;
|
|
8
|
+
declare enum NotificationApiEvent {
|
|
9
|
+
CONFIRM = "event::cn.widgetjs.core.notification.confirm",
|
|
10
|
+
CANCEL = "event::cn.widgetjs.core.notification.cancel",
|
|
11
|
+
HIDE = "event::cn.widgetjs.core.notification.hide"
|
|
12
|
+
}
|
|
13
|
+
declare class NotificationApiImpl extends BaseApi<NotificationApiMethods> implements INotificationApi {
|
|
4
14
|
/**
|
|
5
15
|
* 来电
|
|
6
16
|
* @param avatar 头像地址
|
|
@@ -9,20 +19,20 @@ export declare class NotificationApi {
|
|
|
9
19
|
* @param message 初始消息
|
|
10
20
|
* @param lyric 歌词字符串
|
|
11
21
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
call(avatar: string, audio: string, title: string, message: string, lyric: string): Promise<void>;
|
|
23
|
+
send(notification: AppNotification): Promise<any>;
|
|
24
|
+
reminder(title: string, message: string, icon: string, cancelButtonText: string, confirmButtonText: string, cancelBroadcast: string, confirmBroadcast: string, duration?: number): Promise<any>;
|
|
25
|
+
advanceCountdown(message: string, targetTime: string, title?: string): Promise<any>;
|
|
26
|
+
countdown(message: string, targetTime: string): Promise<void>;
|
|
27
|
+
success(message: string, duration?: number): Promise<void>;
|
|
28
|
+
error(message: string, duration?: number): Promise<void>;
|
|
29
|
+
warning(message: string, duration?: number): Promise<void>;
|
|
30
|
+
info(message: string, duration?: number): Promise<void>;
|
|
21
31
|
/**
|
|
22
32
|
* 隐藏通知
|
|
23
33
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
static setDebugNotification(callback: NotificationCallback): void;
|
|
34
|
+
hide(): Promise<void>;
|
|
35
|
+
getChannel(): string;
|
|
27
36
|
}
|
|
28
|
-
|
|
37
|
+
declare const NotificationApi: NotificationApiImpl;
|
|
38
|
+
export { NotificationApi, NotificationApiMethods, NotificationApiEvent };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface IShortcutApi {
|
|
2
|
+
register(shortcut: string): void;
|
|
3
|
+
unregister(shortcut: string): void;
|
|
4
|
+
}
|
|
5
|
+
type ShortcutApiMethods = keyof IShortcutApi;
|
|
6
|
+
declare enum ShortcutApiEvent {
|
|
7
|
+
TRIGGERED = "channel::cn.widgetjs.core.shortcut.triggered"
|
|
8
|
+
}
|
|
9
|
+
declare const ShortcutApi: IShortcutApi;
|
|
10
|
+
export { ShortcutApi, ShortcutApiMethods, ShortcutApiEvent };
|
|
@@ -1,50 +1,48 @@
|
|
|
1
1
|
import { Widget } from "../model/Widget";
|
|
2
2
|
import { WidgetPackage } from "../model/WidgetPackage";
|
|
3
3
|
import { WidgetParams } from "../model/WidgetParams";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { BaseApi } from "./BaseApi";
|
|
5
|
+
interface IWidgetApi {
|
|
6
|
+
registerWidgets(widgets: Widget[]): Promise<void>;
|
|
7
|
+
registerWidgetPackage(widgetPackage: WidgetPackage): Promise<void>;
|
|
8
|
+
getWidgets(): Promise<Widget[]>;
|
|
9
|
+
getWidget(name: string): Promise<Widget>;
|
|
10
|
+
getWidgetPackage(name: string): Promise<WidgetPackage>;
|
|
11
|
+
getWidgetPackages(): Promise<WidgetPackage[]>;
|
|
12
|
+
getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
13
|
+
getWidgetPackageIndexUrl(packageName: string, hash?: boolean): Promise<string | null>;
|
|
14
|
+
getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
15
|
+
getWidgetPackageUrl(packageName: string): Promise<string | null>;
|
|
8
16
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
type WidgetApiMethods = keyof IWidgetApi;
|
|
18
|
+
declare enum WidgetApiEvent {
|
|
19
|
+
DATA_CHANGED = "event::cn.widgetjs.core.widget.data-changed",
|
|
20
|
+
EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit"
|
|
21
|
+
}
|
|
22
|
+
declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidgetApi {
|
|
23
|
+
getChannel(): string;
|
|
24
|
+
registerWidgets(widgets: Widget[]): Promise<any>;
|
|
25
|
+
registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
|
|
26
|
+
getWidgets(): Promise<Widget[]>;
|
|
27
|
+
getWidgetPackages(): Promise<WidgetPackage[]>;
|
|
20
28
|
/**
|
|
21
29
|
*
|
|
22
30
|
* @param name package name
|
|
23
31
|
*/
|
|
24
|
-
|
|
32
|
+
getWidget(name: string): Promise<Widget>;
|
|
25
33
|
/**
|
|
26
34
|
*
|
|
27
35
|
* @param name package name
|
|
28
36
|
*/
|
|
29
|
-
|
|
37
|
+
getWidgetPackage(name: string): Promise<WidgetPackage>;
|
|
30
38
|
/**
|
|
31
39
|
* 获取组件配置地址
|
|
32
40
|
* @param widgetName
|
|
33
41
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
|
|
40
|
-
* @param data
|
|
41
|
-
* @param options
|
|
42
|
-
*/
|
|
43
|
-
static saveDataByName<T extends WidgetData>(data: T, options?: SaveWidgetOption): Promise<string>;
|
|
44
|
-
private static stores;
|
|
45
|
-
/**
|
|
46
|
-
* 获取组件 LocalForage 存储实例
|
|
47
|
-
* @param name
|
|
48
|
-
*/
|
|
49
|
-
static getStore(name: string): LocalForage;
|
|
42
|
+
getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
43
|
+
getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
44
|
+
getWidgetPackageIndexUrl(packageName: string, hash?: boolean): Promise<string | null>;
|
|
45
|
+
getWidgetPackageUrl(packageName: string): Promise<string | null>;
|
|
50
46
|
}
|
|
47
|
+
declare const WidgetApi: WidgetApiImpl;
|
|
48
|
+
export { WidgetApi, WidgetApiEvent, WidgetApiMethods };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { WidgetData } from "../model/WidgetData";
|
|
2
|
-
export
|
|
2
|
+
export interface SaveWidgetOption {
|
|
3
|
+
sendBroadcast?: boolean;
|
|
4
|
+
id?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class WidgetDataApi {
|
|
3
7
|
private static stores;
|
|
4
8
|
/**
|
|
5
9
|
* 保存组件数据
|
|
@@ -14,8 +18,9 @@ export declare class WidgetDataRepository {
|
|
|
14
18
|
/**
|
|
15
19
|
* 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
|
|
16
20
|
* @param data
|
|
21
|
+
* @param options
|
|
17
22
|
*/
|
|
18
|
-
static saveByName<T extends WidgetData>(data: T): Promise<string>;
|
|
23
|
+
static saveByName<T extends WidgetData>(data: T, options?: SaveWidgetOption): Promise<string>;
|
|
19
24
|
static findByName<T extends WidgetData>(name: string, type: {
|
|
20
25
|
new (name: string, id?: string): T;
|
|
21
26
|
}): Promise<T | undefined>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ export * from "./model/event/NativeKeyboardEvent";
|
|
|
11
11
|
export * from "./model/event/AppMouseEvent";
|
|
12
12
|
export * from "./model/WidgetPackage";
|
|
13
13
|
export * from "./api/ElectronApi";
|
|
14
|
-
export * from "./
|
|
14
|
+
export * from "./api/WidgetDataApi";
|
|
15
15
|
export * from "./api/BrowserWindowApi";
|
|
16
|
-
export * from "./
|
|
16
|
+
export * from "./lang/LanguageCode";
|
|
17
17
|
export * from "./api/NotificationApi";
|
|
18
18
|
export * from "./api/HostedWidgetApi";
|
|
19
19
|
export * from "./api/DeviceApi";
|
|
@@ -21,6 +21,7 @@ export * from "./api/Channel";
|
|
|
21
21
|
export * from "./api/ClipboardApi";
|
|
22
22
|
export * from "./api/WidgetApi";
|
|
23
23
|
export * from "./api/ApiConstants";
|
|
24
|
+
export * from "./api/ShortcutApi";
|
|
24
25
|
export * from "./api/BroadcastApi";
|
|
25
26
|
export * from "./api/AppApi";
|
|
26
27
|
export * from "./api/DialogApi";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
interface Language {
|
|
2
|
+
locale: string;
|
|
3
|
+
language: string;
|
|
4
|
+
code: string;
|
|
5
|
+
}
|
|
6
|
+
interface ILanguageMap {
|
|
7
|
+
'ar-SA': Language;
|
|
8
|
+
'bn-BD': Language;
|
|
9
|
+
'en-US': Language;
|
|
10
|
+
'de-DE': Language;
|
|
11
|
+
'el-GR': Language;
|
|
12
|
+
'es-ES': Language;
|
|
13
|
+
'fi-FI': Language;
|
|
14
|
+
'fil-PH': Language;
|
|
15
|
+
'fr-FR': Language;
|
|
16
|
+
'hi-IN': Language;
|
|
17
|
+
'hu-HU': Language;
|
|
18
|
+
'id-ID': Language;
|
|
19
|
+
'it-IT': Language;
|
|
20
|
+
'ja-JP': Language;
|
|
21
|
+
'ko-KR': Language;
|
|
22
|
+
'nl-NL': Language;
|
|
23
|
+
'pl-PL': Language;
|
|
24
|
+
'pt-BR': Language;
|
|
25
|
+
'pt-PT': Language;
|
|
26
|
+
'ro-RO': Language;
|
|
27
|
+
'ru-RU': Language;
|
|
28
|
+
'sv-SE': Language;
|
|
29
|
+
'ta-IN': Language;
|
|
30
|
+
'tr-TR': Language;
|
|
31
|
+
'uk-UA': Language;
|
|
32
|
+
'vi-VN': Language;
|
|
33
|
+
'zh-CN': Language;
|
|
34
|
+
'zh-TW': Language;
|
|
35
|
+
}
|
|
36
|
+
export type LanguageCode = keyof ILanguageMap;
|
|
37
|
+
export type LanguageTextMap = {
|
|
38
|
+
[key in LanguageCode]?: string;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HostedMode } from "./HostedMode";
|
|
2
2
|
import { WidgetPermission } from "../permission/permission";
|
|
3
|
+
import { LanguageCode, LanguageTextMap } from "../lang/LanguageCode";
|
|
3
4
|
type WidgetOptions = {
|
|
4
5
|
name: string;
|
|
5
6
|
title: {
|
|
@@ -32,6 +33,7 @@ type WidgetOptions = {
|
|
|
32
33
|
hideWhenBlur?: boolean;
|
|
33
34
|
routes: WidgetRoute[];
|
|
34
35
|
permissions?: WidgetPermission[];
|
|
36
|
+
broadcastChannels?: string[];
|
|
35
37
|
};
|
|
36
38
|
export declare class Widget {
|
|
37
39
|
readonly name: string;
|
|
@@ -39,15 +41,11 @@ export declare class Widget {
|
|
|
39
41
|
* 组件标题,显示在界面上的,
|
|
40
42
|
* https://zh.m.wikipedia.org/zh-hans/ISO_639-1
|
|
41
43
|
*/
|
|
42
|
-
readonly title:
|
|
43
|
-
[key: string]: string;
|
|
44
|
-
};
|
|
44
|
+
readonly title: LanguageTextMap;
|
|
45
45
|
/**
|
|
46
46
|
* 组件介绍
|
|
47
47
|
*/
|
|
48
|
-
readonly description:
|
|
49
|
-
[key: string]: string;
|
|
50
|
-
};
|
|
48
|
+
readonly description: LanguageTextMap;
|
|
51
49
|
readonly keywords: WidgetKeyword[];
|
|
52
50
|
/**
|
|
53
51
|
* 组件默认语言
|
|
@@ -86,12 +84,12 @@ export declare class Widget {
|
|
|
86
84
|
* 获取组件标题
|
|
87
85
|
* @param lang 语言环境,不传则获取默认语言
|
|
88
86
|
*/
|
|
89
|
-
getTitle(lang?:
|
|
87
|
+
getTitle(lang?: LanguageCode): string | undefined;
|
|
90
88
|
/**
|
|
91
|
-
*
|
|
89
|
+
* 获取组件描述
|
|
92
90
|
* @param lang 语言环境,不传则获取默认标题
|
|
93
91
|
*/
|
|
94
|
-
getDescription(lang?:
|
|
92
|
+
getDescription(lang?: LanguageCode): string | undefined;
|
|
95
93
|
static parseJSON(json: string): Widget;
|
|
96
94
|
static parseObject(obj: any): Widget;
|
|
97
95
|
/**
|