@widget-js/core 0.11.22-beta.3 → 24.1.1-beta.2
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 +199 -259
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +92 -90
- package/dist/index.js +198 -258
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -604,6 +604,7 @@ __export(src_exports, {
|
|
|
604
604
|
AppApiConstants: () => AppApiConstants,
|
|
605
605
|
AppApiEvent: () => AppApiEvent,
|
|
606
606
|
AppNotification: () => AppNotification,
|
|
607
|
+
BackgroundWidget: () => BackgroundWidget,
|
|
607
608
|
BaseApi: () => BaseApi,
|
|
608
609
|
BroadcastApi: () => BroadcastApi,
|
|
609
610
|
BroadcastEvent: () => BroadcastEvent,
|
|
@@ -647,7 +648,6 @@ __export(src_exports, {
|
|
|
647
648
|
WidgetKeyword: () => WidgetKeyword,
|
|
648
649
|
WidgetPackage: () => WidgetPackage,
|
|
649
650
|
WidgetParams: () => WidgetParams,
|
|
650
|
-
WidgetUrlUtils: () => WidgetUrlUtils,
|
|
651
651
|
getTextByLanguageCode: () => getTextByLanguageCode,
|
|
652
652
|
normalizeUrl: () => normalizeUrl,
|
|
653
653
|
parseQuery: () => parseQuery,
|
|
@@ -752,7 +752,7 @@ var Page = class {
|
|
|
752
752
|
this.maxHeight = options.maxHeight ?? options.height;
|
|
753
753
|
this.minWidth = options.minWidth ?? options.width;
|
|
754
754
|
this.minHeight = options.minHeight ?? options.height;
|
|
755
|
-
this.backgroundThrottling = options.backgroundThrottling
|
|
755
|
+
this.backgroundThrottling = options.backgroundThrottling == void 0 ? true : options.backgroundThrottling;
|
|
756
756
|
this.packageName = options.packageName;
|
|
757
757
|
this.singleton = options.singleton ?? false;
|
|
758
758
|
this.previewImage = options.previewImage;
|
|
@@ -860,6 +860,15 @@ var Widget = class extends Page {
|
|
|
860
860
|
return this.configPagePath != null && this.configPagePath != "";
|
|
861
861
|
}
|
|
862
862
|
};
|
|
863
|
+
var BackgroundWidget = class extends Widget {
|
|
864
|
+
constructor(options) {
|
|
865
|
+
options.supportDeployMode = 65536 /* BACKGROUND */;
|
|
866
|
+
options.backgroundThrottling = false;
|
|
867
|
+
options.width = 1;
|
|
868
|
+
options.height = 1;
|
|
869
|
+
super(options);
|
|
870
|
+
}
|
|
871
|
+
};
|
|
863
872
|
var WidgetKeyword = /* @__PURE__ */ ((WidgetKeyword2) => {
|
|
864
873
|
WidgetKeyword2["RECOMMEND"] = "recommend";
|
|
865
874
|
WidgetKeyword2["TOOLS"] = "tools";
|
|
@@ -1308,6 +1317,177 @@ var Gravity = /* @__PURE__ */ ((Gravity2) => {
|
|
|
1308
1317
|
return Gravity2;
|
|
1309
1318
|
})(Gravity || {});
|
|
1310
1319
|
|
|
1320
|
+
// src/model/WidgetPackage.ts
|
|
1321
|
+
var WidgetPackage = class {
|
|
1322
|
+
/**
|
|
1323
|
+
* 组件包名,一般为域名倒写,e.g. com.example
|
|
1324
|
+
*/
|
|
1325
|
+
name;
|
|
1326
|
+
/**
|
|
1327
|
+
* 组件包版本,可以为空,默认采用package.json里的版本
|
|
1328
|
+
* e.g. 1.0.2
|
|
1329
|
+
*/
|
|
1330
|
+
version;
|
|
1331
|
+
/**
|
|
1332
|
+
* 组件包所需的App版本
|
|
1333
|
+
*/
|
|
1334
|
+
requiredAppVersion;
|
|
1335
|
+
/**
|
|
1336
|
+
* 组件作者署名
|
|
1337
|
+
*/
|
|
1338
|
+
author;
|
|
1339
|
+
development;
|
|
1340
|
+
/**
|
|
1341
|
+
* 组件首页
|
|
1342
|
+
*/
|
|
1343
|
+
homepage;
|
|
1344
|
+
/**
|
|
1345
|
+
* 组件描述
|
|
1346
|
+
*/
|
|
1347
|
+
title;
|
|
1348
|
+
/**
|
|
1349
|
+
* 组件描述
|
|
1350
|
+
*/
|
|
1351
|
+
description;
|
|
1352
|
+
/**
|
|
1353
|
+
* 本地组件入口文件,通常为 index.html
|
|
1354
|
+
*/
|
|
1355
|
+
entry;
|
|
1356
|
+
/**
|
|
1357
|
+
* 远程组件包入口文件
|
|
1358
|
+
*/
|
|
1359
|
+
remoteEntry;
|
|
1360
|
+
/**
|
|
1361
|
+
* 组件包json文件路径
|
|
1362
|
+
* @example https://rtugeek.gitee.io/hotspot/widget.json
|
|
1363
|
+
*/
|
|
1364
|
+
remotePackage;
|
|
1365
|
+
local;
|
|
1366
|
+
remote;
|
|
1367
|
+
/**
|
|
1368
|
+
* 组件包图标
|
|
1369
|
+
*/
|
|
1370
|
+
icon;
|
|
1371
|
+
/**
|
|
1372
|
+
* Hash路由模式,默认为true
|
|
1373
|
+
*/
|
|
1374
|
+
hash = true;
|
|
1375
|
+
/**
|
|
1376
|
+
* 可能是网络地址,或者本地路径(解压后的文件夹路径),
|
|
1377
|
+
* 网络地址:https://www.bilibili.com
|
|
1378
|
+
* 本地地址:file:///C:/Users/neo/Desktop
|
|
1379
|
+
* 在测试时。地址通常为: http://127.0.0.1:8080
|
|
1380
|
+
*/
|
|
1381
|
+
url;
|
|
1382
|
+
widgets = [];
|
|
1383
|
+
pages = [];
|
|
1384
|
+
devOptions;
|
|
1385
|
+
constructor(options) {
|
|
1386
|
+
this.name = options.name;
|
|
1387
|
+
this.development = options.development;
|
|
1388
|
+
this.version = options.version;
|
|
1389
|
+
this.author = options.author;
|
|
1390
|
+
this.homepage = options.homepage;
|
|
1391
|
+
this.title = options.title;
|
|
1392
|
+
this.description = options.description;
|
|
1393
|
+
this.entry = options.entry ?? "index.html";
|
|
1394
|
+
this.remoteEntry = options.remoteEntry;
|
|
1395
|
+
this.requiredAppVersion = options.requiredAppVersion;
|
|
1396
|
+
this.remotePackage = options.remotePackage;
|
|
1397
|
+
this.hash = options.hash;
|
|
1398
|
+
this.url = "";
|
|
1399
|
+
this.icon = options.icon;
|
|
1400
|
+
this.devOptions = options.devOptions;
|
|
1401
|
+
this.remote = options.remote;
|
|
1402
|
+
if (options.widgets) {
|
|
1403
|
+
for (const widget of options.widgets) {
|
|
1404
|
+
this.widgets.push(widget);
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
static parseJSON(json) {
|
|
1409
|
+
const object = JSON.parse(json);
|
|
1410
|
+
return this.parseObject(object);
|
|
1411
|
+
}
|
|
1412
|
+
static parseObject(obj) {
|
|
1413
|
+
const widgetPackage = new WidgetPackage({
|
|
1414
|
+
author: "",
|
|
1415
|
+
description: {
|
|
1416
|
+
"zh-CN": ""
|
|
1417
|
+
},
|
|
1418
|
+
entry: "",
|
|
1419
|
+
hash: false,
|
|
1420
|
+
homepage: "",
|
|
1421
|
+
name: "",
|
|
1422
|
+
title: {
|
|
1423
|
+
"zh-CN": ""
|
|
1424
|
+
},
|
|
1425
|
+
version: ""
|
|
1426
|
+
});
|
|
1427
|
+
Object.assign(widgetPackage, obj);
|
|
1428
|
+
const widgets = [];
|
|
1429
|
+
if (widgetPackage.widgets) {
|
|
1430
|
+
for (const jsonWidget of widgetPackage.widgets) {
|
|
1431
|
+
const widget = new Widget({
|
|
1432
|
+
previewImage: "",
|
|
1433
|
+
path: "",
|
|
1434
|
+
description: { "zh-CN": "" },
|
|
1435
|
+
height: 0,
|
|
1436
|
+
keywords: [],
|
|
1437
|
+
lang: "zh-CN",
|
|
1438
|
+
name: "",
|
|
1439
|
+
title: { "zh-CN": "" },
|
|
1440
|
+
width: 0
|
|
1441
|
+
});
|
|
1442
|
+
Object.assign(widget, jsonWidget);
|
|
1443
|
+
widgets.push(widget);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
widgetPackage.widgets.splice(0, widgetPackage.widgets.length);
|
|
1447
|
+
widgetPackage.widgets.push(...widgets);
|
|
1448
|
+
return widgetPackage;
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* 获取组件包标题
|
|
1452
|
+
* @param lang 语言环境,不传则获取默认语言
|
|
1453
|
+
*/
|
|
1454
|
+
getTitle(lang) {
|
|
1455
|
+
return getTextByLanguageCode(this.title, lang);
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* 获取组件包描述
|
|
1459
|
+
* @param lang 语言环境,不传则获取默认标题
|
|
1460
|
+
*/
|
|
1461
|
+
getDescription(lang) {
|
|
1462
|
+
return getTextByLanguageCode(this.description, lang);
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
|
|
1466
|
+
// src/utils/ElectronUtils.ts
|
|
1467
|
+
var ElectronUtils = class {
|
|
1468
|
+
static hasElectronApi() {
|
|
1469
|
+
return this.getAPI() != null;
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* 获取ElectronAPI
|
|
1473
|
+
* windows api
|
|
1474
|
+
*/
|
|
1475
|
+
static getAPI() {
|
|
1476
|
+
if (Reflect.has(window, "electronAPI")) {
|
|
1477
|
+
return window.electronAPI;
|
|
1478
|
+
} else if (Reflect.has(window.parent, "electronAPI")) {
|
|
1479
|
+
return window.parent.electronAPI;
|
|
1480
|
+
}
|
|
1481
|
+
return null;
|
|
1482
|
+
}
|
|
1483
|
+
static async invokeMethod(channel, method, ...args) {
|
|
1484
|
+
return this.getAPI()?.invoke(channel, method, ...args);
|
|
1485
|
+
}
|
|
1486
|
+
static async invoke(channel, ...args) {
|
|
1487
|
+
return this.getAPI()?.invoke(channel, ...args);
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1311
1491
|
// src/utils/normalizeUrl.ts
|
|
1312
1492
|
var DATA_URL_DEFAULT_MIME_TYPE = "text/plain";
|
|
1313
1493
|
var DATA_URL_DEFAULT_CHARSET = "us-ascii";
|
|
@@ -1503,221 +1683,6 @@ function normalizeUrl(urlString, options) {
|
|
|
1503
1683
|
return urlString;
|
|
1504
1684
|
}
|
|
1505
1685
|
|
|
1506
|
-
// src/utils/WidgetUrlUtils.ts
|
|
1507
|
-
var WidgetUrlUtils = class {
|
|
1508
|
-
static getWidgetUrl(widgetUrl, widgetPackage, widgetParams) {
|
|
1509
|
-
let url = "";
|
|
1510
|
-
const arr = [];
|
|
1511
|
-
if (widgetUrl.startsWith("http")) {
|
|
1512
|
-
url = widgetUrl;
|
|
1513
|
-
} else {
|
|
1514
|
-
url = widgetPackage.getIndexUrl() + widgetUrl;
|
|
1515
|
-
}
|
|
1516
|
-
arr.push(url);
|
|
1517
|
-
if (url.includes("?")) {
|
|
1518
|
-
arr.push("&");
|
|
1519
|
-
} else {
|
|
1520
|
-
arr.push("?");
|
|
1521
|
-
}
|
|
1522
|
-
arr.push(widgetParams.toUrlParams().toString());
|
|
1523
|
-
return normalizeUrl(arr.join("")).replaceAll("//", "/");
|
|
1524
|
-
}
|
|
1525
|
-
static getWidgetPackageUrl(url, entry, hash, path = "") {
|
|
1526
|
-
const arr = [url];
|
|
1527
|
-
if (url.startsWith("http")) {
|
|
1528
|
-
if (hash) {
|
|
1529
|
-
arr.push("#");
|
|
1530
|
-
}
|
|
1531
|
-
} else {
|
|
1532
|
-
arr.push(`/${entry}`);
|
|
1533
|
-
if (hash) {
|
|
1534
|
-
arr.push("#");
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
arr.push(path);
|
|
1538
|
-
return arr.join("");
|
|
1539
|
-
}
|
|
1540
|
-
};
|
|
1541
|
-
|
|
1542
|
-
// src/model/WidgetPackage.ts
|
|
1543
|
-
var WidgetPackage = class {
|
|
1544
|
-
/**
|
|
1545
|
-
* 组件包名,一般为域名倒写,e.g. com.example
|
|
1546
|
-
*/
|
|
1547
|
-
name;
|
|
1548
|
-
/**
|
|
1549
|
-
* 组件包版本,可以为空,默认采用package.json里的版本
|
|
1550
|
-
* e.g. 1.0.2
|
|
1551
|
-
*/
|
|
1552
|
-
version;
|
|
1553
|
-
/**
|
|
1554
|
-
* 组件作者署名
|
|
1555
|
-
*/
|
|
1556
|
-
author;
|
|
1557
|
-
/**
|
|
1558
|
-
* 组件首页
|
|
1559
|
-
*/
|
|
1560
|
-
homepage;
|
|
1561
|
-
/**
|
|
1562
|
-
* 组件描述
|
|
1563
|
-
*/
|
|
1564
|
-
title;
|
|
1565
|
-
/**
|
|
1566
|
-
* 组件描述
|
|
1567
|
-
*/
|
|
1568
|
-
description;
|
|
1569
|
-
/**
|
|
1570
|
-
* 本地组件入口文件,通常为 index.html
|
|
1571
|
-
*/
|
|
1572
|
-
entry;
|
|
1573
|
-
/**
|
|
1574
|
-
* 远程组件包入口文件
|
|
1575
|
-
* @deprecated 使用 remote.entry 替代
|
|
1576
|
-
*/
|
|
1577
|
-
remoteEntry;
|
|
1578
|
-
/**
|
|
1579
|
-
* 组件包json文件路径
|
|
1580
|
-
* @example https://rtugeek.gitee.io/hotspot/widget.json
|
|
1581
|
-
*/
|
|
1582
|
-
remotePackage;
|
|
1583
|
-
local;
|
|
1584
|
-
remote;
|
|
1585
|
-
/**
|
|
1586
|
-
* 组件包图标
|
|
1587
|
-
*/
|
|
1588
|
-
icon;
|
|
1589
|
-
/**
|
|
1590
|
-
* Hash路由模式,默认为true
|
|
1591
|
-
*/
|
|
1592
|
-
hash = true;
|
|
1593
|
-
/**
|
|
1594
|
-
* 可能是网络地址,或者本地路径(解压后的文件夹路径),
|
|
1595
|
-
* 网络地址:https://www.bilibili.com
|
|
1596
|
-
* 本地地址:file:///C:/Users/neo/Desktop
|
|
1597
|
-
* 在测试时。地址通常为: http://127.0.0.1:8080
|
|
1598
|
-
*/
|
|
1599
|
-
url;
|
|
1600
|
-
widgets = [];
|
|
1601
|
-
pages = [];
|
|
1602
|
-
devOptions;
|
|
1603
|
-
constructor(options) {
|
|
1604
|
-
this.name = options.name;
|
|
1605
|
-
this.version = options.version;
|
|
1606
|
-
this.author = options.author;
|
|
1607
|
-
this.homepage = options.homepage;
|
|
1608
|
-
this.title = options.title;
|
|
1609
|
-
this.description = options.description;
|
|
1610
|
-
this.entry = options.entry ?? "index.html";
|
|
1611
|
-
this.remoteEntry = options.remoteEntry;
|
|
1612
|
-
this.remotePackage = options.remotePackage;
|
|
1613
|
-
this.hash = options.hash;
|
|
1614
|
-
this.url = "";
|
|
1615
|
-
this.icon = options.icon;
|
|
1616
|
-
this.devOptions = options.devOptions;
|
|
1617
|
-
this.remote = options.remote;
|
|
1618
|
-
if (options.widgets) {
|
|
1619
|
-
for (const widget of options.widgets) {
|
|
1620
|
-
this.widgets.push(widget);
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
static parseJSON(json) {
|
|
1625
|
-
const object = JSON.parse(json);
|
|
1626
|
-
return this.parseObject(object);
|
|
1627
|
-
}
|
|
1628
|
-
static parseObject(obj) {
|
|
1629
|
-
const widgetPackage = new WidgetPackage({
|
|
1630
|
-
author: "",
|
|
1631
|
-
description: {
|
|
1632
|
-
"zh-CN": ""
|
|
1633
|
-
},
|
|
1634
|
-
entry: "",
|
|
1635
|
-
hash: false,
|
|
1636
|
-
homepage: "",
|
|
1637
|
-
name: "",
|
|
1638
|
-
title: {
|
|
1639
|
-
"zh-CN": ""
|
|
1640
|
-
},
|
|
1641
|
-
version: ""
|
|
1642
|
-
});
|
|
1643
|
-
Object.assign(widgetPackage, obj);
|
|
1644
|
-
const widgets = [];
|
|
1645
|
-
if (widgetPackage.widgets) {
|
|
1646
|
-
for (const jsonWidget of widgetPackage.widgets) {
|
|
1647
|
-
const widget = new Widget({
|
|
1648
|
-
previewImage: "",
|
|
1649
|
-
path: "",
|
|
1650
|
-
description: { "zh-CN": "" },
|
|
1651
|
-
height: 0,
|
|
1652
|
-
keywords: [],
|
|
1653
|
-
lang: "zh-CN",
|
|
1654
|
-
name: "",
|
|
1655
|
-
title: { "zh-CN": "" },
|
|
1656
|
-
width: 0
|
|
1657
|
-
});
|
|
1658
|
-
Object.assign(widget, jsonWidget);
|
|
1659
|
-
widgets.push(widget);
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
widgetPackage.widgets.splice(0, widgetPackage.widgets.length);
|
|
1663
|
-
widgetPackage.widgets.push(...widgets);
|
|
1664
|
-
return widgetPackage;
|
|
1665
|
-
}
|
|
1666
|
-
/**
|
|
1667
|
-
* 获取组件包标题
|
|
1668
|
-
* @param lang 语言环境,不传则获取默认语言
|
|
1669
|
-
*/
|
|
1670
|
-
getTitle(lang) {
|
|
1671
|
-
return getTextByLanguageCode(this.title, lang);
|
|
1672
|
-
}
|
|
1673
|
-
/**
|
|
1674
|
-
* 获取组件包描述
|
|
1675
|
-
* @param lang 语言环境,不传则获取默认标题
|
|
1676
|
-
*/
|
|
1677
|
-
getDescription(lang) {
|
|
1678
|
-
return getTextByLanguageCode(this.description, lang);
|
|
1679
|
-
}
|
|
1680
|
-
/**
|
|
1681
|
-
* 获取组件完整路径
|
|
1682
|
-
* 如果url是http链接,直接返回链接
|
|
1683
|
-
* 如果是本地组件:file://链接,则返回 url+entry,
|
|
1684
|
-
* 如果是远程组件:http://链接,则返回 entry,
|
|
1685
|
-
* @example file://C:/users/neo/desktop/index.html#
|
|
1686
|
-
* @example file://C:/users/neo/desktop/index.html#
|
|
1687
|
-
*/
|
|
1688
|
-
getIndexUrl(hash) {
|
|
1689
|
-
return WidgetUrlUtils.getWidgetPackageUrl(this.url, this.entry, hash == null ? this.hash : hash);
|
|
1690
|
-
}
|
|
1691
|
-
getUrl(path, hash) {
|
|
1692
|
-
return WidgetUrlUtils.getWidgetPackageUrl(this.url, this.entry, hash == null ? this.hash : hash, path);
|
|
1693
|
-
}
|
|
1694
|
-
};
|
|
1695
|
-
|
|
1696
|
-
// src/utils/ElectronUtils.ts
|
|
1697
|
-
var ElectronUtils = class {
|
|
1698
|
-
static hasElectronApi() {
|
|
1699
|
-
return this.getAPI() != null;
|
|
1700
|
-
}
|
|
1701
|
-
/**
|
|
1702
|
-
* 获取ElectronAPI
|
|
1703
|
-
* windows api
|
|
1704
|
-
*/
|
|
1705
|
-
static getAPI() {
|
|
1706
|
-
if (Reflect.has(window, "electronAPI")) {
|
|
1707
|
-
return window.electronAPI;
|
|
1708
|
-
} else if (Reflect.has(window.parent, "electronAPI")) {
|
|
1709
|
-
return window.parent.electronAPI;
|
|
1710
|
-
}
|
|
1711
|
-
return null;
|
|
1712
|
-
}
|
|
1713
|
-
static async invokeMethod(channel, method, ...args) {
|
|
1714
|
-
return this.getAPI()?.invoke(channel, method, ...args);
|
|
1715
|
-
}
|
|
1716
|
-
static async invoke(channel, ...args) {
|
|
1717
|
-
return this.getAPI()?.invoke(channel, ...args);
|
|
1718
|
-
}
|
|
1719
|
-
};
|
|
1720
|
-
|
|
1721
1686
|
// src/grid/GridSystem.ts
|
|
1722
1687
|
var GridRect = class {
|
|
1723
1688
|
top;
|
|
@@ -2004,43 +1969,6 @@ var WidgetApiImpl = class extends BaseApi {
|
|
|
2004
1969
|
async getWidgetPackage(name) {
|
|
2005
1970
|
return WidgetPackage.parseObject(await this.invokeMethod("getWidgetPackage", name));
|
|
2006
1971
|
}
|
|
2007
|
-
/**
|
|
2008
|
-
* 获取组件配置地址
|
|
2009
|
-
* @param widgetName
|
|
2010
|
-
*/
|
|
2011
|
-
async getWidgetConfigUrl(widgetName, widgetParams) {
|
|
2012
|
-
const widget = await this.getWidget(widgetName);
|
|
2013
|
-
if (!widget) {
|
|
2014
|
-
return null;
|
|
2015
|
-
}
|
|
2016
|
-
const configPagePath = widget.configPagePath;
|
|
2017
|
-
if (!configPagePath) {
|
|
2018
|
-
return null;
|
|
2019
|
-
}
|
|
2020
|
-
const widgetPackage = await this.getWidgetPackage(widget.packageName);
|
|
2021
|
-
if (!widgetPackage) {
|
|
2022
|
-
return null;
|
|
2023
|
-
}
|
|
2024
|
-
return WidgetUrlUtils.getWidgetUrl(configPagePath, widgetPackage, widgetParams);
|
|
2025
|
-
}
|
|
2026
|
-
async getWidgetUrl(widgetName, widgetParams) {
|
|
2027
|
-
const widget = await this.getWidget(widgetName);
|
|
2028
|
-
if (!widget) {
|
|
2029
|
-
return null;
|
|
2030
|
-
}
|
|
2031
|
-
const widgetPackage = await this.getWidgetPackage(widget.packageName);
|
|
2032
|
-
if (!widgetPackage) {
|
|
2033
|
-
return null;
|
|
2034
|
-
}
|
|
2035
|
-
return WidgetUrlUtils.getWidgetUrl(widget.path, widgetPackage, widgetParams);
|
|
2036
|
-
}
|
|
2037
|
-
async getWidgetPackageIndexUrl(packageName, hash) {
|
|
2038
|
-
const widgetPackage = await this.getWidgetPackage(packageName);
|
|
2039
|
-
if (!widgetPackage) {
|
|
2040
|
-
return null;
|
|
2041
|
-
}
|
|
2042
|
-
return widgetPackage.getIndexUrl(hash);
|
|
2043
|
-
}
|
|
2044
1972
|
async getWidgetPackageUrl(packageName) {
|
|
2045
1973
|
const widgetPackage = await this.getWidgetPackage(packageName);
|
|
2046
1974
|
if (!widgetPackage) {
|
|
@@ -2097,7 +2025,7 @@ var WidgetDataApiImpl = class {
|
|
|
2097
2025
|
* @param options
|
|
2098
2026
|
*/
|
|
2099
2027
|
async save(data, options = { sendBroadcast: true }) {
|
|
2100
|
-
const store = this.getStore(data.name);
|
|
2028
|
+
const store = this.getStore(data.name, options.storeName);
|
|
2101
2029
|
const json = JSON.stringify(data);
|
|
2102
2030
|
const result = await store.setItem(this.getKey(data.name, data.id), json);
|
|
2103
2031
|
if (options.sendBroadcast) {
|
|
@@ -2182,6 +2110,12 @@ var BrowserWindowApiEvent = /* @__PURE__ */ ((BrowserWindowApiEvent2) => {
|
|
|
2182
2110
|
return BrowserWindowApiEvent2;
|
|
2183
2111
|
})(BrowserWindowApiEvent || {});
|
|
2184
2112
|
var BrowserWindowApiImpl = class extends BaseApi {
|
|
2113
|
+
setNoActivate() {
|
|
2114
|
+
return this.invokeMethod("setNoActivate");
|
|
2115
|
+
}
|
|
2116
|
+
async isVisible() {
|
|
2117
|
+
return await this.invokeMethod("isVisible");
|
|
2118
|
+
}
|
|
2185
2119
|
getChannel() {
|
|
2186
2120
|
return "channel::cn.widgetjs.core.browser_window" /* BROWSER_WINDOW */;
|
|
2187
2121
|
}
|
|
@@ -2282,7 +2216,7 @@ var BrowserWindowApiImpl = class extends BaseApi {
|
|
|
2282
2216
|
return await this.invokeMethod("unmaximize");
|
|
2283
2217
|
}
|
|
2284
2218
|
async setZoomLevel(level) {
|
|
2285
|
-
return await this.invokeMethod("setZoomLevel");
|
|
2219
|
+
return await this.invokeMethod("setZoomLevel", level);
|
|
2286
2220
|
}
|
|
2287
2221
|
async reload() {
|
|
2288
2222
|
return await this.invokeMethod("reload");
|
|
@@ -2514,6 +2448,9 @@ var DeviceApiImpl = class extends BaseApi {
|
|
|
2514
2448
|
async getCursorScreenPoint() {
|
|
2515
2449
|
return this.invokeMethod("getCursorScreenPoint");
|
|
2516
2450
|
}
|
|
2451
|
+
async sendCtrlV() {
|
|
2452
|
+
return this.invokeMethod("sendCtrlV");
|
|
2453
|
+
}
|
|
2517
2454
|
/**
|
|
2518
2455
|
* 判断是否所有按键都已经释放
|
|
2519
2456
|
*/
|
|
@@ -2532,6 +2469,9 @@ var ClipboardApiEvent = /* @__PURE__ */ ((ClipboardApiEvent2) => {
|
|
|
2532
2469
|
return ClipboardApiEvent2;
|
|
2533
2470
|
})(ClipboardApiEvent || {});
|
|
2534
2471
|
var ClipboardApiImpl = class extends BaseApi {
|
|
2472
|
+
writeText(text) {
|
|
2473
|
+
return this.invokeMethod("writeText", text);
|
|
2474
|
+
}
|
|
2535
2475
|
async getSelectedText() {
|
|
2536
2476
|
return this.invokeMethod("getSelectedText");
|
|
2537
2477
|
}
|
|
@@ -2646,8 +2586,8 @@ var AppApiImpl = class extends BaseApi {
|
|
|
2646
2586
|
/**
|
|
2647
2587
|
* 获取应用版本号,格式为 x.y.z
|
|
2648
2588
|
*/
|
|
2649
|
-
async getVersion() {
|
|
2650
|
-
return this.invokeMethod("getVersion");
|
|
2589
|
+
async getVersion(type) {
|
|
2590
|
+
return this.invokeMethod("getVersion", type);
|
|
2651
2591
|
}
|
|
2652
2592
|
async getPreloadPath() {
|
|
2653
2593
|
return this.invokeMethod("getPreloadPath");
|
|
@@ -2797,6 +2737,7 @@ var SystemApiEvent = /* @__PURE__ */ ((SystemApiEvent2) => {
|
|
|
2797
2737
|
AppApiConstants,
|
|
2798
2738
|
AppApiEvent,
|
|
2799
2739
|
AppNotification,
|
|
2740
|
+
BackgroundWidget,
|
|
2800
2741
|
BaseApi,
|
|
2801
2742
|
BroadcastApi,
|
|
2802
2743
|
BroadcastEvent,
|
|
@@ -2840,7 +2781,6 @@ var SystemApiEvent = /* @__PURE__ */ ((SystemApiEvent2) => {
|
|
|
2840
2781
|
WidgetKeyword,
|
|
2841
2782
|
WidgetPackage,
|
|
2842
2783
|
WidgetParams,
|
|
2843
|
-
WidgetUrlUtils,
|
|
2844
2784
|
getTextByLanguageCode,
|
|
2845
2785
|
normalizeUrl,
|
|
2846
2786
|
parseQuery,
|