@widget-js/core 0.11.22-beta.2 → 24.1.1-beta.1

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.d.ts CHANGED
@@ -1,39 +1,7 @@
1
1
  import * as CSS from 'csstype';
2
- import { Config, CPUUsage, IOCounters, BlinkMemoryInfo, HeapStatistics, ProcessMemoryInfo, SystemMemoryInfo } from 'electron';
3
2
  import { FileTypeResult } from 'file-type';
4
3
  import { FormatEnum, ColourspaceEnum, Channels, LevelMetadata } from 'sharp';
5
4
 
6
- /**
7
- * @deprecated use DeployedMode instead
8
- */
9
- declare enum HostedMode {
10
- NORMAL = 1,
11
- /**
12
- * 悬浮窗
13
- */
14
- OVERLAP = 16,
15
- WALLPAPER = 256,
16
- SCREEN = 4096,
17
- /**
18
- * 后台组件,没有界面,一般在后台执行定时任务
19
- */
20
- BACKGROUND = 65536,
21
- /**
22
- * 页面
23
- */
24
- PAGE = 1048576,
25
- ALL = 1118481
26
- }
27
- declare enum DeployMode {
28
- NORMAL = 1,
29
- /**
30
- * 悬浮窗
31
- */
32
- OVERLAP = 16,
33
- BACKGROUND = 65536,
34
- ALL = 1118481
35
- }
36
-
37
5
  interface Language {
38
6
  locale: string;
39
7
  language: string;
@@ -74,11 +42,42 @@ type LanguageTextMap = {
74
42
  [key in LanguageCode]?: string;
75
43
  };
76
44
 
45
+ /**
46
+ * @deprecated use DeployedMode instead
47
+ */
48
+ declare enum HostedMode {
49
+ NORMAL = 1,
50
+ /**
51
+ * 悬浮窗
52
+ */
53
+ OVERLAP = 16,
54
+ WALLPAPER = 256,
55
+ SCREEN = 4096,
56
+ /**
57
+ * 后台组件,没有界面,一般在后台执行定时任务
58
+ */
59
+ BACKGROUND = 65536,
60
+ /**
61
+ * 页面
62
+ */
63
+ PAGE = 1048576,
64
+ ALL = 1118481
65
+ }
66
+ declare enum DeployMode {
67
+ NORMAL = 1,
68
+ /**
69
+ * 悬浮窗
70
+ */
71
+ OVERLAP = 16,
72
+ BACKGROUND = 65536,
73
+ ALL = 1118481
74
+ }
75
+
77
76
  type WidgetPermission = 'keyboard' | 'mouse' | 'clipboard' | 'notification' | 'storage' | 'network' | 'cpu' | 'system-info';
78
77
 
79
- type MetaInfo = {
78
+ interface MetaInfo {
80
79
  [key: string]: string | number | boolean;
81
- };
80
+ }
82
81
  interface IWindowSize {
83
82
  width: number;
84
83
  height: number;
@@ -413,12 +412,12 @@ declare class WidgetPackage implements RemotePackageUrlInfo {
413
412
  getIndexUrl(hash?: boolean): string;
414
413
  getUrl(path: string, hash?: boolean): string;
415
414
  }
416
- type DevOptions = {
415
+ interface DevOptions {
417
416
  folder?: string;
418
417
  route?: boolean;
419
418
  devUrl?: string;
420
419
  remoteEntry?: string;
421
- };
420
+ }
422
421
 
423
422
  declare class WidgetParams {
424
423
  static readonly PARAM_PREFIX = "w_";
@@ -540,7 +539,7 @@ declare const WidgetApi: WidgetApiImpl;
540
539
  interface IAppApi {
541
540
  setConfig(key: string, value: string | number | boolean): Promise<any>;
542
541
  getConfig(key: string, defaultValue: string | number | boolean): Promise<string | number | boolean>;
543
- getVersion(): Promise<string>;
542
+ getVersion(type?: 'app' | 'electron' | 'chrome' | 'node' | 'v8'): Promise<string>;
544
543
  getPreloadPath(): Promise<string>;
545
544
  getAppPath(): Promise<string>;
546
545
  openAddWidgetWindow(): Promise<void>;
@@ -669,7 +668,7 @@ declare class WidgetData {
669
668
  injectThemeProperties(): void;
670
669
  }
671
670
 
672
- type NotificationType = "countdown" | "advance-countdown" | "error" | "success" | "warning" | "info" | "reminder" | "url" | "call";
671
+ type NotificationType = 'countdown' | 'advance-countdown' | 'error' | 'success' | 'warning' | 'info' | 'reminder' | 'url' | 'call';
673
672
  declare enum NotificationSize {
674
673
  SMALL = "small",
675
674
  NORMAL = "normal",
@@ -770,10 +769,10 @@ interface Point {
770
769
  x: number;
771
770
  y: number;
772
771
  }
773
- type Position = {
772
+ interface Position {
774
773
  x: number;
775
774
  y: number;
776
- };
775
+ }
777
776
  declare enum Gravity {
778
777
  TOP = "TOP",
779
778
  LEFT = "LEFT",
@@ -881,21 +880,21 @@ declare function parseQuery(search: string): LocationQuery;
881
880
  */
882
881
  declare function stringifyQuery(query: LocationQueryRaw): string;
883
882
 
884
- type NormalizeOptions = {
883
+ interface NormalizeOptions {
885
884
  /**
886
885
  @default 'http'
887
886
  */
888
887
  defaultProtocol?: string | 'http' | 'https';
889
888
  /**
890
889
  Prepends `defaultProtocol` to the URL if it's protocol-relative.
891
-
890
+
892
891
  @default true
893
-
892
+
894
893
  @example
895
894
  ```
896
895
  normalizeUrl('//sindresorhus.com');
897
896
  //=> 'http://sindresorhus.com'
898
-
897
+
899
898
  normalizeUrl('//sindresorhus.com', {normalizeProtocol: false});
900
899
  //=> '//sindresorhus.com'
901
900
  ```
@@ -903,14 +902,14 @@ type NormalizeOptions = {
903
902
  readonly normalizeProtocol?: boolean;
904
903
  /**
905
904
  Normalizes HTTPS URLs to HTTP.
906
-
905
+
907
906
  @default false
908
-
907
+
909
908
  @example
910
909
  ```
911
910
  normalizeUrl('https://sindresorhus.com');
912
911
  //=> 'https://sindresorhus.com'
913
-
912
+
914
913
  normalizeUrl('https://sindresorhus.com', {forceHttp: true});
915
914
  //=> 'http://sindresorhus.com'
916
915
  ```
@@ -918,16 +917,16 @@ type NormalizeOptions = {
918
917
  readonly forceHttp?: boolean;
919
918
  /**
920
919
  Normalizes HTTP URLs to HTTPS.
921
-
920
+
922
921
  This option cannot be used with the `forceHttp` option at the same time.
923
-
922
+
924
923
  @default false
925
-
924
+
926
925
  @example
927
926
  ```
928
927
  normalizeUrl('http://sindresorhus.com');
929
928
  //=> 'http://sindresorhus.com'
930
-
929
+
931
930
  normalizeUrl('http://sindresorhus.com', {forceHttps: true});
932
931
  //=> 'https://sindresorhus.com'
933
932
  ```
@@ -935,14 +934,14 @@ type NormalizeOptions = {
935
934
  readonly forceHttps?: boolean;
936
935
  /**
937
936
  Strip the [authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) part of a URL.
938
-
937
+
939
938
  @default true
940
-
939
+
941
940
  @example
942
941
  ```
943
942
  normalizeUrl('https://user:password@sindresorhus.com');
944
943
  //=> 'https://sindresorhus.com'
945
-
944
+
946
945
  normalizeUrl('https://user:password@sindresorhus.com', {stripAuthentication: false});
947
946
  //=> 'https://user:password@sindresorhus.com'
948
947
  ```
@@ -950,14 +949,14 @@ type NormalizeOptions = {
950
949
  readonly stripAuthentication?: boolean;
951
950
  /**
952
951
  Removes hash from the URL.
953
-
952
+
954
953
  @default false
955
-
954
+
956
955
  @example
957
956
  ```
958
957
  normalizeUrl('sindresorhus.com/about.html#contact');
959
958
  //=> 'http://sindresorhus.com/about.html#contact'
960
-
959
+
961
960
  normalizeUrl('sindresorhus.com/about.html#contact', {stripHash: true});
962
961
  //=> 'http://sindresorhus.com/about.html'
963
962
  ```
@@ -965,16 +964,16 @@ type NormalizeOptions = {
965
964
  readonly stripHash?: boolean;
966
965
  /**
967
966
  Remove the protocol from the URL: `http://sindresorhus.com` → `sindresorhus.com`.
968
-
967
+
969
968
  It will only remove `https://` and `http://` protocols.
970
-
969
+
971
970
  @default false
972
-
971
+
973
972
  @example
974
973
  ```
975
974
  normalizeUrl('https://sindresorhus.com');
976
975
  //=> 'https://sindresorhus.com'
977
-
976
+
978
977
  normalizeUrl('sindresorhus.com', {stripProtocol: true});
979
978
  //=> 'sindresorhus.com'
980
979
  ```
@@ -982,22 +981,22 @@ type NormalizeOptions = {
982
981
  readonly stripProtocol?: boolean;
983
982
  /**
984
983
  Strip the [text fragment](https://web.dev/text-fragments/) part of the URL
985
-
984
+
986
985
  __Note:__ The text fragment will always be removed if the `stripHash` option is set to `true`, as the hash contains the text fragment.
987
-
986
+
988
987
  @default true
989
-
988
+
990
989
  @example
991
990
  ```
992
991
  normalizeUrl('http://sindresorhus.com/about.html#:~:text=hello');
993
992
  //=> 'http://sindresorhus.com/about.html#'
994
-
993
+
995
994
  normalizeUrl('http://sindresorhus.com/about.html#section:~:text=hello');
996
995
  //=> 'http://sindresorhus.com/about.html#section'
997
-
996
+
998
997
  normalizeUrl('http://sindresorhus.com/about.html#:~:text=hello', {stripTextFragment: false});
999
998
  //=> 'http://sindresorhus.com/about.html#:~:text=hello'
1000
-
999
+
1001
1000
  normalizeUrl('http://sindresorhus.com/about.html#section:~:text=hello', {stripTextFragment: false});
1002
1001
  //=> 'http://sindresorhus.com/about.html#section:~:text=hello'
1003
1002
  ```
@@ -1005,14 +1004,14 @@ type NormalizeOptions = {
1005
1004
  readonly stripTextFragment?: boolean;
1006
1005
  /**
1007
1006
  Removes `www.` from the URL.
1008
-
1007
+
1009
1008
  @default true
1010
-
1009
+
1011
1010
  @example
1012
1011
  ```
1013
1012
  normalizeUrl('http://www.sindresorhus.com');
1014
1013
  //=> 'http://sindresorhus.com'
1015
-
1014
+
1016
1015
  normalizeUrl('http://www.sindresorhus.com', {stripWWW: false});
1017
1016
  //=> 'http://www.sindresorhus.com'
1018
1017
  ```
@@ -1020,9 +1019,9 @@ type NormalizeOptions = {
1020
1019
  readonly stripWWW?: boolean;
1021
1020
  /**
1022
1021
  Removes query parameters that matches any of the provided strings or regexes.
1023
-
1022
+
1024
1023
  @default [/^utm_\w+/i]
1025
-
1024
+
1026
1025
  @example
1027
1026
  ```
1028
1027
  normalizeUrl('www.sindresorhus.com?foo=bar&ref=test_ref', {
@@ -1030,18 +1029,18 @@ type NormalizeOptions = {
1030
1029
  });
1031
1030
  //=> 'http://sindresorhus.com/?foo=bar'
1032
1031
  ```
1033
-
1032
+
1034
1033
  If a boolean is provided, `true` will remove all the query parameters.
1035
-
1034
+
1036
1035
  ```
1037
1036
  normalizeUrl('www.sindresorhus.com?foo=bar', {
1038
1037
  removeQueryParameters: true
1039
1038
  });
1040
1039
  //=> 'http://sindresorhus.com'
1041
1040
  ```
1042
-
1041
+
1043
1042
  `false` will not remove any query parameter.
1044
-
1043
+
1045
1044
  ```
1046
1045
  normalizeUrl('www.sindresorhus.com?foo=bar&utm_medium=test&ref=test_ref', {
1047
1046
  removeQueryParameters: false
@@ -1052,11 +1051,11 @@ type NormalizeOptions = {
1052
1051
  readonly removeQueryParameters?: ReadonlyArray<RegExp | string> | boolean;
1053
1052
  /**
1054
1053
  Keeps only query parameters that matches any of the provided strings or regexes.
1055
-
1054
+
1056
1055
  __Note__: It overrides the `removeQueryParameters` option.
1057
-
1056
+
1058
1057
  @default undefined
1059
-
1058
+
1060
1059
  @example
1061
1060
  ```
1062
1061
  normalizeUrl('https://sindresorhus.com?foo=bar&ref=unicorn', {
@@ -1068,19 +1067,19 @@ type NormalizeOptions = {
1068
1067
  readonly keepQueryParameters?: ReadonlyArray<RegExp | string>;
1069
1068
  /**
1070
1069
  Removes trailing slash.
1071
-
1070
+
1072
1071
  __Note__: Trailing slash is always removed if the URL doesn't have a pathname unless the `removeSingleSlash` option is set to `false`.
1073
-
1072
+
1074
1073
  @default true
1075
-
1074
+
1076
1075
  @example
1077
1076
  ```
1078
1077
  normalizeUrl('http://sindresorhus.com/redirect/');
1079
1078
  //=> 'http://sindresorhus.com/redirect'
1080
-
1079
+
1081
1080
  normalizeUrl('http://sindresorhus.com/redirect/', {removeTrailingSlash: false});
1082
1081
  //=> 'http://sindresorhus.com/redirect/'
1083
-
1082
+
1084
1083
  normalizeUrl('http://sindresorhus.com/', {removeTrailingSlash: false});
1085
1084
  //=> 'http://sindresorhus.com'
1086
1085
  ```
@@ -1088,14 +1087,14 @@ type NormalizeOptions = {
1088
1087
  readonly removeTrailingSlash?: boolean;
1089
1088
  /**
1090
1089
  Remove a sole `/` pathname in the output. This option is independent of `removeTrailingSlash`.
1091
-
1090
+
1092
1091
  @default true
1093
-
1092
+
1094
1093
  @example
1095
1094
  ```
1096
1095
  normalizeUrl('https://sindresorhus.com/');
1097
1096
  //=> 'https://sindresorhus.com'
1098
-
1097
+
1099
1098
  normalizeUrl('https://sindresorhus.com/', {removeSingleSlash: false});
1100
1099
  //=> 'https://sindresorhus.com/'
1101
1100
  ```
@@ -1104,9 +1103,9 @@ type NormalizeOptions = {
1104
1103
  /**
1105
1104
  Removes the default directory index file from path that matches any of the provided strings or regexes.
1106
1105
  When `true`, the regex `/^index\.[a-z]+$/` is used.
1107
-
1106
+
1108
1107
  @default false
1109
-
1108
+
1110
1109
  @example
1111
1110
  ```
1112
1111
  normalizeUrl('www.sindresorhus.com/foo/default.php', {
@@ -1118,11 +1117,11 @@ type NormalizeOptions = {
1118
1117
  removeDirectoryIndex?: boolean | ReadonlyArray<RegExp | string>;
1119
1118
  /**
1120
1119
  Removes an explicit port number from the URL.
1121
-
1120
+
1122
1121
  Port 443 is always removed from HTTPS URLs and 80 is always removed from HTTP URLs regardless of this option.
1123
-
1122
+
1124
1123
  @default false
1125
-
1124
+
1126
1125
  @example
1127
1126
  ```
1128
1127
  normalizeUrl('sindresorhus.com:123', {
@@ -1134,9 +1133,9 @@ type NormalizeOptions = {
1134
1133
  readonly removeExplicitPort?: boolean;
1135
1134
  /**
1136
1135
  Sorts the query parameters alphabetically by key.
1137
-
1136
+
1138
1137
  @default true
1139
-
1138
+
1140
1139
  @example
1141
1140
  ```
1142
1141
  normalizeUrl('www.sindresorhus.com?b=two&a=one&c=three', {
@@ -1146,7 +1145,7 @@ type NormalizeOptions = {
1146
1145
  ```
1147
1146
  */
1148
1147
  readonly sortQueryParameters?: boolean;
1149
- };
1148
+ }
1150
1149
  declare function normalizeUrl(urlString: string, options?: NormalizeOptions): string;
1151
1150
 
1152
1151
  interface IGridRect {
@@ -1231,8 +1230,8 @@ declare class GridSystem extends GridRect {
1231
1230
  }
1232
1231
 
1233
1232
  declare class ElectronApi {
1234
- static addIpcListener(key: String, f: Function): Promise<void>;
1235
- static removeIpcListener(key: String): Promise<void>;
1233
+ static addIpcListener(key: string, f: Function): Promise<void>;
1234
+ static removeIpcListener(key: string): Promise<void>;
1236
1235
  }
1237
1236
 
1238
1237
  interface SaveWidgetOption {
@@ -1301,7 +1300,7 @@ interface IBrowserWindowApi {
1301
1300
  setMinimumSize(width: number, height: number): Promise<void>;
1302
1301
  setZoomLevel(level: number): Promise<void>;
1303
1302
  setZoomFactor(factor: number): Promise<void>;
1304
- setProxy(config: Config): Promise<void>;
1303
+ setProxy(config: Electron.Config): Promise<void>;
1305
1304
  isFocused(): Promise<boolean>;
1306
1305
  }
1307
1306
  type BrowserWindowApiMethods = keyof IBrowserWindowApi;
@@ -1387,7 +1386,7 @@ declare class BrowserWindowApiImpl extends BaseApi<BrowserWindowApiMethods> impl
1387
1386
  close(): Promise<void>;
1388
1387
  setZoomFactor(factor: number): Promise<void>;
1389
1388
  setup(options: SetupOptions): Promise<void>;
1390
- setProxy(config: Config): Promise<void>;
1389
+ setProxy(config: Electron.Config): Promise<void>;
1391
1390
  }
1392
1391
  declare const BrowserWindowApi: BrowserWindowApiImpl;
1393
1392
 
@@ -1549,18 +1548,18 @@ type BroadcastApiMethods = keyof IBroadcastApi;
1549
1548
  declare const BroadcastApi: IBroadcastApi;
1550
1549
 
1551
1550
  interface IProcessApi {
1552
- getCPUUsage(): Promise<CPUUsage>;
1553
- getIOCounters(): Promise<IOCounters>;
1554
- getBlinkMemoryInfo(): Promise<BlinkMemoryInfo>;
1555
- getHeapStatistics(): Promise<HeapStatistics>;
1551
+ getCPUUsage(): Promise<Electron.CPUUsage>;
1552
+ getIOCounters(): Promise<Electron.IOCounters>;
1553
+ getBlinkMemoryInfo(): Promise<Electron.BlinkMemoryInfo>;
1554
+ getHeapStatistics(): Promise<Electron.HeapStatistics>;
1556
1555
  /**
1557
1556
  * // On macOS -> '10.13.6'
1558
1557
  * // On Windows -> '10.0.17763'
1559
1558
  * // On Linux -> '4.15.0-45-generic'
1560
1559
  */
1561
1560
  getSystemVersion(): Promise<string>;
1562
- getProcessMemoryInfo(): Promise<ProcessMemoryInfo>;
1563
- getSystemMemoryInfo(): Promise<SystemMemoryInfo>;
1561
+ getProcessMemoryInfo(): Promise<Electron.ProcessMemoryInfo>;
1562
+ getSystemMemoryInfo(): Promise<Electron.SystemMemoryInfo>;
1564
1563
  }
1565
1564
  type ProcessApiMethods = keyof IProcessApi;
1566
1565
  declare const ProcessApi: IProcessApi;
@@ -1725,4 +1724,8 @@ interface IFileApi {
1725
1724
  type FileApiMethods = keyof IFileApi;
1726
1725
  declare const FileApi: IFileApi;
1727
1726
 
1728
- 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 };
1727
+ declare enum SystemApiEvent {
1728
+ DATE_CHANGED = "event::cn.widgetjs.core.sys.date.changed"
1729
+ }
1730
+
1731
+ 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, SystemApiEvent, SystemFile, ThemeMode, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, WidgetApiMethods, WidgetData, WidgetDataApi, WidgetDataApiMethods, WidgetKeyword, WidgetPackage, WidgetPackageOptions, WidgetParams, WidgetPermission, WidgetRoute, WidgetTheme, WidgetThemeKey, WidgetUrlUtils, getTextByLanguageCode, normalizeUrl, parseQuery, stringifyQuery };