@talex-touch/utils 1.0.31 → 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.
- 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 +87 -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 +3 -6
- package/core-box/preview/index.ts +1 -0
- package/core-box/preview/types.ts +43 -0
- package/core-box/tuff/index.ts +1 -1
- package/core-box/tuff/tuff-dsl.ts +328 -266
- package/electron/clipboard-helper.ts +20 -12
- 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 +1 -1
- 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/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/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 +8 -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 +147 -141
- 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 +215 -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 +413 -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 +79 -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/plugin/sdk/types.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* @version 1.0.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { ITouchChannel, ITouchClientChannel, StandardChannelData } from '@talex-touch/utils/channel'
|
|
8
|
-
import type { IPluginFeature } from '../index'
|
|
7
|
+
import type { ITouchChannel, ITouchClientChannel, StandardChannelData } from '@talex-touch/utils/channel'
|
|
8
|
+
import type { IPluginFeature } from '../index'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Handler signature for plugin channel events.
|
|
12
12
|
*/
|
|
13
|
-
export type PluginChannelHandler = (event: StandardChannelData) => any
|
|
13
|
+
export type PluginChannelHandler = (event: StandardChannelData) => any
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Bridge exposed to plugin backends for channel-based communication.
|
|
@@ -21,14 +21,14 @@ export interface IPluginChannelBridge {
|
|
|
21
21
|
* @param eventName - Channel event name.
|
|
22
22
|
* @param payload - Optional data payload.
|
|
23
23
|
*/
|
|
24
|
-
sendToMain<T = any>(eventName: string, payload?: any)
|
|
24
|
+
sendToMain: <T = any>(eventName: string, payload?: any) => Promise<T>
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Sends a payload to this plugin's renderer view.
|
|
28
28
|
* @param eventName - Channel event name.
|
|
29
29
|
* @param payload - Optional data payload.
|
|
30
30
|
*/
|
|
31
|
-
sendToRenderer<T = any>(eventName: string, payload?: any)
|
|
31
|
+
sendToRenderer: <T = any>(eventName: string, payload?: any) => Promise<T>
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Registers a handler for main renderer messages.
|
|
@@ -36,7 +36,7 @@ export interface IPluginChannelBridge {
|
|
|
36
36
|
* @param handler - Handler invoked with the raw channel event.
|
|
37
37
|
* @returns Unsubscribe function.
|
|
38
38
|
*/
|
|
39
|
-
onMain(eventName: string, handler: PluginChannelHandler)
|
|
39
|
+
onMain: (eventName: string, handler: PluginChannelHandler) => () => void
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Registers a handler for renderer-originated messages scoped to this plugin.
|
|
@@ -44,12 +44,12 @@ export interface IPluginChannelBridge {
|
|
|
44
44
|
* @param handler - Handler invoked with the raw channel event.
|
|
45
45
|
* @returns Unsubscribe function.
|
|
46
46
|
*/
|
|
47
|
-
onRenderer(eventName: string, handler: PluginChannelHandler)
|
|
47
|
+
onRenderer: (eventName: string, handler: PluginChannelHandler) => () => void
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Access to the underlying channel implementation for advanced scenarios.
|
|
51
51
|
*/
|
|
52
|
-
readonly raw: ITouchChannel
|
|
52
|
+
readonly raw: ITouchChannel
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -59,29 +59,29 @@ export interface IPluginRendererChannel {
|
|
|
59
59
|
/**
|
|
60
60
|
* Sends a message asynchronously and resolves with the reply payload.
|
|
61
61
|
*/
|
|
62
|
-
send<T = any>(eventName: string, payload?: any)
|
|
62
|
+
send: <T = any>(eventName: string, payload?: any) => Promise<T>
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Sends a message synchronously and returns the reply payload.
|
|
66
66
|
*/
|
|
67
|
-
sendSync<T = any>(eventName: string, payload?: any)
|
|
67
|
+
sendSync: <T = any>(eventName: string, payload?: any) => T
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Registers a handler for renderer channel events.
|
|
71
71
|
* @returns Unsubscribe function.
|
|
72
72
|
*/
|
|
73
|
-
on(eventName: string, handler: PluginChannelHandler)
|
|
73
|
+
on: (eventName: string, handler: PluginChannelHandler) => () => void
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Registers a one-off handler for a renderer channel event.
|
|
77
77
|
* @returns Unsubscribe function (no-op after invocation).
|
|
78
78
|
*/
|
|
79
|
-
once(eventName: string, handler: PluginChannelHandler)
|
|
79
|
+
once: (eventName: string, handler: PluginChannelHandler) => () => void
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* Provides access to the raw client channel.
|
|
83
83
|
*/
|
|
84
|
-
readonly raw: ITouchClientChannel
|
|
84
|
+
readonly raw: ITouchClientChannel
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/**
|
|
@@ -133,84 +133,90 @@ export interface IPluginUtils {
|
|
|
133
133
|
* HTTP client for network requests (axios instance)
|
|
134
134
|
* @remarks Provides direct access to axios for making HTTP requests
|
|
135
135
|
*/
|
|
136
|
-
http: any
|
|
136
|
+
http: any
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
* Data storage manager for persistent data operations
|
|
140
140
|
* @see {@link IStorageManager}
|
|
141
141
|
*/
|
|
142
|
-
storage: IStorageManager
|
|
142
|
+
storage: IStorageManager
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Clipboard manager for system clipboard operations
|
|
146
146
|
* @see {@link IClipboardManager}
|
|
147
147
|
*/
|
|
148
|
-
clipboard: IClipboardManager
|
|
148
|
+
clipboard: IClipboardManager
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
151
|
* Channel bridge for communicating with renderer and main processes
|
|
152
152
|
* @see {@link IPluginChannelBridge}
|
|
153
153
|
*/
|
|
154
|
-
channel: IPluginChannelBridge
|
|
154
|
+
channel: IPluginChannelBridge
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* Search result manager for handling search operations
|
|
158
158
|
* @see {@link ISearchManager}
|
|
159
159
|
*/
|
|
160
|
-
search: ISearchManager
|
|
160
|
+
search: ISearchManager
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
163
|
* Dialog manager for system dialog operations
|
|
164
164
|
* @see {@link IDialogManager}
|
|
165
165
|
*/
|
|
166
|
-
dialog: IDialogManager
|
|
166
|
+
dialog: IDialogManager
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* Logger for plugin logging operations
|
|
170
170
|
* @see {@link ILogger}
|
|
171
171
|
*/
|
|
172
|
-
logger: ILogger
|
|
172
|
+
logger: ILogger
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Event manager for plugin event handling
|
|
176
176
|
* @see {@link IEventManager}
|
|
177
177
|
*/
|
|
178
|
-
$event: IEventManager
|
|
178
|
+
$event: IEventManager
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* DivisionBox manager for creating floating window containers
|
|
182
|
+
* @see {@link DivisionBoxSDK}
|
|
183
|
+
*/
|
|
184
|
+
divisionBox: import('./division-box').DivisionBoxSDK
|
|
179
185
|
|
|
180
186
|
/**
|
|
181
187
|
* Opens a URL in the default browser
|
|
182
188
|
* @param url - The URL to open
|
|
183
189
|
*/
|
|
184
|
-
openUrl: (url: string) => void
|
|
190
|
+
openUrl: (url: string) => void
|
|
185
191
|
|
|
186
192
|
/**
|
|
187
193
|
* Pushes search result items to the search interface
|
|
188
194
|
* @param items - Array of search result items to add
|
|
189
195
|
*/
|
|
190
|
-
pushItems: (items: any[]) => void
|
|
196
|
+
pushItems: (items: any[]) => void
|
|
191
197
|
|
|
192
198
|
/**
|
|
193
199
|
* Clears all current search results
|
|
194
200
|
*/
|
|
195
|
-
clearItems: () => void
|
|
201
|
+
clearItems: () => void
|
|
196
202
|
|
|
197
203
|
/**
|
|
198
204
|
* Gets all current search result items
|
|
199
205
|
* @returns Array of current search result items
|
|
200
206
|
*/
|
|
201
|
-
getItems: () => any[]
|
|
207
|
+
getItems: () => any[]
|
|
202
208
|
|
|
203
209
|
/**
|
|
204
210
|
* Features manager for dynamic feature management
|
|
205
211
|
* @see {@link IFeaturesManager}
|
|
206
212
|
*/
|
|
207
|
-
features: IFeaturesManager
|
|
213
|
+
features: IFeaturesManager
|
|
208
214
|
|
|
209
215
|
/**
|
|
210
216
|
* Plugin information manager
|
|
211
217
|
* @see {@link IPluginInfoManager}
|
|
212
218
|
*/
|
|
213
|
-
plugin: IPluginInfoManager
|
|
219
|
+
plugin: IPluginInfoManager
|
|
214
220
|
}
|
|
215
221
|
|
|
216
222
|
/**
|
|
@@ -226,7 +232,7 @@ export interface IStorageManager {
|
|
|
226
232
|
* @param value - The value to store (will be JSON serialized)
|
|
227
233
|
* @returns Promise that resolves when the value is stored
|
|
228
234
|
*/
|
|
229
|
-
set(key: string, value: any)
|
|
235
|
+
set: (key: string, value: any) => Promise<void>
|
|
230
236
|
|
|
231
237
|
/**
|
|
232
238
|
* Gets a value for the given key
|
|
@@ -234,33 +240,33 @@ export interface IStorageManager {
|
|
|
234
240
|
* @param defaultValue - Default value to return if key doesn't exist
|
|
235
241
|
* @returns Promise that resolves to the stored value or default value
|
|
236
242
|
*/
|
|
237
|
-
get(key: string, defaultValue?: any)
|
|
243
|
+
get: (key: string, defaultValue?: any) => Promise<any>
|
|
238
244
|
|
|
239
245
|
/**
|
|
240
246
|
* Checks if a key exists in storage
|
|
241
247
|
* @param key - The storage key to check
|
|
242
248
|
* @returns Promise that resolves to true if key exists, false otherwise
|
|
243
249
|
*/
|
|
244
|
-
has(key: string)
|
|
250
|
+
has: (key: string) => Promise<boolean>
|
|
245
251
|
|
|
246
252
|
/**
|
|
247
253
|
* Removes a key from storage
|
|
248
254
|
* @param key - The storage key to remove
|
|
249
255
|
* @returns Promise that resolves when the key is removed
|
|
250
256
|
*/
|
|
251
|
-
remove(key: string)
|
|
257
|
+
remove: (key: string) => Promise<void>
|
|
252
258
|
|
|
253
259
|
/**
|
|
254
260
|
* Clears all stored data
|
|
255
261
|
* @returns Promise that resolves when all data is cleared
|
|
256
262
|
*/
|
|
257
|
-
clear()
|
|
263
|
+
clear: () => Promise<void>
|
|
258
264
|
|
|
259
265
|
/**
|
|
260
266
|
* Gets all storage keys
|
|
261
267
|
* @returns Promise that resolves to an array of all storage keys
|
|
262
268
|
*/
|
|
263
|
-
keys()
|
|
269
|
+
keys: () => Promise<string[]>
|
|
264
270
|
}
|
|
265
271
|
|
|
266
272
|
/**
|
|
@@ -274,42 +280,42 @@ export interface IClipboardManager {
|
|
|
274
280
|
* Reads text from the clipboard
|
|
275
281
|
* @returns The text content from clipboard
|
|
276
282
|
*/
|
|
277
|
-
readText()
|
|
283
|
+
readText: () => string
|
|
278
284
|
|
|
279
285
|
/**
|
|
280
286
|
* Writes text to the clipboard
|
|
281
287
|
* @param text - The text to write to clipboard
|
|
282
288
|
*/
|
|
283
|
-
writeText(text: string)
|
|
289
|
+
writeText: (text: string) => void
|
|
284
290
|
|
|
285
291
|
/**
|
|
286
292
|
* Reads image from the clipboard
|
|
287
293
|
* @returns The image data from clipboard, or null if no image
|
|
288
294
|
*/
|
|
289
|
-
readImage()
|
|
295
|
+
readImage: () => any | null
|
|
290
296
|
|
|
291
297
|
/**
|
|
292
298
|
* Writes image to the clipboard
|
|
293
299
|
* @param image - The image data to write to clipboard
|
|
294
300
|
*/
|
|
295
|
-
writeImage(image: any)
|
|
301
|
+
writeImage: (image: any) => void
|
|
296
302
|
|
|
297
303
|
/**
|
|
298
304
|
* Clears the clipboard content
|
|
299
305
|
*/
|
|
300
|
-
clear()
|
|
306
|
+
clear: () => void
|
|
301
307
|
|
|
302
308
|
/**
|
|
303
309
|
* Checks if clipboard contains text
|
|
304
310
|
* @returns True if clipboard has text content, false otherwise
|
|
305
311
|
*/
|
|
306
|
-
hasText()
|
|
312
|
+
hasText: () => boolean
|
|
307
313
|
|
|
308
314
|
/**
|
|
309
315
|
* Checks if clipboard contains image
|
|
310
316
|
* @returns True if clipboard has image content, false otherwise
|
|
311
317
|
*/
|
|
312
|
-
hasImage()
|
|
318
|
+
hasImage: () => boolean
|
|
313
319
|
}
|
|
314
320
|
|
|
315
321
|
/**
|
|
@@ -323,19 +329,19 @@ export interface ISearchManager {
|
|
|
323
329
|
* Updates the current search query
|
|
324
330
|
* @param query - The new search query string
|
|
325
331
|
*/
|
|
326
|
-
updateQuery(query: string)
|
|
332
|
+
updateQuery: (query: string) => void
|
|
327
333
|
|
|
328
334
|
/**
|
|
329
335
|
* Gets the current search query
|
|
330
336
|
* @returns The current search query string
|
|
331
337
|
*/
|
|
332
|
-
getQuery()
|
|
338
|
+
getQuery: () => string
|
|
333
339
|
|
|
334
340
|
/**
|
|
335
341
|
* Gets the timestamp of the last query update
|
|
336
342
|
* @returns Timestamp in milliseconds since epoch
|
|
337
343
|
*/
|
|
338
|
-
getTimestamp()
|
|
344
|
+
getTimestamp: () => number
|
|
339
345
|
}
|
|
340
346
|
|
|
341
347
|
/**
|
|
@@ -355,13 +361,13 @@ export interface IDialogManager {
|
|
|
355
361
|
* @param options.buttons - Array of button labels
|
|
356
362
|
* @returns Promise that resolves to the dialog result
|
|
357
363
|
*/
|
|
358
|
-
showMessageBox(options: {
|
|
359
|
-
type?: 'info' | 'warning' | 'error' | 'question'
|
|
360
|
-
title?: string
|
|
361
|
-
message: string
|
|
362
|
-
detail?: string
|
|
363
|
-
buttons?: string[]
|
|
364
|
-
})
|
|
364
|
+
showMessageBox: (options: {
|
|
365
|
+
type?: 'info' | 'warning' | 'error' | 'question'
|
|
366
|
+
title?: string
|
|
367
|
+
message: string
|
|
368
|
+
detail?: string
|
|
369
|
+
buttons?: string[]
|
|
370
|
+
}) => Promise<any>
|
|
365
371
|
|
|
366
372
|
/**
|
|
367
373
|
* Shows an open file/folder dialog
|
|
@@ -372,12 +378,12 @@ export interface IDialogManager {
|
|
|
372
378
|
* @param options.properties - Dialog properties (openFile, openDirectory, etc.)
|
|
373
379
|
* @returns Promise that resolves to the selected file/folder paths
|
|
374
380
|
*/
|
|
375
|
-
showOpenDialog(options: {
|
|
376
|
-
title?: string
|
|
377
|
-
defaultPath?: string
|
|
378
|
-
filters?: Array<{ name: string
|
|
379
|
-
properties?: string[]
|
|
380
|
-
})
|
|
381
|
+
showOpenDialog: (options: {
|
|
382
|
+
title?: string
|
|
383
|
+
defaultPath?: string
|
|
384
|
+
filters?: Array<{ name: string, extensions: string[] }>
|
|
385
|
+
properties?: string[]
|
|
386
|
+
}) => Promise<any>
|
|
381
387
|
|
|
382
388
|
/**
|
|
383
389
|
* Shows a save file dialog
|
|
@@ -387,11 +393,11 @@ export interface IDialogManager {
|
|
|
387
393
|
* @param options.filters - File type filters
|
|
388
394
|
* @returns Promise that resolves to the selected save path
|
|
389
395
|
*/
|
|
390
|
-
showSaveDialog(options: {
|
|
391
|
-
title?: string
|
|
392
|
-
defaultPath?: string
|
|
393
|
-
filters?: Array<{ name: string
|
|
394
|
-
})
|
|
396
|
+
showSaveDialog: (options: {
|
|
397
|
+
title?: string
|
|
398
|
+
defaultPath?: string
|
|
399
|
+
filters?: Array<{ name: string, extensions: string[] }>
|
|
400
|
+
}) => Promise<any>
|
|
395
401
|
}
|
|
396
402
|
|
|
397
403
|
/**
|
|
@@ -406,28 +412,28 @@ export interface ILogger {
|
|
|
406
412
|
* @param message - The log message
|
|
407
413
|
* @param args - Additional arguments to log
|
|
408
414
|
*/
|
|
409
|
-
info(message: string, ...args: any[])
|
|
415
|
+
info: (message: string, ...args: any[]) => void
|
|
410
416
|
|
|
411
417
|
/**
|
|
412
418
|
* Logs a warning message
|
|
413
419
|
* @param message - The warning message
|
|
414
420
|
* @param args - Additional arguments to log
|
|
415
421
|
*/
|
|
416
|
-
warn(message: string, ...args: any[])
|
|
422
|
+
warn: (message: string, ...args: any[]) => void
|
|
417
423
|
|
|
418
424
|
/**
|
|
419
425
|
* Logs an error message
|
|
420
426
|
* @param message - The error message
|
|
421
427
|
* @param args - Additional arguments to log
|
|
422
428
|
*/
|
|
423
|
-
error(message: string, ...args: any[])
|
|
429
|
+
error: (message: string, ...args: any[]) => void
|
|
424
430
|
|
|
425
431
|
/**
|
|
426
432
|
* Logs a debug message
|
|
427
433
|
* @param message - The debug message
|
|
428
434
|
* @param args - Additional arguments to log
|
|
429
435
|
*/
|
|
430
|
-
debug(message: string, ...args: any[])
|
|
436
|
+
debug: (message: string, ...args: any[]) => void
|
|
431
437
|
}
|
|
432
438
|
|
|
433
439
|
/**
|
|
@@ -442,21 +448,21 @@ export interface IEventManager {
|
|
|
442
448
|
* @param event - The event name to listen for
|
|
443
449
|
* @param callback - The callback function to execute when event is emitted
|
|
444
450
|
*/
|
|
445
|
-
on(event: string, callback: Function)
|
|
451
|
+
on: (event: string, callback: Function) => void
|
|
446
452
|
|
|
447
453
|
/**
|
|
448
454
|
* Removes an event listener
|
|
449
455
|
* @param event - The event name to stop listening for
|
|
450
456
|
* @param callback - The callback function to remove
|
|
451
457
|
*/
|
|
452
|
-
off(event: string, callback: Function)
|
|
458
|
+
off: (event: string, callback: Function) => void
|
|
453
459
|
|
|
454
460
|
/**
|
|
455
461
|
* Emits an event with optional arguments
|
|
456
462
|
* @param event - The event name to emit
|
|
457
463
|
* @param args - Arguments to pass to event listeners
|
|
458
464
|
*/
|
|
459
|
-
emit(event: string, ...args: any[])
|
|
465
|
+
emit: (event: string, ...args: any[]) => void
|
|
460
466
|
}
|
|
461
467
|
|
|
462
468
|
/**
|
|
@@ -467,7 +473,7 @@ export interface IEventManager {
|
|
|
467
473
|
*/
|
|
468
474
|
export interface IPluginConfig {
|
|
469
475
|
/** Dynamic configuration properties */
|
|
470
|
-
[key: string]: any
|
|
476
|
+
[key: string]: any
|
|
471
477
|
}
|
|
472
478
|
|
|
473
479
|
/**
|
|
@@ -480,24 +486,24 @@ export interface IPluginContext {
|
|
|
480
486
|
/**
|
|
481
487
|
* The name of the plugin
|
|
482
488
|
*/
|
|
483
|
-
pluginName: string
|
|
489
|
+
pluginName: string
|
|
484
490
|
|
|
485
491
|
/**
|
|
486
492
|
* The file system path to the plugin directory
|
|
487
493
|
*/
|
|
488
|
-
pluginPath: string
|
|
494
|
+
pluginPath: string
|
|
489
495
|
|
|
490
496
|
/**
|
|
491
497
|
* Plugin configuration object
|
|
492
498
|
* @see {@link IPluginConfig}
|
|
493
499
|
*/
|
|
494
|
-
config: IPluginConfig
|
|
500
|
+
config: IPluginConfig
|
|
495
501
|
|
|
496
502
|
/**
|
|
497
503
|
* Plugin utilities and tools
|
|
498
504
|
* @see {@link IPluginUtils}
|
|
499
505
|
*/
|
|
500
|
-
utils: IPluginUtils
|
|
506
|
+
utils: IPluginUtils
|
|
501
507
|
}
|
|
502
508
|
|
|
503
509
|
/**
|
|
@@ -513,7 +519,7 @@ export interface IPluginLifecycle {
|
|
|
513
519
|
* @returns Promise or void
|
|
514
520
|
* @optional
|
|
515
521
|
*/
|
|
516
|
-
onInit
|
|
522
|
+
onInit?: (context: IPluginContext) => Promise<void> | void
|
|
517
523
|
|
|
518
524
|
/**
|
|
519
525
|
* Called when a plugin feature is triggered
|
|
@@ -542,7 +548,7 @@ export interface IPluginLifecycle {
|
|
|
542
548
|
* }
|
|
543
549
|
* ```
|
|
544
550
|
*/
|
|
545
|
-
onFeatureTriggered(featureId: string, query: any, feature: any)
|
|
551
|
+
onFeatureTriggered: (featureId: string, query: any, feature: any) => Promise<void> | void
|
|
546
552
|
|
|
547
553
|
/**
|
|
548
554
|
* Called when user input changes (for real-time features)
|
|
@@ -550,7 +556,7 @@ export interface IPluginLifecycle {
|
|
|
550
556
|
* @returns Promise or void
|
|
551
557
|
* @optional
|
|
552
558
|
*/
|
|
553
|
-
onInputChanged
|
|
559
|
+
onInputChanged?: (input: string) => Promise<void> | void
|
|
554
560
|
|
|
555
561
|
/**
|
|
556
562
|
* Called when an action button is clicked
|
|
@@ -559,14 +565,14 @@ export interface IPluginLifecycle {
|
|
|
559
565
|
* @returns Promise or void
|
|
560
566
|
* @optional
|
|
561
567
|
*/
|
|
562
|
-
onActionClick
|
|
568
|
+
onActionClick?: (actionId: string, data?: any) => Promise<void> | void
|
|
563
569
|
|
|
564
570
|
/**
|
|
565
571
|
* Called when the plugin is being destroyed/unloaded
|
|
566
572
|
* @returns Promise or void
|
|
567
573
|
* @optional
|
|
568
574
|
*/
|
|
569
|
-
onDestroy
|
|
575
|
+
onDestroy?: () => Promise<void> | void
|
|
570
576
|
}
|
|
571
577
|
|
|
572
578
|
/**
|
|
@@ -588,10 +594,10 @@ export interface IPluginLifecycle {
|
|
|
588
594
|
*/
|
|
589
595
|
export function createStorageManager(
|
|
590
596
|
pluginPath: string,
|
|
591
|
-
fse: any
|
|
597
|
+
fse: any,
|
|
592
598
|
): IStorageManager {
|
|
593
|
-
const path = require('path')
|
|
594
|
-
const dataPath = path.join(pluginPath, 'data')
|
|
599
|
+
const path = require('node:path')
|
|
600
|
+
const dataPath = path.join(pluginPath, 'data')
|
|
595
601
|
|
|
596
602
|
/**
|
|
597
603
|
* Ensures the data directory exists
|
|
@@ -599,54 +605,54 @@ export function createStorageManager(
|
|
|
599
605
|
*/
|
|
600
606
|
const ensureDataDir = async (): Promise<void> => {
|
|
601
607
|
if (!await fse.pathExists(dataPath)) {
|
|
602
|
-
await fse.ensureDir(dataPath)
|
|
608
|
+
await fse.ensureDir(dataPath)
|
|
603
609
|
}
|
|
604
|
-
}
|
|
610
|
+
}
|
|
605
611
|
|
|
606
612
|
return {
|
|
607
613
|
async set(key: string, value: any): Promise<void> {
|
|
608
|
-
await ensureDataDir()
|
|
609
|
-
const filePath = path.join(dataPath, `${key}.json`)
|
|
610
|
-
await fse.writeJSON(filePath, value, { spaces: 2 })
|
|
614
|
+
await ensureDataDir()
|
|
615
|
+
const filePath = path.join(dataPath, `${key}.json`)
|
|
616
|
+
await fse.writeJSON(filePath, value, { spaces: 2 })
|
|
611
617
|
},
|
|
612
618
|
|
|
613
619
|
async get(key: string, defaultValue?: any): Promise<any> {
|
|
614
|
-
await ensureDataDir()
|
|
615
|
-
const filePath = path.join(dataPath, `${key}.json`)
|
|
620
|
+
await ensureDataDir()
|
|
621
|
+
const filePath = path.join(dataPath, `${key}.json`)
|
|
616
622
|
if (await fse.pathExists(filePath)) {
|
|
617
|
-
return await fse.readJSON(filePath)
|
|
623
|
+
return await fse.readJSON(filePath)
|
|
618
624
|
}
|
|
619
|
-
return defaultValue
|
|
625
|
+
return defaultValue
|
|
620
626
|
},
|
|
621
627
|
|
|
622
628
|
async has(key: string): Promise<boolean> {
|
|
623
|
-
await ensureDataDir()
|
|
624
|
-
const filePath = path.join(dataPath, `${key}.json`)
|
|
625
|
-
return await fse.pathExists(filePath)
|
|
629
|
+
await ensureDataDir()
|
|
630
|
+
const filePath = path.join(dataPath, `${key}.json`)
|
|
631
|
+
return await fse.pathExists(filePath)
|
|
626
632
|
},
|
|
627
633
|
|
|
628
634
|
async remove(key: string): Promise<void> {
|
|
629
|
-
await ensureDataDir()
|
|
630
|
-
const filePath = path.join(dataPath, `${key}.json`)
|
|
635
|
+
await ensureDataDir()
|
|
636
|
+
const filePath = path.join(dataPath, `${key}.json`)
|
|
631
637
|
if (await fse.pathExists(filePath)) {
|
|
632
|
-
await fse.remove(filePath)
|
|
638
|
+
await fse.remove(filePath)
|
|
633
639
|
}
|
|
634
640
|
},
|
|
635
641
|
|
|
636
642
|
async clear(): Promise<void> {
|
|
637
643
|
if (await fse.pathExists(dataPath)) {
|
|
638
|
-
await fse.emptyDir(dataPath)
|
|
644
|
+
await fse.emptyDir(dataPath)
|
|
639
645
|
}
|
|
640
646
|
},
|
|
641
647
|
|
|
642
648
|
async keys(): Promise<string[]> {
|
|
643
|
-
await ensureDataDir()
|
|
644
|
-
const files = await fse.readdir(dataPath)
|
|
649
|
+
await ensureDataDir()
|
|
650
|
+
const files = await fse.readdir(dataPath)
|
|
645
651
|
return files
|
|
646
652
|
.filter((file: string) => file.endsWith('.json'))
|
|
647
|
-
.map((file: string) => path.basename(file, '.json'))
|
|
648
|
-
}
|
|
649
|
-
}
|
|
653
|
+
.map((file: string) => path.basename(file, '.json'))
|
|
654
|
+
},
|
|
655
|
+
}
|
|
650
656
|
}
|
|
651
657
|
|
|
652
658
|
/**
|
|
@@ -668,34 +674,34 @@ export function createStorageManager(
|
|
|
668
674
|
export function createClipboardManager(clipboard: any): IClipboardManager {
|
|
669
675
|
return {
|
|
670
676
|
readText(): string {
|
|
671
|
-
return clipboard.readText()
|
|
677
|
+
return clipboard.readText()
|
|
672
678
|
},
|
|
673
679
|
|
|
674
680
|
writeText(text: string): void {
|
|
675
|
-
clipboard.writeText(text)
|
|
681
|
+
clipboard.writeText(text)
|
|
676
682
|
},
|
|
677
683
|
|
|
678
684
|
readImage(): any | null {
|
|
679
|
-
const image = clipboard.readImage()
|
|
680
|
-
return image.isEmpty() ? null : image
|
|
685
|
+
const image = clipboard.readImage()
|
|
686
|
+
return image.isEmpty() ? null : image
|
|
681
687
|
},
|
|
682
688
|
|
|
683
689
|
writeImage(image: any): void {
|
|
684
|
-
clipboard.writeImage(image)
|
|
690
|
+
clipboard.writeImage(image)
|
|
685
691
|
},
|
|
686
692
|
|
|
687
693
|
clear(): void {
|
|
688
|
-
clipboard.clear()
|
|
694
|
+
clipboard.clear()
|
|
689
695
|
},
|
|
690
696
|
|
|
691
697
|
hasText(): boolean {
|
|
692
|
-
return clipboard.has('text/plain')
|
|
698
|
+
return clipboard.has('text/plain')
|
|
693
699
|
},
|
|
694
700
|
|
|
695
701
|
hasImage(): boolean {
|
|
696
|
-
return clipboard.has('image/png') || clipboard.has('image/jpeg')
|
|
697
|
-
}
|
|
698
|
-
}
|
|
702
|
+
return clipboard.has('image/png') || clipboard.has('image/jpeg')
|
|
703
|
+
},
|
|
704
|
+
}
|
|
699
705
|
}
|
|
700
706
|
|
|
701
707
|
/**
|
|
@@ -715,23 +721,23 @@ export function createClipboardManager(clipboard: any): IClipboardManager {
|
|
|
715
721
|
* ```
|
|
716
722
|
*/
|
|
717
723
|
export function createSearchManager(): ISearchManager {
|
|
718
|
-
let currentQuery = ''
|
|
719
|
-
let timestamp = Date.now()
|
|
724
|
+
let currentQuery = ''
|
|
725
|
+
let timestamp = Date.now()
|
|
720
726
|
|
|
721
727
|
return {
|
|
722
728
|
updateQuery(query: string): void {
|
|
723
|
-
currentQuery = query
|
|
724
|
-
timestamp = Date.now()
|
|
729
|
+
currentQuery = query
|
|
730
|
+
timestamp = Date.now()
|
|
725
731
|
},
|
|
726
732
|
|
|
727
733
|
getQuery(): string {
|
|
728
|
-
return currentQuery
|
|
734
|
+
return currentQuery
|
|
729
735
|
},
|
|
730
736
|
|
|
731
737
|
getTimestamp(): number {
|
|
732
|
-
return timestamp
|
|
733
|
-
}
|
|
734
|
-
}
|
|
738
|
+
return timestamp
|
|
739
|
+
},
|
|
740
|
+
}
|
|
735
741
|
}
|
|
736
742
|
|
|
737
743
|
/**
|
|
@@ -746,27 +752,27 @@ export interface IFeaturesManager {
|
|
|
746
752
|
* @param feature - 功能定义
|
|
747
753
|
* @returns 是否添加成功
|
|
748
754
|
*/
|
|
749
|
-
addFeature(feature: IPluginFeature)
|
|
755
|
+
addFeature: (feature: IPluginFeature) => boolean
|
|
750
756
|
|
|
751
757
|
/**
|
|
752
758
|
* 删除功能
|
|
753
759
|
* @param featureId - 功能ID
|
|
754
760
|
* @returns 是否删除成功
|
|
755
761
|
*/
|
|
756
|
-
removeFeature(featureId: string)
|
|
762
|
+
removeFeature: (featureId: string) => boolean
|
|
757
763
|
|
|
758
764
|
/**
|
|
759
765
|
* 获取所有功能
|
|
760
766
|
* @returns 所有功能列表
|
|
761
767
|
*/
|
|
762
|
-
getFeatures()
|
|
768
|
+
getFeatures: () => IPluginFeature[]
|
|
763
769
|
|
|
764
770
|
/**
|
|
765
771
|
* 获取指定功能
|
|
766
772
|
* @param featureId - 功能ID
|
|
767
773
|
* @returns 功能对象,如果不存在返回null
|
|
768
774
|
*/
|
|
769
|
-
getFeature(featureId: string)
|
|
775
|
+
getFeature: (featureId: string) => IPluginFeature | null
|
|
770
776
|
|
|
771
777
|
/**
|
|
772
778
|
* 设置功能优先级
|
|
@@ -774,40 +780,40 @@ export interface IFeaturesManager {
|
|
|
774
780
|
* @param priority - 优先级值(数字越大优先级越高)
|
|
775
781
|
* @returns 是否设置成功
|
|
776
782
|
*/
|
|
777
|
-
setPriority(featureId: string, priority: number)
|
|
783
|
+
setPriority: (featureId: string, priority: number) => boolean
|
|
778
784
|
|
|
779
785
|
/**
|
|
780
786
|
* 获取功能优先级
|
|
781
787
|
* @param featureId - 功能ID
|
|
782
788
|
* @returns 优先级值,如果功能不存在返回null
|
|
783
789
|
*/
|
|
784
|
-
getPriority(featureId: string)
|
|
790
|
+
getPriority: (featureId: string) => number | null
|
|
785
791
|
|
|
786
792
|
/**
|
|
787
793
|
* 按优先级排序获取所有功能
|
|
788
794
|
* @returns 按优先级排序的功能列表(高优先级在前)
|
|
789
795
|
*/
|
|
790
|
-
getFeaturesByPriority()
|
|
796
|
+
getFeaturesByPriority: () => IPluginFeature[]
|
|
791
797
|
|
|
792
798
|
/**
|
|
793
799
|
* 批量设置功能优先级
|
|
794
800
|
* @param priorities - 优先级映射对象 {featureId: priority}
|
|
795
801
|
* @returns 设置成功的功能数量
|
|
796
802
|
*/
|
|
797
|
-
setPriorities(priorities: Record<string, number>)
|
|
803
|
+
setPriorities: (priorities: Record<string, number>) => number
|
|
798
804
|
|
|
799
805
|
/**
|
|
800
806
|
* 重置功能优先级为默认值(0)
|
|
801
807
|
* @param featureId - 功能ID
|
|
802
808
|
* @returns 是否重置成功
|
|
803
809
|
*/
|
|
804
|
-
resetPriority(featureId: string)
|
|
810
|
+
resetPriority: (featureId: string) => boolean
|
|
805
811
|
|
|
806
812
|
/**
|
|
807
813
|
* 获取功能统计信息
|
|
808
814
|
* @returns 功能统计对象
|
|
809
815
|
*/
|
|
810
|
-
getStats()
|
|
816
|
+
getStats: () => {
|
|
811
817
|
total: number
|
|
812
818
|
byPriority: Record<number, number>
|
|
813
819
|
averagePriority: number
|
|
@@ -825,7 +831,7 @@ export interface IPluginInfoManager {
|
|
|
825
831
|
* 获取完整插件信息
|
|
826
832
|
* @returns 包含所有插件信息的对象
|
|
827
833
|
*/
|
|
828
|
-
getInfo()
|
|
834
|
+
getInfo: () => {
|
|
829
835
|
name: string
|
|
830
836
|
version: string
|
|
831
837
|
desc: string
|
|
@@ -842,25 +848,25 @@ export interface IPluginInfoManager {
|
|
|
842
848
|
* 获取插件路径
|
|
843
849
|
* @returns 插件文件系统路径
|
|
844
850
|
*/
|
|
845
|
-
getPath()
|
|
851
|
+
getPath: () => string
|
|
846
852
|
|
|
847
853
|
/**
|
|
848
854
|
* 获取插件状态
|
|
849
855
|
* @returns 当前插件状态
|
|
850
856
|
*/
|
|
851
|
-
getStatus()
|
|
857
|
+
getStatus: () => number
|
|
852
858
|
|
|
853
859
|
/**
|
|
854
860
|
* 获取开发信息
|
|
855
861
|
* @returns 开发配置信息
|
|
856
862
|
*/
|
|
857
|
-
getDevInfo()
|
|
863
|
+
getDevInfo: () => any
|
|
858
864
|
|
|
859
865
|
/**
|
|
860
866
|
* 获取平台支持信息
|
|
861
867
|
* @returns 平台兼容性信息
|
|
862
868
|
*/
|
|
863
|
-
getPlatforms()
|
|
869
|
+
getPlatforms: () => any
|
|
864
870
|
}
|
|
865
871
|
|
|
866
872
|
/**
|
|
@@ -869,12 +875,12 @@ export interface IPluginInfoManager {
|
|
|
869
875
|
* @description
|
|
870
876
|
* Represents different types of plugin state changes for incremental updates
|
|
871
877
|
*/
|
|
872
|
-
export type PluginStateEvent
|
|
873
|
-
| { type: 'added'
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
+
export type PluginStateEvent
|
|
879
|
+
= | { type: 'added', plugin: any }
|
|
880
|
+
| { type: 'removed', name: string }
|
|
881
|
+
| { type: 'updated', name: string, changes: Partial<any> }
|
|
882
|
+
| { type: 'status-changed', name: string, status: number }
|
|
883
|
+
| { type: 'readme-updated', name: string, readme: string }
|
|
878
884
|
|
|
879
885
|
/**
|
|
880
886
|
* Plugin filter options for list queries
|