@widget-js/core 24.1.1-beta.2 → 24.1.1-beta.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/electron.d.ts +36 -36
- package/dist/index.cjs +37 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +61 -26
- package/dist/index.js +35 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -302,7 +302,7 @@ interface LocalPackageUrlInfo {
|
|
|
302
302
|
/**
|
|
303
303
|
* 是否使用hash路由
|
|
304
304
|
*/
|
|
305
|
-
hash
|
|
305
|
+
hash?: boolean;
|
|
306
306
|
}
|
|
307
307
|
interface RemotePackageUrlInfo extends LocalPackageUrlInfo {
|
|
308
308
|
/**
|
|
@@ -431,21 +431,28 @@ declare abstract class BaseApi<T extends string> {
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
interface IWidgetApi {
|
|
434
|
-
registerWidgets(widgets: Widget[])
|
|
435
|
-
registerWidgetPackage(widgetPackage: WidgetPackage)
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
434
|
+
registerWidgets: (widgets: Widget[]) => Promise<void>;
|
|
435
|
+
registerWidgetPackage: (widgetPackage: WidgetPackage) => Promise<void>;
|
|
436
|
+
/**
|
|
437
|
+
* 升级组件包
|
|
438
|
+
* @param packageName 组件包名称
|
|
439
|
+
*/
|
|
440
|
+
upgradePackage: (packageName: string) => Promise<void>;
|
|
441
|
+
getWidgets: () => Promise<Widget[]>;
|
|
442
|
+
getWidget: (name: string) => Promise<Widget>;
|
|
443
|
+
getWidgetPackage: (name: string) => Promise<WidgetPackage | undefined>;
|
|
444
|
+
getWidgetPackages: () => Promise<WidgetPackage[]>;
|
|
445
|
+
openConfigPage: (id?: string) => Promise<void>;
|
|
446
|
+
openConfigPageByName: (name: string) => Promise<void>;
|
|
447
|
+
reload: () => Promise<void>;
|
|
448
|
+
getWidgetPackageUrl: (packageName: string) => Promise<string | null>;
|
|
444
449
|
}
|
|
445
450
|
type WidgetApiMethods = keyof IWidgetApi;
|
|
446
451
|
declare enum WidgetApiEvent {
|
|
447
452
|
DATA_CHANGED = "event::cn.widgetjs.core.widget.data-changed",
|
|
448
|
-
EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit"
|
|
453
|
+
EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit",
|
|
454
|
+
PACKAGE_UPGRADE = "event::cn.widgetjs.core.widget.package.upgraded",
|
|
455
|
+
PACKAGE_INSTALLED = "event::cn.widgetjs.core.widget.package.installed"
|
|
449
456
|
}
|
|
450
457
|
declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidgetApi {
|
|
451
458
|
reload(): Promise<void>;
|
|
@@ -453,7 +460,7 @@ declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidget
|
|
|
453
460
|
registerWidgets(widgets: Widget[]): Promise<any>;
|
|
454
461
|
registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
|
|
455
462
|
getWidgets(): Promise<Widget[]>;
|
|
456
|
-
openConfigPage(widgetId
|
|
463
|
+
openConfigPage(widgetId?: string): Promise<any>;
|
|
457
464
|
openConfigPageByName(widgetName: string): Promise<any>;
|
|
458
465
|
getWidgetPackages(): Promise<WidgetPackage[]>;
|
|
459
466
|
/**
|
|
@@ -465,8 +472,9 @@ declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidget
|
|
|
465
472
|
*
|
|
466
473
|
* @param name package name
|
|
467
474
|
*/
|
|
468
|
-
getWidgetPackage(name: string): Promise<WidgetPackage>;
|
|
475
|
+
getWidgetPackage(name: string): Promise<WidgetPackage | undefined>;
|
|
469
476
|
getWidgetPackageUrl(packageName: string): Promise<string | null>;
|
|
477
|
+
upgradePackage(packageName: string): Promise<void>;
|
|
470
478
|
}
|
|
471
479
|
declare const WidgetApi: WidgetApiImpl;
|
|
472
480
|
|
|
@@ -1426,16 +1434,25 @@ declare class NotificationApiImpl extends BaseApi<NotificationApiMethods> implem
|
|
|
1426
1434
|
}
|
|
1427
1435
|
declare const NotificationApi: NotificationApiImpl;
|
|
1428
1436
|
|
|
1437
|
+
interface AddWidgetOption {
|
|
1438
|
+
widgetName: string;
|
|
1439
|
+
deployMode: DeployMode;
|
|
1440
|
+
packageJsonUrl?: string;
|
|
1441
|
+
}
|
|
1429
1442
|
interface IDeployedWidgetApi {
|
|
1430
|
-
removeDeployedWidget(id: string)
|
|
1431
|
-
removeDeployedWidgetByName(name: string)
|
|
1432
|
-
getDeployedWidgets()
|
|
1433
|
-
openDevTools(id: string)
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1443
|
+
removeDeployedWidget: (id: string) => Promise<void>;
|
|
1444
|
+
removeDeployedWidgetByName: (name: string) => Promise<DeployedWidget[]>;
|
|
1445
|
+
getDeployedWidgets: () => Promise<DeployedWidget[]>;
|
|
1446
|
+
openDevTools: (id: string) => Promise<void>;
|
|
1447
|
+
/**
|
|
1448
|
+
* @deprecated 使用WidgetApi.openConfigPage代替
|
|
1449
|
+
* @param id
|
|
1450
|
+
*/
|
|
1451
|
+
openConfigPage: (id?: string, params?: WidgetParams) => Promise<void>;
|
|
1452
|
+
registerActiveShortcut: (id: string, shortcut: string) => Promise<boolean>;
|
|
1453
|
+
setProxy: (id: string, proxy: string) => Promise<boolean>;
|
|
1454
|
+
getDeployedWidget: (id: string) => Promise<DeployedWidget>;
|
|
1455
|
+
addWidget: (options: AddWidgetOption) => Promise<Widget[]>;
|
|
1439
1456
|
}
|
|
1440
1457
|
type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
|
|
1441
1458
|
declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
|
|
@@ -1445,7 +1462,7 @@ declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> im
|
|
|
1445
1462
|
* @param id
|
|
1446
1463
|
*/
|
|
1447
1464
|
removeDeployedWidget(id: string): Promise<any>;
|
|
1448
|
-
addWidget(
|
|
1465
|
+
addWidget(options: AddWidgetOption): Promise<Widget[]>;
|
|
1449
1466
|
/**
|
|
1450
1467
|
* 通过组件名移除已添加的组件
|
|
1451
1468
|
* @param name 组件名
|
|
@@ -1464,7 +1481,7 @@ declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> im
|
|
|
1464
1481
|
* @return {Promise} A Promise that resolves when the dev tools are opened.
|
|
1465
1482
|
*/
|
|
1466
1483
|
openDevTools(widgetId: string): Promise<any>;
|
|
1467
|
-
openConfigPage(widgetId
|
|
1484
|
+
openConfigPage(widgetId?: string, params?: WidgetParams): Promise<any>;
|
|
1468
1485
|
/**
|
|
1469
1486
|
* 注册激活、呼出、置顶组件快捷键
|
|
1470
1487
|
* @param widgetId 组件id
|
|
@@ -1489,6 +1506,7 @@ declare enum Channel {
|
|
|
1489
1506
|
BROWSER_WINDOW = "channel::cn.widgetjs.core.browser_window",
|
|
1490
1507
|
BROADCAST = "channel::cn.widgetjs.core.broadcast",
|
|
1491
1508
|
WIDGET = "channel::cn.widgetjs.core.widget",
|
|
1509
|
+
WIDGET_PACKAGE = "channel::cn.widgetjs.core.widget.package",
|
|
1492
1510
|
DEPLOYED_WIDGET = "channel::cn.widgetjs.core.deployed_widget",
|
|
1493
1511
|
APP = "channel::cn.widgetjs.core.app",
|
|
1494
1512
|
DIALOG = "channel::cn.widgetjs.core.dialog",
|
|
@@ -1730,4 +1748,21 @@ declare enum SystemApiEvent {
|
|
|
1730
1748
|
DATE_CHANGED = "event::cn.widgetjs.core.sys.date.changed"
|
|
1731
1749
|
}
|
|
1732
1750
|
|
|
1733
|
-
|
|
1751
|
+
interface IWidgetPackageApi {
|
|
1752
|
+
/**
|
|
1753
|
+
* 升级组件包
|
|
1754
|
+
* @param packageName 组件包名称
|
|
1755
|
+
*/
|
|
1756
|
+
upgrade: (packageName: string) => Promise<void>;
|
|
1757
|
+
}
|
|
1758
|
+
type WidgetPackageApiMethods = keyof IWidgetPackageApi;
|
|
1759
|
+
declare enum WidgetPackageApiEvent {
|
|
1760
|
+
PACKAGE_UPGRADE = "event::cn.widgetjs.core.widget.package.upgraded"
|
|
1761
|
+
}
|
|
1762
|
+
declare class WidgetPackageApiImpl extends BaseApi<WidgetPackageApiMethods> implements IWidgetPackageApi {
|
|
1763
|
+
getChannel(): string;
|
|
1764
|
+
upgrade(packageName: string): Promise<void>;
|
|
1765
|
+
}
|
|
1766
|
+
declare const WidgetPackageApi: WidgetPackageApiImpl;
|
|
1767
|
+
|
|
1768
|
+
export { AddWidgetOption, AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, AppApiMethods, AppMouseEvent, AppNotification, BackgroundWidget, BaseApi, BroadcastApi, BroadcastApiMethods, BroadcastEvent, BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, BrowserWindowApiMethods, Channel, ClipboardApi, ClipboardApiEvent, ClipboardApiMethods, DefaultWidgetTheme, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, DeployedWidgetApiMethods, DevOptions, DeviceApi, DeviceApiMethods, DialogApi, DialogApiMethods, DownloadUrlOptions, ElectronApi, ElectronUtils, FileApi, FileApiMethods, FileInfo, Gravity, GridRect, GridSystem, HostedMode, IBackgroundWidgetOptions, IGridRect, IPage, IPageOptions, IWidgetDataApi, IWidgetOptions, IWindowSize, LanguageCode, LanguageTextMap, LocalPackageUrlInfo, LocationQuery, LocationQueryRaw, LocationQueryValue, LocationQueryValueRaw, LogApi, LogApiMethods, MetaInfo, Metadata, NativeKeyboardEvent, NormalizeOptions, NotificationApi, NotificationApiEvent, NotificationApiMethods, NotificationOption, NotificationSize, NotificationType, OpenUrlOptions, Page, Point, Position, ProcessApi, ProcessApiMethods, ReadDirOptions, Rectangle, RemotePackageUrlInfo, SaveWidgetOption, SetPositionOptions, ShortcutApi, ShortcutApiEvent, ShortcutApiMethods, StoreApi, StoreApiMethods, SystemApiEvent, SystemFile, ThemeMode, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, WidgetApiMethods, WidgetData, WidgetDataApi, WidgetDataApiMethods, WidgetKeyword, WidgetPackage, WidgetPackageApi, WidgetPackageApiEvent, WidgetPackageApiMethods, WidgetPackageOptions, WidgetParams, WidgetPermission, WidgetRoute, WidgetTheme, WidgetThemeKey, getTextByLanguageCode, normalizeUrl, parseQuery, stringifyQuery };
|
package/dist/index.js
CHANGED
|
@@ -1329,7 +1329,7 @@ var WidgetPackage = class {
|
|
|
1329
1329
|
this.remoteEntry = options.remoteEntry;
|
|
1330
1330
|
this.requiredAppVersion = options.requiredAppVersion;
|
|
1331
1331
|
this.remotePackage = options.remotePackage;
|
|
1332
|
-
this.hash = options.hash;
|
|
1332
|
+
this.hash = options.hash ?? false;
|
|
1333
1333
|
this.url = "";
|
|
1334
1334
|
this.icon = options.icon;
|
|
1335
1335
|
this.devOptions = options.devOptions;
|
|
@@ -1809,6 +1809,7 @@ var Channel = /* @__PURE__ */ ((Channel2) => {
|
|
|
1809
1809
|
Channel2["BROWSER_WINDOW"] = "channel::cn.widgetjs.core.browser_window";
|
|
1810
1810
|
Channel2["BROADCAST"] = "channel::cn.widgetjs.core.broadcast";
|
|
1811
1811
|
Channel2["WIDGET"] = "channel::cn.widgetjs.core.widget";
|
|
1812
|
+
Channel2["WIDGET_PACKAGE"] = "channel::cn.widgetjs.core.widget.package";
|
|
1812
1813
|
Channel2["DEPLOYED_WIDGET"] = "channel::cn.widgetjs.core.deployed_widget";
|
|
1813
1814
|
Channel2["APP"] = "channel::cn.widgetjs.core.app";
|
|
1814
1815
|
Channel2["DIALOG"] = "channel::cn.widgetjs.core.dialog";
|
|
@@ -1856,6 +1857,8 @@ var BroadcastApi = new BroadcastApiImpl();
|
|
|
1856
1857
|
var WidgetApiEvent = /* @__PURE__ */ ((WidgetApiEvent2) => {
|
|
1857
1858
|
WidgetApiEvent2["DATA_CHANGED"] = "event::cn.widgetjs.core.widget.data-changed";
|
|
1858
1859
|
WidgetApiEvent2["EDIT_DESKTOP_WIDGETS"] = "event::cn.widgetjs.core.widget.desktop.edit";
|
|
1860
|
+
WidgetApiEvent2["PACKAGE_UPGRADE"] = "event::cn.widgetjs.core.widget.package.upgraded";
|
|
1861
|
+
WidgetApiEvent2["PACKAGE_INSTALLED"] = "event::cn.widgetjs.core.widget.package.installed";
|
|
1859
1862
|
return WidgetApiEvent2;
|
|
1860
1863
|
})(WidgetApiEvent || {});
|
|
1861
1864
|
var WidgetApiImpl = class extends BaseApi {
|
|
@@ -1902,7 +1905,11 @@ var WidgetApiImpl = class extends BaseApi {
|
|
|
1902
1905
|
* @param name package name
|
|
1903
1906
|
*/
|
|
1904
1907
|
async getWidgetPackage(name) {
|
|
1905
|
-
|
|
1908
|
+
const result = await this.invokeMethod("getWidgetPackage", name);
|
|
1909
|
+
if (result) {
|
|
1910
|
+
return WidgetPackage.parseObject(result);
|
|
1911
|
+
}
|
|
1912
|
+
return void 0;
|
|
1906
1913
|
}
|
|
1907
1914
|
async getWidgetPackageUrl(packageName) {
|
|
1908
1915
|
const widgetPackage = await this.getWidgetPackage(packageName);
|
|
@@ -1911,6 +1918,9 @@ var WidgetApiImpl = class extends BaseApi {
|
|
|
1911
1918
|
}
|
|
1912
1919
|
return widgetPackage.url;
|
|
1913
1920
|
}
|
|
1921
|
+
async upgradePackage(packageName) {
|
|
1922
|
+
return await this.invokeMethod("upgradePackage", packageName);
|
|
1923
|
+
}
|
|
1914
1924
|
// /**
|
|
1915
1925
|
// * 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
|
|
1916
1926
|
// * @param data
|
|
@@ -2004,8 +2014,8 @@ var WidgetDataApiImpl = class {
|
|
|
2004
2014
|
let data;
|
|
2005
2015
|
if (args.length === 2) {
|
|
2006
2016
|
name = args[0];
|
|
2007
|
-
const
|
|
2008
|
-
data = new
|
|
2017
|
+
const Type = args[1];
|
|
2018
|
+
data = new Type(name);
|
|
2009
2019
|
} else {
|
|
2010
2020
|
data = args[0];
|
|
2011
2021
|
name = data.name;
|
|
@@ -2018,11 +2028,11 @@ var WidgetDataApiImpl = class {
|
|
|
2018
2028
|
}
|
|
2019
2029
|
return void 0;
|
|
2020
2030
|
}
|
|
2021
|
-
async find(name, id,
|
|
2031
|
+
async find(name, id, Type) {
|
|
2022
2032
|
const store = this.getStore(name);
|
|
2023
2033
|
const result = await store.getItem(this.getKey(name, id));
|
|
2024
2034
|
if (result) {
|
|
2025
|
-
const widgetData = new
|
|
2035
|
+
const widgetData = new Type(name, id);
|
|
2026
2036
|
widgetData.parseJSON(JSON.parse(result));
|
|
2027
2037
|
return widgetData;
|
|
2028
2038
|
}
|
|
@@ -2328,8 +2338,8 @@ var DeployedWidgetApiImpl = class extends BaseApi {
|
|
|
2328
2338
|
async removeDeployedWidget(id) {
|
|
2329
2339
|
return this.invokeMethod("removeDeployedWidget", id);
|
|
2330
2340
|
}
|
|
2331
|
-
addWidget(
|
|
2332
|
-
return this.invokeMethod("addWidget",
|
|
2341
|
+
addWidget(options) {
|
|
2342
|
+
return this.invokeMethod("addWidget", options);
|
|
2333
2343
|
}
|
|
2334
2344
|
/**
|
|
2335
2345
|
* 通过组件名移除已添加的组件
|
|
@@ -2665,6 +2675,21 @@ var SystemApiEvent = /* @__PURE__ */ ((SystemApiEvent2) => {
|
|
|
2665
2675
|
SystemApiEvent2["DATE_CHANGED"] = "event::cn.widgetjs.core.sys.date.changed";
|
|
2666
2676
|
return SystemApiEvent2;
|
|
2667
2677
|
})(SystemApiEvent || {});
|
|
2678
|
+
|
|
2679
|
+
// src/api/WidgetPackageApi.ts
|
|
2680
|
+
var WidgetPackageApiEvent = /* @__PURE__ */ ((WidgetPackageApiEvent2) => {
|
|
2681
|
+
WidgetPackageApiEvent2["PACKAGE_UPGRADE"] = "event::cn.widgetjs.core.widget.package.upgraded";
|
|
2682
|
+
return WidgetPackageApiEvent2;
|
|
2683
|
+
})(WidgetPackageApiEvent || {});
|
|
2684
|
+
var WidgetPackageApiImpl = class extends BaseApi {
|
|
2685
|
+
getChannel() {
|
|
2686
|
+
return "channel::cn.widgetjs.core.widget.package" /* WIDGET_PACKAGE */;
|
|
2687
|
+
}
|
|
2688
|
+
upgrade(packageName) {
|
|
2689
|
+
return this.invokeMethod("upgrade", packageName);
|
|
2690
|
+
}
|
|
2691
|
+
};
|
|
2692
|
+
var WidgetPackageApi = new WidgetPackageApiImpl();
|
|
2668
2693
|
export {
|
|
2669
2694
|
ApiConstants,
|
|
2670
2695
|
AppApi,
|
|
@@ -2714,6 +2739,8 @@ export {
|
|
|
2714
2739
|
WidgetDataApi,
|
|
2715
2740
|
WidgetKeyword,
|
|
2716
2741
|
WidgetPackage,
|
|
2742
|
+
WidgetPackageApi,
|
|
2743
|
+
WidgetPackageApiEvent,
|
|
2717
2744
|
WidgetParams,
|
|
2718
2745
|
getTextByLanguageCode,
|
|
2719
2746
|
normalizeUrl,
|