@widget-js/core 0.11.15 → 0.11.21
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 +69 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +74 -4
- package/dist/index.js +67 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
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
|
|
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,
|
|
546
|
+
urlParams.append(_WidgetParams.PARAM_PREFIX + (0, import_snakeCase.default)(ownPropertyName), value.toString());
|
|
494
547
|
}
|
|
495
548
|
}
|
|
496
549
|
return urlParams;
|
|
@@ -944,13 +997,18 @@ var WidgetPackage = class {
|
|
|
944
997
|
*/
|
|
945
998
|
description;
|
|
946
999
|
/**
|
|
947
|
-
*
|
|
1000
|
+
* 本地组件入口文件,通常为 index.html
|
|
948
1001
|
*/
|
|
949
1002
|
entry;
|
|
950
1003
|
/**
|
|
951
|
-
*
|
|
1004
|
+
* 远程组件包入口文件
|
|
1005
|
+
* @deprecated 使用 remote.entry 替代
|
|
952
1006
|
*/
|
|
953
1007
|
remoteEntry;
|
|
1008
|
+
/**
|
|
1009
|
+
* 组件包json文件路径
|
|
1010
|
+
* @example https://rtugeek.gitee.io/hotspot/widget.json
|
|
1011
|
+
*/
|
|
954
1012
|
remotePackage;
|
|
955
1013
|
local;
|
|
956
1014
|
remote;
|
|
@@ -1331,6 +1389,9 @@ var WidgetApiEvent = /* @__PURE__ */ ((WidgetApiEvent2) => {
|
|
|
1331
1389
|
return WidgetApiEvent2;
|
|
1332
1390
|
})(WidgetApiEvent || {});
|
|
1333
1391
|
var WidgetApiImpl = class extends BaseApi {
|
|
1392
|
+
reload() {
|
|
1393
|
+
return this.invokeMethod("reload");
|
|
1394
|
+
}
|
|
1334
1395
|
getChannel() {
|
|
1335
1396
|
return "channel::cn.widgetjs.core.widget" /* WIDGET */;
|
|
1336
1397
|
}
|
|
@@ -1978,6 +2039,9 @@ var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
|
|
|
1978
2039
|
return AppApiConstants2;
|
|
1979
2040
|
})(AppApiConstants || {});
|
|
1980
2041
|
var AppApiImpl = class extends BaseApi {
|
|
2042
|
+
isWindowsStore() {
|
|
2043
|
+
return this.invokeMethod("isWindowsStore");
|
|
2044
|
+
}
|
|
1981
2045
|
getAppPath() {
|
|
1982
2046
|
return this.invokeMethod("getAppPath");
|
|
1983
2047
|
}
|
|
@@ -2162,6 +2226,7 @@ var FileApi = new FileApiImpl();
|
|
|
2162
2226
|
Channel,
|
|
2163
2227
|
ClipboardApi,
|
|
2164
2228
|
ClipboardApiEvent,
|
|
2229
|
+
DefaultWidgetTheme,
|
|
2165
2230
|
DeployMode,
|
|
2166
2231
|
DeployedPage,
|
|
2167
2232
|
DeployedWidget,
|