@widget-js/core 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +44 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +32 -143
- package/dist/index.js +42 -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,30 +1095,6 @@ 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 {
|
|
@@ -1246,9 +1151,10 @@ interface SetPositionOptions {
|
|
|
1246
1151
|
}
|
|
1247
1152
|
declare enum BrowserWindowApiEvent {
|
|
1248
1153
|
BLUR = "event::cn.widgetjs.core.browser-window.blur",
|
|
1154
|
+
MOVED = "event::cn.widgetjs.core.browser-window.moved",
|
|
1249
1155
|
FOCUS = "event::cn.widgetjs.core.browser-window.focus",
|
|
1250
1156
|
SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.snap_to_edge",
|
|
1251
|
-
|
|
1157
|
+
RESIZED = "event::cn.widgetjs.core.browser-window.resized",
|
|
1252
1158
|
CANCEL_SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge"
|
|
1253
1159
|
}
|
|
1254
1160
|
declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> implements IBrowserWindowApi {
|
|
@@ -1336,37 +1242,37 @@ declare class NotificationApiImpl extends BaseApi<NotificationApiMethods> implem
|
|
|
1336
1242
|
}
|
|
1337
1243
|
declare const NotificationApi: NotificationApiImpl;
|
|
1338
1244
|
|
|
1339
|
-
interface
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1245
|
+
interface IDeployedWidgetApi {
|
|
1246
|
+
removeDeployedWidget(id: string): Promise<void>;
|
|
1247
|
+
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1248
|
+
getDeployedWidgets(): Promise<DeployedWidget[]>;
|
|
1343
1249
|
openDevTools(id: string): Promise<void>;
|
|
1344
1250
|
openConfigRoute(id: string): Promise<void>;
|
|
1345
1251
|
registerActiveShortcut(id: string, shortcut: string): Promise<boolean>;
|
|
1346
1252
|
setProxy(id: string, proxy: string): Promise<boolean>;
|
|
1347
|
-
|
|
1348
|
-
addWidget(widgetName: string, hostMode:
|
|
1253
|
+
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
1254
|
+
addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
|
|
1349
1255
|
}
|
|
1350
|
-
type
|
|
1351
|
-
declare class
|
|
1256
|
+
type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
|
|
1257
|
+
declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
|
|
1352
1258
|
getChannel(): string;
|
|
1353
1259
|
/**
|
|
1354
1260
|
* 移除组件
|
|
1355
1261
|
* @param id
|
|
1356
1262
|
*/
|
|
1357
|
-
|
|
1358
|
-
addWidget(widgetName: string, hostMode:
|
|
1263
|
+
removeDeployedWidget(id: string): Promise<any>;
|
|
1264
|
+
addWidget(widgetName: string, hostMode: DeployMode): Promise<Widget[]>;
|
|
1359
1265
|
/**
|
|
1360
1266
|
* 通过组件名移除已添加的组件
|
|
1361
1267
|
* @param name 组件名
|
|
1362
1268
|
*/
|
|
1363
|
-
|
|
1269
|
+
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1364
1270
|
/**
|
|
1365
1271
|
* 获取已添加的组件
|
|
1366
1272
|
* @param name 组件名,可以不传
|
|
1367
1273
|
*/
|
|
1368
|
-
|
|
1369
|
-
|
|
1274
|
+
getDeployedWidgets(name?: string): Promise<DeployedWidget[]>;
|
|
1275
|
+
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
1370
1276
|
/**
|
|
1371
1277
|
* Opens the dev tools for a widget with the specified ID.
|
|
1372
1278
|
*
|
|
@@ -1384,24 +1290,13 @@ declare class HostedWidgetApiImpl extends BaseApi<HostedWidgetApiMethods> implem
|
|
|
1384
1290
|
registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
|
|
1385
1291
|
setProxy(widgetId: string, proxy: string): Promise<boolean>;
|
|
1386
1292
|
}
|
|
1387
|
-
declare const
|
|
1293
|
+
declare const DeployedWidgetApi: DeployedWidgetApiImpl;
|
|
1388
1294
|
|
|
1389
1295
|
interface IDeviceApi {
|
|
1390
1296
|
getCursorScreenPoint(): Promise<Point>;
|
|
1391
1297
|
isAllKeyReleased(): Promise<boolean>;
|
|
1392
1298
|
}
|
|
1393
1299
|
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
1300
|
declare const DeviceApi: IDeviceApi;
|
|
1406
1301
|
|
|
1407
1302
|
declare enum Channel {
|
|
@@ -1458,12 +1353,6 @@ interface IBroadcastApi {
|
|
|
1458
1353
|
unregister(...event: BroadcastEventType[]): Promise<void>;
|
|
1459
1354
|
}
|
|
1460
1355
|
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
1356
|
declare const BroadcastApi: IBroadcastApi;
|
|
1468
1357
|
|
|
1469
1358
|
interface IDialogApi {
|
|
@@ -1504,4 +1393,4 @@ interface IFileApi {
|
|
|
1504
1393
|
type FileApiMethods = keyof IFileApi;
|
|
1505
1394
|
declare const FileApi: IFileApi;
|
|
1506
1395
|
|
|
1507
|
-
export { AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, AppApiMethods, AppMouseEvent, AppNotification, BaseApi, BroadcastApi,
|
|
1396
|
+
export { AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, AppApiMethods, AppMouseEvent, AppNotification, BaseApi, BroadcastApi, BroadcastApiMethods, BroadcastEvent, BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, BrowserWindowApiMethods, Channel, ClipboardApi, ClipboardApiEvent, ClipboardApiMethods, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, DeployedWidgetApiMethods, DevOptions, DeviceApi, DeviceApiMethods, DialogApi, DialogApiMethods, ElectronApi, ElectronUtils, FileApi, FileApiMethods, Gravity, GridRect, GridSystem, HostedMode, IGridRect, IPage, IWidgetDataApi, IWidgetOptions, IWindowOptions, IWindowSize, LanguageCode, LanguageTextMap, LocalPackageUrlInfo, LocationQuery, LocationQueryRaw, LocationQueryValue, LocationQueryValueRaw, LogApi, LogApiMethods, MetaInfo, NativeKeyboardEvent, NormalizeOptions, NotificationApi, NotificationApiEvent, NotificationApiMethods, NotificationOption, NotificationSize, NotificationType, OpenUrlOptions, Page, Point, Position, ReadDirOptions, Rectangle, RemotePackageUrlInfo, SaveWidgetOption, SetPositionOptions, ShortcutApi, ShortcutApiEvent, ShortcutApiMethods, StoreApi, StoreApiMethods, ThemeMode, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, WidgetApiMethods, WidgetData, WidgetDataApi, WidgetDataApiMethods, WidgetKeyword, WidgetPackage, WidgetPackageOptions, WidgetParams, WidgetPermission, WidgetUrlUtils, normalizeUrl, parseQuery, stringifyQuery };
|
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;
|
|
155
|
-
/**
|
|
156
|
-
* 组件其他页面的url在这注册
|
|
157
|
-
* @deprecated
|
|
158
|
-
*/
|
|
159
|
-
routes;
|
|
149
|
+
supportDeployMode;
|
|
160
150
|
/**
|
|
161
|
-
*
|
|
151
|
+
* 配置页面路径,没有则不能修改
|
|
162
152
|
*/
|
|
163
|
-
|
|
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 || {});
|
|
@@ -1670,7 +1624,7 @@ var NotificationApiImpl = class extends BaseApi {
|
|
|
1670
1624
|
var NotificationApi = new NotificationApiImpl();
|
|
1671
1625
|
|
|
1672
1626
|
// src/api/HostedWidgetApi.ts
|
|
1673
|
-
var
|
|
1627
|
+
var DeployedWidgetApiImpl = class extends BaseApi {
|
|
1674
1628
|
getChannel() {
|
|
1675
1629
|
return "channel::cn.widgetjs.core.hosted_widget" /* HOSTED_WIDGET */;
|
|
1676
1630
|
}
|
|
@@ -1678,8 +1632,8 @@ var HostedWidgetApiImpl = class extends BaseApi {
|
|
|
1678
1632
|
* 移除组件
|
|
1679
1633
|
* @param id
|
|
1680
1634
|
*/
|
|
1681
|
-
async
|
|
1682
|
-
return this.invokeMethod("
|
|
1635
|
+
async removeDeployedWidget(id) {
|
|
1636
|
+
return this.invokeMethod("removeDeployedWidget", id);
|
|
1683
1637
|
}
|
|
1684
1638
|
addWidget(widgetName, hostMode) {
|
|
1685
1639
|
return this.invokeMethod("addWidget", widgetName, hostMode);
|
|
@@ -1688,18 +1642,18 @@ var HostedWidgetApiImpl = class extends BaseApi {
|
|
|
1688
1642
|
* 通过组件名移除已添加的组件
|
|
1689
1643
|
* @param name 组件名
|
|
1690
1644
|
*/
|
|
1691
|
-
async
|
|
1692
|
-
return this.invokeMethod("
|
|
1645
|
+
async removeDeployedWidgetByName(name) {
|
|
1646
|
+
return this.invokeMethod("removeDeployedWidgetByName", name);
|
|
1693
1647
|
}
|
|
1694
1648
|
/**
|
|
1695
1649
|
* 获取已添加的组件
|
|
1696
1650
|
* @param name 组件名,可以不传
|
|
1697
1651
|
*/
|
|
1698
|
-
async
|
|
1699
|
-
return this.invokeMethod("
|
|
1652
|
+
async getDeployedWidgets(name) {
|
|
1653
|
+
return this.invokeMethod("getDeployedWidgets", name);
|
|
1700
1654
|
}
|
|
1701
|
-
async
|
|
1702
|
-
return this.invokeMethod("
|
|
1655
|
+
async getDeployedWidget(id) {
|
|
1656
|
+
return this.invokeMethod("getDeployedWidget", id);
|
|
1703
1657
|
}
|
|
1704
1658
|
/**
|
|
1705
1659
|
* Opens the dev tools for a widget with the specified ID.
|
|
@@ -1726,7 +1680,7 @@ var HostedWidgetApiImpl = class extends BaseApi {
|
|
|
1726
1680
|
return this.invokeMethod("setProxy", widgetId, proxy);
|
|
1727
1681
|
}
|
|
1728
1682
|
};
|
|
1729
|
-
var
|
|
1683
|
+
var DeployedWidgetApi = new DeployedWidgetApiImpl();
|
|
1730
1684
|
|
|
1731
1685
|
// src/api/DeviceApi.ts
|
|
1732
1686
|
var DeviceApiImpl = class extends BaseApi {
|
|
@@ -1796,6 +1750,7 @@ var ShortcutApi = new ShortcutApiImpl();
|
|
|
1796
1750
|
// src/api/AppApi.ts
|
|
1797
1751
|
var AppApiEvent = /* @__PURE__ */ ((AppApiEvent2) => {
|
|
1798
1752
|
AppApiEvent2["CONFIG_CHANGED"] = "event::cn.widgetjs.core.app.config.changed";
|
|
1753
|
+
AppApiEvent2["MOVING_GRID_WINDOW"] = "event::cn.widgetjs.core.app.moving.grid.window";
|
|
1799
1754
|
return AppApiEvent2;
|
|
1800
1755
|
})(AppApiEvent || {});
|
|
1801
1756
|
var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
|
|
@@ -1943,19 +1898,17 @@ export {
|
|
|
1943
1898
|
AppNotification,
|
|
1944
1899
|
BaseApi,
|
|
1945
1900
|
BroadcastApi,
|
|
1946
|
-
BroadcastApiImpl,
|
|
1947
1901
|
BroadcastEvent,
|
|
1948
1902
|
BrowserWindowApi,
|
|
1949
1903
|
BrowserWindowApiEvent,
|
|
1950
|
-
BrowserWindowApiImpl,
|
|
1951
1904
|
Channel,
|
|
1952
1905
|
ClipboardApi,
|
|
1953
1906
|
ClipboardApiEvent,
|
|
1954
|
-
|
|
1907
|
+
DeployMode,
|
|
1955
1908
|
DeployedPage,
|
|
1956
1909
|
DeployedWidget,
|
|
1910
|
+
DeployedWidgetApi,
|
|
1957
1911
|
DeviceApi,
|
|
1958
|
-
DeviceApiImpl,
|
|
1959
1912
|
DialogApi,
|
|
1960
1913
|
ElectronApi,
|
|
1961
1914
|
ElectronUtils,
|
|
@@ -1964,9 +1917,6 @@ export {
|
|
|
1964
1917
|
GridRect,
|
|
1965
1918
|
GridSystem,
|
|
1966
1919
|
HostedMode,
|
|
1967
|
-
HostedWidget,
|
|
1968
|
-
HostedWidgetApi,
|
|
1969
|
-
HostedWidgetApiImpl,
|
|
1970
1920
|
LogApi,
|
|
1971
1921
|
NotificationApi,
|
|
1972
1922
|
NotificationApiEvent,
|
|
@@ -1983,7 +1933,6 @@ export {
|
|
|
1983
1933
|
WidgetApiEvent,
|
|
1984
1934
|
WidgetData,
|
|
1985
1935
|
WidgetDataApi,
|
|
1986
|
-
WidgetDataApiImpl,
|
|
1987
1936
|
WidgetKeyword,
|
|
1988
1937
|
WidgetPackage,
|
|
1989
1938
|
WidgetParams,
|