@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
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,103 @@ 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
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Box SDK for controlling CoreBox window behavior
|
|
188
|
+
* @see {@link BoxSDK}
|
|
189
|
+
*/
|
|
190
|
+
box: import('./box-sdk').BoxSDK
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Feature SDK for managing search result items
|
|
194
|
+
* @see {@link FeatureSDK}
|
|
195
|
+
*/
|
|
196
|
+
feature: import('./feature-sdk').FeatureSDK
|
|
179
197
|
|
|
180
198
|
/**
|
|
181
199
|
* Opens a URL in the default browser
|
|
182
200
|
* @param url - The URL to open
|
|
183
201
|
*/
|
|
184
|
-
openUrl: (url: string) => void
|
|
202
|
+
openUrl: (url: string) => void
|
|
185
203
|
|
|
186
204
|
/**
|
|
187
|
-
*
|
|
188
|
-
* @
|
|
205
|
+
* @deprecated Use plugin.feature.pushItems() instead
|
|
206
|
+
* @throws Error indicating the API is deprecated
|
|
189
207
|
*/
|
|
190
|
-
pushItems: (items: any[]) =>
|
|
208
|
+
pushItems: (items: any[]) => never
|
|
191
209
|
|
|
192
210
|
/**
|
|
193
|
-
*
|
|
211
|
+
* @deprecated Use plugin.feature.clearItems() instead
|
|
212
|
+
* @throws Error indicating the API is deprecated
|
|
194
213
|
*/
|
|
195
|
-
clearItems: () =>
|
|
214
|
+
clearItems: () => never
|
|
196
215
|
|
|
197
216
|
/**
|
|
198
|
-
*
|
|
199
|
-
* @
|
|
217
|
+
* @deprecated Use plugin.feature.getItems() instead
|
|
218
|
+
* @throws Error indicating the API is deprecated
|
|
200
219
|
*/
|
|
201
|
-
getItems: () =>
|
|
220
|
+
getItems: () => never
|
|
202
221
|
|
|
203
222
|
/**
|
|
204
223
|
* Features manager for dynamic feature management
|
|
205
224
|
* @see {@link IFeaturesManager}
|
|
206
225
|
*/
|
|
207
|
-
features: IFeaturesManager
|
|
226
|
+
features: IFeaturesManager
|
|
208
227
|
|
|
209
228
|
/**
|
|
210
229
|
* Plugin information manager
|
|
211
230
|
* @see {@link IPluginInfoManager}
|
|
212
231
|
*/
|
|
213
|
-
plugin: IPluginInfoManager
|
|
232
|
+
plugin: IPluginInfoManager
|
|
214
233
|
}
|
|
215
234
|
|
|
216
235
|
/**
|
|
@@ -226,7 +245,7 @@ export interface IStorageManager {
|
|
|
226
245
|
* @param value - The value to store (will be JSON serialized)
|
|
227
246
|
* @returns Promise that resolves when the value is stored
|
|
228
247
|
*/
|
|
229
|
-
set(key: string, value: any)
|
|
248
|
+
set: (key: string, value: any) => Promise<void>
|
|
230
249
|
|
|
231
250
|
/**
|
|
232
251
|
* Gets a value for the given key
|
|
@@ -234,33 +253,33 @@ export interface IStorageManager {
|
|
|
234
253
|
* @param defaultValue - Default value to return if key doesn't exist
|
|
235
254
|
* @returns Promise that resolves to the stored value or default value
|
|
236
255
|
*/
|
|
237
|
-
get(key: string, defaultValue?: any)
|
|
256
|
+
get: (key: string, defaultValue?: any) => Promise<any>
|
|
238
257
|
|
|
239
258
|
/**
|
|
240
259
|
* Checks if a key exists in storage
|
|
241
260
|
* @param key - The storage key to check
|
|
242
261
|
* @returns Promise that resolves to true if key exists, false otherwise
|
|
243
262
|
*/
|
|
244
|
-
has(key: string)
|
|
263
|
+
has: (key: string) => Promise<boolean>
|
|
245
264
|
|
|
246
265
|
/**
|
|
247
266
|
* Removes a key from storage
|
|
248
267
|
* @param key - The storage key to remove
|
|
249
268
|
* @returns Promise that resolves when the key is removed
|
|
250
269
|
*/
|
|
251
|
-
remove(key: string)
|
|
270
|
+
remove: (key: string) => Promise<void>
|
|
252
271
|
|
|
253
272
|
/**
|
|
254
273
|
* Clears all stored data
|
|
255
274
|
* @returns Promise that resolves when all data is cleared
|
|
256
275
|
*/
|
|
257
|
-
clear()
|
|
276
|
+
clear: () => Promise<void>
|
|
258
277
|
|
|
259
278
|
/**
|
|
260
279
|
* Gets all storage keys
|
|
261
280
|
* @returns Promise that resolves to an array of all storage keys
|
|
262
281
|
*/
|
|
263
|
-
keys()
|
|
282
|
+
keys: () => Promise<string[]>
|
|
264
283
|
}
|
|
265
284
|
|
|
266
285
|
/**
|
|
@@ -274,42 +293,42 @@ export interface IClipboardManager {
|
|
|
274
293
|
* Reads text from the clipboard
|
|
275
294
|
* @returns The text content from clipboard
|
|
276
295
|
*/
|
|
277
|
-
readText()
|
|
296
|
+
readText: () => string
|
|
278
297
|
|
|
279
298
|
/**
|
|
280
299
|
* Writes text to the clipboard
|
|
281
300
|
* @param text - The text to write to clipboard
|
|
282
301
|
*/
|
|
283
|
-
writeText(text: string)
|
|
302
|
+
writeText: (text: string) => void
|
|
284
303
|
|
|
285
304
|
/**
|
|
286
305
|
* Reads image from the clipboard
|
|
287
306
|
* @returns The image data from clipboard, or null if no image
|
|
288
307
|
*/
|
|
289
|
-
readImage()
|
|
308
|
+
readImage: () => any | null
|
|
290
309
|
|
|
291
310
|
/**
|
|
292
311
|
* Writes image to the clipboard
|
|
293
312
|
* @param image - The image data to write to clipboard
|
|
294
313
|
*/
|
|
295
|
-
writeImage(image: any)
|
|
314
|
+
writeImage: (image: any) => void
|
|
296
315
|
|
|
297
316
|
/**
|
|
298
317
|
* Clears the clipboard content
|
|
299
318
|
*/
|
|
300
|
-
clear()
|
|
319
|
+
clear: () => void
|
|
301
320
|
|
|
302
321
|
/**
|
|
303
322
|
* Checks if clipboard contains text
|
|
304
323
|
* @returns True if clipboard has text content, false otherwise
|
|
305
324
|
*/
|
|
306
|
-
hasText()
|
|
325
|
+
hasText: () => boolean
|
|
307
326
|
|
|
308
327
|
/**
|
|
309
328
|
* Checks if clipboard contains image
|
|
310
329
|
* @returns True if clipboard has image content, false otherwise
|
|
311
330
|
*/
|
|
312
|
-
hasImage()
|
|
331
|
+
hasImage: () => boolean
|
|
313
332
|
}
|
|
314
333
|
|
|
315
334
|
/**
|
|
@@ -323,19 +342,19 @@ export interface ISearchManager {
|
|
|
323
342
|
* Updates the current search query
|
|
324
343
|
* @param query - The new search query string
|
|
325
344
|
*/
|
|
326
|
-
updateQuery(query: string)
|
|
345
|
+
updateQuery: (query: string) => void
|
|
327
346
|
|
|
328
347
|
/**
|
|
329
348
|
* Gets the current search query
|
|
330
349
|
* @returns The current search query string
|
|
331
350
|
*/
|
|
332
|
-
getQuery()
|
|
351
|
+
getQuery: () => string
|
|
333
352
|
|
|
334
353
|
/**
|
|
335
354
|
* Gets the timestamp of the last query update
|
|
336
355
|
* @returns Timestamp in milliseconds since epoch
|
|
337
356
|
*/
|
|
338
|
-
getTimestamp()
|
|
357
|
+
getTimestamp: () => number
|
|
339
358
|
}
|
|
340
359
|
|
|
341
360
|
/**
|
|
@@ -355,13 +374,13 @@ export interface IDialogManager {
|
|
|
355
374
|
* @param options.buttons - Array of button labels
|
|
356
375
|
* @returns Promise that resolves to the dialog result
|
|
357
376
|
*/
|
|
358
|
-
showMessageBox(options: {
|
|
359
|
-
type?: 'info' | 'warning' | 'error' | 'question'
|
|
360
|
-
title?: string
|
|
361
|
-
message: string
|
|
362
|
-
detail?: string
|
|
363
|
-
buttons?: string[]
|
|
364
|
-
})
|
|
377
|
+
showMessageBox: (options: {
|
|
378
|
+
type?: 'info' | 'warning' | 'error' | 'question'
|
|
379
|
+
title?: string
|
|
380
|
+
message: string
|
|
381
|
+
detail?: string
|
|
382
|
+
buttons?: string[]
|
|
383
|
+
}) => Promise<any>
|
|
365
384
|
|
|
366
385
|
/**
|
|
367
386
|
* Shows an open file/folder dialog
|
|
@@ -372,12 +391,12 @@ export interface IDialogManager {
|
|
|
372
391
|
* @param options.properties - Dialog properties (openFile, openDirectory, etc.)
|
|
373
392
|
* @returns Promise that resolves to the selected file/folder paths
|
|
374
393
|
*/
|
|
375
|
-
showOpenDialog(options: {
|
|
376
|
-
title?: string
|
|
377
|
-
defaultPath?: string
|
|
378
|
-
filters?: Array<{ name: string
|
|
379
|
-
properties?: string[]
|
|
380
|
-
})
|
|
394
|
+
showOpenDialog: (options: {
|
|
395
|
+
title?: string
|
|
396
|
+
defaultPath?: string
|
|
397
|
+
filters?: Array<{ name: string, extensions: string[] }>
|
|
398
|
+
properties?: string[]
|
|
399
|
+
}) => Promise<any>
|
|
381
400
|
|
|
382
401
|
/**
|
|
383
402
|
* Shows a save file dialog
|
|
@@ -387,11 +406,11 @@ export interface IDialogManager {
|
|
|
387
406
|
* @param options.filters - File type filters
|
|
388
407
|
* @returns Promise that resolves to the selected save path
|
|
389
408
|
*/
|
|
390
|
-
showSaveDialog(options: {
|
|
391
|
-
title?: string
|
|
392
|
-
defaultPath?: string
|
|
393
|
-
filters?: Array<{ name: string
|
|
394
|
-
})
|
|
409
|
+
showSaveDialog: (options: {
|
|
410
|
+
title?: string
|
|
411
|
+
defaultPath?: string
|
|
412
|
+
filters?: Array<{ name: string, extensions: string[] }>
|
|
413
|
+
}) => Promise<any>
|
|
395
414
|
}
|
|
396
415
|
|
|
397
416
|
/**
|
|
@@ -406,28 +425,28 @@ export interface ILogger {
|
|
|
406
425
|
* @param message - The log message
|
|
407
426
|
* @param args - Additional arguments to log
|
|
408
427
|
*/
|
|
409
|
-
info(message: string, ...args: any[])
|
|
428
|
+
info: (message: string, ...args: any[]) => void
|
|
410
429
|
|
|
411
430
|
/**
|
|
412
431
|
* Logs a warning message
|
|
413
432
|
* @param message - The warning message
|
|
414
433
|
* @param args - Additional arguments to log
|
|
415
434
|
*/
|
|
416
|
-
warn(message: string, ...args: any[])
|
|
435
|
+
warn: (message: string, ...args: any[]) => void
|
|
417
436
|
|
|
418
437
|
/**
|
|
419
438
|
* Logs an error message
|
|
420
439
|
* @param message - The error message
|
|
421
440
|
* @param args - Additional arguments to log
|
|
422
441
|
*/
|
|
423
|
-
error(message: string, ...args: any[])
|
|
442
|
+
error: (message: string, ...args: any[]) => void
|
|
424
443
|
|
|
425
444
|
/**
|
|
426
445
|
* Logs a debug message
|
|
427
446
|
* @param message - The debug message
|
|
428
447
|
* @param args - Additional arguments to log
|
|
429
448
|
*/
|
|
430
|
-
debug(message: string, ...args: any[])
|
|
449
|
+
debug: (message: string, ...args: any[]) => void
|
|
431
450
|
}
|
|
432
451
|
|
|
433
452
|
/**
|
|
@@ -442,21 +461,21 @@ export interface IEventManager {
|
|
|
442
461
|
* @param event - The event name to listen for
|
|
443
462
|
* @param callback - The callback function to execute when event is emitted
|
|
444
463
|
*/
|
|
445
|
-
on(event: string, callback: Function)
|
|
464
|
+
on: (event: string, callback: Function) => void
|
|
446
465
|
|
|
447
466
|
/**
|
|
448
467
|
* Removes an event listener
|
|
449
468
|
* @param event - The event name to stop listening for
|
|
450
469
|
* @param callback - The callback function to remove
|
|
451
470
|
*/
|
|
452
|
-
off(event: string, callback: Function)
|
|
471
|
+
off: (event: string, callback: Function) => void
|
|
453
472
|
|
|
454
473
|
/**
|
|
455
474
|
* Emits an event with optional arguments
|
|
456
475
|
* @param event - The event name to emit
|
|
457
476
|
* @param args - Arguments to pass to event listeners
|
|
458
477
|
*/
|
|
459
|
-
emit(event: string, ...args: any[])
|
|
478
|
+
emit: (event: string, ...args: any[]) => void
|
|
460
479
|
}
|
|
461
480
|
|
|
462
481
|
/**
|
|
@@ -467,7 +486,7 @@ export interface IEventManager {
|
|
|
467
486
|
*/
|
|
468
487
|
export interface IPluginConfig {
|
|
469
488
|
/** Dynamic configuration properties */
|
|
470
|
-
[key: string]: any
|
|
489
|
+
[key: string]: any
|
|
471
490
|
}
|
|
472
491
|
|
|
473
492
|
/**
|
|
@@ -480,24 +499,24 @@ export interface IPluginContext {
|
|
|
480
499
|
/**
|
|
481
500
|
* The name of the plugin
|
|
482
501
|
*/
|
|
483
|
-
pluginName: string
|
|
502
|
+
pluginName: string
|
|
484
503
|
|
|
485
504
|
/**
|
|
486
505
|
* The file system path to the plugin directory
|
|
487
506
|
*/
|
|
488
|
-
pluginPath: string
|
|
507
|
+
pluginPath: string
|
|
489
508
|
|
|
490
509
|
/**
|
|
491
510
|
* Plugin configuration object
|
|
492
511
|
* @see {@link IPluginConfig}
|
|
493
512
|
*/
|
|
494
|
-
config: IPluginConfig
|
|
513
|
+
config: IPluginConfig
|
|
495
514
|
|
|
496
515
|
/**
|
|
497
516
|
* Plugin utilities and tools
|
|
498
517
|
* @see {@link IPluginUtils}
|
|
499
518
|
*/
|
|
500
|
-
utils: IPluginUtils
|
|
519
|
+
utils: IPluginUtils
|
|
501
520
|
}
|
|
502
521
|
|
|
503
522
|
/**
|
|
@@ -513,7 +532,7 @@ export interface IPluginLifecycle {
|
|
|
513
532
|
* @returns Promise or void
|
|
514
533
|
* @optional
|
|
515
534
|
*/
|
|
516
|
-
onInit
|
|
535
|
+
onInit?: (context: IPluginContext) => Promise<void> | void
|
|
517
536
|
|
|
518
537
|
/**
|
|
519
538
|
* Called when a plugin feature is triggered
|
|
@@ -542,7 +561,7 @@ export interface IPluginLifecycle {
|
|
|
542
561
|
* }
|
|
543
562
|
* ```
|
|
544
563
|
*/
|
|
545
|
-
onFeatureTriggered(featureId: string, query: any, feature: any)
|
|
564
|
+
onFeatureTriggered: (featureId: string, query: any, feature: any) => Promise<void> | void
|
|
546
565
|
|
|
547
566
|
/**
|
|
548
567
|
* Called when user input changes (for real-time features)
|
|
@@ -550,7 +569,7 @@ export interface IPluginLifecycle {
|
|
|
550
569
|
* @returns Promise or void
|
|
551
570
|
* @optional
|
|
552
571
|
*/
|
|
553
|
-
onInputChanged
|
|
572
|
+
onInputChanged?: (input: string) => Promise<void> | void
|
|
554
573
|
|
|
555
574
|
/**
|
|
556
575
|
* Called when an action button is clicked
|
|
@@ -559,14 +578,14 @@ export interface IPluginLifecycle {
|
|
|
559
578
|
* @returns Promise or void
|
|
560
579
|
* @optional
|
|
561
580
|
*/
|
|
562
|
-
onActionClick
|
|
581
|
+
onActionClick?: (actionId: string, data?: any) => Promise<void> | void
|
|
563
582
|
|
|
564
583
|
/**
|
|
565
584
|
* Called when the plugin is being destroyed/unloaded
|
|
566
585
|
* @returns Promise or void
|
|
567
586
|
* @optional
|
|
568
587
|
*/
|
|
569
|
-
onDestroy
|
|
588
|
+
onDestroy?: () => Promise<void> | void
|
|
570
589
|
}
|
|
571
590
|
|
|
572
591
|
/**
|
|
@@ -588,10 +607,10 @@ export interface IPluginLifecycle {
|
|
|
588
607
|
*/
|
|
589
608
|
export function createStorageManager(
|
|
590
609
|
pluginPath: string,
|
|
591
|
-
fse: any
|
|
610
|
+
fse: any,
|
|
592
611
|
): IStorageManager {
|
|
593
|
-
const path = require('path')
|
|
594
|
-
const dataPath = path.join(pluginPath, 'data')
|
|
612
|
+
const path = require('node:path')
|
|
613
|
+
const dataPath = path.join(pluginPath, 'data')
|
|
595
614
|
|
|
596
615
|
/**
|
|
597
616
|
* Ensures the data directory exists
|
|
@@ -599,54 +618,54 @@ export function createStorageManager(
|
|
|
599
618
|
*/
|
|
600
619
|
const ensureDataDir = async (): Promise<void> => {
|
|
601
620
|
if (!await fse.pathExists(dataPath)) {
|
|
602
|
-
await fse.ensureDir(dataPath)
|
|
621
|
+
await fse.ensureDir(dataPath)
|
|
603
622
|
}
|
|
604
|
-
}
|
|
623
|
+
}
|
|
605
624
|
|
|
606
625
|
return {
|
|
607
626
|
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 })
|
|
627
|
+
await ensureDataDir()
|
|
628
|
+
const filePath = path.join(dataPath, `${key}.json`)
|
|
629
|
+
await fse.writeJSON(filePath, value, { spaces: 2 })
|
|
611
630
|
},
|
|
612
631
|
|
|
613
632
|
async get(key: string, defaultValue?: any): Promise<any> {
|
|
614
|
-
await ensureDataDir()
|
|
615
|
-
const filePath = path.join(dataPath, `${key}.json`)
|
|
633
|
+
await ensureDataDir()
|
|
634
|
+
const filePath = path.join(dataPath, `${key}.json`)
|
|
616
635
|
if (await fse.pathExists(filePath)) {
|
|
617
|
-
return await fse.readJSON(filePath)
|
|
636
|
+
return await fse.readJSON(filePath)
|
|
618
637
|
}
|
|
619
|
-
return defaultValue
|
|
638
|
+
return defaultValue
|
|
620
639
|
},
|
|
621
640
|
|
|
622
641
|
async has(key: string): Promise<boolean> {
|
|
623
|
-
await ensureDataDir()
|
|
624
|
-
const filePath = path.join(dataPath, `${key}.json`)
|
|
625
|
-
return await fse.pathExists(filePath)
|
|
642
|
+
await ensureDataDir()
|
|
643
|
+
const filePath = path.join(dataPath, `${key}.json`)
|
|
644
|
+
return await fse.pathExists(filePath)
|
|
626
645
|
},
|
|
627
646
|
|
|
628
647
|
async remove(key: string): Promise<void> {
|
|
629
|
-
await ensureDataDir()
|
|
630
|
-
const filePath = path.join(dataPath, `${key}.json`)
|
|
648
|
+
await ensureDataDir()
|
|
649
|
+
const filePath = path.join(dataPath, `${key}.json`)
|
|
631
650
|
if (await fse.pathExists(filePath)) {
|
|
632
|
-
await fse.remove(filePath)
|
|
651
|
+
await fse.remove(filePath)
|
|
633
652
|
}
|
|
634
653
|
},
|
|
635
654
|
|
|
636
655
|
async clear(): Promise<void> {
|
|
637
656
|
if (await fse.pathExists(dataPath)) {
|
|
638
|
-
await fse.emptyDir(dataPath)
|
|
657
|
+
await fse.emptyDir(dataPath)
|
|
639
658
|
}
|
|
640
659
|
},
|
|
641
660
|
|
|
642
661
|
async keys(): Promise<string[]> {
|
|
643
|
-
await ensureDataDir()
|
|
644
|
-
const files = await fse.readdir(dataPath)
|
|
662
|
+
await ensureDataDir()
|
|
663
|
+
const files = await fse.readdir(dataPath)
|
|
645
664
|
return files
|
|
646
665
|
.filter((file: string) => file.endsWith('.json'))
|
|
647
|
-
.map((file: string) => path.basename(file, '.json'))
|
|
648
|
-
}
|
|
649
|
-
}
|
|
666
|
+
.map((file: string) => path.basename(file, '.json'))
|
|
667
|
+
},
|
|
668
|
+
}
|
|
650
669
|
}
|
|
651
670
|
|
|
652
671
|
/**
|
|
@@ -668,34 +687,34 @@ export function createStorageManager(
|
|
|
668
687
|
export function createClipboardManager(clipboard: any): IClipboardManager {
|
|
669
688
|
return {
|
|
670
689
|
readText(): string {
|
|
671
|
-
return clipboard.readText()
|
|
690
|
+
return clipboard.readText()
|
|
672
691
|
},
|
|
673
692
|
|
|
674
693
|
writeText(text: string): void {
|
|
675
|
-
clipboard.writeText(text)
|
|
694
|
+
clipboard.writeText(text)
|
|
676
695
|
},
|
|
677
696
|
|
|
678
697
|
readImage(): any | null {
|
|
679
|
-
const image = clipboard.readImage()
|
|
680
|
-
return image.isEmpty() ? null : image
|
|
698
|
+
const image = clipboard.readImage()
|
|
699
|
+
return image.isEmpty() ? null : image
|
|
681
700
|
},
|
|
682
701
|
|
|
683
702
|
writeImage(image: any): void {
|
|
684
|
-
clipboard.writeImage(image)
|
|
703
|
+
clipboard.writeImage(image)
|
|
685
704
|
},
|
|
686
705
|
|
|
687
706
|
clear(): void {
|
|
688
|
-
clipboard.clear()
|
|
707
|
+
clipboard.clear()
|
|
689
708
|
},
|
|
690
709
|
|
|
691
710
|
hasText(): boolean {
|
|
692
|
-
return clipboard.has('text/plain')
|
|
711
|
+
return clipboard.has('text/plain')
|
|
693
712
|
},
|
|
694
713
|
|
|
695
714
|
hasImage(): boolean {
|
|
696
|
-
return clipboard.has('image/png') || clipboard.has('image/jpeg')
|
|
697
|
-
}
|
|
698
|
-
}
|
|
715
|
+
return clipboard.has('image/png') || clipboard.has('image/jpeg')
|
|
716
|
+
},
|
|
717
|
+
}
|
|
699
718
|
}
|
|
700
719
|
|
|
701
720
|
/**
|
|
@@ -715,23 +734,23 @@ export function createClipboardManager(clipboard: any): IClipboardManager {
|
|
|
715
734
|
* ```
|
|
716
735
|
*/
|
|
717
736
|
export function createSearchManager(): ISearchManager {
|
|
718
|
-
let currentQuery = ''
|
|
719
|
-
let timestamp = Date.now()
|
|
737
|
+
let currentQuery = ''
|
|
738
|
+
let timestamp = Date.now()
|
|
720
739
|
|
|
721
740
|
return {
|
|
722
741
|
updateQuery(query: string): void {
|
|
723
|
-
currentQuery = query
|
|
724
|
-
timestamp = Date.now()
|
|
742
|
+
currentQuery = query
|
|
743
|
+
timestamp = Date.now()
|
|
725
744
|
},
|
|
726
745
|
|
|
727
746
|
getQuery(): string {
|
|
728
|
-
return currentQuery
|
|
747
|
+
return currentQuery
|
|
729
748
|
},
|
|
730
749
|
|
|
731
750
|
getTimestamp(): number {
|
|
732
|
-
return timestamp
|
|
733
|
-
}
|
|
734
|
-
}
|
|
751
|
+
return timestamp
|
|
752
|
+
},
|
|
753
|
+
}
|
|
735
754
|
}
|
|
736
755
|
|
|
737
756
|
/**
|
|
@@ -746,27 +765,27 @@ export interface IFeaturesManager {
|
|
|
746
765
|
* @param feature - 功能定义
|
|
747
766
|
* @returns 是否添加成功
|
|
748
767
|
*/
|
|
749
|
-
addFeature(feature: IPluginFeature)
|
|
768
|
+
addFeature: (feature: IPluginFeature) => boolean
|
|
750
769
|
|
|
751
770
|
/**
|
|
752
771
|
* 删除功能
|
|
753
772
|
* @param featureId - 功能ID
|
|
754
773
|
* @returns 是否删除成功
|
|
755
774
|
*/
|
|
756
|
-
removeFeature(featureId: string)
|
|
775
|
+
removeFeature: (featureId: string) => boolean
|
|
757
776
|
|
|
758
777
|
/**
|
|
759
778
|
* 获取所有功能
|
|
760
779
|
* @returns 所有功能列表
|
|
761
780
|
*/
|
|
762
|
-
getFeatures()
|
|
781
|
+
getFeatures: () => IPluginFeature[]
|
|
763
782
|
|
|
764
783
|
/**
|
|
765
784
|
* 获取指定功能
|
|
766
785
|
* @param featureId - 功能ID
|
|
767
786
|
* @returns 功能对象,如果不存在返回null
|
|
768
787
|
*/
|
|
769
|
-
getFeature(featureId: string)
|
|
788
|
+
getFeature: (featureId: string) => IPluginFeature | null
|
|
770
789
|
|
|
771
790
|
/**
|
|
772
791
|
* 设置功能优先级
|
|
@@ -774,40 +793,40 @@ export interface IFeaturesManager {
|
|
|
774
793
|
* @param priority - 优先级值(数字越大优先级越高)
|
|
775
794
|
* @returns 是否设置成功
|
|
776
795
|
*/
|
|
777
|
-
setPriority(featureId: string, priority: number)
|
|
796
|
+
setPriority: (featureId: string, priority: number) => boolean
|
|
778
797
|
|
|
779
798
|
/**
|
|
780
799
|
* 获取功能优先级
|
|
781
800
|
* @param featureId - 功能ID
|
|
782
801
|
* @returns 优先级值,如果功能不存在返回null
|
|
783
802
|
*/
|
|
784
|
-
getPriority(featureId: string)
|
|
803
|
+
getPriority: (featureId: string) => number | null
|
|
785
804
|
|
|
786
805
|
/**
|
|
787
806
|
* 按优先级排序获取所有功能
|
|
788
807
|
* @returns 按优先级排序的功能列表(高优先级在前)
|
|
789
808
|
*/
|
|
790
|
-
getFeaturesByPriority()
|
|
809
|
+
getFeaturesByPriority: () => IPluginFeature[]
|
|
791
810
|
|
|
792
811
|
/**
|
|
793
812
|
* 批量设置功能优先级
|
|
794
813
|
* @param priorities - 优先级映射对象 {featureId: priority}
|
|
795
814
|
* @returns 设置成功的功能数量
|
|
796
815
|
*/
|
|
797
|
-
setPriorities(priorities: Record<string, number>)
|
|
816
|
+
setPriorities: (priorities: Record<string, number>) => number
|
|
798
817
|
|
|
799
818
|
/**
|
|
800
819
|
* 重置功能优先级为默认值(0)
|
|
801
820
|
* @param featureId - 功能ID
|
|
802
821
|
* @returns 是否重置成功
|
|
803
822
|
*/
|
|
804
|
-
resetPriority(featureId: string)
|
|
823
|
+
resetPriority: (featureId: string) => boolean
|
|
805
824
|
|
|
806
825
|
/**
|
|
807
826
|
* 获取功能统计信息
|
|
808
827
|
* @returns 功能统计对象
|
|
809
828
|
*/
|
|
810
|
-
getStats()
|
|
829
|
+
getStats: () => {
|
|
811
830
|
total: number
|
|
812
831
|
byPriority: Record<number, number>
|
|
813
832
|
averagePriority: number
|
|
@@ -825,7 +844,7 @@ export interface IPluginInfoManager {
|
|
|
825
844
|
* 获取完整插件信息
|
|
826
845
|
* @returns 包含所有插件信息的对象
|
|
827
846
|
*/
|
|
828
|
-
getInfo()
|
|
847
|
+
getInfo: () => {
|
|
829
848
|
name: string
|
|
830
849
|
version: string
|
|
831
850
|
desc: string
|
|
@@ -842,25 +861,25 @@ export interface IPluginInfoManager {
|
|
|
842
861
|
* 获取插件路径
|
|
843
862
|
* @returns 插件文件系统路径
|
|
844
863
|
*/
|
|
845
|
-
getPath()
|
|
864
|
+
getPath: () => string
|
|
846
865
|
|
|
847
866
|
/**
|
|
848
867
|
* 获取插件状态
|
|
849
868
|
* @returns 当前插件状态
|
|
850
869
|
*/
|
|
851
|
-
getStatus()
|
|
870
|
+
getStatus: () => number
|
|
852
871
|
|
|
853
872
|
/**
|
|
854
873
|
* 获取开发信息
|
|
855
874
|
* @returns 开发配置信息
|
|
856
875
|
*/
|
|
857
|
-
getDevInfo()
|
|
876
|
+
getDevInfo: () => any
|
|
858
877
|
|
|
859
878
|
/**
|
|
860
879
|
* 获取平台支持信息
|
|
861
880
|
* @returns 平台兼容性信息
|
|
862
881
|
*/
|
|
863
|
-
getPlatforms()
|
|
882
|
+
getPlatforms: () => any
|
|
864
883
|
}
|
|
865
884
|
|
|
866
885
|
/**
|
|
@@ -869,12 +888,12 @@ export interface IPluginInfoManager {
|
|
|
869
888
|
* @description
|
|
870
889
|
* Represents different types of plugin state changes for incremental updates
|
|
871
890
|
*/
|
|
872
|
-
export type PluginStateEvent
|
|
873
|
-
| { type: 'added'
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
891
|
+
export type PluginStateEvent
|
|
892
|
+
= | { type: 'added', plugin: any }
|
|
893
|
+
| { type: 'removed', name: string }
|
|
894
|
+
| { type: 'updated', name: string, changes: Partial<any> }
|
|
895
|
+
| { type: 'status-changed', name: string, status: number }
|
|
896
|
+
| { type: 'readme-updated', name: string, readme: string }
|
|
878
897
|
|
|
879
898
|
/**
|
|
880
899
|
* Plugin filter options for list queries
|