@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 CHANGED
@@ -42,19 +42,17 @@ __export(src_exports, {
42
42
  AppNotification: () => AppNotification,
43
43
  BaseApi: () => BaseApi,
44
44
  BroadcastApi: () => BroadcastApi,
45
- BroadcastApiImpl: () => BroadcastApiImpl,
46
45
  BroadcastEvent: () => BroadcastEvent,
47
46
  BrowserWindowApi: () => BrowserWindowApi,
48
47
  BrowserWindowApiEvent: () => BrowserWindowApiEvent,
49
- BrowserWindowApiImpl: () => BrowserWindowApiImpl,
50
48
  Channel: () => Channel,
51
49
  ClipboardApi: () => ClipboardApi,
52
50
  ClipboardApiEvent: () => ClipboardApiEvent,
53
- DeployedMode: () => DeployedMode,
51
+ DeployMode: () => DeployMode,
54
52
  DeployedPage: () => DeployedPage,
55
53
  DeployedWidget: () => DeployedWidget,
54
+ DeployedWidgetApi: () => DeployedWidgetApi,
56
55
  DeviceApi: () => DeviceApi,
57
- DeviceApiImpl: () => DeviceApiImpl,
58
56
  DialogApi: () => DialogApi,
59
57
  ElectronApi: () => ElectronApi,
60
58
  ElectronUtils: () => ElectronUtils,
@@ -63,9 +61,6 @@ __export(src_exports, {
63
61
  GridRect: () => GridRect,
64
62
  GridSystem: () => GridSystem,
65
63
  HostedMode: () => HostedMode,
66
- HostedWidget: () => HostedWidget,
67
- HostedWidgetApi: () => HostedWidgetApi,
68
- HostedWidgetApiImpl: () => HostedWidgetApiImpl,
69
64
  LogApi: () => LogApi,
70
65
  NotificationApi: () => NotificationApi,
71
66
  NotificationApiEvent: () => NotificationApiEvent,
@@ -82,7 +77,6 @@ __export(src_exports, {
82
77
  WidgetApiEvent: () => WidgetApiEvent,
83
78
  WidgetData: () => WidgetData,
84
79
  WidgetDataApi: () => WidgetDataApi,
85
- WidgetDataApiImpl: () => WidgetDataApiImpl,
86
80
  WidgetKeyword: () => WidgetKeyword,
87
81
  WidgetPackage: () => WidgetPackage,
88
82
  WidgetParams: () => WidgetParams,
@@ -93,7 +87,7 @@ __export(src_exports, {
93
87
  });
94
88
  module.exports = __toCommonJS(src_exports);
95
89
 
96
- // src/model/DeployedMode.ts
90
+ // src/model/DeployMode.ts
97
91
  var HostedMode = /* @__PURE__ */ ((HostedMode2) => {
98
92
  HostedMode2[HostedMode2["NORMAL"] = 1] = "NORMAL";
99
93
  HostedMode2[HostedMode2["OVERLAP"] = 16] = "OVERLAP";
@@ -104,13 +98,13 @@ var HostedMode = /* @__PURE__ */ ((HostedMode2) => {
104
98
  HostedMode2[HostedMode2["ALL"] = 1118481] = "ALL";
105
99
  return HostedMode2;
106
100
  })(HostedMode || {});
107
- var DeployedMode = /* @__PURE__ */ ((DeployedMode2) => {
108
- DeployedMode2[DeployedMode2["NORMAL"] = 1] = "NORMAL";
109
- DeployedMode2[DeployedMode2["OVERLAP"] = 16] = "OVERLAP";
110
- DeployedMode2[DeployedMode2["BACKGROUND"] = 65536] = "BACKGROUND";
111
- DeployedMode2[DeployedMode2["ALL"] = 1118481] = "ALL";
112
- return DeployedMode2;
113
- })(DeployedMode || {});
101
+ var DeployMode = /* @__PURE__ */ ((DeployMode2) => {
102
+ DeployMode2[DeployMode2["NORMAL"] = 1] = "NORMAL";
103
+ DeployMode2[DeployMode2["OVERLAP"] = 16] = "OVERLAP";
104
+ DeployMode2[DeployMode2["BACKGROUND"] = 65536] = "BACKGROUND";
105
+ DeployMode2[DeployMode2["ALL"] = 1118481] = "ALL";
106
+ return DeployMode2;
107
+ })(DeployMode || {});
114
108
 
115
109
  // src/utils/LanguageUtils.ts
116
110
  function getTextByLanguageCode(langMap, langCode, fallbackToBrowser = true) {
@@ -166,7 +160,7 @@ var Page = class {
166
160
  movable;
167
161
  singleton;
168
162
  resizable;
169
- url;
163
+ path;
170
164
  meta;
171
165
  backgroundThrottling;
172
166
  /**
@@ -191,7 +185,7 @@ var Page = class {
191
185
  this.packageName = options.packageName;
192
186
  this.singleton = options.singleton ?? false;
193
187
  this.previewImage = options.previewImage;
194
- this.url = options.url;
188
+ this.path = options.path;
195
189
  this.meta = options.meta ?? {};
196
190
  }
197
191
  /**
@@ -214,7 +208,7 @@ var Page = class {
214
208
  }
215
209
  static parseObject(obj) {
216
210
  let widget = new Page({
217
- url: "",
211
+ path: "",
218
212
  description: {},
219
213
  height: 0,
220
214
  keywords: [],
@@ -234,38 +228,15 @@ var Page = class {
234
228
 
235
229
  // src/model/Widget.ts
236
230
  var Widget = class extends Page {
237
- supportHostedMode;
238
- supportDeployedMode;
239
- /**
240
- * @deprecated
241
- */
242
- refreshWhenResided;
243
- /**
244
- * 组件其他页面的url在这注册
245
- * @deprecated
246
- */
247
- routes;
231
+ supportDeployMode;
248
232
  /**
249
- * @deprecated
233
+ * 配置页面路径,没有则不能修改
250
234
  */
251
- permissions;
235
+ configPagePath;
252
236
  constructor(options) {
253
237
  super(options);
254
- this.refreshWhenResided = options.refreshWhenResided ?? false;
255
- this.supportHostedMode = options.supportDeployedMode ?? 1 /* NORMAL */ | 16 /* OVERLAP */;
256
- this.supportDeployedMode = options.supportDeployedMode ?? 1 /* NORMAL */ | 16 /* OVERLAP */;
257
- this.permissions = options.permissions ?? [];
258
- this.routes = options.routes;
259
- }
260
- getIndexRoute() {
261
- const result = this.routes.find((it) => it.name.toLowerCase() == "index");
262
- return result;
263
- }
264
- getConfigRoute() {
265
- return this.routes.find((it) => it.name.toLowerCase() == "config");
266
- }
267
- isConfigurable() {
268
- return this.getConfigRoute() != null;
238
+ this.configPagePath = options.configPagePath;
239
+ this.supportDeployMode = options.supportDeployMode ?? 1 /* NORMAL */ | 16 /* OVERLAP */;
269
240
  }
270
241
  static parseJSON(json) {
271
242
  const object = JSON.parse(json);
@@ -273,13 +244,12 @@ var Widget = class extends Page {
273
244
  }
274
245
  static parseObject(obj) {
275
246
  let widget = new Widget({
276
- url: "",
247
+ path: "",
277
248
  description: {},
278
249
  height: 0,
279
250
  keywords: [],
280
251
  lang: "zh-CN",
281
252
  name: "",
282
- routes: [],
283
253
  previewImage: "",
284
254
  title: {},
285
255
  width: 0
@@ -291,16 +261,16 @@ var Widget = class extends Page {
291
261
  * 是否支持悬浮窗
292
262
  */
293
263
  isSupportOverlap() {
294
- return (this.supportHostedMode & 16 /* OVERLAP */) > 0;
264
+ return (this.supportDeployMode & 16 /* OVERLAP */) > 0;
295
265
  }
296
266
  isSupportBackground() {
297
- return (this.supportHostedMode & 65536 /* BACKGROUND */) > 0;
267
+ return (this.supportDeployMode & 65536 /* BACKGROUND */) > 0;
298
268
  }
299
269
  /**
300
270
  * 是否支持普通模式
301
271
  */
302
272
  isSupportNormal() {
303
- return (this.supportHostedMode & 1 /* NORMAL */) > 0;
273
+ return (this.supportDeployMode & 1 /* NORMAL */) > 0;
304
274
  }
305
275
  };
306
276
  var WidgetKeyword = /* @__PURE__ */ ((WidgetKeyword2) => {
@@ -680,32 +650,11 @@ var DeployedPage = class {
680
650
  };
681
651
 
682
652
  // src/model/DeployedWidget.ts
683
- var HostedWidget = class extends DeployedPage {
684
- /**
685
- * @deprecated
686
- */
687
- widgetName;
688
- x = 0;
689
- y = 0;
690
- /**
691
- * @deprecated
692
- */
693
- browserWindowStatus;
694
- shortcut;
695
- /**
696
- * @deprecated use deployedMode instead
697
- */
698
- hostedMode;
699
- deployedMode;
700
- isOverlap() {
701
- return (this.deployedMode & 16 /* OVERLAP */) > 0;
702
- }
703
- };
704
653
  var DeployedWidget = class extends DeployedPage {
705
654
  shortcut;
706
- hostedMode;
655
+ deployMode;
707
656
  isOverlap() {
708
- return (this.hostedMode & 16 /* OVERLAP */) > 0;
657
+ return (this.deployMode & 16 /* OVERLAP */) > 0;
709
658
  }
710
659
  };
711
660
 
@@ -1051,13 +1000,12 @@ var WidgetPackage = class {
1051
1000
  for (let jsonWidget of widgetPackage.widgets) {
1052
1001
  let widget = new Widget({
1053
1002
  previewImage: "",
1054
- url: "",
1003
+ path: "",
1055
1004
  description: { "zh-CN": "" },
1056
1005
  height: 0,
1057
1006
  keywords: [],
1058
1007
  lang: "zh-CN",
1059
1008
  name: "",
1060
- routes: [],
1061
1009
  title: { "zh-CN": "" },
1062
1010
  width: 0
1063
1011
  });
@@ -1356,23 +1304,22 @@ var WidgetApiImpl = class extends BaseApi {
1356
1304
  const widget = await this.getWidget(widgetName);
1357
1305
  if (!widget)
1358
1306
  return null;
1359
- const configRoute = widget.getConfigRoute();
1360
- if (!configRoute)
1307
+ const configPagePath = widget.configPagePath;
1308
+ if (!configPagePath)
1361
1309
  return null;
1362
1310
  const widgetPackage = await this.getWidgetPackage(widget.packageName);
1363
1311
  if (!widgetPackage)
1364
1312
  return null;
1365
- return WidgetUrlUtils.getWidgetUrl(configRoute.url, widgetPackage, widgetParams);
1313
+ return WidgetUrlUtils.getWidgetUrl(configPagePath, widgetPackage, widgetParams);
1366
1314
  }
1367
1315
  async getWidgetUrl(widgetName, widgetParams) {
1368
1316
  const widget = await this.getWidget(widgetName);
1369
1317
  if (!widget)
1370
1318
  return null;
1371
- const indexRoute = widget.getIndexRoute();
1372
1319
  const widgetPackage = await this.getWidgetPackage(widget.packageName);
1373
1320
  if (!widgetPackage)
1374
1321
  return null;
1375
- return WidgetUrlUtils.getWidgetUrl(indexRoute.url, widgetPackage, widgetParams);
1322
+ return WidgetUrlUtils.getWidgetUrl(widget.path, widgetPackage, widgetParams);
1376
1323
  }
1377
1324
  async getWidgetPackageIndexUrl(packageName, hash) {
1378
1325
  const widgetPackage = await this.getWidgetPackage(packageName);
@@ -1513,9 +1460,10 @@ var WidgetDataApi = new WidgetDataApiImpl();
1513
1460
  // src/api/BrowserWindowApi.ts
1514
1461
  var BrowserWindowApiEvent = /* @__PURE__ */ ((BrowserWindowApiEvent2) => {
1515
1462
  BrowserWindowApiEvent2["BLUR"] = "event::cn.widgetjs.core.browser-window.blur";
1463
+ BrowserWindowApiEvent2["MOVED"] = "event::cn.widgetjs.core.browser-window.moved";
1516
1464
  BrowserWindowApiEvent2["FOCUS"] = "event::cn.widgetjs.core.browser-window.focus";
1517
1465
  BrowserWindowApiEvent2["SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.snap_to_edge";
1518
- BrowserWindowApiEvent2["RESIZE"] = "event::cn.widgetjs.core.browser-window.resize";
1466
+ BrowserWindowApiEvent2["RESIZED"] = "event::cn.widgetjs.core.browser-window.resized";
1519
1467
  BrowserWindowApiEvent2["CANCEL_SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge";
1520
1468
  return BrowserWindowApiEvent2;
1521
1469
  })(BrowserWindowApiEvent || {});
@@ -1758,7 +1706,7 @@ var NotificationApiImpl = class extends BaseApi {
1758
1706
  var NotificationApi = new NotificationApiImpl();
1759
1707
 
1760
1708
  // src/api/HostedWidgetApi.ts
1761
- var HostedWidgetApiImpl = class extends BaseApi {
1709
+ var DeployedWidgetApiImpl = class extends BaseApi {
1762
1710
  getChannel() {
1763
1711
  return "channel::cn.widgetjs.core.hosted_widget" /* HOSTED_WIDGET */;
1764
1712
  }
@@ -1766,8 +1714,8 @@ var HostedWidgetApiImpl = class extends BaseApi {
1766
1714
  * 移除组件
1767
1715
  * @param id
1768
1716
  */
1769
- async removeHostedWidget(id) {
1770
- return this.invokeMethod("removeHostedWidget", id);
1717
+ async removeDeployedWidget(id) {
1718
+ return this.invokeMethod("removeDeployedWidget", id);
1771
1719
  }
1772
1720
  addWidget(widgetName, hostMode) {
1773
1721
  return this.invokeMethod("addWidget", widgetName, hostMode);
@@ -1776,18 +1724,18 @@ var HostedWidgetApiImpl = class extends BaseApi {
1776
1724
  * 通过组件名移除已添加的组件
1777
1725
  * @param name 组件名
1778
1726
  */
1779
- async removeHostedWidgetByName(name) {
1780
- return this.invokeMethod("removeHostedWidgetByName", name);
1727
+ async removeDeployedWidgetByName(name) {
1728
+ return this.invokeMethod("removeDeployedWidgetByName", name);
1781
1729
  }
1782
1730
  /**
1783
1731
  * 获取已添加的组件
1784
1732
  * @param name 组件名,可以不传
1785
1733
  */
1786
- async getHostedWidgets(name) {
1787
- return this.invokeMethod("getHostedWidgets", name);
1734
+ async getDeployedWidgets(name) {
1735
+ return this.invokeMethod("getDeployedWidgets", name);
1788
1736
  }
1789
- async getHostedWidget(id) {
1790
- return this.invokeMethod("getHostedWidget", id);
1737
+ async getDeployedWidget(id) {
1738
+ return this.invokeMethod("getDeployedWidget", id);
1791
1739
  }
1792
1740
  /**
1793
1741
  * Opens the dev tools for a widget with the specified ID.
@@ -1814,7 +1762,7 @@ var HostedWidgetApiImpl = class extends BaseApi {
1814
1762
  return this.invokeMethod("setProxy", widgetId, proxy);
1815
1763
  }
1816
1764
  };
1817
- var HostedWidgetApi = new HostedWidgetApiImpl();
1765
+ var DeployedWidgetApi = new DeployedWidgetApiImpl();
1818
1766
 
1819
1767
  // src/api/DeviceApi.ts
1820
1768
  var DeviceApiImpl = class extends BaseApi {
@@ -1884,6 +1832,7 @@ var ShortcutApi = new ShortcutApiImpl();
1884
1832
  // src/api/AppApi.ts
1885
1833
  var AppApiEvent = /* @__PURE__ */ ((AppApiEvent2) => {
1886
1834
  AppApiEvent2["CONFIG_CHANGED"] = "event::cn.widgetjs.core.app.config.changed";
1835
+ AppApiEvent2["MOVING_GRID_WINDOW"] = "event::cn.widgetjs.core.app.moving.grid.window";
1887
1836
  return AppApiEvent2;
1888
1837
  })(AppApiEvent || {});
1889
1838
  var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
@@ -2032,19 +1981,17 @@ var FileApi = new FileApiImpl();
2032
1981
  AppNotification,
2033
1982
  BaseApi,
2034
1983
  BroadcastApi,
2035
- BroadcastApiImpl,
2036
1984
  BroadcastEvent,
2037
1985
  BrowserWindowApi,
2038
1986
  BrowserWindowApiEvent,
2039
- BrowserWindowApiImpl,
2040
1987
  Channel,
2041
1988
  ClipboardApi,
2042
1989
  ClipboardApiEvent,
2043
- DeployedMode,
1990
+ DeployMode,
2044
1991
  DeployedPage,
2045
1992
  DeployedWidget,
1993
+ DeployedWidgetApi,
2046
1994
  DeviceApi,
2047
- DeviceApiImpl,
2048
1995
  DialogApi,
2049
1996
  ElectronApi,
2050
1997
  ElectronUtils,
@@ -2053,9 +2000,6 @@ var FileApi = new FileApiImpl();
2053
2000
  GridRect,
2054
2001
  GridSystem,
2055
2002
  HostedMode,
2056
- HostedWidget,
2057
- HostedWidgetApi,
2058
- HostedWidgetApiImpl,
2059
2003
  LogApi,
2060
2004
  NotificationApi,
2061
2005
  NotificationApiEvent,
@@ -2072,7 +2016,6 @@ var FileApi = new FileApiImpl();
2072
2016
  WidgetApiEvent,
2073
2017
  WidgetData,
2074
2018
  WidgetDataApi,
2075
- WidgetDataApiImpl,
2076
2019
  WidgetKeyword,
2077
2020
  WidgetPackage,
2078
2021
  WidgetParams,