@widget-js/core 0.7.6 → 0.7.8
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 +33 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +46 -13
- package/dist/index.js +33 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -82,14 +82,26 @@ interface IWindowSize {
|
|
|
82
82
|
minWidth?: number;
|
|
83
83
|
minHeight?: number;
|
|
84
84
|
}
|
|
85
|
-
interface
|
|
85
|
+
interface IPageOptions extends IWindowSize {
|
|
86
86
|
name: string;
|
|
87
|
+
/**
|
|
88
|
+
* 当showInSearch为true时,此项必填
|
|
89
|
+
*/
|
|
87
90
|
title: LanguageTextMap;
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
/**
|
|
92
|
+
* 当showInSearch为true时,此项必填
|
|
93
|
+
*/
|
|
94
|
+
description?: LanguageTextMap;
|
|
95
|
+
/**
|
|
96
|
+
* 当showInSearch为true时,此项必填
|
|
97
|
+
*/
|
|
98
|
+
keywords?: WidgetKeyword[];
|
|
90
99
|
lang: LanguageCode;
|
|
91
100
|
packageName?: string;
|
|
92
|
-
|
|
101
|
+
/**
|
|
102
|
+
* 当showInSearch为true时,此项必填
|
|
103
|
+
*/
|
|
104
|
+
previewImage?: string;
|
|
93
105
|
/**
|
|
94
106
|
* 是否在搜索中显示
|
|
95
107
|
*/
|
|
@@ -142,7 +154,7 @@ interface IPage {
|
|
|
142
154
|
/**
|
|
143
155
|
* 预览图片,可以是GIF
|
|
144
156
|
*/
|
|
145
|
-
readonly previewImage
|
|
157
|
+
readonly previewImage?: string;
|
|
146
158
|
}
|
|
147
159
|
declare class Page implements IPage {
|
|
148
160
|
readonly name: string;
|
|
@@ -178,8 +190,8 @@ declare class Page implements IPage {
|
|
|
178
190
|
/**
|
|
179
191
|
* 预览图片,可以是GIF
|
|
180
192
|
*/
|
|
181
|
-
readonly previewImage
|
|
182
|
-
constructor(options:
|
|
193
|
+
readonly previewImage?: string;
|
|
194
|
+
constructor(options: IPageOptions);
|
|
183
195
|
/**
|
|
184
196
|
* 获取组件标题
|
|
185
197
|
* @param lang 语言环境,不传则获取默认语言
|
|
@@ -195,11 +207,15 @@ declare class Page implements IPage {
|
|
|
195
207
|
isResizable(): boolean;
|
|
196
208
|
}
|
|
197
209
|
|
|
198
|
-
interface IWidgetOptions extends IWindowSize,
|
|
210
|
+
interface IWidgetOptions extends IWindowSize, IPageOptions {
|
|
199
211
|
supportDeployMode?: DeployMode;
|
|
200
212
|
configPagePath?: string;
|
|
213
|
+
previewImage: string;
|
|
214
|
+
description: LanguageTextMap;
|
|
215
|
+
keywords: WidgetKeyword[];
|
|
201
216
|
}
|
|
202
217
|
declare class Widget extends Page {
|
|
218
|
+
readonly previewImage: string;
|
|
203
219
|
readonly supportDeployMode: number;
|
|
204
220
|
/**
|
|
205
221
|
* 配置页面路径,没有则不能修改
|
|
@@ -217,6 +233,7 @@ declare class Widget extends Page {
|
|
|
217
233
|
* 是否支持普通模式
|
|
218
234
|
*/
|
|
219
235
|
isSupportNormal(): boolean;
|
|
236
|
+
isConfigurable(): boolean;
|
|
220
237
|
}
|
|
221
238
|
declare enum WidgetKeyword {
|
|
222
239
|
RECOMMEND = "recommend",
|
|
@@ -434,6 +451,7 @@ interface IWidgetApi {
|
|
|
434
451
|
getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
435
452
|
getWidgetPackageIndexUrl(packageName: string, hash?: boolean): Promise<string | null>;
|
|
436
453
|
getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
454
|
+
openConfigPage(id: string): Promise<void>;
|
|
437
455
|
getWidgetPackageUrl(packageName: string): Promise<string | null>;
|
|
438
456
|
}
|
|
439
457
|
type WidgetApiMethods = keyof IWidgetApi;
|
|
@@ -446,6 +464,7 @@ declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidget
|
|
|
446
464
|
registerWidgets(widgets: Widget[]): Promise<any>;
|
|
447
465
|
registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
|
|
448
466
|
getWidgets(): Promise<Widget[]>;
|
|
467
|
+
openConfigPage(widgetId: string): Promise<any>;
|
|
449
468
|
getWidgetPackages(): Promise<WidgetPackage[]>;
|
|
450
469
|
/**
|
|
451
470
|
*
|
|
@@ -480,7 +499,8 @@ interface IAppApi {
|
|
|
480
499
|
type AppApiMethods = keyof IAppApi;
|
|
481
500
|
declare enum AppApiEvent {
|
|
482
501
|
CONFIG_CHANGED = "event::cn.widgetjs.core.app.config.changed",
|
|
483
|
-
MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window"
|
|
502
|
+
MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window",
|
|
503
|
+
STOP_MOVING_GRID_WINDOW = "event::cn.widgetjs.core.app.moving.grid.window.stop"
|
|
484
504
|
}
|
|
485
505
|
declare enum AppApiConstants {
|
|
486
506
|
CONFIG_GRID_CELL_SIZE = "cn.widgetjs.config.grid.size"
|
|
@@ -495,7 +515,7 @@ interface BroadcastEventOptions {
|
|
|
495
515
|
sender?: string;
|
|
496
516
|
/**
|
|
497
517
|
* 广播事件携带的数据,只支持部分数据类型。
|
|
498
|
-
*
|
|
518
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
|
499
519
|
*/
|
|
500
520
|
payload?: any;
|
|
501
521
|
}
|
|
@@ -1159,6 +1179,18 @@ declare enum BrowserWindowApiEvent {
|
|
|
1159
1179
|
RESIZED = "event::cn.widgetjs.core.browser-window.resized",
|
|
1160
1180
|
CANCEL_SNAP_TO_EDGE = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge"
|
|
1161
1181
|
}
|
|
1182
|
+
interface SetupOptions {
|
|
1183
|
+
width: number;
|
|
1184
|
+
height: number;
|
|
1185
|
+
minWidth?: number;
|
|
1186
|
+
minHeight?: number;
|
|
1187
|
+
maxWidth?: number;
|
|
1188
|
+
maxHeight?: number;
|
|
1189
|
+
resizable?: boolean;
|
|
1190
|
+
movable?: boolean;
|
|
1191
|
+
center?: boolean;
|
|
1192
|
+
alwaysOnTop?: boolean;
|
|
1193
|
+
}
|
|
1162
1194
|
declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> implements IBrowserWindowApi {
|
|
1163
1195
|
getChannel(): string;
|
|
1164
1196
|
setIgnoreMouseEvent(ignore: boolean): Promise<void>;
|
|
@@ -1207,6 +1239,7 @@ declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> impl
|
|
|
1207
1239
|
getMinimumSize(): Promise<number[]>;
|
|
1208
1240
|
close(): Promise<void>;
|
|
1209
1241
|
setZoomFactor(factor: number): Promise<void>;
|
|
1242
|
+
setup(options: SetupOptions): Promise<void>;
|
|
1210
1243
|
}
|
|
1211
1244
|
declare const BrowserWindowApi: BrowserWindowApiImpl;
|
|
1212
1245
|
|
|
@@ -1251,7 +1284,7 @@ interface IDeployedWidgetApi {
|
|
|
1251
1284
|
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1252
1285
|
getDeployedWidgets(): Promise<DeployedWidget[]>;
|
|
1253
1286
|
openDevTools(id: string): Promise<void>;
|
|
1254
|
-
|
|
1287
|
+
openConfigPage(id: string): Promise<void>;
|
|
1255
1288
|
registerActiveShortcut(id: string, shortcut: string): Promise<boolean>;
|
|
1256
1289
|
setProxy(id: string, proxy: string): Promise<boolean>;
|
|
1257
1290
|
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
@@ -1284,7 +1317,7 @@ declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> im
|
|
|
1284
1317
|
* @return {Promise} A Promise that resolves when the dev tools are opened.
|
|
1285
1318
|
*/
|
|
1286
1319
|
openDevTools(widgetId: string): Promise<any>;
|
|
1287
|
-
|
|
1320
|
+
openConfigPage(widgetId: string, params?: WidgetParams): Promise<any>;
|
|
1288
1321
|
/**
|
|
1289
1322
|
* 注册激活、呼出、置顶组件快捷键
|
|
1290
1323
|
* @param widgetId 组件id
|
|
@@ -1397,4 +1430,4 @@ interface IFileApi {
|
|
|
1397
1430
|
type FileApiMethods = keyof IFileApi;
|
|
1398
1431
|
declare const FileApi: IFileApi;
|
|
1399
1432
|
|
|
1400
|
-
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,
|
|
1433
|
+
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, IPageOptions, IWidgetDataApi, IWidgetOptions, 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
|
@@ -88,8 +88,8 @@ var Page = class {
|
|
|
88
88
|
constructor(options) {
|
|
89
89
|
this.name = options.name;
|
|
90
90
|
this.title = options.title;
|
|
91
|
-
this.description = options.description;
|
|
92
|
-
this.keywords = options.keywords;
|
|
91
|
+
this.description = options.description ?? {};
|
|
92
|
+
this.keywords = options.keywords ?? [];
|
|
93
93
|
this.lang = options.lang;
|
|
94
94
|
this.width = options.width;
|
|
95
95
|
this.height = options.height;
|
|
@@ -118,6 +118,8 @@ var Page = class {
|
|
|
118
118
|
* @param lang 语言环境,不传则获取默认标题
|
|
119
119
|
*/
|
|
120
120
|
getDescription(lang) {
|
|
121
|
+
if (this.description == void 0)
|
|
122
|
+
return void 0;
|
|
121
123
|
return getTextByLanguageCode(this.description, lang);
|
|
122
124
|
}
|
|
123
125
|
static parseJSON(json) {
|
|
@@ -190,6 +192,9 @@ var Widget = class extends Page {
|
|
|
190
192
|
isSupportNormal() {
|
|
191
193
|
return (this.supportDeployMode & 1 /* NORMAL */) > 0;
|
|
192
194
|
}
|
|
195
|
+
isConfigurable() {
|
|
196
|
+
return this.configPagePath != null && this.configPagePath != "";
|
|
197
|
+
}
|
|
193
198
|
};
|
|
194
199
|
var WidgetKeyword = /* @__PURE__ */ ((WidgetKeyword2) => {
|
|
195
200
|
WidgetKeyword2["RECOMMEND"] = "recommend";
|
|
@@ -1197,6 +1202,9 @@ var WidgetApiImpl = class extends BaseApi {
|
|
|
1197
1202
|
}
|
|
1198
1203
|
return widgets;
|
|
1199
1204
|
}
|
|
1205
|
+
async openConfigPage(widgetId) {
|
|
1206
|
+
return this.invokeMethod("openConfigPage", widgetId);
|
|
1207
|
+
}
|
|
1200
1208
|
async getWidgetPackages() {
|
|
1201
1209
|
return await this.invokeMethod("getWidgetPackages");
|
|
1202
1210
|
}
|
|
@@ -1515,6 +1523,25 @@ var BrowserWindowApiImpl = class extends BaseApi {
|
|
|
1515
1523
|
setZoomFactor(factor) {
|
|
1516
1524
|
return this.invokeMethod("setZoomFactor", factor);
|
|
1517
1525
|
}
|
|
1526
|
+
async setup(options) {
|
|
1527
|
+
if (options.alwaysOnTop) {
|
|
1528
|
+
await this.setAlwaysOnTop(true);
|
|
1529
|
+
}
|
|
1530
|
+
if (options.center) {
|
|
1531
|
+
await this.center();
|
|
1532
|
+
}
|
|
1533
|
+
await this.setResizable(!!options.resizable);
|
|
1534
|
+
await this.setMovable(!!options.movable);
|
|
1535
|
+
if (options.width && options.height) {
|
|
1536
|
+
await this.setSize(options.width, options.height);
|
|
1537
|
+
}
|
|
1538
|
+
if (options.minWidth && options.minHeight) {
|
|
1539
|
+
await this.setMinimumSize(options.minWidth, options.minHeight);
|
|
1540
|
+
}
|
|
1541
|
+
if (options.maxWidth && options.maxHeight) {
|
|
1542
|
+
await this.setMaximumSize(options.maxWidth, options.maxHeight);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1518
1545
|
};
|
|
1519
1546
|
var BrowserWindowApi = new BrowserWindowApiImpl();
|
|
1520
1547
|
|
|
@@ -1629,7 +1656,7 @@ var NotificationApiImpl = class extends BaseApi {
|
|
|
1629
1656
|
};
|
|
1630
1657
|
var NotificationApi = new NotificationApiImpl();
|
|
1631
1658
|
|
|
1632
|
-
// src/api/
|
|
1659
|
+
// src/api/DeployedWidgetApi.ts
|
|
1633
1660
|
var DeployedWidgetApiImpl = class extends BaseApi {
|
|
1634
1661
|
getChannel() {
|
|
1635
1662
|
return "channel::cn.widgetjs.core.hosted_widget" /* HOSTED_WIDGET */;
|
|
@@ -1670,8 +1697,8 @@ var DeployedWidgetApiImpl = class extends BaseApi {
|
|
|
1670
1697
|
async openDevTools(widgetId) {
|
|
1671
1698
|
return this.invokeMethod("openDevTools", widgetId);
|
|
1672
1699
|
}
|
|
1673
|
-
async
|
|
1674
|
-
return this.invokeMethod("
|
|
1700
|
+
async openConfigPage(widgetId, params) {
|
|
1701
|
+
return this.invokeMethod("openConfigPage", widgetId, params);
|
|
1675
1702
|
}
|
|
1676
1703
|
/**
|
|
1677
1704
|
* 注册激活、呼出、置顶组件快捷键
|
|
@@ -1757,6 +1784,7 @@ var ShortcutApi = new ShortcutApiImpl();
|
|
|
1757
1784
|
var AppApiEvent = /* @__PURE__ */ ((AppApiEvent2) => {
|
|
1758
1785
|
AppApiEvent2["CONFIG_CHANGED"] = "event::cn.widgetjs.core.app.config.changed";
|
|
1759
1786
|
AppApiEvent2["MOVING_GRID_WINDOW"] = "event::cn.widgetjs.core.app.moving.grid.window";
|
|
1787
|
+
AppApiEvent2["STOP_MOVING_GRID_WINDOW"] = "event::cn.widgetjs.core.app.moving.grid.window.stop";
|
|
1760
1788
|
return AppApiEvent2;
|
|
1761
1789
|
})(AppApiEvent || {});
|
|
1762
1790
|
var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
|