@talex-touch/utils 1.0.31 → 1.0.33

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 (116) hide show
  1. package/animation/window-node.ts +15 -12
  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 +4 -4
  7. package/auth/useClerkProvider.ts +3 -2
  8. package/channel/index.ts +23 -22
  9. package/common/file-scan-constants.ts +137 -121
  10. package/common/file-scan-utils.ts +48 -27
  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 +5 -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 +14 -6
  19. package/common/utils/index.ts +62 -52
  20. package/common/utils/polling.ts +88 -84
  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 +254 -229
  26. package/core-box/index.ts +4 -6
  27. package/core-box/preview/index.ts +1 -0
  28. package/core-box/preview/types.ts +43 -0
  29. package/core-box/recommendation.ts +77 -0
  30. package/core-box/tuff/index.ts +1 -1
  31. package/core-box/tuff/tuff-dsl.ts +328 -266
  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 +2 -2
  39. package/eventbus/index.ts +11 -11
  40. package/index.ts +5 -4
  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 +96 -82
  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 +1 -1
  54. package/plugin/providers/registry.ts +8 -7
  55. package/plugin/providers/types.ts +6 -6
  56. package/plugin/sdk/README.md +216 -0
  57. package/plugin/sdk/box-sdk.ts +219 -0
  58. package/plugin/sdk/channel.ts +20 -20
  59. package/plugin/sdk/clipboard.ts +8 -6
  60. package/plugin/sdk/common.ts +10 -6
  61. package/plugin/sdk/core-box.ts +2 -3
  62. package/plugin/sdk/division-box.ts +266 -0
  63. package/plugin/sdk/enum/bridge-event.ts +1 -1
  64. package/plugin/sdk/examples/storage-onDidChange-example.js +1 -1
  65. package/plugin/sdk/feature-sdk.ts +235 -0
  66. package/plugin/sdk/features.ts +34 -26
  67. package/plugin/sdk/hooks/bridge.ts +3 -6
  68. package/plugin/sdk/hooks/index.ts +1 -1
  69. package/plugin/sdk/hooks/life-cycle.ts +4 -10
  70. package/plugin/sdk/index.ts +10 -7
  71. package/plugin/sdk/service/index.ts +3 -3
  72. package/plugin/sdk/storage.ts +4 -4
  73. package/plugin/sdk/system.ts +1 -1
  74. package/plugin/sdk/types.ts +165 -146
  75. package/plugin/sdk/window/index.ts +8 -5
  76. package/preload/loading.ts +6 -6
  77. package/preload/renderer.ts +4 -2
  78. package/renderer/hooks/arg-mapper.ts +1 -2
  79. package/renderer/hooks/index.ts +2 -0
  80. package/renderer/hooks/initialize.ts +10 -8
  81. package/renderer/hooks/performance.ts +4 -4
  82. package/renderer/hooks/use-channel.ts +150 -0
  83. package/renderer/hooks/use-intelligence.ts +236 -0
  84. package/renderer/index.ts +6 -2
  85. package/renderer/ref.ts +32 -36
  86. package/renderer/slots.ts +29 -26
  87. package/renderer/storage/app-settings.ts +16 -6
  88. package/renderer/storage/base-storage.ts +222 -114
  89. package/renderer/storage/index.ts +3 -0
  90. package/renderer/storage/intelligence-storage.ts +218 -0
  91. package/renderer/storage/openers.ts +13 -3
  92. package/renderer/touch-sdk/env.ts +41 -41
  93. package/renderer/touch-sdk/index.ts +1 -1
  94. package/renderer/touch-sdk/terminal.ts +5 -5
  95. package/renderer/touch-sdk/utils.ts +4 -3
  96. package/search/levenshtein-utils.ts +11 -11
  97. package/search/types.ts +102 -102
  98. package/service/index.ts +11 -11
  99. package/service/protocol/index.ts +217 -14
  100. package/types/division-box.ts +248 -0
  101. package/types/download.ts +72 -34
  102. package/types/index.ts +3 -1
  103. package/types/intelligence.ts +607 -0
  104. package/types/modules/base.ts +16 -16
  105. package/types/modules/index.ts +1 -1
  106. package/types/modules/module-lifecycle.ts +21 -21
  107. package/types/modules/module-manager.ts +11 -11
  108. package/types/modules/module.ts +16 -16
  109. package/types/storage.ts +0 -1
  110. package/types/touch-app-core.ts +32 -32
  111. package/types/update.ts +91 -21
  112. package/core-box/README.md +0 -218
  113. package/core-box/builder/tuff-builder.example.ts.bak +0 -258
  114. package/core-box/run-tests.sh +0 -7
  115. package/core-box/search.ts +0 -1
  116. package/electron/clipboard-helper.ts +0 -199
@@ -1,4 +1,4 @@
1
- import { TalexTouch } from '../types'
1
+ import type { TalexTouch } from '../types'
2
2
 
3
3
  /**
4
4
  * Window animation controller return type
@@ -44,7 +44,7 @@ interface AnimationState {
44
44
  * Simple easing function for smooth animation
45
45
  */
46
46
  function easeInOutCubic(t: number): number {
47
- return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2
47
+ return t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2
48
48
  }
49
49
 
50
50
  /**
@@ -58,7 +58,7 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
58
58
 
59
59
  const animationState: AnimationState = {
60
60
  intervalId: null,
61
- completed: false
61
+ completed: false,
62
62
  }
63
63
 
64
64
  /**
@@ -67,9 +67,9 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
67
67
  */
68
68
  const isWindowValid = (): boolean => {
69
69
  return (
70
- currentWindow !== null &&
71
- currentWindow.window !== null &&
72
- !currentWindow.window.isDestroyed()
70
+ currentWindow !== null
71
+ && currentWindow.window !== null
72
+ && !currentWindow.window.isDestroyed()
73
73
  )
74
74
  }
75
75
 
@@ -136,7 +136,8 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
136
136
  }
137
137
  }, 16) // ~60fps
138
138
  })
139
- } catch (error) {
139
+ }
140
+ catch (error) {
140
141
  console.error('Error in updateHeight:', error)
141
142
  return Promise.resolve(false)
142
143
  }
@@ -162,12 +163,14 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
162
163
  if (targetVisible) {
163
164
  // Show window
164
165
  browserWindow.show()
165
- } else {
166
+ }
167
+ else {
166
168
  // Hide window
167
169
  if (process.platform === 'darwin') {
168
170
  // On macOS, we can simply hide the window
169
171
  browserWindow.hide()
170
- } else {
172
+ }
173
+ else {
171
174
  // On other platforms, move window far off-screen before hiding
172
175
  browserWindow.setPosition(-100000, -100000)
173
176
  browserWindow.hide()
@@ -175,7 +178,8 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
175
178
  }
176
179
 
177
180
  return Promise.resolve(true)
178
- } catch (error) {
181
+ }
182
+ catch (error) {
179
183
  console.error('Error in toggleWindow:', error)
180
184
  return Promise.resolve(false)
181
185
  }
@@ -196,7 +200,6 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
196
200
  updateHeight,
197
201
  cancel,
198
202
  toggleWindow,
199
- changeWindow
203
+ changeWindow,
200
204
  }
201
205
  }
202
-
@@ -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, computed } 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,4 +1,4 @@
1
- import { ClerkConfig } from "./clerk-types"
1
+ import type { ClerkConfig } from './clerk-types'
2
2
 
3
3
  const clerkPublishableKey = (import.meta.env as any).VITE_CLERK_PUBLISHABLE_KEY
4
4
  const clerkDomain = (import.meta.env as any).VITE_CLERK_DOMAIN
@@ -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,12 +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
  // }
178
179
 
179
180
  // Default export for Vite compatibility (only values, not types)
180
181
  export default {
181
182
  ChannelType,
182
- DataCode
183
+ DataCode,
183
184
  }