@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.
- package/animation/window-node.ts +15 -12
- package/animation/window.ts +19 -15
- package/auth/clerk-types.ts +1 -1
- package/auth/index.ts +1 -1
- package/auth/useAuthState.ts +6 -5
- package/auth/useClerkConfig.ts +4 -4
- package/auth/useClerkProvider.ts +3 -2
- package/channel/index.ts +23 -22
- package/common/file-scan-constants.ts +137 -121
- package/common/file-scan-utils.ts +48 -27
- package/common/index.ts +3 -3
- package/common/search/gather.ts +1 -1
- package/common/search/index.ts +5 -6
- package/common/storage/constants.ts +3 -2
- package/common/storage/entity/app-settings.ts +5 -3
- package/common/storage/entity/shortcut-settings.ts +10 -10
- package/common/storage/shortcut-storage.ts +6 -4
- package/common/utils/file.ts +14 -6
- package/common/utils/index.ts +62 -52
- package/common/utils/polling.ts +88 -84
- package/common/utils/task-queue.ts +11 -10
- package/common/utils/time.ts +50 -47
- package/common/utils/timing.ts +41 -37
- package/core-box/builder/index.ts +1 -1
- package/core-box/builder/tuff-builder.ts +254 -229
- package/core-box/index.ts +4 -6
- package/core-box/preview/index.ts +1 -0
- package/core-box/preview/types.ts +43 -0
- package/core-box/recommendation.ts +77 -0
- package/core-box/tuff/index.ts +1 -1
- package/core-box/tuff/tuff-dsl.ts +328 -266
- package/electron/download-manager.ts +43 -42
- package/electron/env-tool.ts +19 -18
- package/electron/file-parsers/index.ts +2 -2
- package/electron/file-parsers/parsers/text-parser.ts +15 -14
- package/electron/file-parsers/registry.ts +9 -7
- package/electron/file-parsers/types.ts +4 -4
- package/electron/index.ts +2 -2
- package/eventbus/index.ts +11 -11
- package/index.ts +5 -4
- package/intelligence/client.ts +87 -0
- package/intelligence/index.ts +1 -0
- package/package.json +14 -14
- package/permission/index.ts +8 -8
- package/plugin/channel.ts +77 -68
- package/plugin/index.ts +96 -82
- package/plugin/install.ts +8 -8
- package/plugin/log/types.ts +5 -5
- package/plugin/node/index.ts +1 -1
- package/plugin/node/logger-manager.ts +14 -11
- package/plugin/node/logger.ts +8 -8
- package/plugin/plugin-source.ts +11 -11
- package/plugin/preload.ts +1 -1
- package/plugin/providers/registry.ts +8 -7
- package/plugin/providers/types.ts +6 -6
- package/plugin/sdk/README.md +216 -0
- package/plugin/sdk/box-sdk.ts +219 -0
- package/plugin/sdk/channel.ts +20 -20
- package/plugin/sdk/clipboard.ts +8 -6
- package/plugin/sdk/common.ts +10 -6
- package/plugin/sdk/core-box.ts +2 -3
- package/plugin/sdk/division-box.ts +266 -0
- package/plugin/sdk/enum/bridge-event.ts +1 -1
- package/plugin/sdk/examples/storage-onDidChange-example.js +1 -1
- package/plugin/sdk/feature-sdk.ts +235 -0
- package/plugin/sdk/features.ts +34 -26
- package/plugin/sdk/hooks/bridge.ts +3 -6
- package/plugin/sdk/hooks/index.ts +1 -1
- package/plugin/sdk/hooks/life-cycle.ts +4 -10
- package/plugin/sdk/index.ts +10 -7
- package/plugin/sdk/service/index.ts +3 -3
- package/plugin/sdk/storage.ts +4 -4
- package/plugin/sdk/system.ts +1 -1
- package/plugin/sdk/types.ts +165 -146
- package/plugin/sdk/window/index.ts +8 -5
- package/preload/loading.ts +6 -6
- package/preload/renderer.ts +4 -2
- package/renderer/hooks/arg-mapper.ts +1 -2
- package/renderer/hooks/index.ts +2 -0
- package/renderer/hooks/initialize.ts +10 -8
- package/renderer/hooks/performance.ts +4 -4
- package/renderer/hooks/use-channel.ts +150 -0
- package/renderer/hooks/use-intelligence.ts +236 -0
- package/renderer/index.ts +6 -2
- package/renderer/ref.ts +32 -36
- package/renderer/slots.ts +29 -26
- package/renderer/storage/app-settings.ts +16 -6
- package/renderer/storage/base-storage.ts +222 -114
- package/renderer/storage/index.ts +3 -0
- package/renderer/storage/intelligence-storage.ts +218 -0
- package/renderer/storage/openers.ts +13 -3
- package/renderer/touch-sdk/env.ts +41 -41
- package/renderer/touch-sdk/index.ts +1 -1
- package/renderer/touch-sdk/terminal.ts +5 -5
- package/renderer/touch-sdk/utils.ts +4 -3
- package/search/levenshtein-utils.ts +11 -11
- package/search/types.ts +102 -102
- package/service/index.ts +11 -11
- package/service/protocol/index.ts +217 -14
- package/types/division-box.ts +248 -0
- package/types/download.ts +72 -34
- package/types/index.ts +3 -1
- package/types/intelligence.ts +607 -0
- package/types/modules/base.ts +16 -16
- package/types/modules/index.ts +1 -1
- package/types/modules/module-lifecycle.ts +21 -21
- package/types/modules/module-manager.ts +11 -11
- package/types/modules/module.ts +16 -16
- package/types/storage.ts +0 -1
- package/types/touch-app-core.ts +32 -32
- package/types/update.ts +91 -21
- package/core-box/README.md +0 -218
- package/core-box/builder/tuff-builder.example.ts.bak +0 -258
- package/core-box/run-tests.sh +0 -7
- package/core-box/search.ts +0 -1
- 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
|