@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 +65 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +67 -1
- package/dist/index.js +63 -1
- 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;
|
|
@@ -478,6 +490,7 @@ interface IWidgetApi {
|
|
|
478
490
|
getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
479
491
|
openConfigPage(id: string): Promise<void>;
|
|
480
492
|
openConfigPageByName(name: string): Promise<void>;
|
|
493
|
+
reload(): Promise<void>;
|
|
481
494
|
getWidgetPackageUrl(packageName: string): Promise<string | null>;
|
|
482
495
|
}
|
|
483
496
|
type WidgetApiMethods = keyof IWidgetApi;
|
|
@@ -486,6 +499,7 @@ declare enum WidgetApiEvent {
|
|
|
486
499
|
EDIT_DESKTOP_WIDGETS = "event::cn.widgetjs.core.widget.desktop.edit"
|
|
487
500
|
}
|
|
488
501
|
declare class WidgetApiImpl extends BaseApi<WidgetApiMethods> implements IWidgetApi {
|
|
502
|
+
reload(): Promise<void>;
|
|
489
503
|
getChannel(): string;
|
|
490
504
|
registerWidgets(widgets: Widget[]): Promise<any>;
|
|
491
505
|
registerWidgetPackage(widgetPackage: WidgetPackage): Promise<any>;
|
|
@@ -523,6 +537,10 @@ interface IAppApi {
|
|
|
523
537
|
openAddWidgetWindow(): Promise<void>;
|
|
524
538
|
openSettingWindow(): Promise<void>;
|
|
525
539
|
getIconFile(): Promise<string>;
|
|
540
|
+
/**
|
|
541
|
+
* 应用是否是从微软商店下载
|
|
542
|
+
*/
|
|
543
|
+
isWindowsStore(): Promise<boolean>;
|
|
526
544
|
}
|
|
527
545
|
type AppApiMethods = keyof IAppApi;
|
|
528
546
|
declare enum AppApiEvent {
|
|
@@ -563,6 +581,30 @@ declare class WebSocketEvent {
|
|
|
563
581
|
constructor(type: WebSocketEventType, payload: any);
|
|
564
582
|
}
|
|
565
583
|
|
|
584
|
+
interface WidgetTheme {
|
|
585
|
+
borderRadius?: CSS.Properties['borderRadius'];
|
|
586
|
+
backgroundColor?: CSS.Properties['color'];
|
|
587
|
+
fontSize?: CSS.Properties['fontSize'];
|
|
588
|
+
dividerColor?: CSS.Properties['color'];
|
|
589
|
+
/**
|
|
590
|
+
* 主色调
|
|
591
|
+
*/
|
|
592
|
+
primaryColor?: CSS.Properties['color'];
|
|
593
|
+
/**
|
|
594
|
+
* 文字颜色
|
|
595
|
+
*/
|
|
596
|
+
color?: CSS.Properties['color'];
|
|
597
|
+
fontFamily?: CSS.Properties['fontFamily'];
|
|
598
|
+
shadowColor?: CSS.Properties['color'];
|
|
599
|
+
padding?: CSS.Properties['padding'];
|
|
600
|
+
borderColor?: CSS.Properties['borderColor'];
|
|
601
|
+
}
|
|
602
|
+
type WidgetThemeKey = keyof WidgetTheme;
|
|
603
|
+
/**
|
|
604
|
+
* Widget default theme, this object is immutable. Clone it before use.
|
|
605
|
+
*/
|
|
606
|
+
declare const DefaultWidgetTheme: WidgetTheme;
|
|
607
|
+
|
|
566
608
|
/**
|
|
567
609
|
* 组件配置数据,用于存储组件自定义页面所设置的数据
|
|
568
610
|
*/
|
|
@@ -577,26 +619,45 @@ declare class WidgetData {
|
|
|
577
619
|
name: string;
|
|
578
620
|
/**
|
|
579
621
|
* 背景颜色
|
|
622
|
+
* @deprecated
|
|
580
623
|
*/
|
|
581
624
|
backgroundColor?: string;
|
|
582
625
|
/**
|
|
583
626
|
* 文字颜色
|
|
627
|
+
* @deprecated
|
|
584
628
|
*/
|
|
585
629
|
color?: string;
|
|
586
630
|
/**
|
|
587
631
|
* 字体大小
|
|
632
|
+
* @deprecated
|
|
588
633
|
*/
|
|
589
634
|
fontSize?: number;
|
|
590
635
|
/**
|
|
591
636
|
* 字体
|
|
637
|
+
* @deprecated
|
|
592
638
|
*/
|
|
593
639
|
fontFamily?: string;
|
|
594
640
|
/**
|
|
595
641
|
* 圆角半径
|
|
642
|
+
* @deprecated
|
|
596
643
|
*/
|
|
597
644
|
borderRadius?: number;
|
|
645
|
+
/**
|
|
646
|
+
* 组件样式
|
|
647
|
+
*/
|
|
648
|
+
theme: WidgetTheme;
|
|
598
649
|
constructor(name: string, id?: string);
|
|
599
650
|
parseJSON(json: {}): void;
|
|
651
|
+
/**
|
|
652
|
+
* Gets the style properties from the widget's style object.
|
|
653
|
+
* @returns A record representing CSS custom properties and their values.
|
|
654
|
+
*/
|
|
655
|
+
getThemeProperties(): Record<string, string>;
|
|
656
|
+
/**
|
|
657
|
+
* Injects the style properties as css variable.
|
|
658
|
+
* @remarks Only works in a browser environment.
|
|
659
|
+
*/
|
|
660
|
+
injectThemeProperties(): void;
|
|
600
661
|
}
|
|
601
662
|
|
|
602
663
|
type NotificationType = "countdown" | "advance-countdown" | "error" | "success" | "warning" | "info" | "reminder" | "url" | "call";
|
|
@@ -1613,6 +1674,11 @@ interface IFileApi {
|
|
|
1613
1674
|
exists(filePath: string): Promise<boolean>;
|
|
1614
1675
|
delete(filePath: string): Promise<boolean>;
|
|
1615
1676
|
getInfo(absoluteFilePath: string): Promise<FileInfo>;
|
|
1677
|
+
/**
|
|
1678
|
+
* 显示系统文件夹
|
|
1679
|
+
* @param absoluteFolderPath
|
|
1680
|
+
*/
|
|
1681
|
+
showSystemFolder(absoluteFolderPath: string): void;
|
|
1616
1682
|
/**
|
|
1617
1683
|
* @param childPath
|
|
1618
1684
|
* @example childPath = "/images/" will return "C:/Users/username/Documents/widgets/com/exmaple/widget/images"
|
|
@@ -1641,4 +1707,4 @@ interface IFileApi {
|
|
|
1641
1707
|
type FileApiMethods = keyof IFileApi;
|
|
1642
1708
|
declare const FileApi: IFileApi;
|
|
1643
1709
|
|
|
1644
|
-
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 };
|
|
1710
|
+
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;
|
|
@@ -1247,6 +1299,9 @@ var WidgetApiEvent = /* @__PURE__ */ ((WidgetApiEvent2) => {
|
|
|
1247
1299
|
return WidgetApiEvent2;
|
|
1248
1300
|
})(WidgetApiEvent || {});
|
|
1249
1301
|
var WidgetApiImpl = class extends BaseApi {
|
|
1302
|
+
reload() {
|
|
1303
|
+
return this.invokeMethod("reload");
|
|
1304
|
+
}
|
|
1250
1305
|
getChannel() {
|
|
1251
1306
|
return "channel::cn.widgetjs.core.widget" /* WIDGET */;
|
|
1252
1307
|
}
|
|
@@ -1894,6 +1949,9 @@ var AppApiConstants = /* @__PURE__ */ ((AppApiConstants2) => {
|
|
|
1894
1949
|
return AppApiConstants2;
|
|
1895
1950
|
})(AppApiConstants || {});
|
|
1896
1951
|
var AppApiImpl = class extends BaseApi {
|
|
1952
|
+
isWindowsStore() {
|
|
1953
|
+
return this.invokeMethod("isWindowsStore");
|
|
1954
|
+
}
|
|
1897
1955
|
getAppPath() {
|
|
1898
1956
|
return this.invokeMethod("getAppPath");
|
|
1899
1957
|
}
|
|
@@ -2058,6 +2116,9 @@ var FileApiImpl = class extends BaseApi {
|
|
|
2058
2116
|
async getInfo(absoluteFilePath) {
|
|
2059
2117
|
return this.invokeMethod("getInfo", absoluteFilePath);
|
|
2060
2118
|
}
|
|
2119
|
+
async showSystemFolder(absoluteFolderPath) {
|
|
2120
|
+
return this.invokeMethod("showSystemFolder", absoluteFolderPath);
|
|
2121
|
+
}
|
|
2061
2122
|
};
|
|
2062
2123
|
var FileApi = new FileApiImpl();
|
|
2063
2124
|
export {
|
|
@@ -2074,6 +2135,7 @@ export {
|
|
|
2074
2135
|
Channel,
|
|
2075
2136
|
ClipboardApi,
|
|
2076
2137
|
ClipboardApiEvent,
|
|
2138
|
+
DefaultWidgetTheme,
|
|
2077
2139
|
DeployMode,
|
|
2078
2140
|
DeployedPage,
|
|
2079
2141
|
DeployedWidget,
|