@talex-touch/utils 1.0.13 → 1.0.15

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.
Files changed (41) hide show
  1. package/base/index.ts +181 -181
  2. package/channel/index.ts +108 -99
  3. package/common/index.ts +2 -39
  4. package/common/storage/constants.ts +3 -0
  5. package/common/storage/entity/app-settings.ts +47 -0
  6. package/common/storage/entity/index.ts +1 -0
  7. package/common/storage/index.ts +3 -0
  8. package/common/utils.ts +160 -0
  9. package/core-box/README.md +218 -0
  10. package/core-box/index.ts +7 -0
  11. package/core-box/search.ts +536 -0
  12. package/core-box/types.ts +384 -0
  13. package/electron/download-manager.ts +118 -0
  14. package/{common → electron}/env-tool.ts +56 -56
  15. package/electron/touch-core.ts +167 -0
  16. package/electron/window.ts +71 -0
  17. package/eventbus/index.ts +86 -87
  18. package/index.ts +5 -0
  19. package/package.json +55 -30
  20. package/permission/index.ts +48 -48
  21. package/plugin/channel.ts +203 -193
  22. package/plugin/index.ts +216 -121
  23. package/plugin/log/logger-manager.ts +60 -0
  24. package/plugin/log/logger.ts +75 -0
  25. package/plugin/log/types.ts +27 -0
  26. package/plugin/preload.ts +39 -39
  27. package/plugin/sdk/common.ts +27 -27
  28. package/plugin/sdk/hooks/life-cycle.ts +95 -95
  29. package/plugin/sdk/index.ts +18 -13
  30. package/plugin/sdk/service/index.ts +29 -29
  31. package/plugin/sdk/types.ts +578 -0
  32. package/plugin/sdk/window/index.ts +40 -40
  33. package/renderer/index.ts +2 -0
  34. package/renderer/ref.ts +54 -54
  35. package/renderer/slots.ts +124 -0
  36. package/renderer/storage/app-settings.ts +34 -0
  37. package/renderer/storage/base-storage.ts +335 -0
  38. package/renderer/storage/index.ts +1 -0
  39. package/search/types.ts +726 -0
  40. package/service/index.ts +67 -67
  41. package/service/protocol/index.ts +77 -77
package/base/index.ts CHANGED
@@ -1,181 +1,181 @@
1
- export type Arch = 'x64' | 'x86' | 'arm' | 'arm64'
2
-
3
- export type OS = 'Win' | 'Darwin' | 'Linux' | 'Android' | 'iOS' | 'ipadOS' | 'web' | 'watchOS' | 'tvOS' | 'wearOS' | 'visionOS'
4
-
5
- export enum DepartedOS {
6
- WINDOWS_8 = 'Windows 8',
7
- WINDOWS_7 = 'Windows 7',
8
- WINDOWS_VISTA = 'Windows Vista',
9
- WINDOWS_XP = 'Windows XP',
10
- WINDOWS_2000 = 'Windows 2000',
11
- WINDOWS_NT = 'Windows NT',
12
- WINDOWS_ME = 'Windows ME',
13
- WINDOWS_98 = 'Windows 98',
14
- WINDOWS_95 = 'Windows 95',
15
- WINDOWS_CE = 'Windows CE',
16
- WINDOWS_3_11 = 'Windows 3.11',
17
-
18
- MACOS_MOJAVE = 'macOS Mojave',
19
- MACOS_HIGH_SIERRA = 'macOS High Sierra',
20
- MACOS_SIERRA = 'macOS Sierra',
21
- MACOS_EL_CAPITAN = 'OS X El Capitan',
22
- MACOS_YOSEMITE = 'OS X Yosemite',
23
- MACOS_MAVERICKS = 'OS X Mavericks',
24
- MACOS_MOUNTAIN_LION = 'OS X Mountain Lion',
25
- MACOS_LION = 'Mac OS X Lion',
26
- MACOS_SNOW_LEOPARD = 'Mac OS X Snow Leopard',
27
- MACOS_LEOPARD = 'Mac OS X Leopard',
28
- MACOS_TIGER = 'Mac OS X Tiger',
29
- MACOS_PANTHER = 'Mac OS X Panther',
30
- MACOS_JAGUAR = 'Mac OS X Jaguar',
31
- MACOS_PUMA = 'Mac OS X Puma',
32
- MACOS_CHEETAH = 'Mac OS X Cheetah',
33
-
34
- LINUX_MANDRIVA = 'Linux Mandriva',
35
- LINUX_MINT = 'Linux Mint',
36
- LINUX_GENTOO = 'Linux Gentoo',
37
- LINUX_KNOPPIX = 'Linux Knoppix',
38
- LINUX_SLACKWARE = 'Linux Slackware',
39
- LINUX_XANDROS = 'Linux Xandros',
40
- LINUX_JOLI = 'Linux Joli',
41
- LINUX_SUSE = 'Linux SUSE',
42
-
43
- ANDROID_9 = 'Android 9',
44
- ANDROID_8_1 = 'Android 8.1',
45
- ANDROID_8 = 'Android 8',
46
- ANDROID_7_1 = 'Android 7.1',
47
- ANDROID_7 = 'Android 7',
48
- ANDROID_6 = 'Android 6',
49
- ANDROID_5_1 = 'Android 5.1',
50
- ANDROID_5 = 'Android 5',
51
- ANDROID_4_4 = 'Android 4.4',
52
- ANDROID_4_3 = 'Android 4.3',
53
- ANDROID_4_2 = 'Android 4.2',
54
- ANDROID_4_1 = 'Android 4.1',
55
- ANDROID_4 = 'Android 4',
56
- ANDROID_3_2 = 'Android 3.2',
57
- ANDROID_3_1 = 'Android 3.1',
58
- ANDROID_3 = 'Android 3',
59
- ANDROID_2_3 = 'Android 2.3',
60
- ANDROID_2_2 = 'Android 2.2',
61
- ANDROID_2_1 = 'Android 2.1',
62
- ANDROID_2 = 'Android 2',
63
- ANDROID_1_6 = 'Android 1.6',
64
- ANDROID_1_5 = 'Android 1.5',
65
- ANDROID_1_1 = 'Android 1.1',
66
- ANDROID_1_0 = 'Android 1.0',
67
-
68
- IOS_15 = 'iOS 15',
69
- IOS_14 = 'iOS 14',
70
- IOS_13 = 'iOS 13',
71
- IOS_12 = 'iOS 12',
72
- IOS_11 = 'iOS 11',
73
- IOS_10 = 'iOS 10',
74
- IOS_9 = 'iOS 9',
75
- IOS_8 = 'iOS 8',
76
- IOS_7 = 'iOS 7',
77
- IOS_6 = 'iOS 6',
78
- IOS_5 = 'iOS 5',
79
-
80
- IPADOS_15 = 'iPadOS 15',
81
- IPADOS_14 = 'iPadOS 14',
82
- IPADOS_13 = 'iPadOS 13',
83
- IPADOS_12 = 'iPadOS 12',
84
- IPADOS_11 = 'iPadOS 11',
85
- IPADOS_10 = 'iPadOS 10',
86
- IPADOS_9 = 'iPadOS 9',
87
- IPADOS_8 = 'iPadOS 8',
88
- IPADOS_7 = 'iPadOS 7',
89
- IPADOS_6 = 'iPadOS 6',
90
- IPADOS_5 = 'iPadOS 5',
91
-
92
- WEB_IE = 'Web IE',
93
-
94
- WATCHOS_8 = 'watchOS 8',
95
- WATCHOS_7 = 'watchOS 7',
96
- WATCHOS_6 = 'watchOS 6',
97
- WATCHOS_5 = 'watchOS 5',
98
- WATCHOS_4 = 'watchOS 4',
99
- WATCHOS_3 = 'watchOS 3',
100
- WATCHOS_2 = 'watchOS 2',
101
- WATCHOS_1 = 'watchOS 1',
102
-
103
- TVOS_15 = 'tvOS 15',
104
- TVOS_14 = 'tvOS 14',
105
- TVOS_13 = 'tvOS 13',
106
- TVOS_12 = 'tvOS 12',
107
- TVOS_11 = 'tvOS 11',
108
- TVOS_10 = 'tvOS 10',
109
- TVOS_9 = 'tvOS 9',
110
- TVOS_8 = 'tvOS 8',
111
- TVOS_7 = 'tvOS 7',
112
- TVOS_6 = 'tvOS 6',
113
- TVOS_5 = 'tvOS 5',
114
- TVOS_4 = 'tvOS 4',
115
- TVOS_3 = 'tvOS 3',
116
- TVOS_2 = 'tvOS 2',
117
- TVOS_1 = 'tvOS 1',
118
-
119
- WEAROS_3 = 'WearOS 3',
120
- WEAROS_2 = 'WearOS 2',
121
- WEAROS_1 = 'WearOS 1',
122
- }
123
-
124
- export enum SupportOS {
125
- WINDOWS = 'Windows',
126
- WINDOWS_11 = 'Windows 10 Pro',
127
- WINDOWS_10 = 'Windows 10',
128
-
129
- MACOS = 'macOS',
130
- MACOS_SONOMA = 'macOS Sonoma',
131
- MACOS_MONTEREY = 'macOS Monterey',
132
- MACOS_BIG_SUR = 'macOS Big Sur',
133
-
134
- LINUX = 'Linux',
135
- LINUX_UBUNTU = 'Linux Ubuntu',
136
- LINUX_DEBIAN = 'Linux Debian',
137
- LINUX_FEDORA = 'Linux Fedora',
138
- LINUX_RED_HAT = 'Linux Red Hat',
139
- LINUX_CENTOS = 'Linux CentOS',
140
- LINUX_CHROME_OS = 'Linux Chrome OS',
141
- LINUX_CHROMIUM_OS = 'Linux Chromium OS',
142
-
143
- ANDROID = 'Android',
144
- ANDROID_14 = 'Android 14',
145
- ANDROID_13 = 'Android 13',
146
- ANDROID_12 = 'Android 12',
147
- ANDROID_11 = 'Android 11',
148
- ANDROID_10 = 'Android 10',
149
-
150
- IOS = 'iOS',
151
- IOS_17 = 'iOS 17',
152
- IOS_16 = 'iOS 16',
153
-
154
- IPADOS = 'iPadOS',
155
- IPADOS_17 = 'iPadOS 17',
156
- IPADOS_16 = 'iPadOS 16',
157
-
158
- WEB = 'Web',
159
- WEB_CHROME = 'Web Chrome',
160
- WEB_FIREFOX = 'Web Firefox',
161
- WEB_SAFARI = 'Web Safari',
162
- WEB_EDGE = 'Web Edge',
163
- WEB_OPERA = 'Web Opera',
164
- WEB_ANDROID = 'Web Android',
165
- WEB_IOS = 'Web iOS',
166
- WEB_IPADOS = 'Web iPadOS',
167
-
168
- WATCHOS = 'watchOS',
169
- WATCHOS_9 = 'watchOS 10',
170
- WATCHOS_10 = 'watchOS 9',
171
-
172
- TVOS = 'tvOS',
173
- TVOS_17 = 'tvOS 17',
174
- TVOS_16 = 'tvOS 16',
175
-
176
- WEAROS = 'WearOS',
177
- WEAROS_4 = 'WearOS 4',
178
-
179
- VISIONOS = 'VisionOS',
180
- VISIONOS_1 = 'VisionOS 1',
181
- }
1
+ export type Arch = 'x64' | 'x86' | 'arm' | 'arm64'
2
+
3
+ export type OS = 'Win' | 'Darwin' | 'Linux' | 'Android' | 'iOS' | 'ipadOS' | 'web' | 'watchOS' | 'tvOS' | 'wearOS' | 'visionOS'
4
+
5
+ export enum DepartedOS {
6
+ WINDOWS_8 = 'Windows 8',
7
+ WINDOWS_7 = 'Windows 7',
8
+ WINDOWS_VISTA = 'Windows Vista',
9
+ WINDOWS_XP = 'Windows XP',
10
+ WINDOWS_2000 = 'Windows 2000',
11
+ WINDOWS_NT = 'Windows NT',
12
+ WINDOWS_ME = 'Windows ME',
13
+ WINDOWS_98 = 'Windows 98',
14
+ WINDOWS_95 = 'Windows 95',
15
+ WINDOWS_CE = 'Windows CE',
16
+ WINDOWS_3_11 = 'Windows 3.11',
17
+
18
+ MACOS_MOJAVE = 'macOS Mojave',
19
+ MACOS_HIGH_SIERRA = 'macOS High Sierra',
20
+ MACOS_SIERRA = 'macOS Sierra',
21
+ MACOS_EL_CAPITAN = 'OS X El Capitan',
22
+ MACOS_YOSEMITE = 'OS X Yosemite',
23
+ MACOS_MAVERICKS = 'OS X Mavericks',
24
+ MACOS_MOUNTAIN_LION = 'OS X Mountain Lion',
25
+ MACOS_LION = 'Mac OS X Lion',
26
+ MACOS_SNOW_LEOPARD = 'Mac OS X Snow Leopard',
27
+ MACOS_LEOPARD = 'Mac OS X Leopard',
28
+ MACOS_TIGER = 'Mac OS X Tiger',
29
+ MACOS_PANTHER = 'Mac OS X Panther',
30
+ MACOS_JAGUAR = 'Mac OS X Jaguar',
31
+ MACOS_PUMA = 'Mac OS X Puma',
32
+ MACOS_CHEETAH = 'Mac OS X Cheetah',
33
+
34
+ LINUX_MANDRIVA = 'Linux Mandriva',
35
+ LINUX_MINT = 'Linux Mint',
36
+ LINUX_GENTOO = 'Linux Gentoo',
37
+ LINUX_KNOPPIX = 'Linux Knoppix',
38
+ LINUX_SLACKWARE = 'Linux Slackware',
39
+ LINUX_XANDROS = 'Linux Xandros',
40
+ LINUX_JOLI = 'Linux Joli',
41
+ LINUX_SUSE = 'Linux SUSE',
42
+
43
+ ANDROID_9 = 'Android 9',
44
+ ANDROID_8_1 = 'Android 8.1',
45
+ ANDROID_8 = 'Android 8',
46
+ ANDROID_7_1 = 'Android 7.1',
47
+ ANDROID_7 = 'Android 7',
48
+ ANDROID_6 = 'Android 6',
49
+ ANDROID_5_1 = 'Android 5.1',
50
+ ANDROID_5 = 'Android 5',
51
+ ANDROID_4_4 = 'Android 4.4',
52
+ ANDROID_4_3 = 'Android 4.3',
53
+ ANDROID_4_2 = 'Android 4.2',
54
+ ANDROID_4_1 = 'Android 4.1',
55
+ ANDROID_4 = 'Android 4',
56
+ ANDROID_3_2 = 'Android 3.2',
57
+ ANDROID_3_1 = 'Android 3.1',
58
+ ANDROID_3 = 'Android 3',
59
+ ANDROID_2_3 = 'Android 2.3',
60
+ ANDROID_2_2 = 'Android 2.2',
61
+ ANDROID_2_1 = 'Android 2.1',
62
+ ANDROID_2 = 'Android 2',
63
+ ANDROID_1_6 = 'Android 1.6',
64
+ ANDROID_1_5 = 'Android 1.5',
65
+ ANDROID_1_1 = 'Android 1.1',
66
+ ANDROID_1_0 = 'Android 1.0',
67
+
68
+ IOS_15 = 'iOS 15',
69
+ IOS_14 = 'iOS 14',
70
+ IOS_13 = 'iOS 13',
71
+ IOS_12 = 'iOS 12',
72
+ IOS_11 = 'iOS 11',
73
+ IOS_10 = 'iOS 10',
74
+ IOS_9 = 'iOS 9',
75
+ IOS_8 = 'iOS 8',
76
+ IOS_7 = 'iOS 7',
77
+ IOS_6 = 'iOS 6',
78
+ IOS_5 = 'iOS 5',
79
+
80
+ IPADOS_15 = 'iPadOS 15',
81
+ IPADOS_14 = 'iPadOS 14',
82
+ IPADOS_13 = 'iPadOS 13',
83
+ IPADOS_12 = 'iPadOS 12',
84
+ IPADOS_11 = 'iPadOS 11',
85
+ IPADOS_10 = 'iPadOS 10',
86
+ IPADOS_9 = 'iPadOS 9',
87
+ IPADOS_8 = 'iPadOS 8',
88
+ IPADOS_7 = 'iPadOS 7',
89
+ IPADOS_6 = 'iPadOS 6',
90
+ IPADOS_5 = 'iPadOS 5',
91
+
92
+ WEB_IE = 'Web IE',
93
+
94
+ WATCHOS_8 = 'watchOS 8',
95
+ WATCHOS_7 = 'watchOS 7',
96
+ WATCHOS_6 = 'watchOS 6',
97
+ WATCHOS_5 = 'watchOS 5',
98
+ WATCHOS_4 = 'watchOS 4',
99
+ WATCHOS_3 = 'watchOS 3',
100
+ WATCHOS_2 = 'watchOS 2',
101
+ WATCHOS_1 = 'watchOS 1',
102
+
103
+ TVOS_15 = 'tvOS 15',
104
+ TVOS_14 = 'tvOS 14',
105
+ TVOS_13 = 'tvOS 13',
106
+ TVOS_12 = 'tvOS 12',
107
+ TVOS_11 = 'tvOS 11',
108
+ TVOS_10 = 'tvOS 10',
109
+ TVOS_9 = 'tvOS 9',
110
+ TVOS_8 = 'tvOS 8',
111
+ TVOS_7 = 'tvOS 7',
112
+ TVOS_6 = 'tvOS 6',
113
+ TVOS_5 = 'tvOS 5',
114
+ TVOS_4 = 'tvOS 4',
115
+ TVOS_3 = 'tvOS 3',
116
+ TVOS_2 = 'tvOS 2',
117
+ TVOS_1 = 'tvOS 1',
118
+
119
+ WEAROS_3 = 'WearOS 3',
120
+ WEAROS_2 = 'WearOS 2',
121
+ WEAROS_1 = 'WearOS 1',
122
+ }
123
+
124
+ export enum SupportOS {
125
+ WINDOWS = 'Windows',
126
+ WINDOWS_11 = 'Windows 10 Pro',
127
+ WINDOWS_10 = 'Windows 10',
128
+
129
+ MACOS = 'macOS',
130
+ MACOS_SONOMA = 'macOS Sonoma',
131
+ MACOS_MONTEREY = 'macOS Monterey',
132
+ MACOS_BIG_SUR = 'macOS Big Sur',
133
+
134
+ LINUX = 'Linux',
135
+ LINUX_UBUNTU = 'Linux Ubuntu',
136
+ LINUX_DEBIAN = 'Linux Debian',
137
+ LINUX_FEDORA = 'Linux Fedora',
138
+ LINUX_RED_HAT = 'Linux Red Hat',
139
+ LINUX_CENTOS = 'Linux CentOS',
140
+ LINUX_CHROME_OS = 'Linux Chrome OS',
141
+ LINUX_CHROMIUM_OS = 'Linux Chromium OS',
142
+
143
+ ANDROID = 'Android',
144
+ ANDROID_14 = 'Android 14',
145
+ ANDROID_13 = 'Android 13',
146
+ ANDROID_12 = 'Android 12',
147
+ ANDROID_11 = 'Android 11',
148
+ ANDROID_10 = 'Android 10',
149
+
150
+ IOS = 'iOS',
151
+ IOS_17 = 'iOS 17',
152
+ IOS_16 = 'iOS 16',
153
+
154
+ IPADOS = 'iPadOS',
155
+ IPADOS_17 = 'iPadOS 17',
156
+ IPADOS_16 = 'iPadOS 16',
157
+
158
+ WEB = 'Web',
159
+ WEB_CHROME = 'Web Chrome',
160
+ WEB_FIREFOX = 'Web Firefox',
161
+ WEB_SAFARI = 'Web Safari',
162
+ WEB_EDGE = 'Web Edge',
163
+ WEB_OPERA = 'Web Opera',
164
+ WEB_ANDROID = 'Web Android',
165
+ WEB_IOS = 'Web iOS',
166
+ WEB_IPADOS = 'Web iPadOS',
167
+
168
+ WATCHOS = 'watchOS',
169
+ WATCHOS_9 = 'watchOS 10',
170
+ WATCHOS_10 = 'watchOS 9',
171
+
172
+ TVOS = 'tvOS',
173
+ TVOS_17 = 'tvOS 17',
174
+ TVOS_16 = 'tvOS 16',
175
+
176
+ WEAROS = 'WearOS',
177
+ WEAROS_4 = 'WearOS 4',
178
+
179
+ VISIONOS = 'VisionOS',
180
+ VISIONOS_1 = 'VisionOS 1',
181
+ }
package/channel/index.ts CHANGED
@@ -1,99 +1,108 @@
1
- export enum ChannelType {
2
- MAIN = "main",
3
- PLUGIN = "plugin"
4
- }
5
-
6
- export enum DataCode {
7
- SUCCESS = 200,
8
- NETWORK_ERROR = 500,
9
- ERROR = 100
10
- }
11
-
12
- export interface ITouchChannel {
13
-
14
- /**
15
- * Register a channel
16
- * @description Register a channel, and return a function to cancel the registration
17
- * @param type {@link ChannelType} The type of channel
18
- * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
19
- * @param callback {Function} The callback function
20
- */
21
- regChannel(type: ChannelType, eventName: string, callback: (data: StandardChannelData) => any): () => void
22
-
23
- /**
24
- * Send a message to a channel
25
- * @param type {@link ChannelType} The type of channel
26
- * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
27
- * @param arg {any} The arguments of the message
28
- */
29
- send(type: ChannelType, eventName: string, arg?: any): Promise<any>
30
- }
31
-
32
- export interface ITouchClientChannel {
33
-
34
- /**
35
- * Register a channel
36
- * @description Register a channel, and return a function to cancel the registration
37
- * @param type {@link ChannelType} The type of channel
38
- * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType
39
- * @param callback {Function} The callback function
40
- */
41
- regChannel(eventName: string, callback: Function): () => void
42
-
43
- /**
44
- * Send a message to a channel
45
- * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
46
- * @param arg {any} The arguments of the message
47
- */
48
- send(eventName: string, arg?: any): Promise<any>
49
-
50
- /**
51
- * Send a message to a channel and get the response
52
- * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
53
- * @param arg {any} The arguments of the message
54
- */
55
- sendSync(eventName: string, arg?: any): any
56
- }
57
-
58
- export interface RawChannelSyncData {
59
- timeStamp: number
60
- /**
61
- * The sync-data timeout
62
- * @description The unit is milliseconds, and set it to 0 to cancel it.
63
- * @default 10000
64
- */
65
- timeout: 10000
66
-
67
- /**
68
- * The sync-data unique id
69
- * @description To identify each sync-request.
70
- */
71
- id: string
72
- }
73
-
74
- export interface RawChannelHeaderData {
75
- status: "reply" | "request";
76
- type: ChannelType;
77
- _originData?: any;
78
- event: Electron.IpcMainEvent | Electron.IpcRendererEvent;
79
- }
80
-
81
- export interface RawChannelData {
82
- name: string
83
- header: RawChannelHeaderData
84
- sync?: RawChannelSyncData
85
- }
86
-
87
- export interface RawStandardChannelData extends RawChannelData {
88
- code: DataCode
89
- data?: IChannelData
90
- plugin?: string
91
- }
92
-
93
- export interface StandardChannelData extends RawStandardChannelData {
94
- reply: (code: DataCode, data: IChannelData) => void
95
- }
96
-
97
- export interface IChannelData {
98
- [prop: string]: any
99
- }
1
+ export enum ChannelType {
2
+ MAIN = "main",
3
+ PLUGIN = "plugin"
4
+ }
5
+
6
+ export enum DataCode {
7
+ SUCCESS = 200,
8
+ NETWORK_ERROR = 500,
9
+ ERROR = 100
10
+ }
11
+
12
+ export interface ITouchChannel {
13
+
14
+ /**
15
+ * Register a channel
16
+ * @description Register a channel, and return a function to cancel the registration
17
+ * @param type {@link ChannelType} The type of channel
18
+ * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
19
+ * @param callback {Function} The callback function
20
+ */
21
+ regChannel(type: ChannelType, eventName: string, callback: (data: StandardChannelData) => any): () => void
22
+
23
+ /**
24
+ * Send a message to a channel
25
+ * @param type {@link ChannelType} The type of channel
26
+ * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
27
+ * @param arg {any} The arguments of the message
28
+ */
29
+ send(type: ChannelType, eventName: string, arg?: any): Promise<any>
30
+
31
+ /**
32
+ * Send a message to a channel with settled window
33
+ * @param win {@link Electron.BrowserWindow} the window you want to sent
34
+ * @param type {@link ChannelType} The type of channel
35
+ * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
36
+ * @param arg {any} The arguments of the message
37
+ */
38
+ sendTo(win: Electron.BrowserWindow, type: ChannelType, eventName: string, arg: any): Promise<any>
39
+ }
40
+
41
+ export interface ITouchClientChannel {
42
+
43
+ /**
44
+ * Register a channel
45
+ * @description Register a channel, and return a function to cancel the registration
46
+ * @param type {@link ChannelType} The type of channel
47
+ * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType
48
+ * @param callback {Function} The callback function
49
+ */
50
+ regChannel(eventName: string, callback: (data: StandardChannelData) => any): () => void
51
+
52
+ /**
53
+ * Send a message to a channel
54
+ * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
55
+ * @param arg {any} The arguments of the message
56
+ */
57
+ send(eventName: string, arg?: any): Promise<any>
58
+
59
+ /**
60
+ * Send a message to a channel and get the response
61
+ * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
62
+ * @param arg {any} The arguments of the message
63
+ */
64
+ sendSync(eventName: string, arg?: any): any
65
+ }
66
+
67
+ export interface RawChannelSyncData {
68
+ timeStamp: number
69
+ /**
70
+ * The sync-data timeout
71
+ * @description The unit is milliseconds, and set it to 0 to cancel it.
72
+ * @default 10000
73
+ */
74
+ timeout: 10000
75
+
76
+ /**
77
+ * The sync-data unique id
78
+ * @description To identify each sync-request.
79
+ */
80
+ id: string
81
+ }
82
+
83
+ export interface RawChannelHeaderData {
84
+ status: "reply" | "request";
85
+ type: ChannelType;
86
+ _originData?: any;
87
+ event?: Electron.IpcMainEvent | Electron.IpcRendererEvent;
88
+ }
89
+
90
+ export interface RawChannelData {
91
+ name: string
92
+ header: RawChannelHeaderData
93
+ sync?: RawChannelSyncData
94
+ }
95
+
96
+ export interface RawStandardChannelData extends RawChannelData {
97
+ code: DataCode
98
+ data?: IChannelData
99
+ plugin?: string
100
+ }
101
+
102
+ export interface StandardChannelData extends RawStandardChannelData {
103
+ reply: (code: DataCode, data: IChannelData) => void
104
+ }
105
+
106
+ export type IChannelData = any //boolean | number | string | null | undefined | {
107
+ // [prop: string]: any
108
+ // }
package/common/index.ts CHANGED
@@ -1,39 +1,2 @@
1
- export async function sleep(time: number) {
2
- return new Promise(resolve => setTimeout(() => resolve(time), time))
3
- }
4
-
5
- export function anyStr2Num(str: string): BigInt {
6
- const numbers = new Array<String>
7
- let minium = Infinity
8
-
9
- for (let index = 0; index < str.length; index++) {
10
- const e = +str.charCodeAt(index);
11
-
12
- numbers.push(("" + e).padStart(5, "0"))
13
-
14
- if (minium > e) minium = e
15
-
16
- }
17
-
18
- // each number transform
19
- numbers.forEach((e, i) => numbers[i] = (BigInt(+e) - BigInt(minium)).toString().padStart(2, "0"))
20
-
21
- return BigInt(`${minium}000${BigInt(+numbers.join(""))}`)
22
- }
23
-
24
- export function num2anyStr(num: BigInt): string {
25
- const strs = num.toString().split("000")
26
- const baseNum = +strs[0]
27
- const length = +strs[1].length / 2
28
-
29
- let text = ''
30
-
31
- for (let i = 0; i < length; i++) {
32
- const str = strs[1].slice(i * 2, i * 2 + 2)
33
-
34
- // strs[1] = strs[1].replace(str, (BigInt(+str) + BigInt(baseNum)).toString().padStart(5, "0"))
35
- text += String.fromCharCode(+str + baseNum)
36
- }
37
-
38
- return text
39
- }
1
+ export * from './storage/index'
2
+ export * from './utils'
@@ -0,0 +1,3 @@
1
+ export enum StorageList {
2
+ APP_SETTING = "app-setting.ini"
3
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Default configuration object for application settings
3
+ */
4
+ const _appSettingOriginData = {
5
+ autoStart: false,
6
+ defaultApp: 0,
7
+ plugin: {
8
+ sync: 0,
9
+ syncLatest: false,
10
+ dataSync: false,
11
+ },
12
+ dev: {
13
+ autoCloseDev: true,
14
+ },
15
+ lang: {
16
+ followSystem: true,
17
+ locale: 0,
18
+ },
19
+ keyBind: {
20
+ summon: 'CTRL + E',
21
+ home: 0,
22
+ plugins: 0,
23
+ settings: 0,
24
+ },
25
+ beginner: {
26
+ init: false,
27
+ },
28
+ tools: {
29
+ autoPaste: {
30
+ enable: true,
31
+ time: 180,
32
+ },
33
+ autoHide: true,
34
+ autoClear: 600,
35
+ },
36
+ };
37
+
38
+ export const appSettingOriginData = Object.freeze(_appSettingOriginData)
39
+
40
+ /**
41
+ * Type definition for application settings.
42
+ *
43
+ * Combines the default configuration with support for dynamic additional properties.
44
+ */
45
+ export type AppSetting = typeof _appSettingOriginData & {
46
+ [key: string]: any;
47
+ };
@@ -0,0 +1 @@
1
+ export * from './app-settings'
@@ -0,0 +1,3 @@
1
+ export * from './constants'
2
+
3
+ export * from './entity'