@widget-js/core 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +47 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +34 -143
- package/dist/index.js +45 -93
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare enum HostedMode {
|
|
|
21
21
|
PAGE = 1048576,
|
|
22
22
|
ALL = 1118481
|
|
23
23
|
}
|
|
24
|
-
declare enum
|
|
24
|
+
declare enum DeployMode {
|
|
25
25
|
NORMAL = 1,
|
|
26
26
|
/**
|
|
27
27
|
* 悬浮窗
|
|
@@ -31,8 +31,6 @@ declare enum DeployedMode {
|
|
|
31
31
|
ALL = 1118481
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
type WidgetPermission = 'keyboard' | 'mouse' | 'clipboard' | 'notification' | 'storage' | 'network' | 'cpu' | 'system-info';
|
|
35
|
-
|
|
36
34
|
interface Language {
|
|
37
35
|
locale: string;
|
|
38
36
|
language: string;
|
|
@@ -102,7 +100,7 @@ interface IWindowOptions extends IWindowSize {
|
|
|
102
100
|
movable?: boolean;
|
|
103
101
|
resizable?: boolean;
|
|
104
102
|
backgroundThrottling?: boolean;
|
|
105
|
-
|
|
103
|
+
path: string;
|
|
106
104
|
/**
|
|
107
105
|
* 是否只能添加一次
|
|
108
106
|
*/
|
|
@@ -136,7 +134,7 @@ interface IPage {
|
|
|
136
134
|
readonly movable: boolean;
|
|
137
135
|
readonly singleton: boolean;
|
|
138
136
|
readonly resizable: boolean;
|
|
139
|
-
readonly
|
|
137
|
+
readonly path: string;
|
|
140
138
|
readonly meta: {
|
|
141
139
|
[key: string]: string | number | boolean;
|
|
142
140
|
};
|
|
@@ -172,7 +170,7 @@ declare class Page implements IPage {
|
|
|
172
170
|
readonly movable: boolean;
|
|
173
171
|
readonly singleton: boolean;
|
|
174
172
|
readonly resizable: boolean;
|
|
175
|
-
readonly
|
|
173
|
+
readonly path: string;
|
|
176
174
|
readonly meta: {
|
|
177
175
|
[key: string]: string | number | boolean;
|
|
178
176
|
};
|
|
@@ -198,45 +196,16 @@ declare class Page implements IPage {
|
|
|
198
196
|
}
|
|
199
197
|
|
|
200
198
|
interface IWidgetOptions extends IWindowSize, IWindowOptions {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
*/
|
|
204
|
-
supportHostedMode?: DeployedMode;
|
|
205
|
-
supportDeployedMode?: DeployedMode;
|
|
206
|
-
/**
|
|
207
|
-
* 组件拉伸后,是否强制刷新组件
|
|
208
|
-
* @deprecated
|
|
209
|
-
*/
|
|
210
|
-
refreshWhenResided?: boolean;
|
|
211
|
-
/**
|
|
212
|
-
* @deprecated
|
|
213
|
-
*/
|
|
214
|
-
routes: WidgetRoute[];
|
|
215
|
-
/**
|
|
216
|
-
* @deprecated
|
|
217
|
-
*/
|
|
218
|
-
permissions?: WidgetPermission[];
|
|
199
|
+
supportDeployMode?: DeployMode;
|
|
200
|
+
configPagePath?: string;
|
|
219
201
|
}
|
|
220
202
|
declare class Widget extends Page {
|
|
221
|
-
readonly
|
|
222
|
-
readonly supportDeployedMode: number;
|
|
223
|
-
/**
|
|
224
|
-
* @deprecated
|
|
225
|
-
*/
|
|
226
|
-
readonly refreshWhenResided: boolean;
|
|
203
|
+
readonly supportDeployMode: number;
|
|
227
204
|
/**
|
|
228
|
-
*
|
|
229
|
-
* @deprecated
|
|
205
|
+
* 配置页面路径,没有则不能修改
|
|
230
206
|
*/
|
|
231
|
-
readonly
|
|
232
|
-
/**
|
|
233
|
-
* @deprecated
|
|
234
|
-
*/
|
|
235
|
-
readonly permissions: WidgetPermission[];
|
|
207
|
+
readonly configPagePath?: string;
|
|
236
208
|
constructor(options: IWidgetOptions);
|
|
237
|
-
getIndexRoute(): WidgetRoute;
|
|
238
|
-
getConfigRoute(): WidgetRoute | undefined;
|
|
239
|
-
isConfigurable(): boolean;
|
|
240
209
|
static parseJSON(json: string): Widget;
|
|
241
210
|
static parseObject(obj: any): Widget;
|
|
242
211
|
/**
|
|
@@ -249,17 +218,6 @@ declare class Widget extends Page {
|
|
|
249
218
|
*/
|
|
250
219
|
isSupportNormal(): boolean;
|
|
251
220
|
}
|
|
252
|
-
interface WidgetRoute {
|
|
253
|
-
name: string;
|
|
254
|
-
url: string;
|
|
255
|
-
meta?: {
|
|
256
|
-
[key: string]: string;
|
|
257
|
-
};
|
|
258
|
-
/**
|
|
259
|
-
* 使用自定义悬浮窗样式
|
|
260
|
-
*/
|
|
261
|
-
customOverlapView?: boolean;
|
|
262
|
-
}
|
|
263
221
|
declare enum WidgetKeyword {
|
|
264
222
|
RECOMMEND = "recommend",
|
|
265
223
|
TOOLS = "tools",
|
|
@@ -273,6 +231,8 @@ declare enum WidgetKeyword {
|
|
|
273
231
|
DASHBOARD = "dashboard"
|
|
274
232
|
}
|
|
275
233
|
|
|
234
|
+
type WidgetPermission = 'keyboard' | 'mouse' | 'clipboard' | 'notification' | 'storage' | 'network' | 'cpu' | 'system-info';
|
|
235
|
+
|
|
276
236
|
interface LocalPackageUrlInfo {
|
|
277
237
|
/**
|
|
278
238
|
* 入口文件,默认为index.html,也可以是/
|
|
@@ -424,7 +384,7 @@ declare class WidgetParams {
|
|
|
424
384
|
preview?: boolean;
|
|
425
385
|
lang?: string;
|
|
426
386
|
theme?: ThemeMode;
|
|
427
|
-
mode?:
|
|
387
|
+
mode?: DeployMode;
|
|
428
388
|
radius?: number;
|
|
429
389
|
name?: string;
|
|
430
390
|
title?: string;
|
|
@@ -519,7 +479,8 @@ interface IAppApi {
|
|
|
519
479
|
}
|
|
520
480
|
type AppApiMethods = keyof IAppApi;
|
|
521
481
|
declare enum AppApiEvent {
|
|
522
|
-
CONFIG_CHANGED = "event::cn.widgetjs.core.app.config.changed"
|
|
482
|
+
CONFIG_CHANGED = "event::cn.widgetjs.core.app.config.changed",
|
|
483
|
+
MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window"
|
|
523
484
|
}
|
|
524
485
|
declare enum AppApiConstants {
|
|
525
486
|
CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size"
|
|
@@ -662,41 +623,9 @@ declare class DeployedPage implements IDeployedPage {
|
|
|
662
623
|
id: string;
|
|
663
624
|
}
|
|
664
625
|
|
|
665
|
-
declare class BrowserWindowStatus {
|
|
666
|
-
height: number;
|
|
667
|
-
width: number;
|
|
668
|
-
x?: number;
|
|
669
|
-
y?: number;
|
|
670
|
-
isAlwaysOnTop: boolean;
|
|
671
|
-
isAutoHide: boolean;
|
|
672
|
-
constructor(width: number, height: number);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* @deprecated
|
|
677
|
-
*/
|
|
678
|
-
declare class HostedWidget extends DeployedPage {
|
|
679
|
-
/**
|
|
680
|
-
* @deprecated
|
|
681
|
-
*/
|
|
682
|
-
widgetName: string;
|
|
683
|
-
x: number;
|
|
684
|
-
y: number;
|
|
685
|
-
/**
|
|
686
|
-
* @deprecated
|
|
687
|
-
*/
|
|
688
|
-
browserWindowStatus?: BrowserWindowStatus;
|
|
689
|
-
shortcut?: string;
|
|
690
|
-
/**
|
|
691
|
-
* @deprecated use deployedMode instead
|
|
692
|
-
*/
|
|
693
|
-
hostedMode: number;
|
|
694
|
-
deployedMode: number;
|
|
695
|
-
isOverlap(): boolean;
|
|
696
|
-
}
|
|
697
626
|
declare class DeployedWidget extends DeployedPage {
|
|
698
627
|
shortcut?: string;
|
|
699
|
-
|
|
628
|
+
deployMode: number;
|
|
700
629
|
isOverlap(): boolean;
|
|
701
630
|
}
|
|
702
631
|
|
|
@@ -1166,36 +1095,13 @@ interface IWidgetDataApi {
|
|
|
1166
1095
|
}): Promise<T | undefined>;
|
|
1167
1096
|
}
|
|
1168
1097
|
type WidgetDataApiMethods = keyof IWidgetDataApi;
|
|
1169
|
-
declare class WidgetDataApiImpl implements IWidgetDataApi {
|
|
1170
|
-
private stores;
|
|
1171
|
-
/**
|
|
1172
|
-
* 保存组件数据
|
|
1173
|
-
* @param data
|
|
1174
|
-
*/
|
|
1175
|
-
save(data: WidgetData): Promise<string>;
|
|
1176
|
-
/**
|
|
1177
|
-
* 获取组件 LocalForage 存储实例
|
|
1178
|
-
* @param name
|
|
1179
|
-
*/
|
|
1180
|
-
getStore(name: string): LocalForage;
|
|
1181
|
-
/**
|
|
1182
|
-
* 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
|
|
1183
|
-
* @param data
|
|
1184
|
-
* @param options
|
|
1185
|
-
*/
|
|
1186
|
-
saveByName<T extends WidgetData>(data: T, options?: SaveWidgetOption): Promise<string>;
|
|
1187
|
-
findByName<T extends WidgetData>(...args: any[]): Promise<T | undefined>;
|
|
1188
|
-
find<T extends WidgetData>(name: string, id: string, type: {
|
|
1189
|
-
new (name: string, id?: string): T;
|
|
1190
|
-
}): Promise<T | undefined>;
|
|
1191
|
-
private getKey;
|
|
1192
|
-
}
|
|
1193
1098
|
declare const WidgetDataApi: IWidgetDataApi;
|
|
1194
1099
|
|
|
1195
1100
|
interface IBrowserWindowApi {
|
|
1196
1101
|
setIgnoreMouseEvent(ignore: boolean): Promise<void>;
|
|
1197
1102
|
show(): Promise<void>;
|
|
1198
1103
|
hide(): Promise<void>;
|
|
1104
|
+
close(): Promise<void>;
|
|
1199
1105
|
showInactive(): Promise<void>;
|
|
1200
1106
|
center(): Promise<void>;
|
|
1201
1107
|
startDraggingWindow(): Promise<void>;
|
|
@@ -1246,9 +1152,10 @@ interface SetPositionOptions {
|
|
|
1246
1152
|
}
|
|
1247
1153
|
declare enum BrowserWindowApiEvent {
|
|
1248
1154
|
BLUR = "event::cn.widgetjs.core.browser-window.blur",
|
|
1155
|
+
MOVED = "event::cn.widgetjs.core.browser-window.moved",
|
|
1249
1156
|
FOCUS = "event::cn.widgetjs.core.browser-window.focus",
|
|
1250
1157
|
SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.snap_to_edge",
|
|
1251
|
-
|
|
1158
|
+
RESIZED = "event::cn.widgetjs.core.browser-window.resized",
|
|
1252
1159
|
CANCEL_SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge"
|
|
1253
1160
|
}
|
|
1254
1161
|
declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> implements IBrowserWindowApi {
|
|
@@ -1297,6 +1204,7 @@ declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> impl
|
|
|
1297
1204
|
setMaximumSize(width: number, height: number): Promise<void>;
|
|
1298
1205
|
setMinimumSize(width: number, height: number): Promise<void>;
|
|
1299
1206
|
getMinimumSize(): Promise<number[]>;
|
|
1207
|
+
close(): Promise<void>;
|
|
1300
1208
|
}
|
|
1301
1209
|
declare const BrowserWindowApi: BrowserWindowApiImpl;
|
|
1302
1210
|
|
|
@@ -1336,37 +1244,37 @@ declare class NotificationApiImpl extends BaseApi<NotificationApiMethods> implem
|
|
|
1336
1244
|
}
|
|
1337
1245
|
declare const NotificationApi: NotificationApiImpl;
|
|
1338
1246
|
|
|
1339
|
-
interface
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1247
|
+
interface IDeployedWidgetApi {
|
|
1248
|
+
removeDeployedWidget(id: string): Promise<void>;
|
|
1249
|
+
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1250
|
+
getDeployedWidgets(): Promise<DeployedWidget[]>;
|
|
1343
1251
|
openDevTools(id: string): Promise<void>;
|
|
1344
1252
|
openConfigRoute(id: string): Promise<void>;
|
|
1345
1253
|
registerActiveShortcut(id: string, shortcut: string): Promise<boolean>;
|
|
1346
1254
|
setProxy(id: string, proxy: string): Promise<boolean>;
|
|
1347
|
-
|
|
1348
|
-
addWidget(widgetName: string, hostMode:
|
|
1255
|
+
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
1256
|
+
addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
|
|
1349
1257
|
}
|
|
1350
|
-
type
|
|
1351
|
-
declare class
|
|
1258
|
+
type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
|
|
1259
|
+
declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
|
|
1352
1260
|
getChannel(): string;
|
|
1353
1261
|
/**
|
|
1354
1262
|
* 移除组件
|
|
1355
1263
|
* @param id
|
|
1356
1264
|
*/
|
|
1357
|
-
|
|
1358
|
-
addWidget(widgetName: string, hostMode:
|
|
1265
|
+
removeDeployedWidget(id: string): Promise<any>;
|
|
1266
|
+
addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
|
|
1359
1267
|
/**
|
|
1360
1268
|
* 通过组件名移除已添加的组件
|
|
1361
1269
|
* @param name 组件名
|
|
1362
1270
|
*/
|
|
1363
|
-
|
|
1271
|
+
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1364
1272
|
/**
|
|
1365
1273
|
* 获取已添加的组件
|
|
1366
1274
|
* @param name 组件名,可以不传
|
|
1367
1275
|
*/
|
|
1368
|
-
|
|
1369
|
-
|
|
1276
|
+
getDeployedWidgets(name?: string): Promise<DeployedWidget[]>;
|
|
1277
|
+
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
1370
1278
|
/**
|
|
1371
1279
|
* Opens the dev tools for a widget with the specified ID.
|
|
1372
1280
|
*
|
|
@@ -1384,24 +1292,13 @@ declare class HostedWidgetApiImpl extends BaseApi<HostedWidgetApiMethods> implem
|
|
|
1384
1292
|
registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
|
|
1385
1293
|
setProxy(widgetId: string, proxy: string): Promise<boolean>;
|
|
1386
1294
|
}
|
|
1387
|
-
declare const
|
|
1295
|
+
declare const DeployedWidgetApi: DeployedWidgetApiImpl;
|
|
1388
1296
|
|
|
1389
1297
|
interface IDeviceApi {
|
|
1390
1298
|
getCursorScreenPoint(): Promise<Point>;
|
|
1391
1299
|
isAllKeyReleased(): Promise<boolean>;
|
|
1392
1300
|
}
|
|
1393
1301
|
type DeviceApiMethods = keyof IDeviceApi;
|
|
1394
|
-
declare class DeviceApiImpl extends BaseApi<DeviceApiMethods> implements IDeviceApi {
|
|
1395
|
-
/**
|
|
1396
|
-
* 获取当前鼠标位置
|
|
1397
|
-
*/
|
|
1398
|
-
getCursorScreenPoint(): Promise<Point>;
|
|
1399
|
-
/**
|
|
1400
|
-
* 判断是否所有按键都已经释放
|
|
1401
|
-
*/
|
|
1402
|
-
isAllKeyReleased(): Promise<boolean>;
|
|
1403
|
-
getChannel(): string;
|
|
1404
|
-
}
|
|
1405
1302
|
declare const DeviceApi: IDeviceApi;
|
|
1406
1303
|
|
|
1407
1304
|
declare enum Channel {
|
|
@@ -1458,12 +1355,6 @@ interface IBroadcastApi {
|
|
|
1458
1355
|
unregister(...event: BroadcastEventType[]): Promise<void>;
|
|
1459
1356
|
}
|
|
1460
1357
|
type BroadcastApiMethods = keyof IBroadcastApi;
|
|
1461
|
-
declare class BroadcastApiImpl extends BaseApi<BroadcastApiMethods> implements IBroadcastApi {
|
|
1462
|
-
send(event: BroadcastEvent): Promise<void>;
|
|
1463
|
-
register(...event: BroadcastEventType[]): Promise<void>;
|
|
1464
|
-
unregister(...event: BroadcastEventType[]): Promise<void>;
|
|
1465
|
-
getChannel(): string;
|
|
1466
|
-
}
|
|
1467
1358
|
declare const BroadcastApi: IBroadcastApi;
|
|
1468
1359
|
|
|
1469
1360
|
interface IDialogApi {
|
|
@@ -1504,4 +1395,4 @@ interface IFileApi {
|
|
|
1504
1395
|
type FileApiMethods = keyof IFileApi;
|
|
1505
1396
|
declare const FileApi: IFileApi;
|
|
1506
1397
|
|
|
1507
|
-
export { AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, AppApiMethods, AppMouseEvent, AppNotification, BaseApi, BroadcastApi,
|
|
1398
|
+
export { AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, AppApiMethods, AppMouseEvent, AppNotification, BaseApi, BroadcastApi, BroadcastApiMethods, BroadcastEvent, BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, BrowserWindowApiMethods, Channel, ClipboardApi, ClipboardApiEvent, ClipboardApiMethods, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, DeployedWidgetApiMethods, DevOptions, DeviceApi, DeviceApiMethods, DialogApi, DialogApiMethods, ElectronApi, ElectronUtils, FileApi, FileApiMethods, Gravity, GridRect, GridSystem, HostedMode, IGridRect, IPage, IWidgetDataApi, IWidgetOptions, IWindowOptions, IWindowSize, LanguageCode, LanguageTextMap, LocalPackageUrlInfo, LocationQuery, LocationQueryRaw, LocationQueryValue, LocationQueryValueRaw, LogApi, LogApiMethods, MetaInfo, NativeKeyboardEvent, NormalizeOptions, NotificationApi, NotificationApiEvent, NotificationApiMethods, NotificationOption, NotificationSize, NotificationType, OpenUrlOptions, Page, Point, Position, ReadDirOptions, Rectangle, RemotePackageUrlInfo, SaveWidgetOption, SetPositionOptions, ShortcutApi, ShortcutApiEvent, ShortcutApiMethods, StoreApi, StoreApiMethods, ThemeMode, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, WidgetApiMethods, WidgetData, WidgetDataApi, WidgetDataApiMethods, WidgetKeyword, WidgetPackage, WidgetPackageOptions, WidgetParams, WidgetPermission, WidgetUrlUtils, normalizeUrl, parseQuery, stringifyQuery };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
// src/model/
|
|
8
|
+
// src/model/DeployMode.ts
|
|
9
9
|
var HostedMode = /* @__PURE__ */ ((HostedMode2) => {
|
|
10
10
|
HostedMode2[HostedMode2["NORMAL"] = 1] = "NORMAL";
|
|
11
11
|
HostedMode2[HostedMode2["OVERLAP"] = 16] = "OVERLAP";
|
|
@@ -16,13 +16,13 @@ var HostedMode = /* @__PURE__ */ ((HostedMode2) => {
|
|
|
16
16
|
HostedMode2[HostedMode2["ALL"] = 1118481] = "ALL";
|
|
17
17
|
return HostedMode2;
|
|
18
18
|
})(HostedMode || {});
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
25
|
-
})(
|
|
19
|
+
var DeployMode = /* @__PURE__ */ ((DeployMode2) => {
|
|
20
|
+
DeployMode2[DeployMode2["NORMAL"] = 1] = "NORMAL";
|
|
21
|
+
DeployMode2[DeployMode2["OVERLAP"] = 16] = "OVERLAP";
|
|
22
|
+
DeployMode2[DeployMode2["BACKGROUND"] = 65536] = "BACKGROUND";
|
|
23
|
+
DeployMode2[DeployMode2["ALL"] = 1118481] = "ALL";
|
|
24
|
+
return DeployMode2;
|
|
25
|
+
})(DeployMode || {});
|
|
26
26
|
|
|
27
27
|
// src/utils/LanguageUtils.ts
|
|
28
28
|
function getTextByLanguageCode(langMap, langCode, fallbackToBrowser = true) {
|
|
@@ -78,7 +78,7 @@ var Page = class {
|
|
|
78
78
|
movable;
|
|
79
79
|
singleton;
|
|
80
80
|
resizable;
|
|
81
|
-
|
|
81
|
+
path;
|
|
82
82
|
meta;
|
|
83
83
|
backgroundThrottling;
|
|
84
84
|
/**
|
|
@@ -103,7 +103,7 @@ var Page = class {
|
|
|
103
103
|
this.packageName = options.packageName;
|
|
104
104
|
this.singleton = options.singleton ?? false;
|
|
105
105
|
this.previewImage = options.previewImage;
|
|
106
|
-
this.
|
|
106
|
+
this.path = options.path;
|
|
107
107
|
this.meta = options.meta ?? {};
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
@@ -126,7 +126,7 @@ var Page = class {
|
|
|
126
126
|
}
|
|
127
127
|
static parseObject(obj) {
|
|
128
128
|
let widget = new Page({
|
|
129
|
-
|
|
129
|
+
path: "",
|
|
130
130
|
description: {},
|
|
131
131
|
height: 0,
|
|
132
132
|
keywords: [],
|
|
@@ -146,38 +146,15 @@ var Page = class {
|
|
|
146
146
|
|
|
147
147
|
// src/model/Widget.ts
|
|
148
148
|
var Widget = class extends Page {
|
|
149
|
-
|
|
150
|
-
supportDeployedMode;
|
|
151
|
-
/**
|
|
152
|
-
* @deprecated
|
|
153
|
-
*/
|
|
154
|
-
refreshWhenResided;
|
|
149
|
+
supportDeployMode;
|
|
155
150
|
/**
|
|
156
|
-
*
|
|
157
|
-
* @deprecated
|
|
151
|
+
* 配置页面路径,没有则不能修改
|
|
158
152
|
*/
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @deprecated
|
|
162
|
-
*/
|
|
163
|
-
permissions;
|
|
153
|
+
configPagePath;
|
|
164
154
|
constructor(options) {
|
|
165
155
|
super(options);
|
|
166
|
-
this.
|
|
167
|
-
this.
|
|
168
|
-
this.supportDeployedMode = options.supportDeployedMode ?? 1 /* NORMAL */ | 16 /* OVERLAP */;
|
|
169
|
-
this.permissions = options.permissions ?? [];
|
|
170
|
-
this.routes = options.routes;
|
|
171
|
-
}
|
|
172
|
-
getIndexRoute() {
|
|
173
|
-
const result = this.routes.find((it) => it.name.toLowerCase() == "index");
|
|
174
|
-
return result;
|
|
175
|
-
}
|
|
176
|
-
getConfigRoute() {
|
|
177
|
-
return this.routes.find((it) => it.name.toLowerCase() == "config");
|
|
178
|
-
}
|
|
179
|
-
isConfigurable() {
|
|
180
|
-
return this.getConfigRoute() != null;
|
|
156
|
+
this.configPagePath = options.configPagePath;
|
|
157
|
+
this.supportDeployMode = options.supportDeployMode ?? 1 /* NORMAL */ | 16 /* OVERLAP */;
|
|
181
158
|
}
|
|
182
159
|
static parseJSON(json) {
|
|
183
160
|
const object = JSON.parse(json);
|
|
@@ -185,13 +162,12 @@ var Widget = class extends Page {
|
|
|
185
162
|
}
|
|
186
163
|
static parseObject(obj) {
|
|
187
164
|
let widget = new Widget({
|
|
188
|
-
|
|
165
|
+
path: "",
|
|
189
166
|
description: {},
|
|
190
167
|
height: 0,
|
|
191
168
|
keywords: [],
|
|
192
169
|
lang: "zh-CN",
|
|
193
170
|
name: "",
|
|
194
|
-
routes: [],
|
|
195
171
|
previewImage: "",
|
|
196
172
|
title: {},
|
|
197
173
|
width: 0
|
|
@@ -203,16 +179,16 @@ var Widget = class extends Page {
|
|
|
203
179
|
* 是否支持悬浮窗
|
|
204
180
|
*/
|
|
205
181
|
isSupportOverlap() {
|
|
206
|
-
return (this.
|
|
182
|
+
return (this.supportDeployMode & 16 /* OVERLAP */) > 0;
|
|
207
183
|
}
|
|
208
184
|
isSupportBackground() {
|
|
209
|
-
return (this.
|
|
185
|
+
return (this.supportDeployMode & 65536 /* BACKGROUND */) > 0;
|
|
210
186
|
}
|
|
211
187
|
/**
|
|
212
188
|
* 是否支持普通模式
|
|
213
189
|
*/
|
|
214
190
|
isSupportNormal() {
|
|
215
|
-
return (this.
|
|
191
|
+
return (this.supportDeployMode & 1 /* NORMAL */) > 0;
|
|
216
192
|
}
|
|
217
193
|
};
|
|
218
194
|
var WidgetKeyword = /* @__PURE__ */ ((WidgetKeyword2) => {
|
|
@@ -592,32 +568,11 @@ var DeployedPage = class {
|
|
|
592
568
|
};
|
|
593
569
|
|
|
594
570
|
// src/model/DeployedWidget.ts
|
|
595
|
-
var HostedWidget = class extends DeployedPage {
|
|
596
|
-
/**
|
|
597
|
-
* @deprecated
|
|
598
|
-
*/
|
|
599
|
-
widgetName;
|
|
600
|
-
x = 0;
|
|
601
|
-
y = 0;
|
|
602
|
-
/**
|
|
603
|
-
* @deprecated
|
|
604
|
-
*/
|
|
605
|
-
browserWindowStatus;
|
|
606
|
-
shortcut;
|
|
607
|
-
/**
|
|
608
|
-
* @deprecated use deployedMode instead
|
|
609
|
-
*/
|
|
610
|
-
hostedMode;
|
|
611
|
-
deployedMode;
|
|
612
|
-
isOverlap() {
|
|
613
|
-
return (this.deployedMode & 16 /* OVERLAP */) > 0;
|
|
614
|
-
}
|
|
615
|
-
};
|
|
616
571
|
var DeployedWidget = class extends DeployedPage {
|
|
617
572
|
shortcut;
|
|
618
|
-
|
|
573
|
+
deployMode;
|
|
619
574
|
isOverlap() {
|
|
620
|
-
return (this.
|
|
575
|
+
return (this.deployMode & 16 /* OVERLAP */) > 0;
|
|
621
576
|
}
|
|
622
577
|
};
|
|
623
578
|
|
|
@@ -963,13 +918,12 @@ var WidgetPackage = class {
|
|
|
963
918
|
for (let jsonWidget of widgetPackage.widgets) {
|
|
964
919
|
let widget = new Widget({
|
|
965
920
|
previewImage: "",
|
|
966
|
-
|
|
921
|
+
path: "",
|
|
967
922
|
description: { "zh-CN": "" },
|
|
968
923
|
height: 0,
|
|
969
924
|
keywords: [],
|
|
970
925
|
lang: "zh-CN",
|
|
971
926
|
name: "",
|
|
972
|
-
routes: [],
|
|
973
927
|
title: { "zh-CN": "" },
|
|
974
928
|
width: 0
|
|
975
929
|
});
|
|
@@ -1268,23 +1222,22 @@ var WidgetApiImpl = class extends BaseApi {
|
|
|
1268
1222
|
const widget = await this.getWidget(widgetName);
|
|
1269
1223
|
if (!widget)
|
|
1270
1224
|
return null;
|
|
1271
|
-
const
|
|
1272
|
-
if (!
|
|
1225
|
+
const configPagePath = widget.configPagePath;
|
|
1226
|
+
if (!configPagePath)
|
|
1273
1227
|
return null;
|
|
1274
1228
|
const widgetPackage = await this.getWidgetPackage(widget.packageName);
|
|
1275
1229
|
if (!widgetPackage)
|
|
1276
1230
|
return null;
|
|
1277
|
-
return WidgetUrlUtils.getWidgetUrl(
|
|
1231
|
+
return WidgetUrlUtils.getWidgetUrl(configPagePath, widgetPackage, widgetParams);
|
|
1278
1232
|
}
|
|
1279
1233
|
async getWidgetUrl(widgetName, widgetParams) {
|
|
1280
1234
|
const widget = await this.getWidget(widgetName);
|
|
1281
1235
|
if (!widget)
|
|
1282
1236
|
return null;
|
|
1283
|
-
const indexRoute = widget.getIndexRoute();
|
|
1284
1237
|
const widgetPackage = await this.getWidgetPackage(widget.packageName);
|
|
1285
1238
|
if (!widgetPackage)
|
|
1286
1239
|
return null;
|
|
1287
|
-
return WidgetUrlUtils.getWidgetUrl(
|
|
1240
|
+
return WidgetUrlUtils.getWidgetUrl(widget.path, widgetPackage, widgetParams);
|
|
1288
1241
|
}
|
|
1289
1242
|
async getWidgetPackageIndexUrl(packageName, hash) {
|
|
1290
1243
|
const widgetPackage = await this.getWidgetPackage(packageName);
|
|
@@ -1425,9 +1378,10 @@ var WidgetDataApi = new WidgetDataApiImpl();
|
|
|
1425
1378
|
// src/api/BrowserWindowApi.ts
|
|
1426
1379
|
var BrowserWindowApiEvent = /* @__PURE__ */ ((BrowserWindowApiEvent2) => {
|
|
1427
1380
|
BrowserWindowApiEvent2["BLUR"] = "event::cn.widgetjs.core.browser-window.blur";
|
|
1381
|
+
BrowserWindowApiEvent2["MOVED"] = "event::cn.widgetjs.core.browser-window.moved";
|
|
1428
1382
|
BrowserWindowApiEvent2["FOCUS"] = "event::cn.widgetjs.core.browser-window.focus";
|
|
1429
1383
|
BrowserWindowApiEvent2["SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.snap_to_edge";
|
|
1430
|
-
BrowserWindowApiEvent2["
|
|
1384
|
+
BrowserWindowApiEvent2["RESIZED"] = "event::cn.widgetjs.core.browser-window.resized";
|
|
1431
1385
|
BrowserWindowApiEvent2["CANCEL_SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge";
|
|
1432
1386
|
return BrowserWindowApiEvent2;
|
|
1433
1387
|
})(BrowserWindowApiEvent || {});
|
|
@@ -1555,6 +1509,9 @@ var BrowserWindowApiImpl = class extends BaseApi {
|
|
|
1555
1509
|
getMinimumSize() {
|
|
1556
1510
|
return this.invokeMethod("getMinimumSize");
|
|
1557
1511
|
}
|
|
1512
|
+
close() {
|
|
1513
|
+
return this.invokeMethod("close");
|
|
1514
|
+
}
|
|
1558
1515
|
};
|
|
1559
1516
|
var BrowserWindowApi = new BrowserWindowApiImpl();
|
|
1560
1517
|
|
|
@@ -1670,7 +1627,7 @@ var NotificationApiImpl = class extends BaseApi {
|
|
|
1670
1627
|
var NotificationApi = new NotificationApiImpl();
|
|
1671
1628
|
|
|
1672
1629
|
// src/api/HostedWidgetApi.ts
|
|
1673
|
-
var
|
|
1630
|
+
var DeployedWidgetApiImpl = class extends BaseApi {
|
|
1674
1631
|
getChannel() {
|
|
1675
1632
|
return "channel::cn.widgetjs.core.hosted_widget" /* HOSTED_WIDGET */;
|
|
1676
1633
|
}
|
|
@@ -1678,8 +1635,8 @@ var HostedWidgetApiImpl = class extends BaseApi {
|
|
|
1678
1635
|
* 移除组件
|
|
1679
1636
|
* @param id
|
|
1680
1637
|
*/
|
|
1681
|
-
async
|
|
1682
|
-
return this.invokeMethod("
|
|
1638
|
+
async removeDeployedWidget(id) {
|
|
1639
|
+
return this.invokeMethod("removeDeployedWidget", id);
|
|
1683
1640
|
}
|
|
1684
1641
|
addWidget(widgetName, hostMode) {
|
|
1685
1642
|
return this.invokeMethod("addWidget", widgetName, hostMode);
|
|
@@ -1688,18 +1645,18 @@ var HostedWidgetApiImpl = class extends BaseApi {
|
|
|
1688
1645
|
* 通过组件名移除已添加的组件
|
|
1689
1646
|
* @param name 组件名
|
|
1690
1647
|
*/
|
|
1691
|
-
async
|
|
1692
|
-
return this.invokeMethod("
|
|
1648
|
+
async removeDeployedWidgetByName(name) {
|
|
1649
|
+
return this.invokeMethod("removeDeployedWidgetByName", name);
|
|
1693
1650
|
}
|
|
1694
1651
|
/**
|
|
1695
1652
|
* 获取已添加的组件
|
|
1696
1653
|
* @param name 组件名,可以不传
|
|
1697
1654
|
*/
|
|
1698
|
-
async
|
|
1699
|
-
return this.invokeMethod("
|
|
1655
|
+
async getDeployedWidgets(name) {
|
|
1656
|
+
return this.invokeMethod("getDeployedWidgets", name);
|
|
1700
1657
|
}
|
|
1701
|
-
async
|
|
1702
|
-
return this.invokeMethod("
|
|
1658
|
+
async getDeployedWidget(id) {
|
|
1659
|
+
return this.invokeMethod("getDeployedWidget", id);
|
|
1703
1660
|
}
|
|
1704
1661
|
/**
|
|
1705
1662
|
* Opens the dev tools for a widget with the specified ID.
|
|
@@ -1726,7 +1683,7 @@ var HostedWidgetApiImpl = class extends BaseApi {
|
|
|
1726
1683
|
return this.invokeMethod("setProxy", widgetId, proxy);
|
|
1727
1684
|
}
|
|
1728
1685
|
};
|
|
1729
|
-
var
|
|
1686
|
+
var DeployedWidgetApi = new DeployedWidgetApiImpl();
|
|
1730
1687
|
|
|
1731
1688
|
// src/api/DeviceApi.ts
|
|
1732
1689
|
var DeviceApiImpl = class extends BaseApi {
|
|
@@ -1796,6 +1753,7 @@ var ShortcutApi = new ShortcutApiImpl();
|
|
|
1796
1753
|
// src/api/AppApi.ts
|
|
1797
1754
|
var AppApiEvent = /* @__PURE__ */ ((AppApiEvent2) => {
|
|
1798
1755
|
AppApiEvent2["CONFIG_CHANGED"] = "event::cn.widgetjs.core.app.config.changed";
|
|
1756
|
+
AppApiEvent2["MOVING_GRID_WINDOW"] = "event::cn.widgetjs.core.app.moving.grid.window";
|
|
1799
1757
|
return AppApiEvent2;
|
|
1800
1758
|
})(AppApiEvent || {});
|
|
1801
1759
|
var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
|
|
@@ -1943,19 +1901,17 @@ export {
|
|
|
1943
1901
|
AppNotification,
|
|
1944
1902
|
BaseApi,
|
|
1945
1903
|
BroadcastApi,
|
|
1946
|
-
BroadcastApiImpl,
|
|
1947
1904
|
BroadcastEvent,
|
|
1948
1905
|
BrowserWindowApi,
|
|
1949
1906
|
BrowserWindowApiEvent,
|
|
1950
|
-
BrowserWindowApiImpl,
|
|
1951
1907
|
Channel,
|
|
1952
1908
|
ClipboardApi,
|
|
1953
1909
|
ClipboardApiEvent,
|
|
1954
|
-
|
|
1910
|
+
DeployMode,
|
|
1955
1911
|
DeployedPage,
|
|
1956
1912
|
DeployedWidget,
|
|
1913
|
+
DeployedWidgetApi,
|
|
1957
1914
|
DeviceApi,
|
|
1958
|
-
DeviceApiImpl,
|
|
1959
1915
|
DialogApi,
|
|
1960
1916
|
ElectronApi,
|
|
1961
1917
|
ElectronUtils,
|
|
@@ -1964,9 +1920,6 @@ export {
|
|
|
1964
1920
|
GridRect,
|
|
1965
1921
|
GridSystem,
|
|
1966
1922
|
HostedMode,
|
|
1967
|
-
HostedWidget,
|
|
1968
|
-
HostedWidgetApi,
|
|
1969
|
-
HostedWidgetApiImpl,
|
|
1970
1923
|
LogApi,
|
|
1971
1924
|
NotificationApi,
|
|
1972
1925
|
NotificationApiEvent,
|
|
@@ -1983,7 +1936,6 @@ export {
|
|
|
1983
1936
|
WidgetApiEvent,
|
|
1984
1937
|
WidgetData,
|
|
1985
1938
|
WidgetDataApi,
|
|
1986
|
-
WidgetDataApiImpl,
|
|
1987
1939
|
WidgetKeyword,
|
|
1988
1940
|
WidgetPackage,
|
|
1989
1941
|
WidgetParams,
|