@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
@@ -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): Promise<T>;
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): Promise<T>;
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): () => void;
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): () => void;
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): Promise<T>;
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): T;
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): () => void;
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): () => void;
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): Promise<void>;
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): Promise<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): Promise<boolean>;
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): Promise<void>;
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(): Promise<void>;
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(): Promise<string[]>;
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(): string;
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): void;
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(): any | null;
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): void;
301
+ writeImage: (image: any) => void
296
302
 
297
303
  /**
298
304
  * Clears the clipboard content
299
305
  */
300
- clear(): void;
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(): boolean;
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(): boolean;
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): void;
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(): string;
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(): number;
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
- }): Promise<any>;
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; extensions: string[] }>;
379
- properties?: string[];
380
- }): Promise<any>;
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; extensions: string[] }>;
394
- }): Promise<any>;
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[]): void;
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[]): void;
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[]): void;
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[]): void;
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): void;
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): void;
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[]): void;
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,16 +519,36 @@ export interface IPluginLifecycle {
513
519
  * @returns Promise or void
514
520
  * @optional
515
521
  */
516
- onInit?(context: IPluginContext): Promise<void> | void;
522
+ onInit?: (context: IPluginContext) => Promise<void> | void
517
523
 
518
524
  /**
519
525
  * Called when a plugin feature is triggered
520
526
  * @param featureId - The ID of the triggered feature
521
- * @param query - The search query or input data
527
+ * @param query - The search query or input data. Can be:
528
+ * - string: Plain text query (backward compatible)
529
+ * - TuffQuery object: Complete query with text and optional inputs array
530
+ * - query.text: The text query string
531
+ * - query.inputs: Array of TuffQueryInput objects (images, files, HTML)
522
532
  * @param feature - The feature configuration object
523
533
  * @returns Promise or void
524
- */
525
- onFeatureTriggered(featureId: string, query: any, feature: any): Promise<void> | void;
534
+ * @example
535
+ * ```typescript
536
+ * onFeatureTriggered(featureId, query, feature) {
537
+ * if (typeof query === 'string') {
538
+ * // Backward compatible: plain text query
539
+ * console.log('Text query:', query)
540
+ * } else {
541
+ * // New: complete query object
542
+ * console.log('Text:', query.text)
543
+ * const imageInput = query.inputs?.find(i => i.type === 'image')
544
+ * if (imageInput) {
545
+ * console.log('Image data:', imageInput.content)
546
+ * }
547
+ * }
548
+ * }
549
+ * ```
550
+ */
551
+ onFeatureTriggered: (featureId: string, query: any, feature: any) => Promise<void> | void
526
552
 
527
553
  /**
528
554
  * Called when user input changes (for real-time features)
@@ -530,7 +556,7 @@ export interface IPluginLifecycle {
530
556
  * @returns Promise or void
531
557
  * @optional
532
558
  */
533
- onInputChanged?(input: string): Promise<void> | void;
559
+ onInputChanged?: (input: string) => Promise<void> | void
534
560
 
535
561
  /**
536
562
  * Called when an action button is clicked
@@ -539,14 +565,14 @@ export interface IPluginLifecycle {
539
565
  * @returns Promise or void
540
566
  * @optional
541
567
  */
542
- onActionClick?(actionId: string, data?: any): Promise<void> | void;
568
+ onActionClick?: (actionId: string, data?: any) => Promise<void> | void
543
569
 
544
570
  /**
545
571
  * Called when the plugin is being destroyed/unloaded
546
572
  * @returns Promise or void
547
573
  * @optional
548
574
  */
549
- onDestroy?(): Promise<void> | void;
575
+ onDestroy?: () => Promise<void> | void
550
576
  }
551
577
 
552
578
  /**
@@ -568,10 +594,10 @@ export interface IPluginLifecycle {
568
594
  */
569
595
  export function createStorageManager(
570
596
  pluginPath: string,
571
- fse: any
597
+ fse: any,
572
598
  ): IStorageManager {
573
- const path = require('path');
574
- const dataPath = path.join(pluginPath, 'data');
599
+ const path = require('node:path')
600
+ const dataPath = path.join(pluginPath, 'data')
575
601
 
576
602
  /**
577
603
  * Ensures the data directory exists
@@ -579,54 +605,54 @@ export function createStorageManager(
579
605
  */
580
606
  const ensureDataDir = async (): Promise<void> => {
581
607
  if (!await fse.pathExists(dataPath)) {
582
- await fse.ensureDir(dataPath);
608
+ await fse.ensureDir(dataPath)
583
609
  }
584
- };
610
+ }
585
611
 
586
612
  return {
587
613
  async set(key: string, value: any): Promise<void> {
588
- await ensureDataDir();
589
- const filePath = path.join(dataPath, `${key}.json`);
590
- 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 })
591
617
  },
592
618
 
593
619
  async get(key: string, defaultValue?: any): Promise<any> {
594
- await ensureDataDir();
595
- const filePath = path.join(dataPath, `${key}.json`);
620
+ await ensureDataDir()
621
+ const filePath = path.join(dataPath, `${key}.json`)
596
622
  if (await fse.pathExists(filePath)) {
597
- return await fse.readJSON(filePath);
623
+ return await fse.readJSON(filePath)
598
624
  }
599
- return defaultValue;
625
+ return defaultValue
600
626
  },
601
627
 
602
628
  async has(key: string): Promise<boolean> {
603
- await ensureDataDir();
604
- const filePath = path.join(dataPath, `${key}.json`);
605
- return await fse.pathExists(filePath);
629
+ await ensureDataDir()
630
+ const filePath = path.join(dataPath, `${key}.json`)
631
+ return await fse.pathExists(filePath)
606
632
  },
607
633
 
608
634
  async remove(key: string): Promise<void> {
609
- await ensureDataDir();
610
- const filePath = path.join(dataPath, `${key}.json`);
635
+ await ensureDataDir()
636
+ const filePath = path.join(dataPath, `${key}.json`)
611
637
  if (await fse.pathExists(filePath)) {
612
- await fse.remove(filePath);
638
+ await fse.remove(filePath)
613
639
  }
614
640
  },
615
641
 
616
642
  async clear(): Promise<void> {
617
643
  if (await fse.pathExists(dataPath)) {
618
- await fse.emptyDir(dataPath);
644
+ await fse.emptyDir(dataPath)
619
645
  }
620
646
  },
621
647
 
622
648
  async keys(): Promise<string[]> {
623
- await ensureDataDir();
624
- const files = await fse.readdir(dataPath);
649
+ await ensureDataDir()
650
+ const files = await fse.readdir(dataPath)
625
651
  return files
626
652
  .filter((file: string) => file.endsWith('.json'))
627
- .map((file: string) => path.basename(file, '.json'));
628
- }
629
- };
653
+ .map((file: string) => path.basename(file, '.json'))
654
+ },
655
+ }
630
656
  }
631
657
 
632
658
  /**
@@ -648,34 +674,34 @@ export function createStorageManager(
648
674
  export function createClipboardManager(clipboard: any): IClipboardManager {
649
675
  return {
650
676
  readText(): string {
651
- return clipboard.readText();
677
+ return clipboard.readText()
652
678
  },
653
679
 
654
680
  writeText(text: string): void {
655
- clipboard.writeText(text);
681
+ clipboard.writeText(text)
656
682
  },
657
683
 
658
684
  readImage(): any | null {
659
- const image = clipboard.readImage();
660
- return image.isEmpty() ? null : image;
685
+ const image = clipboard.readImage()
686
+ return image.isEmpty() ? null : image
661
687
  },
662
688
 
663
689
  writeImage(image: any): void {
664
- clipboard.writeImage(image);
690
+ clipboard.writeImage(image)
665
691
  },
666
692
 
667
693
  clear(): void {
668
- clipboard.clear();
694
+ clipboard.clear()
669
695
  },
670
696
 
671
697
  hasText(): boolean {
672
- return clipboard.has('text/plain');
698
+ return clipboard.has('text/plain')
673
699
  },
674
700
 
675
701
  hasImage(): boolean {
676
- return clipboard.has('image/png') || clipboard.has('image/jpeg');
677
- }
678
- };
702
+ return clipboard.has('image/png') || clipboard.has('image/jpeg')
703
+ },
704
+ }
679
705
  }
680
706
 
681
707
  /**
@@ -695,23 +721,23 @@ export function createClipboardManager(clipboard: any): IClipboardManager {
695
721
  * ```
696
722
  */
697
723
  export function createSearchManager(): ISearchManager {
698
- let currentQuery = '';
699
- let timestamp = Date.now();
724
+ let currentQuery = ''
725
+ let timestamp = Date.now()
700
726
 
701
727
  return {
702
728
  updateQuery(query: string): void {
703
- currentQuery = query;
704
- timestamp = Date.now();
729
+ currentQuery = query
730
+ timestamp = Date.now()
705
731
  },
706
732
 
707
733
  getQuery(): string {
708
- return currentQuery;
734
+ return currentQuery
709
735
  },
710
736
 
711
737
  getTimestamp(): number {
712
- return timestamp;
713
- }
714
- };
738
+ return timestamp
739
+ },
740
+ }
715
741
  }
716
742
 
717
743
  /**
@@ -726,27 +752,27 @@ export interface IFeaturesManager {
726
752
  * @param feature - 功能定义
727
753
  * @returns 是否添加成功
728
754
  */
729
- addFeature(feature: IPluginFeature): boolean
755
+ addFeature: (feature: IPluginFeature) => boolean
730
756
 
731
757
  /**
732
758
  * 删除功能
733
759
  * @param featureId - 功能ID
734
760
  * @returns 是否删除成功
735
761
  */
736
- removeFeature(featureId: string): boolean
762
+ removeFeature: (featureId: string) => boolean
737
763
 
738
764
  /**
739
765
  * 获取所有功能
740
766
  * @returns 所有功能列表
741
767
  */
742
- getFeatures(): IPluginFeature[]
768
+ getFeatures: () => IPluginFeature[]
743
769
 
744
770
  /**
745
771
  * 获取指定功能
746
772
  * @param featureId - 功能ID
747
773
  * @returns 功能对象,如果不存在返回null
748
774
  */
749
- getFeature(featureId: string): IPluginFeature | null
775
+ getFeature: (featureId: string) => IPluginFeature | null
750
776
 
751
777
  /**
752
778
  * 设置功能优先级
@@ -754,40 +780,40 @@ export interface IFeaturesManager {
754
780
  * @param priority - 优先级值(数字越大优先级越高)
755
781
  * @returns 是否设置成功
756
782
  */
757
- setPriority(featureId: string, priority: number): boolean
783
+ setPriority: (featureId: string, priority: number) => boolean
758
784
 
759
785
  /**
760
786
  * 获取功能优先级
761
787
  * @param featureId - 功能ID
762
788
  * @returns 优先级值,如果功能不存在返回null
763
789
  */
764
- getPriority(featureId: string): number | null
790
+ getPriority: (featureId: string) => number | null
765
791
 
766
792
  /**
767
793
  * 按优先级排序获取所有功能
768
794
  * @returns 按优先级排序的功能列表(高优先级在前)
769
795
  */
770
- getFeaturesByPriority(): IPluginFeature[]
796
+ getFeaturesByPriority: () => IPluginFeature[]
771
797
 
772
798
  /**
773
799
  * 批量设置功能优先级
774
800
  * @param priorities - 优先级映射对象 {featureId: priority}
775
801
  * @returns 设置成功的功能数量
776
802
  */
777
- setPriorities(priorities: Record<string, number>): number
803
+ setPriorities: (priorities: Record<string, number>) => number
778
804
 
779
805
  /**
780
806
  * 重置功能优先级为默认值(0)
781
807
  * @param featureId - 功能ID
782
808
  * @returns 是否重置成功
783
809
  */
784
- resetPriority(featureId: string): boolean
810
+ resetPriority: (featureId: string) => boolean
785
811
 
786
812
  /**
787
813
  * 获取功能统计信息
788
814
  * @returns 功能统计对象
789
815
  */
790
- getStats(): {
816
+ getStats: () => {
791
817
  total: number
792
818
  byPriority: Record<number, number>
793
819
  averagePriority: number
@@ -805,7 +831,7 @@ export interface IPluginInfoManager {
805
831
  * 获取完整插件信息
806
832
  * @returns 包含所有插件信息的对象
807
833
  */
808
- getInfo(): {
834
+ getInfo: () => {
809
835
  name: string
810
836
  version: string
811
837
  desc: string
@@ -822,25 +848,25 @@ export interface IPluginInfoManager {
822
848
  * 获取插件路径
823
849
  * @returns 插件文件系统路径
824
850
  */
825
- getPath(): string
851
+ getPath: () => string
826
852
 
827
853
  /**
828
854
  * 获取插件状态
829
855
  * @returns 当前插件状态
830
856
  */
831
- getStatus(): number
857
+ getStatus: () => number
832
858
 
833
859
  /**
834
860
  * 获取开发信息
835
861
  * @returns 开发配置信息
836
862
  */
837
- getDevInfo(): any
863
+ getDevInfo: () => any
838
864
 
839
865
  /**
840
866
  * 获取平台支持信息
841
867
  * @returns 平台兼容性信息
842
868
  */
843
- getPlatforms(): any
869
+ getPlatforms: () => any
844
870
  }
845
871
 
846
872
  /**
@@ -849,12 +875,12 @@ export interface IPluginInfoManager {
849
875
  * @description
850
876
  * Represents different types of plugin state changes for incremental updates
851
877
  */
852
- export type PluginStateEvent =
853
- | { type: 'added'; plugin: any }
854
- | { type: 'removed'; name: string }
855
- | { type: 'updated'; name: string; changes: Partial<any> }
856
- | { type: 'status-changed'; name: string; status: number }
857
- | { type: 'readme-updated'; name: string; readme: string }
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 }
858
884
 
859
885
  /**
860
886
  * Plugin filter options for list queries