@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.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as CSS from 'csstype';
|
|
1
2
|
import { Config, CPUUsage, IOCounters, BlinkMemoryInfo, HeapStatistics, ProcessMemoryInfo, SystemMemoryInfo } from 'electron';
|
|
2
3
|
import { FileTypeResult } from 'file-type';
|
|
3
4
|
import { FormatEnum, ColourspaceEnum, Channels, LevelMetadata } from 'sharp';
|
|
@@ -219,6 +220,12 @@ declare class Page implements IPage {
|
|
|
219
220
|
isResizable(): boolean;
|
|
220
221
|
}
|
|
221
222
|
|
|
223
|
+
type SocialType = 'qq' | 'wechat' | 'qq-group' | 'discord' | 'telegram' | 'tiktok' | 'douyin' | 'youtube' | 'instagram' | 'twitter' | 'facebook' | 'kuaishou' | 'bilibili' | 'github' | 'email' | 'gitee' | 'homepage';
|
|
224
|
+
interface SocialLink {
|
|
225
|
+
name: SocialType;
|
|
226
|
+
link: string;
|
|
227
|
+
}
|
|
228
|
+
|
|
222
229
|
interface IWidgetOptions extends IWindowSize, IPageOptions {
|
|
223
230
|
supportDeployMode?: DeployMode;
|
|
224
231
|
configPagePath?: string;
|
|
@@ -228,6 +235,10 @@ interface IWidgetOptions extends IWindowSize, IPageOptions {
|
|
|
228
235
|
/**
|
|
229
236
|
*/
|
|
230
237
|
routes?: WidgetRoute[];
|
|
238
|
+
/**
|
|
239
|
+
* 一般用于填写教程链接
|
|
240
|
+
*/
|
|
241
|
+
socialLinks?: SocialLink[];
|
|
231
242
|
}
|
|
232
243
|
/**
|
|
233
244
|
* @deprecated
|
|
@@ -247,6 +258,7 @@ declare class Widget extends Page {
|
|
|
247
258
|
* @deprecated
|
|
248
259
|
*/
|
|
249
260
|
readonly routes: WidgetRoute[];
|
|
261
|
+
readonly socialLinks?: SocialLink[];
|
|
250
262
|
constructor(options: IWidgetOptions);
|
|
251
263
|
static parseJSON(json: string): Widget;
|
|
252
264
|
static parseObject(obj: any): Widget;
|
|
@@ -301,6 +313,10 @@ interface WidgetPackageOptions extends LocalPackageUrlInfo {
|
|
|
301
313
|
title: LanguageTextMap;
|
|
302
314
|
permissions?: WidgetPermission[];
|
|
303
315
|
description: LanguageTextMap;
|
|
316
|
+
/**
|
|
317
|
+
* 远程组件包入口文件
|
|
318
|
+
* @deprecated 使用 remote.entry 替代
|
|
319
|
+
*/
|
|
304
320
|
remoteEntry?: string;
|
|
305
321
|
remotePackage?: string;
|
|
306
322
|
remote?: RemotePackageUrlInfo;
|
|
@@ -340,13 +356,18 @@ declare class WidgetPackage implements RemotePackageUrlInfo {
|
|
|
340
356
|
[key: LanguageCode | string]: string;
|
|
341
357
|
};
|
|
342
358
|
/**
|
|
343
|
-
*
|
|
359
|
+
* 本地组件入口文件,通常为 index.html
|
|
344
360
|
*/
|
|
345
361
|
entry: string | 'index.html';
|
|
346
362
|
/**
|
|
347
|
-
*
|
|
363
|
+
* 远程组件包入口文件
|
|
364
|
+
* @deprecated 使用 remote.entry 替代
|
|
348
365
|
*/
|
|
349
366
|
remoteEntry?: string;
|
|
367
|
+
/**
|
|
368
|
+
* 组件包json文件路径
|
|
369
|
+
* @example https://rtugeek.gitee.io/hotspot/widget.json
|
|
370
|
+
*/
|
|
350
371
|
readonly remotePackage?: string;
|
|
351
372
|
readonly local?: LocalPackageUrlInfo;
|
|
352
373
|
readonly remote?: RemotePackageUrlInfo;
|
|
@@ -478,6 +499,7 @@ interface IWidgetApi {
|
|
|
478
499
|
getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
479
500
|
openConfigPage(id: string): Promise<void>;
|
|
480
501
|
openConfigPageByName(name: string): Promise<void>;
|
|
502
|
+
reload(): Promise<void>;
|
|
481
503
|
getWidgetPackageUrl(packageName: string): Promise<string | null>;
|
|
482
504
|
}
|
|
483
505
|
type WidgetApiMethods = keyof IWidgetApi;
|
|
@@ -486,6 +508,7 @@ declare enum WidgetApiEvent {
|
|
|
486
508
|
EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit"
|
|
487
509
|
}
|
|
488
510
|
declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidgetApi {
|
|
511
|
+
reload(): Promise<void>;
|
|
489
512
|
getChannel(): string;
|
|
490
513
|
registerWidgets(widgets: Widget[]): Promise<any>;
|
|
491
514
|
registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
|
|
@@ -523,6 +546,10 @@ interface IAppApi {
|
|
|
523
546
|
openAddWidgetWindow(): Promise<void>;
|
|
524
547
|
openSettingWindow(): Promise<void>;
|
|
525
548
|
getIconFile(): Promise<string>;
|
|
549
|
+
/**
|
|
550
|
+
* 应用是否是从微软商店下载
|
|
551
|
+
*/
|
|
552
|
+
isWindowsStore(): Promise<boolean>;
|
|
526
553
|
}
|
|
527
554
|
type AppApiMethods = keyof IAppApi;
|
|
528
555
|
declare enum AppApiEvent {
|
|
@@ -563,6 +590,30 @@ declare class WebSocketEvent {
|
|
|
563
590
|
constructor(type: WebSocketEventType, payload: any);
|
|
564
591
|
}
|
|
565
592
|
|
|
593
|
+
interface WidgetTheme {
|
|
594
|
+
borderRadius?: CSS.Properties['borderRadius'];
|
|
595
|
+
backgroundColor?: CSS.Properties['color'];
|
|
596
|
+
fontSize?: CSS.Properties['fontSize'];
|
|
597
|
+
dividerColor?: CSS.Properties['color'];
|
|
598
|
+
/**
|
|
599
|
+
* 主色调
|
|
600
|
+
*/
|
|
601
|
+
primaryColor?: CSS.Properties['color'];
|
|
602
|
+
/**
|
|
603
|
+
* 文字颜色
|
|
604
|
+
*/
|
|
605
|
+
color?: CSS.Properties['color'];
|
|
606
|
+
fontFamily?: CSS.Properties['fontFamily'];
|
|
607
|
+
shadowColor?: CSS.Properties['color'];
|
|
608
|
+
padding?: CSS.Properties['padding'];
|
|
609
|
+
borderColor?: CSS.Properties['borderColor'];
|
|
610
|
+
}
|
|
611
|
+
type WidgetThemeKey = keyof WidgetTheme;
|
|
612
|
+
/**
|
|
613
|
+
* Widget default theme, this object is immutable. Clone it before use.
|
|
614
|
+
*/
|
|
615
|
+
declare const DefaultWidgetTheme: WidgetTheme;
|
|
616
|
+
|
|
566
617
|
/**
|
|
567
618
|
* 组件配置数据,用于存储组件自定义页面所设置的数据
|
|
568
619
|
*/
|
|
@@ -577,26 +628,45 @@ declare class WidgetData {
|
|
|
577
628
|
name: string;
|
|
578
629
|
/**
|
|
579
630
|
* 背景颜色
|
|
631
|
+
* @deprecated
|
|
580
632
|
*/
|
|
581
633
|
backgroundColor?: string;
|
|
582
634
|
/**
|
|
583
635
|
* 文字颜色
|
|
636
|
+
* @deprecated
|
|
584
637
|
*/
|
|
585
638
|
color?: string;
|
|
586
639
|
/**
|
|
587
640
|
* 字体大小
|
|
641
|
+
* @deprecated
|
|
588
642
|
*/
|
|
589
643
|
fontSize?: number;
|
|
590
644
|
/**
|
|
591
645
|
* 字体
|
|
646
|
+
* @deprecated
|
|
592
647
|
*/
|
|
593
648
|
fontFamily?: string;
|
|
594
649
|
/**
|
|
595
650
|
* 圆角半径
|
|
651
|
+
* @deprecated
|
|
596
652
|
*/
|
|
597
653
|
borderRadius?: number;
|
|
654
|
+
/**
|
|
655
|
+
* 组件样式
|
|
656
|
+
*/
|
|
657
|
+
theme: WidgetTheme;
|
|
598
658
|
constructor(name: string, id?: string);
|
|
599
659
|
parseJSON(json: {}): void;
|
|
660
|
+
/**
|
|
661
|
+
* Gets the style properties from the widget's style object.
|
|
662
|
+
* @returns A record representing CSS custom properties and their values.
|
|
663
|
+
*/
|
|
664
|
+
getThemeProperties(): Record<string, string>;
|
|
665
|
+
/**
|
|
666
|
+
* Injects the style properties as css variable.
|
|
667
|
+
* @remarks Only works in a browser environment.
|
|
668
|
+
*/
|
|
669
|
+
injectThemeProperties(): void;
|
|
600
670
|
}
|
|
601
671
|
|
|
602
672
|
type NotificationType = "countdown" | "advance-countdown" | "error" | "success" | "warning" | "info" | "reminder" | "url" | "call";
|
|
@@ -1606,7 +1676,7 @@ interface DownloadUrlOptions {
|
|
|
1606
1676
|
overwrite?: boolean;
|
|
1607
1677
|
}
|
|
1608
1678
|
interface IFileApi {
|
|
1609
|
-
readDirectory(path: string, options?: ReadDirOptions): Promise<SystemFile
|
|
1679
|
+
readDirectory(path: string, options?: ReadDirOptions): Promise<SystemFile>;
|
|
1610
1680
|
isDirectory(filePath: string): Promise<boolean>;
|
|
1611
1681
|
getMimeType(absoluteFilePath: string): Promise<FileTypeResult>;
|
|
1612
1682
|
downloadUrl(option: DownloadUrlOptions): Promise<string>;
|
|
@@ -1646,4 +1716,4 @@ interface IFileApi {
|
|
|
1646
1716
|
type FileApiMethods = keyof IFileApi;
|
|
1647
1717
|
declare const FileApi: IFileApi;
|
|
1648
1718
|
|
|
1649
|
-
export { AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, AppApiMethods, AppMouseEvent, AppNotification, BaseApi, BroadcastApi, BroadcastApiMethods, BroadcastEvent, BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, BrowserWindowApiMethods, Channel, ClipboardApi, ClipboardApiEvent, ClipboardApiMethods, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, DeployedWidgetApiMethods, DevOptions, DeviceApi, DeviceApiMethods, DialogApi, DialogApiMethods, DownloadUrlOptions, ElectronApi, ElectronUtils, FileApi, FileApiMethods, FileInfo, Gravity, GridRect, GridSystem, HostedMode, IGridRect, IPage, IPageOptions, IWidgetDataApi, IWidgetOptions, IWindowSize, LanguageCode, LanguageTextMap, LocalPackageUrlInfo, LocationQuery, LocationQueryRaw, LocationQueryValue, LocationQueryValueRaw, LogApi, LogApiMethods, MetaInfo, Metadata, NativeKeyboardEvent, NormalizeOptions, NotificationApi, NotificationApiEvent, NotificationApiMethods, NotificationOption, NotificationSize, NotificationType, OpenUrlOptions, Page, Point, Position, ProcessApi, ProcessApiMethods, ReadDirOptions, Rectangle, RemotePackageUrlInfo, SaveWidgetOption, SetPositionOptions, ShortcutApi, ShortcutApiEvent, ShortcutApiMethods, StoreApi, StoreApiMethods, SystemFile, ThemeMode, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, WidgetApiMethods, WidgetData, WidgetDataApi, WidgetDataApiMethods, WidgetKeyword, WidgetPackage, WidgetPackageOptions, WidgetParams, WidgetPermission, WidgetRoute, WidgetUrlUtils, getTextByLanguageCode, normalizeUrl, parseQuery, stringifyQuery };
|
|
1719
|
+
export { AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, AppApiMethods, AppMouseEvent, AppNotification, BaseApi, BroadcastApi, BroadcastApiMethods, BroadcastEvent, BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, BrowserWindowApiMethods, Channel, ClipboardApi, ClipboardApiEvent, ClipboardApiMethods, DefaultWidgetTheme, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, DeployedWidgetApiMethods, DevOptions, DeviceApi, DeviceApiMethods, DialogApi, DialogApiMethods, DownloadUrlOptions, ElectronApi, ElectronUtils, FileApi, FileApiMethods, FileInfo, Gravity, GridRect, GridSystem, HostedMode, IGridRect, IPage, IPageOptions, IWidgetDataApi, IWidgetOptions, IWindowSize, LanguageCode, LanguageTextMap, LocalPackageUrlInfo, LocationQuery, LocationQueryRaw, LocationQueryValue, LocationQueryValueRaw, LogApi, LogApiMethods, MetaInfo, Metadata, NativeKeyboardEvent, NormalizeOptions, NotificationApi, NotificationApiEvent, NotificationApiMethods, NotificationOption, NotificationSize, NotificationType, OpenUrlOptions, Page, Point, Position, ProcessApi, ProcessApiMethods, ReadDirOptions, Rectangle, RemotePackageUrlInfo, SaveWidgetOption, SetPositionOptions, ShortcutApi, ShortcutApiEvent, ShortcutApiMethods, StoreApi, StoreApiMethods, SystemFile, ThemeMode, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, WidgetApiMethods, WidgetData, WidgetDataApi, WidgetDataApiMethods, WidgetKeyword, WidgetPackage, WidgetPackageOptions, WidgetParams, WidgetPermission, WidgetRoute, WidgetTheme, WidgetThemeKey, WidgetUrlUtils, getTextByLanguageCode, normalizeUrl, parseQuery, stringifyQuery };
|
package/dist/index.js
CHANGED
|
@@ -163,10 +163,12 @@ var Widget = class extends Page {
|
|
|
163
163
|
* @deprecated
|
|
164
164
|
*/
|
|
165
165
|
routes;
|
|
166
|
+
socialLinks;
|
|
166
167
|
constructor(options) {
|
|
167
168
|
super(options);
|
|
168
169
|
this.configPagePath = options.configPagePath;
|
|
169
170
|
this.supportDeployMode = options.supportDeployMode ?? 1 /* NORMAL */ | 16 /* OVERLAP */;
|
|
171
|
+
this.socialLinks = options.socialLinks;
|
|
170
172
|
this.routes = options.routes ?? [];
|
|
171
173
|
}
|
|
172
174
|
static parseJSON(json) {
|
|
@@ -248,6 +250,21 @@ var WebSocketEvent = class {
|
|
|
248
250
|
}
|
|
249
251
|
};
|
|
250
252
|
|
|
253
|
+
// src/model/WidgetData.ts
|
|
254
|
+
import kebabCase from "lodash/kebabCase";
|
|
255
|
+
|
|
256
|
+
// src/model/WidgetTheme.ts
|
|
257
|
+
var DefaultWidgetTheme = {
|
|
258
|
+
backgroundColor: "rgba(0,0,0,0.2)",
|
|
259
|
+
color: "#fff",
|
|
260
|
+
fontSize: "14px",
|
|
261
|
+
borderColor: "rgba(255,255,255,0.4)",
|
|
262
|
+
dividerColor: "rgba(255,255,255,0.4)",
|
|
263
|
+
primaryColor: "rgb(0, 149, 255)",
|
|
264
|
+
borderRadius: "22px"
|
|
265
|
+
};
|
|
266
|
+
Object.freeze(DefaultWidgetTheme);
|
|
267
|
+
|
|
251
268
|
// src/model/WidgetData.ts
|
|
252
269
|
var WidgetData = class {
|
|
253
270
|
/**
|
|
@@ -260,31 +277,66 @@ var WidgetData = class {
|
|
|
260
277
|
name;
|
|
261
278
|
/**
|
|
262
279
|
* 背景颜色
|
|
280
|
+
* @deprecated
|
|
263
281
|
*/
|
|
264
282
|
backgroundColor;
|
|
265
283
|
/**
|
|
266
284
|
* 文字颜色
|
|
285
|
+
* @deprecated
|
|
267
286
|
*/
|
|
268
287
|
color;
|
|
269
288
|
/**
|
|
270
289
|
* 字体大小
|
|
290
|
+
* @deprecated
|
|
271
291
|
*/
|
|
272
292
|
fontSize;
|
|
273
293
|
/**
|
|
274
294
|
* 字体
|
|
295
|
+
* @deprecated
|
|
275
296
|
*/
|
|
276
297
|
fontFamily;
|
|
277
298
|
/**
|
|
278
299
|
* 圆角半径
|
|
300
|
+
* @deprecated
|
|
279
301
|
*/
|
|
280
302
|
borderRadius;
|
|
303
|
+
/**
|
|
304
|
+
* 组件样式
|
|
305
|
+
*/
|
|
306
|
+
theme;
|
|
281
307
|
constructor(name, id) {
|
|
282
308
|
this.id = id;
|
|
283
309
|
this.name = name;
|
|
310
|
+
this.theme = JSON.parse(JSON.stringify(DefaultWidgetTheme));
|
|
284
311
|
}
|
|
285
312
|
parseJSON(json) {
|
|
286
313
|
Object.assign(this, json);
|
|
287
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Gets the style properties from the widget's style object.
|
|
317
|
+
* @returns A record representing CSS custom properties and their values.
|
|
318
|
+
*/
|
|
319
|
+
getThemeProperties() {
|
|
320
|
+
const properties = {};
|
|
321
|
+
if (this.theme) {
|
|
322
|
+
const prefix = "--widget-";
|
|
323
|
+
let keys = Object.keys(this.theme);
|
|
324
|
+
keys.filter((key) => this.theme[key] != void 0).map((key) => {
|
|
325
|
+
properties[`${prefix}${kebabCase(key)}`] = `${this.theme[key]}`;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return properties;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Injects the style properties as css variable.
|
|
332
|
+
* @remarks Only works in a browser environment.
|
|
333
|
+
*/
|
|
334
|
+
injectThemeProperties() {
|
|
335
|
+
const properties = this.getThemeProperties();
|
|
336
|
+
Object.keys(properties).forEach((key) => {
|
|
337
|
+
document.documentElement.style.setProperty(key, properties[key].toString());
|
|
338
|
+
});
|
|
339
|
+
}
|
|
288
340
|
};
|
|
289
341
|
|
|
290
342
|
// src/router/encoding.ts
|
|
@@ -367,7 +419,7 @@ function stringifyQuery(query) {
|
|
|
367
419
|
}
|
|
368
420
|
|
|
369
421
|
// src/model/WidgetParams.ts
|
|
370
|
-
import
|
|
422
|
+
import snakeCase from "lodash/snakeCase";
|
|
371
423
|
var _WidgetParams = class {
|
|
372
424
|
//组件id
|
|
373
425
|
id;
|
|
@@ -860,13 +912,18 @@ var WidgetPackage = class {
|
|
|
860
912
|
*/
|
|
861
913
|
description;
|
|
862
914
|
/**
|
|
863
|
-
*
|
|
915
|
+
* 本地组件入口文件,通常为 index.html
|
|
864
916
|
*/
|
|
865
917
|
entry;
|
|
866
918
|
/**
|
|
867
|
-
*
|
|
919
|
+
* 远程组件包入口文件
|
|
920
|
+
* @deprecated 使用 remote.entry 替代
|
|
868
921
|
*/
|
|
869
922
|
remoteEntry;
|
|
923
|
+
/**
|
|
924
|
+
* 组件包json文件路径
|
|
925
|
+
* @example https://rtugeek.gitee.io/hotspot/widget.json
|
|
926
|
+
*/
|
|
870
927
|
remotePackage;
|
|
871
928
|
local;
|
|
872
929
|
remote;
|
|
@@ -1247,6 +1304,9 @@ var WidgetApiEvent = /* @__PURE__ */ ((WidgetApiEvent2) => {
|
|
|
1247
1304
|
return WidgetApiEvent2;
|
|
1248
1305
|
})(WidgetApiEvent || {});
|
|
1249
1306
|
var WidgetApiImpl = class extends BaseApi {
|
|
1307
|
+
reload() {
|
|
1308
|
+
return this.invokeMethod("reload");
|
|
1309
|
+
}
|
|
1250
1310
|
getChannel() {
|
|
1251
1311
|
return "channel::cn.widgetjs.core.widget" /* WIDGET */;
|
|
1252
1312
|
}
|
|
@@ -1894,6 +1954,9 @@ var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
|
|
|
1894
1954
|
return AppApiConstants2;
|
|
1895
1955
|
})(AppApiConstants || {});
|
|
1896
1956
|
var AppApiImpl = class extends BaseApi {
|
|
1957
|
+
isWindowsStore() {
|
|
1958
|
+
return this.invokeMethod("isWindowsStore");
|
|
1959
|
+
}
|
|
1897
1960
|
getAppPath() {
|
|
1898
1961
|
return this.invokeMethod("getAppPath");
|
|
1899
1962
|
}
|
|
@@ -2077,6 +2140,7 @@ export {
|
|
|
2077
2140
|
Channel,
|
|
2078
2141
|
ClipboardApi,
|
|
2079
2142
|
ClipboardApiEvent,
|
|
2143
|
+
DefaultWidgetTheme,
|
|
2080
2144
|
DeployMode,
|
|
2081
2145
|
DeployedPage,
|
|
2082
2146
|
DeployedWidget,
|