@widget-js/core 0.11.12 → 0.11.20

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
@@ -48,6 +48,7 @@ __export(src_exports, {
48
48
  Channel: () => Channel,
49
49
  ClipboardApi: () => ClipboardApi,
50
50
  ClipboardApiEvent: () => ClipboardApiEvent,
51
+ DefaultWidgetTheme: () => DefaultWidgetTheme,
51
52
  DeployMode: () => DeployMode,
52
53
  DeployedPage: () => DeployedPage,
53
54
  DeployedWidget: () => DeployedWidget,
@@ -247,10 +248,12 @@ var Widget = class extends Page {
247
248
  * @deprecated
248
249
  */
249
250
  routes;
251
+ socialLinks;
250
252
  constructor(options) {
251
253
  super(options);
252
254
  this.configPagePath = options.configPagePath;
253
255
  this.supportDeployMode = options.supportDeployMode ?? 1 /* NORMAL */ | 16 /* OVERLAP */;
256
+ this.socialLinks = options.socialLinks;
254
257
  this.routes = options.routes ?? [];
255
258
  }
256
259
  static parseJSON(json) {
@@ -332,6 +335,21 @@ var WebSocketEvent = class {
332
335
  }
333
336
  };
334
337
 
338
+ // src/model/WidgetData.ts
339
+ var import_kebabCase = __toESM(require("lodash/kebabCase"), 1);
340
+
341
+ // src/model/WidgetTheme.ts
342
+ var DefaultWidgetTheme = {
343
+ backgroundColor: "rgba(0,0,0,0.2)",
344
+ color: "#fff",
345
+ fontSize: "14px",
346
+ borderColor: "rgba(255,255,255,0.4)",
347
+ dividerColor: "rgba(255,255,255,0.4)",
348
+ primaryColor: "rgb(0, 149, 255)",
349
+ borderRadius: "22px"
350
+ };
351
+ Object.freeze(DefaultWidgetTheme);
352
+
335
353
  // src/model/WidgetData.ts
336
354
  var WidgetData = class {
337
355
  /**
@@ -344,31 +362,66 @@ var WidgetData = class {
344
362
  name;
345
363
  /**
346
364
  * 背景颜色
365
+ * @deprecated
347
366
  */
348
367
  backgroundColor;
349
368
  /**
350
369
  * 文字颜色
370
+ * @deprecated
351
371
  */
352
372
  color;
353
373
  /**
354
374
  * 字体大小
375
+ * @deprecated
355
376
  */
356
377
  fontSize;
357
378
  /**
358
379
  * 字体
380
+ * @deprecated
359
381
  */
360
382
  fontFamily;
361
383
  /**
362
384
  * 圆角半径
385
+ * @deprecated
363
386
  */
364
387
  borderRadius;
388
+ /**
389
+ * 组件样式
390
+ */
391
+ theme;
365
392
  constructor(name, id) {
366
393
  this.id = id;
367
394
  this.name = name;
395
+ this.theme = JSON.parse(JSON.stringify(DefaultWidgetTheme));
368
396
  }
369
397
  parseJSON(json) {
370
398
  Object.assign(this, json);
371
399
  }
400
+ /**
401
+ * Gets the style properties from the widget's style object.
402
+ * @returns A record representing CSS custom properties and their values.
403
+ */
404
+ getThemeProperties() {
405
+ const properties = {};
406
+ if (this.theme) {
407
+ const prefix = "--widget-";
408
+ let keys = Object.keys(this.theme);
409
+ keys.filter((key) => this.theme[key] != void 0).map((key) => {
410
+ properties[`${prefix}${(0, import_kebabCase.default)(key)}`] = `${this.theme[key]}`;
411
+ });
412
+ }
413
+ return properties;
414
+ }
415
+ /**
416
+ * Injects the style properties as css variable.
417
+ * @remarks Only works in a browser environment.
418
+ */
419
+ injectThemeProperties() {
420
+ const properties = this.getThemeProperties();
421
+ Object.keys(properties).forEach((key) => {
422
+ document.documentElement.style.setProperty(key, properties[key].toString());
423
+ });
424
+ }
372
425
  };
373
426
 
374
427
  // src/router/encoding.ts
@@ -451,7 +504,7 @@ function stringifyQuery(query) {
451
504
  }
452
505
 
453
506
  // src/model/WidgetParams.ts
454
- var import_change_case = require("change-case");
507
+ var import_snakeCase = __toESM(require("lodash/snakeCase"), 1);
455
508
  var _WidgetParams = class {
456
509
  //组件id
457
510
  id;
@@ -490,7 +543,7 @@ var _WidgetParams = class {
490
543
  const key = ownPropertyName;
491
544
  const value = this[key];
492
545
  if (value) {
493
- urlParams.append(_WidgetParams.PARAM_PREFIX + (0, import_change_case.snakeCase)(ownPropertyName), value.toString());
546
+ urlParams.append(_WidgetParams.PARAM_PREFIX + (0, import_snakeCase.default)(ownPropertyName), value.toString());
494
547
  }
495
548
  }
496
549
  return urlParams;
@@ -1331,6 +1384,9 @@ var WidgetApiEvent = /* @__PURE__ */ ((WidgetApiEvent2) => {
1331
1384
  return WidgetApiEvent2;
1332
1385
  })(WidgetApiEvent || {});
1333
1386
  var WidgetApiImpl = class extends BaseApi {
1387
+ reload() {
1388
+ return this.invokeMethod("reload");
1389
+ }
1334
1390
  getChannel() {
1335
1391
  return "channel::cn.widgetjs.core.widget" /* WIDGET */;
1336
1392
  }
@@ -1978,6 +2034,9 @@ var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
1978
2034
  return AppApiConstants2;
1979
2035
  })(AppApiConstants || {});
1980
2036
  var AppApiImpl = class extends BaseApi {
2037
+ isWindowsStore() {
2038
+ return this.invokeMethod("isWindowsStore");
2039
+ }
1981
2040
  getAppPath() {
1982
2041
  return this.invokeMethod("getAppPath");
1983
2042
  }
@@ -2142,6 +2201,9 @@ var FileApiImpl = class extends BaseApi {
2142
2201
  async getInfo(absoluteFilePath) {
2143
2202
  return this.invokeMethod("getInfo", absoluteFilePath);
2144
2203
  }
2204
+ async showSystemFolder(absoluteFolderPath) {
2205
+ return this.invokeMethod("showSystemFolder", absoluteFolderPath);
2206
+ }
2145
2207
  };
2146
2208
  var FileApi = new FileApiImpl();
2147
2209
  // Annotate the CommonJS export names for ESM import in node:
@@ -2159,6 +2221,7 @@ var FileApi = new FileApiImpl();
2159
2221
  Channel,
2160
2222
  ClipboardApi,
2161
2223
  ClipboardApiEvent,
2224
+ DefaultWidgetTheme,
2162
2225
  DeployMode,
2163
2226
  DeployedPage,
2164
2227
  DeployedWidget,