@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,199 +0,0 @@
1
- import { clipboard } from 'electron'
2
-
3
- /**
4
- * Represents a file object from the clipboard
5
- */
6
- interface ClipboardFileInfo {
7
- /** File data as a buffer */
8
- buffer: Buffer
9
- /** MIME type of the file */
10
- mimetype: string
11
- /** Original filename */
12
- originalname: string
13
- }
14
-
15
- /**
16
- * Possible return types from clipboard file operations
17
- */
18
- export type ClipboardFileResult = string | ClipboardFileInfo
19
-
20
- /**
21
- * Utility class for handling clipboard file operations across different platforms
22
- */
23
- export class ClipboardHelper {
24
- /**
25
- * Check if the current platform is macOS
26
- * @private
27
- */
28
- private get isMac(): boolean {
29
- return process.platform === 'darwin'
30
- }
31
-
32
- /**
33
- * Generate a unique identifier with specified length and radix
34
- * @param length - Length of the generated string
35
- * @param radix - Radix for number conversion (default: 16)
36
- * @returns Generated unique identifier
37
- * @private
38
- */
39
- private generateUuid(length: number, radix: number = 16): string {
40
- const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')
41
- const uuid: string[] = []
42
- let i: number
43
-
44
- radix = radix || chars.length
45
-
46
- if (length) {
47
- for (i = 0; i < length; i++) {
48
- uuid[i] = chars[0 | (Math.random() * radix)]
49
- }
50
- } else {
51
- let r: number
52
- uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'
53
- uuid[14] = '4'
54
-
55
- for (i = 0; i < 36; i++) {
56
- if (!uuid[i]) {
57
- r = 0 | (Math.random() * 16)
58
- uuid[i] = chars[i === 19 ? (r & 0x3) | 0x8 : r]
59
- }
60
- }
61
- }
62
-
63
- return uuid.join('')
64
- }
65
-
66
- /**
67
- * Process clipboard files on macOS platform
68
- * @returns Array of file paths or file info objects
69
- * @private
70
- */
71
- private getClipboardFilesMac(): ClipboardFileResult[] {
72
- let filePath: ClipboardFileResult[] = []
73
-
74
- if (clipboard.has('NSFilenamesPboardType')) {
75
- // Handle multiple files
76
- const tagContent = clipboard.read('NSFilenamesPboardType').match(/<string>.*<\/string>/g)
77
- filePath = tagContent ? tagContent.map(item => item.replace(/<string>|<\/string>/g, '')) : []
78
- } else {
79
- // Handle single file
80
- const clipboardImage = clipboard.readImage('clipboard')
81
- if (!clipboardImage.isEmpty()) {
82
- // Handle image from clipboard
83
- const png = clipboardImage.toPNG()
84
- const fileInfo: ClipboardFileInfo = {
85
- buffer: png,
86
- mimetype: 'image/png',
87
- originalname: this.generateUuid(8, 16) + '.png'
88
- }
89
- filePath = [fileInfo]
90
- } else {
91
- // Handle single file path
92
- const fileUrl = clipboard.read('public.file-url')
93
- if (fileUrl) {
94
- filePath = [fileUrl.replace('file://', '')].filter(item => item)
95
- }
96
- }
97
- }
98
-
99
- return filePath
100
- }
101
-
102
- /**
103
- * Process clipboard files on Windows platform
104
- * @returns Array of file paths or file info objects
105
- * @private
106
- */
107
- private getClipboardFilesWindows(): ClipboardFileResult[] {
108
- let filePath: ClipboardFileResult[] = []
109
-
110
- if (clipboard.has('CF_HDROP')) {
111
- // Handle multiple files
112
- const rawFilePathStr = clipboard.readBuffer('CF_HDROP').toString('ucs2') || ''
113
- let formatFilePathStr = [...rawFilePathStr]
114
- .filter((_, index) => rawFilePathStr.charCodeAt(index) !== 0)
115
- .join('')
116
- .replace(/\\/g, '\\\\')
117
-
118
- const drivePrefix = formatFilePathStr.match(/[a-zA-Z]:\\/)
119
-
120
- if (drivePrefix) {
121
- const drivePrefixIndex = formatFilePathStr.indexOf(drivePrefix[0])
122
- if (drivePrefixIndex !== 0) {
123
- formatFilePathStr = formatFilePathStr.substring(drivePrefixIndex)
124
- }
125
- filePath = formatFilePathStr
126
- .split(drivePrefix[0])
127
- .filter(item => item)
128
- .map(item => drivePrefix[0] + item)
129
- }
130
- } else {
131
- // Handle single file
132
- const clipboardImage = clipboard.readImage('clipboard')
133
- if (!clipboardImage.isEmpty()) {
134
- // Handle image from clipboard
135
- const png = clipboardImage.toPNG()
136
- const fileInfo: ClipboardFileInfo = {
137
- buffer: png,
138
- mimetype: 'image/png',
139
- originalname: this.generateUuid(8, 16) + '.png'
140
- }
141
- filePath = [fileInfo]
142
- } else {
143
- // Handle single file path
144
- try {
145
- const fileName = clipboard.readBuffer('FileNameW').toString('ucs2').replace(RegExp(String.fromCharCode(0), 'g'), '')
146
- if (fileName) {
147
- filePath = [fileName]
148
- }
149
- } catch (error) {
150
- // Ignore read errors for non-file clipboard content
151
- }
152
- }
153
- }
154
-
155
- return filePath
156
- }
157
-
158
- /**
159
- * Retrieves file paths or file information from the system clipboard
160
- *
161
- * This method handles both file paths and images from the clipboard across different platforms.
162
- * On macOS, it uses NSFilenamesPboardType for multiple files and public.file-url for single files.
163
- * On Windows, it uses CF_HDROP for multiple files and FileNameW for single files.
164
- *
165
- * @returns Array of file paths (strings) or file info objects containing buffer data for images
166
- * @throws {Error} When clipboard access fails or platform is unsupported
167
- *
168
- * @example
169
- * ```typescript
170
- * const clipboardHelper = new ClipboardHelper()
171
- * const files = clipboardHelper.getClipboardFiles()
172
- *
173
- * files.forEach(file => {
174
- * if (typeof file === 'string') {
175
- * console.log('File path:', file)
176
- * } else {
177
- * console.log('Image file:', file.originalname, 'Size:', file.buffer.length)
178
- * }
179
- * })
180
- * ```
181
- */
182
- public getClipboardFiles(): ClipboardFileResult[] {
183
- try {
184
- if (this.isMac) {
185
- return this.getClipboardFilesMac()
186
- } else {
187
- return this.getClipboardFilesWindows()
188
- }
189
- } catch (error) {
190
- console.error('Failed to read clipboard files:', error)
191
- return []
192
- }
193
- }
194
- }
195
-
196
- /**
197
- * Default export of ClipboardHelper class for convenience
198
- */
199
- export default ClipboardHelper