@talex-touch/utils 1.0.30 → 1.0.32

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 (113) hide show
  1. package/animation/window-node.ts +205 -0
  2. package/animation/window.ts +19 -15
  3. package/auth/clerk-types.ts +1 -1
  4. package/auth/index.ts +1 -1
  5. package/auth/useAuthState.ts +6 -5
  6. package/auth/useClerkConfig.ts +6 -6
  7. package/auth/useClerkProvider.ts +3 -2
  8. package/channel/index.ts +28 -21
  9. package/common/file-scan-constants.ts +137 -121
  10. package/common/file-scan-utils.ts +49 -25
  11. package/common/index.ts +3 -3
  12. package/common/search/gather.ts +1 -1
  13. package/common/search/index.ts +5 -6
  14. package/common/storage/constants.ts +3 -2
  15. package/common/storage/entity/app-settings.ts +19 -3
  16. package/common/storage/entity/shortcut-settings.ts +10 -10
  17. package/common/storage/shortcut-storage.ts +6 -4
  18. package/common/utils/file.ts +15 -4
  19. package/common/utils/index.ts +62 -52
  20. package/common/utils/polling.ts +114 -63
  21. package/common/utils/task-queue.ts +11 -10
  22. package/common/utils/time.ts +50 -47
  23. package/common/utils/timing.ts +41 -37
  24. package/core-box/builder/index.ts +1 -1
  25. package/core-box/builder/tuff-builder.ts +255 -230
  26. package/core-box/index.ts +3 -6
  27. package/core-box/preview/index.ts +1 -0
  28. package/core-box/preview/types.ts +43 -0
  29. package/core-box/tuff/index.ts +1 -1
  30. package/core-box/tuff/tuff-dsl.ts +419 -253
  31. package/electron/clipboard-helper.ts +20 -12
  32. package/electron/download-manager.ts +43 -42
  33. package/electron/env-tool.ts +19 -18
  34. package/electron/file-parsers/index.ts +2 -2
  35. package/electron/file-parsers/parsers/text-parser.ts +15 -14
  36. package/electron/file-parsers/registry.ts +9 -7
  37. package/electron/file-parsers/types.ts +4 -4
  38. package/electron/index.ts +1 -1
  39. package/eventbus/index.ts +11 -11
  40. package/index.ts +6 -5
  41. package/intelligence/client.ts +87 -0
  42. package/intelligence/index.ts +1 -0
  43. package/package.json +14 -14
  44. package/permission/index.ts +8 -8
  45. package/plugin/channel.ts +77 -68
  46. package/plugin/index.ts +113 -84
  47. package/plugin/install.ts +8 -8
  48. package/plugin/log/types.ts +5 -5
  49. package/plugin/node/index.ts +1 -1
  50. package/plugin/node/logger-manager.ts +14 -11
  51. package/plugin/node/logger.ts +8 -8
  52. package/plugin/plugin-source.ts +11 -11
  53. package/plugin/preload.ts +6 -3
  54. package/plugin/providers/registry.ts +8 -7
  55. package/plugin/providers/types.ts +6 -6
  56. package/plugin/sdk/channel.ts +20 -20
  57. package/plugin/sdk/clipboard.ts +8 -6
  58. package/plugin/sdk/common.ts +10 -6
  59. package/plugin/sdk/core-box.ts +2 -3
  60. package/plugin/sdk/division-box.ts +266 -0
  61. package/plugin/sdk/enum/bridge-event.ts +1 -1
  62. package/plugin/sdk/examples/storage-onDidChange-example.js +1 -1
  63. package/plugin/sdk/features.ts +34 -26
  64. package/plugin/sdk/hooks/bridge.ts +3 -6
  65. package/plugin/sdk/hooks/index.ts +1 -1
  66. package/plugin/sdk/hooks/life-cycle.ts +4 -10
  67. package/plugin/sdk/index.ts +9 -13
  68. package/plugin/sdk/service/index.ts +3 -3
  69. package/plugin/sdk/storage.ts +4 -4
  70. package/plugin/sdk/system.ts +1 -1
  71. package/plugin/sdk/types.ts +169 -143
  72. package/plugin/sdk/window/index.ts +8 -5
  73. package/preload/loading.ts +6 -6
  74. package/preload/renderer.ts +4 -2
  75. package/renderer/hooks/arg-mapper.ts +1 -2
  76. package/renderer/hooks/index.ts +2 -0
  77. package/renderer/hooks/initialize.ts +10 -8
  78. package/renderer/hooks/performance.ts +4 -4
  79. package/renderer/hooks/use-channel.ts +150 -0
  80. package/renderer/hooks/use-intelligence.ts +236 -0
  81. package/renderer/index.ts +6 -1
  82. package/renderer/ref.ts +32 -36
  83. package/renderer/slots.ts +29 -26
  84. package/renderer/storage/app-settings.ts +16 -6
  85. package/renderer/storage/base-storage.ts +236 -88
  86. package/renderer/storage/index.ts +3 -0
  87. package/renderer/storage/intelligence-storage.ts +215 -0
  88. package/renderer/storage/openers.ts +13 -3
  89. package/renderer/touch-sdk/env.ts +41 -41
  90. package/renderer/touch-sdk/index.ts +1 -1
  91. package/renderer/touch-sdk/terminal.ts +5 -5
  92. package/renderer/touch-sdk/utils.ts +4 -3
  93. package/search/levenshtein-utils.ts +11 -11
  94. package/search/types.ts +102 -103
  95. package/service/index.ts +11 -11
  96. package/service/protocol/index.ts +217 -14
  97. package/types/division-box.ts +248 -0
  98. package/types/download.ts +72 -34
  99. package/types/icon.ts +2 -1
  100. package/types/index.ts +3 -1
  101. package/types/intelligence.ts +413 -0
  102. package/types/modules/base.ts +16 -16
  103. package/types/modules/index.ts +1 -1
  104. package/types/modules/module-lifecycle.ts +21 -21
  105. package/types/modules/module-manager.ts +11 -11
  106. package/types/modules/module.ts +16 -16
  107. package/types/storage.ts +0 -1
  108. package/types/touch-app-core.ts +32 -32
  109. package/types/update.ts +79 -21
  110. package/core-box/README.md +0 -218
  111. package/core-box/builder/tuff-builder.example.ts.bak +0 -258
  112. package/core-box/run-tests.sh +0 -7
  113. package/core-box/search.ts +0 -1
@@ -0,0 +1,205 @@
1
+ import type { TalexTouch } from '../types'
2
+
3
+ /**
4
+ * Window animation controller return type
5
+ */
6
+ export interface WindowAnimationController {
7
+ /**
8
+ * Update window height with animation
9
+ * @param newHeight - The new height to animate to
10
+ * @param duration - Animation duration in seconds (default: 0.5)
11
+ * @returns Promise that resolves to true if animation completed successfully, false if interrupted
12
+ */
13
+ updateHeight: (newHeight: number, duration?: number) => Promise<boolean>
14
+
15
+ /**
16
+ * Cancel current animation
17
+ * @returns Promise that resolves to true if there was an animation to cancel, false otherwise
18
+ */
19
+ cancel: () => Promise<boolean>
20
+
21
+ /**
22
+ * Toggle window visibility
23
+ * @param visible - Optional parameter to explicitly set visibility state
24
+ * @returns Promise that resolves to true if operation completed successfully, false otherwise
25
+ */
26
+ toggleWindow: (visible?: boolean) => Promise<boolean>
27
+
28
+ /**
29
+ * Change current window instance
30
+ * @param newWindow - New TouchWindow instance
31
+ */
32
+ changeWindow: (newWindow: TalexTouch.ITouchWindow) => void
33
+ }
34
+
35
+ /**
36
+ * Tracks the state of an animation
37
+ */
38
+ interface AnimationState {
39
+ intervalId: NodeJS.Timeout | null
40
+ completed: boolean
41
+ }
42
+
43
+ /**
44
+ * Simple easing function for smooth animation
45
+ */
46
+ function easeInOutCubic(t: number): number {
47
+ return t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2
48
+ }
49
+
50
+ /**
51
+ * Use native Node.js animation for window (main process only)
52
+ * @param window - TouchWindow instance (optional, can be set later with changeWindow)
53
+ * @returns WindowAnimationController with updateHeight, cancel, toggleWindow, and changeWindow methods
54
+ */
55
+ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnimationController {
56
+ // Store current window reference inside the function scope
57
+ let currentWindow: TalexTouch.ITouchWindow | null = window || null
58
+
59
+ const animationState: AnimationState = {
60
+ intervalId: null,
61
+ completed: false,
62
+ }
63
+
64
+ /**
65
+ * Check if current window is valid
66
+ * @returns true if window is valid, false otherwise
67
+ */
68
+ const isWindowValid = (): boolean => {
69
+ return (
70
+ currentWindow !== null
71
+ && currentWindow.window !== null
72
+ && !currentWindow.window.isDestroyed()
73
+ )
74
+ }
75
+
76
+ /**
77
+ * Get current window with validation
78
+ * @returns current window or throws error if invalid
79
+ */
80
+ const getCurrentWindow = (): TalexTouch.ITouchWindow => {
81
+ if (!isWindowValid()) {
82
+ throw new Error('Window is not valid or has been destroyed')
83
+ }
84
+ return currentWindow!
85
+ }
86
+
87
+ const updateHeight = async (newHeight: number, duration: number = 0.5): Promise<boolean> => {
88
+ try {
89
+ const window = getCurrentWindow()
90
+
91
+ // Cancel any existing animation
92
+ if (animationState.intervalId) {
93
+ clearInterval(animationState.intervalId)
94
+ animationState.intervalId = null
95
+ }
96
+
97
+ // Reset state for new animation
98
+ animationState.completed = false
99
+
100
+ const browserWindow = window.window
101
+ const [currentWidth, currentHeight] = browserWindow.getSize()
102
+ const [x, y] = browserWindow.getPosition()
103
+
104
+ const startHeight = currentHeight
105
+ const heightDelta = newHeight - startHeight
106
+ const startTime = Date.now()
107
+ const durationMs = duration * 1000
108
+
109
+ return new Promise<boolean>((resolve) => {
110
+ animationState.intervalId = setInterval(() => {
111
+ // Check if window is still valid
112
+ if (!isWindowValid()) {
113
+ if (animationState.intervalId) {
114
+ clearInterval(animationState.intervalId)
115
+ animationState.intervalId = null
116
+ }
117
+ resolve(false)
118
+ return
119
+ }
120
+
121
+ const elapsed = Date.now() - startTime
122
+ const progress = Math.min(elapsed / durationMs, 1)
123
+ const easedProgress = easeInOutCubic(progress)
124
+ const animatedHeight = Math.round(startHeight + heightDelta * easedProgress)
125
+
126
+ browserWindow.setSize(currentWidth, animatedHeight)
127
+ browserWindow.setPosition(x, y)
128
+
129
+ if (progress >= 1) {
130
+ if (animationState.intervalId) {
131
+ clearInterval(animationState.intervalId)
132
+ animationState.intervalId = null
133
+ }
134
+ animationState.completed = true
135
+ resolve(true)
136
+ }
137
+ }, 16) // ~60fps
138
+ })
139
+ }
140
+ catch (error) {
141
+ console.error('Error in updateHeight:', error)
142
+ return Promise.resolve(false)
143
+ }
144
+ }
145
+
146
+ const cancel = async (): Promise<boolean> => {
147
+ if (animationState.intervalId) {
148
+ clearInterval(animationState.intervalId)
149
+ animationState.intervalId = null
150
+ return Promise.resolve(true)
151
+ }
152
+ return Promise.resolve(false)
153
+ }
154
+
155
+ const toggleWindow = async (visible?: boolean): Promise<boolean> => {
156
+ try {
157
+ const window = getCurrentWindow()
158
+ const browserWindow = window.window
159
+
160
+ // Determine target visibility state
161
+ const targetVisible = visible !== undefined ? visible : !browserWindow.isVisible()
162
+
163
+ if (targetVisible) {
164
+ // Show window
165
+ browserWindow.show()
166
+ }
167
+ else {
168
+ // Hide window
169
+ if (process.platform === 'darwin') {
170
+ // On macOS, we can simply hide the window
171
+ browserWindow.hide()
172
+ }
173
+ else {
174
+ // On other platforms, move window far off-screen before hiding
175
+ browserWindow.setPosition(-100000, -100000)
176
+ browserWindow.hide()
177
+ }
178
+ }
179
+
180
+ return Promise.resolve(true)
181
+ }
182
+ catch (error) {
183
+ console.error('Error in toggleWindow:', error)
184
+ return Promise.resolve(false)
185
+ }
186
+ }
187
+
188
+ const changeWindow = (newWindow: TalexTouch.ITouchWindow): void => {
189
+ // Cancel any ongoing animation
190
+ if (animationState.intervalId) {
191
+ clearInterval(animationState.intervalId)
192
+ animationState.intervalId = null
193
+ }
194
+
195
+ // Set new window
196
+ currentWindow = newWindow
197
+ }
198
+
199
+ return {
200
+ updateHeight,
201
+ cancel,
202
+ toggleWindow,
203
+ changeWindow,
204
+ }
205
+ }
@@ -1,5 +1,5 @@
1
+ import type { TalexTouch } from '../types'
1
2
  import gsap from 'gsap'
2
- import { TalexTouch } from '../types'
3
3
 
4
4
  /**
5
5
  * Window animation controller return type
@@ -52,7 +52,7 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
52
52
 
53
53
  const animationState: AnimationState = {
54
54
  tween: null,
55
- completed: false
55
+ completed: false,
56
56
  }
57
57
 
58
58
  /**
@@ -61,9 +61,9 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
61
61
  */
62
62
  const isWindowValid = (): boolean => {
63
63
  return (
64
- currentWindow !== null &&
65
- currentWindow.window !== null &&
66
- !currentWindow.window.isDestroyed()
64
+ currentWindow !== null
65
+ && currentWindow.window !== null
66
+ && !currentWindow.window.isDestroyed()
67
67
  )
68
68
  }
69
69
 
@@ -97,13 +97,13 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
97
97
  return new Promise<boolean>((resolve) => {
98
98
  animationState.tween = gsap.to(
99
99
  {
100
- height: currentHeight
100
+ height: currentHeight,
101
101
  },
102
102
  {
103
103
  height: newHeight,
104
104
  duration,
105
105
  ease: 'cubic-bezier(0.785, 0.135, 0.15, 0.86)',
106
- onUpdate: function () {
106
+ onUpdate() {
107
107
  // Check if animation was cancelled or window destroyed
108
108
  if (!animationState.tween || !isWindowValid()) {
109
109
  resolve(false)
@@ -122,11 +122,12 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
122
122
  onKill: () => {
123
123
  animationState.tween = null
124
124
  resolve(false)
125
- }
126
- }
125
+ },
126
+ },
127
127
  )
128
128
  })
129
- } catch (error) {
129
+ }
130
+ catch (error) {
130
131
  console.error('Error in updateHeight:', error)
131
132
  return Promise.resolve(false)
132
133
  }
@@ -152,12 +153,14 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
152
153
  if (targetVisible) {
153
154
  // Show window
154
155
  browserWindow.show()
155
- } else {
156
+ }
157
+ else {
156
158
  // Hide window
157
159
  if (process.platform === 'darwin') {
158
160
  // On macOS, we can simply hide the window
159
161
  browserWindow.hide()
160
- } else {
162
+ }
163
+ else {
161
164
  // On other platforms, move window far off-screen before hiding
162
165
  browserWindow.setPosition(-100000, -100000)
163
166
  browserWindow.hide()
@@ -165,7 +168,8 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
165
168
  }
166
169
 
167
170
  return Promise.resolve(true)
168
- } catch (error) {
171
+ }
172
+ catch (error) {
169
173
  console.error('Error in toggleWindow:', error)
170
174
  return Promise.resolve(false)
171
175
  }
@@ -186,6 +190,6 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
186
190
  updateHeight,
187
191
  cancel,
188
192
  toggleWindow,
189
- changeWindow
193
+ changeWindow,
190
194
  }
191
- }
195
+ }
@@ -50,7 +50,7 @@ export interface ClerkConfig {
50
50
  afterSignUpUrl?: string
51
51
  }
52
52
 
53
- export type ClerkResourceSnapshot = {
53
+ export interface ClerkResourceSnapshot {
54
54
  user?: any | null
55
55
  session?: { id?: string | null } | null
56
56
  }
package/auth/index.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './clerk-types'
2
+ export * from './useAuthState'
2
3
  export * from './useClerkConfig'
3
4
  export * from './useClerkProvider'
4
- export * from './useAuthState'
@@ -1,13 +1,13 @@
1
+ import type { ClerkAuthState, CurrentUser } from './clerk-types'
1
2
  import { createGlobalState } from '@vueuse/core'
2
- import { shallowReactive } from 'vue'
3
- import { ClerkAuthState, CurrentUser } from './clerk-types'
3
+ import { computed, shallowReactive } from 'vue'
4
4
 
5
5
  export const useAuthState = createGlobalState(() => {
6
6
  const authState = shallowReactive<ClerkAuthState>({
7
7
  isLoaded: false,
8
8
  isSignedIn: false,
9
9
  user: null,
10
- sessionId: null
10
+ sessionId: null,
11
11
  })
12
12
 
13
13
  return { authState }
@@ -25,7 +25,8 @@ export function useCurrentUser() {
25
25
  let name = ''
26
26
  if (firstName || lastName) {
27
27
  name = [firstName, lastName].filter(Boolean).join(' ')
28
- } else {
28
+ }
29
+ else {
29
30
  name = username || ''
30
31
  }
31
32
 
@@ -36,7 +37,7 @@ export function useCurrentUser() {
36
37
  name,
37
38
  email,
38
39
  avatar: imageUrl,
39
- provider: 'clerk'
40
+ provider: 'clerk',
40
41
  }
41
42
  })
42
43
 
@@ -1,7 +1,7 @@
1
- import { ClerkConfig } from "./clerk-types"
1
+ import type { ClerkConfig } from './clerk-types'
2
2
 
3
- const clerkPublishableKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY
4
- const clerkDomain = import.meta.env.VITE_CLERK_DOMAIN
3
+ const clerkPublishableKey = (import.meta.env as any).VITE_CLERK_PUBLISHABLE_KEY
4
+ const clerkDomain = (import.meta.env as any).VITE_CLERK_DOMAIN
5
5
 
6
6
  if (!clerkPublishableKey?.length) {
7
7
  throw new Error('VITE_CLERK_PUBLISHABLE_KEY is not set')
@@ -15,7 +15,7 @@ export const defaultClerkConfig: ClerkConfig = {
15
15
  signInUrl: '/sign-in',
16
16
  signUpUrl: '/sign-up',
17
17
  afterSignInUrl: '/home',
18
- afterSignUpUrl: '/home'
18
+ afterSignUpUrl: '/home',
19
19
  }
20
20
 
21
21
  export function useClerkConfig() {
@@ -23,7 +23,7 @@ export function useClerkConfig() {
23
23
  return {
24
24
  ...defaultClerkConfig,
25
25
  publishableKey:
26
- localStorage.getItem(CLERK_PUBLISHABLE_KEY_KEY) || defaultClerkConfig.publishableKey
26
+ localStorage.getItem(CLERK_PUBLISHABLE_KEY_KEY) || defaultClerkConfig.publishableKey,
27
27
  }
28
28
  }
29
29
 
@@ -35,6 +35,6 @@ export function useClerkConfig() {
35
35
 
36
36
  return {
37
37
  getClerkConfig,
38
- setClerkConfig
38
+ setClerkConfig,
39
39
  }
40
40
  }
@@ -22,7 +22,8 @@ export function useClerkProvider() {
22
22
 
23
23
  console.log('Clerk initialized successfully')
24
24
  return clerkInstance
25
- } catch (error) {
25
+ }
26
+ catch (error) {
26
27
  console.error('Failed to initialize Clerk:', error)
27
28
  throw error
28
29
  }
@@ -46,6 +47,6 @@ export function useClerkProvider() {
46
47
  initializeClerk,
47
48
  getClerk,
48
49
  isClerkInitialized,
49
- cleanupClerk
50
+ cleanupClerk,
50
51
  }
51
52
  }
package/channel/index.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export enum ChannelType {
2
- MAIN = "main",
3
- PLUGIN = "plugin"
2
+ MAIN = 'main',
3
+ PLUGIN = 'plugin',
4
4
  }
5
5
 
6
6
  export enum DataCode {
7
7
  SUCCESS = 200,
8
8
  NETWORK_ERROR = 500,
9
- ERROR = 100
9
+ ERROR = 100,
10
10
  }
11
11
 
12
12
  export type ChannelCallback = (data: StandardChannelData) => any
@@ -20,7 +20,7 @@ export interface ITouchChannel {
20
20
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
21
21
  * @param callback {Function} The callback function
22
22
  */
23
- regChannel(type: ChannelType, eventName: string, callback: ChannelCallback): () => void
23
+ regChannel: (type: ChannelType, eventName: string, callback: ChannelCallback) => () => void
24
24
 
25
25
  /**
26
26
  * Unregister a channel
@@ -30,7 +30,7 @@ export interface ITouchChannel {
30
30
  * @param callback {Function} The callback function to unregister
31
31
  * @returns {boolean} Returns true if the channel was successfully unregistered, false otherwise
32
32
  */
33
- unregChannel(type: ChannelType, eventName: string, callback: ChannelCallback): boolean
33
+ unregChannel: (type: ChannelType, eventName: string, callback: ChannelCallback) => boolean
34
34
 
35
35
  /**
36
36
  * @deprecated Use sendMain instead
@@ -39,7 +39,7 @@ export interface ITouchChannel {
39
39
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
40
40
  * @param arg {any} The arguments of the message
41
41
  */
42
- send(type: ChannelType, eventName: string, arg?: any): Promise<any>
42
+ send: (type: ChannelType, eventName: string, arg?: any) => Promise<any>
43
43
 
44
44
  /**
45
45
  * @deprecated Use sendToMain instead
@@ -49,14 +49,14 @@ export interface ITouchChannel {
49
49
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
50
50
  * @param arg {any} The arguments of the message
51
51
  */
52
- sendTo(win: Electron.BrowserWindow, type: ChannelType, eventName: string, arg: any): Promise<any>
52
+ sendTo: (win: Electron.BrowserWindow, type: ChannelType, eventName: string, arg: any) => Promise<any>
53
53
 
54
54
  /**
55
55
  * Send a message to main process
56
56
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
57
57
  * @param arg {any} The arguments of the message
58
58
  */
59
- sendMain(eventName: string, arg?: any): Promise<any>
59
+ sendMain: (eventName: string, arg?: any) => Promise<any>
60
60
 
61
61
  /**
62
62
  * Send a message to main process with settled window
@@ -64,14 +64,14 @@ export interface ITouchChannel {
64
64
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
65
65
  * @param arg {any} The arguments of the message
66
66
  */
67
- sendToMain(win: Electron.BrowserWindow, eventName: string, arg?: any): Promise<any>
67
+ sendToMain: (win: Electron.BrowserWindow, eventName: string, arg?: any) => Promise<any>
68
68
 
69
69
  /**
70
70
  * Send a message to all plugin process with settled window
71
71
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
72
72
  * @param arg {any} The arguments of the message
73
73
  */
74
- sendPlugin(pluginName: string, eventName: string, arg?: any): Promise<any>
74
+ sendPlugin: (pluginName: string, eventName: string, arg?: any) => Promise<any>
75
75
 
76
76
  /**
77
77
  * Send a message to plugin process with settled window
@@ -79,7 +79,7 @@ export interface ITouchChannel {
79
79
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
80
80
  * @param arg {any} The arguments of the message
81
81
  */
82
- sendToPlugin(pluginName: string, eventName: string, arg?: any): Promise<any>
82
+ sendToPlugin: (pluginName: string, eventName: string, arg?: any) => Promise<any>
83
83
 
84
84
  /**
85
85
  * Request a encrypted name key. This key cannot decrypted to get the original name.
@@ -106,7 +106,7 @@ export interface ITouchClientChannel {
106
106
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType
107
107
  * @param callback {Function} The callback function
108
108
  */
109
- regChannel(eventName: string, callback: (data: StandardChannelData) => any): () => void
109
+ regChannel: (eventName: string, callback: (data: StandardChannelData) => any) => () => void
110
110
 
111
111
  /**
112
112
  * Unregister a channel
@@ -115,21 +115,21 @@ export interface ITouchClientChannel {
115
115
  * @param callback {Function} The callback function to unregister
116
116
  * @returns {boolean} Returns true if the channel was successfully unregistered, false otherwise
117
117
  */
118
- unRegChannel(eventName: string, callback: (data: StandardChannelData) => any): boolean
118
+ unRegChannel: (eventName: string, callback: (data: StandardChannelData) => any) => boolean
119
119
 
120
120
  /**
121
121
  * Send a message to a channel
122
122
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
123
123
  * @param arg {any} The arguments of the message
124
124
  */
125
- send(eventName: string, arg?: any): Promise<any>
125
+ send: (eventName: string, arg?: any) => Promise<any>
126
126
 
127
127
  /**
128
128
  * Send a message to a channel and get the response
129
129
  * @param eventName {string} The name of event, must be unique in the channel {@link ChannelType}
130
130
  * @param arg {any} The arguments of the message
131
131
  */
132
- sendSync(eventName: string, arg?: any): any
132
+ sendSync: (eventName: string, arg?: any) => any
133
133
  }
134
134
 
135
135
  export interface RawChannelSyncData {
@@ -149,11 +149,12 @@ export interface RawChannelSyncData {
149
149
  }
150
150
 
151
151
  export interface RawChannelHeaderData {
152
- status: "reply" | "request";
153
- type: ChannelType;
154
- _originData?: any;
152
+ status: 'reply' | 'request'
153
+ type: ChannelType
154
+ _originData?: any
155
155
  uniqueKey?: string
156
- event?: Electron.IpcMainEvent | Electron.IpcRendererEvent;
156
+ event?: Electron.IpcMainEvent | Electron.IpcMainInvokeEvent | Electron.IpcRendererEvent
157
+ plugin?: string
157
158
  }
158
159
 
159
160
  export interface RawChannelData {
@@ -172,6 +173,12 @@ export interface StandardChannelData extends RawStandardChannelData {
172
173
  reply: (code: DataCode, data: IChannelData) => void
173
174
  }
174
175
 
175
- export type IChannelData = any //boolean | number | string | null | undefined | {
176
- // [prop: string]: any
176
+ export type IChannelData = any // boolean | number | string | null | undefined | {
177
+ // [prop: string]: any
177
178
  // }
179
+
180
+ // Default export for Vite compatibility (only values, not types)
181
+ export default {
182
+ ChannelType,
183
+ DataCode,
184
+ }