@widget-js/core 0.7.10 → 0.10.6

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
@@ -81,6 +81,7 @@ __export(src_exports, {
81
81
  WidgetPackage: () => WidgetPackage,
82
82
  WidgetParams: () => WidgetParams,
83
83
  WidgetUrlUtils: () => WidgetUrlUtils,
84
+ getTextByLanguageCode: () => getTextByLanguageCode,
84
85
  normalizeUrl: () => normalizeUrl,
85
86
  parseQuery: () => parseQuery,
86
87
  stringifyQuery: () => stringifyQuery
@@ -147,6 +148,7 @@ var Page = class {
147
148
  description;
148
149
  keywords;
149
150
  security;
151
+ permissions;
150
152
  /**
151
153
  * 组件默认语言
152
154
  */
@@ -189,6 +191,7 @@ var Page = class {
189
191
  this.path = options.path;
190
192
  this.meta = options.meta ?? {};
191
193
  this.security = options.security ?? false;
194
+ this.permissions = options.permissions ?? [];
192
195
  }
193
196
  /**
194
197
  * 获取组件标题
@@ -237,10 +240,15 @@ var Widget = class extends Page {
237
240
  * 配置页面路径,没有则不能修改
238
241
  */
239
242
  configPagePath;
243
+ /**
244
+ * @deprecated
245
+ */
246
+ routes;
240
247
  constructor(options) {
241
248
  super(options);
242
249
  this.configPagePath = options.configPagePath;
243
250
  this.supportDeployMode = options.supportDeployMode ?? 1 /* NORMAL */ | 16 /* OVERLAP */;
251
+ this.routes = options.routes ?? [];
244
252
  }
245
253
  static parseJSON(json) {
246
254
  const object = JSON.parse(json);
@@ -888,7 +896,7 @@ var WidgetUrlUtils = class {
888
896
  arr.push(widgetParams.toUrlParams().toString());
889
897
  return normalizeUrl(arr.join("")).replaceAll("//", "/");
890
898
  }
891
- static getWidgetPackageUrl(url, entry, hash) {
899
+ static getWidgetPackageUrl(url, entry, hash, path = "") {
892
900
  const arr = [url];
893
901
  if (url.startsWith("http")) {
894
902
  if (hash) {
@@ -897,11 +905,11 @@ var WidgetUrlUtils = class {
897
905
  } else {
898
906
  arr.push(`/${entry}`);
899
907
  if (hash) {
900
- arr.push("#/");
908
+ arr.push("#");
901
909
  }
902
910
  }
903
- return normalizeUrl(arr.join("")).replaceAll("//", "/");
904
- ;
911
+ arr.push(path);
912
+ return arr.join("");
905
913
  }
906
914
  };
907
915
 
@@ -1049,6 +1057,9 @@ var WidgetPackage = class {
1049
1057
  getIndexUrl(hash) {
1050
1058
  return WidgetUrlUtils.getWidgetPackageUrl(this.url, this.entry, hash == null ? this.hash : hash);
1051
1059
  }
1060
+ getUrl(path, hash) {
1061
+ return WidgetUrlUtils.getWidgetPackageUrl(this.url, this.entry, hash == null ? this.hash : hash, path);
1062
+ }
1052
1063
  };
1053
1064
 
1054
1065
  // src/utils/ElectronUtils.ts
@@ -1289,6 +1300,9 @@ var WidgetApiImpl = class extends BaseApi {
1289
1300
  async openConfigPage(widgetId) {
1290
1301
  return this.invokeMethod("openConfigPage", widgetId);
1291
1302
  }
1303
+ async openConfigPageByName(widgetName) {
1304
+ return this.invokeMethod("openConfigPageByName", widgetName);
1305
+ }
1292
1306
  async getWidgetPackages() {
1293
1307
  return await this.invokeMethod("getWidgetPackages");
1294
1308
  }
@@ -1389,16 +1403,19 @@ var WidgetDataApiImpl = class {
1389
1403
  /**
1390
1404
  * 保存组件数据
1391
1405
  * @param data
1406
+ * @param options
1392
1407
  */
1393
- async save(data) {
1408
+ async save(data, options = { sendBroadcast: true }) {
1394
1409
  let store = this.getStore(data.name);
1395
1410
  let json = JSON.stringify(data);
1396
1411
  const result = await store.setItem(this.getKey(data.name, data.id), json);
1397
- const broadcastEvent = new BroadcastEvent({
1398
- event: "event::cn.widgetjs.core.widget.data-changed" /* DATA_CHANGED */,
1399
- payload: { name: data.name, json }
1400
- });
1401
- await BroadcastApi.send(broadcastEvent);
1412
+ if (options.sendBroadcast) {
1413
+ const broadcastEvent = new BroadcastEvent({
1414
+ event: "event::cn.widgetjs.core.widget.data-changed" /* DATA_CHANGED */,
1415
+ payload: { name: data.name, json }
1416
+ });
1417
+ await BroadcastApi.send(broadcastEvent);
1418
+ }
1402
1419
  return result;
1403
1420
  }
1404
1421
  /**
@@ -1611,9 +1628,6 @@ var BrowserWindowApiImpl = class extends BaseApi {
1611
1628
  if (options.alwaysOnTop) {
1612
1629
  await this.setAlwaysOnTop(true);
1613
1630
  }
1614
- if (options.center) {
1615
- await this.center();
1616
- }
1617
1631
  await this.setResizable(!!options.resizable);
1618
1632
  await this.setMovable(!!options.movable);
1619
1633
  if (options.width && options.height) {
@@ -1625,6 +1639,9 @@ var BrowserWindowApiImpl = class extends BaseApi {
1625
1639
  if (options.maxWidth && options.maxHeight) {
1626
1640
  await this.setMaximumSize(options.maxWidth, options.maxHeight);
1627
1641
  }
1642
+ if (options.center) {
1643
+ await this.center();
1644
+ }
1628
1645
  }
1629
1646
  };
1630
1647
  var BrowserWindowApi = new BrowserWindowApiImpl();
@@ -2060,6 +2077,7 @@ var FileApi = new FileApiImpl();
2060
2077
  WidgetPackage,
2061
2078
  WidgetParams,
2062
2079
  WidgetUrlUtils,
2080
+ getTextByLanguageCode,
2063
2081
  normalizeUrl,
2064
2082
  parseQuery,
2065
2083
  stringifyQuery