@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.
- package/animation/window-node.ts +205 -0
- 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 +6 -6
- package/auth/useClerkProvider.ts +3 -2
- package/channel/index.ts +28 -21
- package/common/file-scan-constants.ts +137 -121
- package/common/file-scan-utils.ts +49 -25
- 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 +19 -3
- package/common/storage/entity/shortcut-settings.ts +10 -10
- package/common/storage/shortcut-storage.ts +6 -4
- package/common/utils/file.ts +15 -4
- package/common/utils/index.ts +62 -52
- package/common/utils/polling.ts +114 -63
- 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 +255 -230
- 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 +419 -253
- 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 +6 -5
- 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 +113 -84
- 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 +6 -3
- 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 +9 -13
- 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 +169 -143
- 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 -1
- 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 +236 -88
- 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 -103
- 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/icon.ts +2 -1
- 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/search/types.ts
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
* @version 1.0.0
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import type { IFeatureCommand } from '../plugin'
|
|
20
|
-
import type { ITuffIcon } from '../types/icon'
|
|
19
|
+
import type { IFeatureCommand } from '../plugin'
|
|
20
|
+
import type { ITuffIcon, TuffIconType } from '../types/icon'
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Search Result Item Interface
|
|
@@ -41,7 +41,7 @@ export interface ISearchItem {
|
|
|
41
41
|
* @example "Calculator" for an application
|
|
42
42
|
* @example "Translate Text" for a plugin feature
|
|
43
43
|
*/
|
|
44
|
-
name: string
|
|
44
|
+
name: string
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Description or subtitle of the search result item
|
|
@@ -52,7 +52,7 @@ export interface ISearchItem {
|
|
|
52
52
|
* @example "/Applications/Calculator.app" for an application
|
|
53
53
|
* @example "Translate text using Google Translate" for a feature
|
|
54
54
|
*/
|
|
55
|
-
desc: string
|
|
55
|
+
desc: string
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Icon configuration for visual representation
|
|
@@ -62,7 +62,7 @@ export interface ISearchItem {
|
|
|
62
62
|
*
|
|
63
63
|
* @see {@link ITuffIcon} for icon configuration options
|
|
64
64
|
*/
|
|
65
|
-
icon: ITuffIcon
|
|
65
|
+
icon: ITuffIcon
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Whether this item supports push mode functionality
|
|
@@ -74,7 +74,7 @@ export interface ISearchItem {
|
|
|
74
74
|
* @example true for plugin features that accept user input
|
|
75
75
|
* @example false for simple applications or static items
|
|
76
76
|
*/
|
|
77
|
-
push: boolean
|
|
77
|
+
push: boolean
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* List of feature commands associated with this item
|
|
@@ -85,7 +85,7 @@ export interface ISearchItem {
|
|
|
85
85
|
* @optional
|
|
86
86
|
* @see {@link IFeatureCommand} for command structure
|
|
87
87
|
*/
|
|
88
|
-
commands?: IFeatureCommand[]
|
|
88
|
+
commands?: IFeatureCommand[]
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Array of searchable names for this item
|
|
@@ -95,7 +95,7 @@ export interface ISearchItem {
|
|
|
95
95
|
*
|
|
96
96
|
* @example ["Calculator", "Calc", "Math"] for a calculator app
|
|
97
97
|
*/
|
|
98
|
-
names: string[]
|
|
98
|
+
names: string[]
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Array of keywords for search matching
|
|
@@ -105,7 +105,7 @@ export interface ISearchItem {
|
|
|
105
105
|
*
|
|
106
106
|
* @example ["math", "arithmetic", "numbers"] for a calculator
|
|
107
107
|
*/
|
|
108
|
-
keyWords: string[]
|
|
108
|
+
keyWords: string[]
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Type of plugin this item belongs to
|
|
@@ -117,7 +117,7 @@ export interface ISearchItem {
|
|
|
117
117
|
* @example "feature" for plugin features
|
|
118
118
|
* @example "file" for file system items
|
|
119
119
|
*/
|
|
120
|
-
pluginType: string
|
|
120
|
+
pluginType: string
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* General type classification of the item
|
|
@@ -128,7 +128,7 @@ export interface ISearchItem {
|
|
|
128
128
|
* @example "plugin" for plugin-based items
|
|
129
129
|
* @example "app" for applications
|
|
130
130
|
*/
|
|
131
|
-
type: string
|
|
131
|
+
type: string
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
134
|
* Associated value, typically the plugin name or identifier
|
|
@@ -139,7 +139,7 @@ export interface ISearchItem {
|
|
|
139
139
|
* @example "calculator-plugin" for a plugin feature
|
|
140
140
|
* @example "system" for built-in functionality
|
|
141
141
|
*/
|
|
142
|
-
value: string
|
|
142
|
+
value: string
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Usage frequency counter for ranking and sorting
|
|
@@ -151,7 +151,7 @@ export interface ISearchItem {
|
|
|
151
151
|
* @defaultValue 0
|
|
152
152
|
* @minimum 0
|
|
153
153
|
*/
|
|
154
|
-
amo?: number
|
|
154
|
+
amo?: number
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* Matching information from search algorithms
|
|
@@ -160,9 +160,9 @@ export interface ISearchItem {
|
|
|
160
160
|
* Used for highlighting and relevance scoring.
|
|
161
161
|
*
|
|
162
162
|
* @optional
|
|
163
|
-
* @internal
|
|
163
|
+
* @internal
|
|
164
164
|
*/
|
|
165
|
-
matched?: any
|
|
165
|
+
matched?: any
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* Whether this item was matched by its name
|
|
@@ -173,7 +173,7 @@ export interface ISearchItem {
|
|
|
173
173
|
* @optional
|
|
174
174
|
* @defaultValue false
|
|
175
175
|
*/
|
|
176
|
-
matchedByName?: boolean
|
|
176
|
+
matchedByName?: boolean
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* Whether this item was matched by its description
|
|
@@ -184,7 +184,7 @@ export interface ISearchItem {
|
|
|
184
184
|
* @optional
|
|
185
185
|
* @defaultValue false
|
|
186
186
|
*/
|
|
187
|
-
descMatched?: boolean
|
|
187
|
+
descMatched?: boolean
|
|
188
188
|
|
|
189
189
|
/**
|
|
190
190
|
* Whether this item was matched by abbreviation
|
|
@@ -195,7 +195,7 @@ export interface ISearchItem {
|
|
|
195
195
|
* @optional
|
|
196
196
|
* @defaultValue false
|
|
197
197
|
*/
|
|
198
|
-
abridgeMatched?: boolean
|
|
198
|
+
abridgeMatched?: boolean
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* Unique identifier for this search item
|
|
@@ -207,7 +207,7 @@ export interface ISearchItem {
|
|
|
207
207
|
* @example "app-calculator-v1.0"
|
|
208
208
|
* @example "feature-translate-google"
|
|
209
209
|
*/
|
|
210
|
-
id?: string
|
|
210
|
+
id?: string
|
|
211
211
|
|
|
212
212
|
/**
|
|
213
213
|
* Action to execute when this item is selected
|
|
@@ -219,7 +219,7 @@ export interface ISearchItem {
|
|
|
219
219
|
* @example "open /Applications/Calculator.app" for applications
|
|
220
220
|
* @example "translate:google" for plugin features
|
|
221
221
|
*/
|
|
222
|
-
action?: string
|
|
222
|
+
action?: string
|
|
223
223
|
|
|
224
224
|
/**
|
|
225
225
|
* Reference to original feature object for command matching
|
|
@@ -228,9 +228,9 @@ export interface ISearchItem {
|
|
|
228
228
|
* Maintains a link to the original feature for command resolution.
|
|
229
229
|
*
|
|
230
230
|
* @optional
|
|
231
|
-
* @internal
|
|
231
|
+
* @internal
|
|
232
232
|
*/
|
|
233
|
-
originFeature?: ISearchItem
|
|
233
|
+
originFeature?: ISearchItem
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
236
|
* Additional properties for extensibility
|
|
@@ -241,7 +241,7 @@ export interface ISearchItem {
|
|
|
241
241
|
*
|
|
242
242
|
* @example { customData: "value", metadata: { source: "api" } }
|
|
243
243
|
*/
|
|
244
|
-
[key: string]: any
|
|
244
|
+
[key: string]: any
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
/**
|
|
@@ -290,7 +290,7 @@ export interface IDataItem extends ISearchItem {
|
|
|
290
290
|
* @example "local-analyzer"
|
|
291
291
|
* @example "openai-api"
|
|
292
292
|
*/
|
|
293
|
-
source?: string
|
|
293
|
+
source?: string
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
296
|
* Type of data processing performed
|
|
@@ -304,7 +304,7 @@ export interface IDataItem extends ISearchItem {
|
|
|
304
304
|
* @example "conversion"
|
|
305
305
|
* @example "summarization"
|
|
306
306
|
*/
|
|
307
|
-
dataType?: string
|
|
307
|
+
dataType?: string
|
|
308
308
|
|
|
309
309
|
/**
|
|
310
310
|
* Original input data before processing
|
|
@@ -316,7 +316,7 @@ export interface IDataItem extends ISearchItem {
|
|
|
316
316
|
* @example "Hello World" for translation input
|
|
317
317
|
* @example { text: "...", options: {...} } for complex inputs
|
|
318
318
|
*/
|
|
319
|
-
originalData?: any
|
|
319
|
+
originalData?: any
|
|
320
320
|
|
|
321
321
|
/**
|
|
322
322
|
* Processed output data
|
|
@@ -328,7 +328,7 @@ export interface IDataItem extends ISearchItem {
|
|
|
328
328
|
* @example "你好世界" for translation output
|
|
329
329
|
* @example { summary: "...", keywords: [...] } for analysis results
|
|
330
330
|
*/
|
|
331
|
-
processedData?: any
|
|
331
|
+
processedData?: any
|
|
332
332
|
|
|
333
333
|
/**
|
|
334
334
|
* Quality score of the processing result (0-100)
|
|
@@ -342,7 +342,7 @@ export interface IDataItem extends ISearchItem {
|
|
|
342
342
|
* @example 95 for high-quality translation
|
|
343
343
|
* @example 78 for moderate-quality analysis
|
|
344
344
|
*/
|
|
345
|
-
quality?: number
|
|
345
|
+
quality?: number
|
|
346
346
|
|
|
347
347
|
/**
|
|
348
348
|
* Whether this result was retrieved from cache
|
|
@@ -353,7 +353,7 @@ export interface IDataItem extends ISearchItem {
|
|
|
353
353
|
* @optional
|
|
354
354
|
* @defaultValue false
|
|
355
355
|
*/
|
|
356
|
-
cached?: boolean
|
|
356
|
+
cached?: boolean
|
|
357
357
|
|
|
358
358
|
/**
|
|
359
359
|
* Processing time in milliseconds
|
|
@@ -366,7 +366,7 @@ export interface IDataItem extends ISearchItem {
|
|
|
366
366
|
* @example 120 for a 120ms processing time
|
|
367
367
|
* @example 1500 for a 1.5 second operation
|
|
368
368
|
*/
|
|
369
|
-
duration?: number
|
|
369
|
+
duration?: number
|
|
370
370
|
|
|
371
371
|
/**
|
|
372
372
|
* Confidence level of the result (0-100)
|
|
@@ -380,7 +380,7 @@ export interface IDataItem extends ISearchItem {
|
|
|
380
380
|
* @example 92 for high-confidence translation
|
|
381
381
|
* @example 67 for moderate-confidence analysis
|
|
382
382
|
*/
|
|
383
|
-
confidence?: number
|
|
383
|
+
confidence?: number
|
|
384
384
|
|
|
385
385
|
/**
|
|
386
386
|
* Additional metadata about the processing
|
|
@@ -392,7 +392,7 @@ export interface IDataItem extends ISearchItem {
|
|
|
392
392
|
* @example { apiVersion: "v2", model: "gpt-4", tokens: 150 }
|
|
393
393
|
* @example { processingNode: "server-1", retryCount: 0 }
|
|
394
394
|
*/
|
|
395
|
-
metadata?: Record<string, any
|
|
395
|
+
metadata?: Record<string, any>
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
/**
|
|
@@ -403,7 +403,7 @@ export enum SearchMode {
|
|
|
403
403
|
COMMAND = 'COMMAND',
|
|
404
404
|
IMAGE = 'IMAGE',
|
|
405
405
|
FILE = 'FILE',
|
|
406
|
-
FEATURE = 'FEATURE'
|
|
406
|
+
FEATURE = 'FEATURE',
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
/**
|
|
@@ -411,16 +411,16 @@ export enum SearchMode {
|
|
|
411
411
|
*/
|
|
412
412
|
export interface ISearchOptions {
|
|
413
413
|
/** 搜索模式 */
|
|
414
|
-
mode: SearchMode
|
|
414
|
+
mode: SearchMode
|
|
415
415
|
|
|
416
416
|
/** 最大结果数量 */
|
|
417
|
-
maxResults?: number
|
|
417
|
+
maxResults?: number
|
|
418
418
|
|
|
419
419
|
/** 是否启用模糊匹配 */
|
|
420
|
-
fuzzyMatch?: boolean
|
|
420
|
+
fuzzyMatch?: boolean
|
|
421
421
|
|
|
422
422
|
/** 搜索超时时间(毫秒) */
|
|
423
|
-
timeout?: number
|
|
423
|
+
timeout?: number
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
/**
|
|
@@ -428,22 +428,22 @@ export interface ISearchOptions {
|
|
|
428
428
|
*/
|
|
429
429
|
export interface IPluginSearchResult {
|
|
430
430
|
/** 插件名称 */
|
|
431
|
-
pluginName: string
|
|
431
|
+
pluginName: string
|
|
432
432
|
|
|
433
433
|
/** 搜索结果列表 */
|
|
434
|
-
items: ISearchItem[]
|
|
434
|
+
items: ISearchItem[]
|
|
435
435
|
|
|
436
436
|
/** 推送时间戳 */
|
|
437
|
-
timestamp: number
|
|
437
|
+
timestamp: number
|
|
438
438
|
|
|
439
439
|
/** 查询关键词 */
|
|
440
|
-
query: string
|
|
440
|
+
query: string
|
|
441
441
|
|
|
442
442
|
/** 结果总数 */
|
|
443
|
-
total: number
|
|
443
|
+
total: number
|
|
444
444
|
|
|
445
445
|
/** 是否有更多结果 */
|
|
446
|
-
hasMore?: boolean
|
|
446
|
+
hasMore?: boolean
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
/**
|
|
@@ -451,22 +451,22 @@ export interface IPluginSearchResult {
|
|
|
451
451
|
*/
|
|
452
452
|
export interface ISearchResultManager {
|
|
453
453
|
/** 推送搜索结果 */
|
|
454
|
-
pushItems(items: ISearchItem[])
|
|
454
|
+
pushItems: (items: ISearchItem[]) => void
|
|
455
455
|
|
|
456
456
|
/** 清空搜索结果 */
|
|
457
|
-
clearItems()
|
|
457
|
+
clearItems: () => void
|
|
458
458
|
|
|
459
459
|
/** 获取当前搜索结果 */
|
|
460
|
-
getItems()
|
|
460
|
+
getItems: () => ISearchItem[]
|
|
461
461
|
|
|
462
462
|
/** 更新单个搜索结果 */
|
|
463
|
-
updateItem(id: string, item: Partial<ISearchItem>)
|
|
463
|
+
updateItem: (id: string, item: Partial<ISearchItem>) => boolean
|
|
464
464
|
|
|
465
465
|
/** 删除单个搜索结果 */
|
|
466
|
-
removeItem(id: string)
|
|
466
|
+
removeItem: (id: string) => boolean
|
|
467
467
|
|
|
468
468
|
/** 获取结果数量 */
|
|
469
|
-
getCount()
|
|
469
|
+
getCount: () => number
|
|
470
470
|
}
|
|
471
471
|
|
|
472
472
|
/**
|
|
@@ -533,37 +533,37 @@ export interface ISearchResultManager {
|
|
|
533
533
|
*/
|
|
534
534
|
export function createDataItem(options: {
|
|
535
535
|
/** Display name for the processed result */
|
|
536
|
-
name: string
|
|
536
|
+
name: string
|
|
537
537
|
/** Description of the processing or result */
|
|
538
|
-
desc: string
|
|
538
|
+
desc: string
|
|
539
539
|
/** Name of the plugin that created this item */
|
|
540
|
-
pluginName: string
|
|
540
|
+
pluginName: string
|
|
541
541
|
/** Source identifier (e.g., "google-api") */
|
|
542
|
-
source?: string
|
|
542
|
+
source?: string
|
|
543
543
|
/** Type of processing performed (e.g., "translation") */
|
|
544
|
-
dataType?: string
|
|
544
|
+
dataType?: string
|
|
545
545
|
/** Input data before processing */
|
|
546
|
-
originalData?: any
|
|
546
|
+
originalData?: any
|
|
547
547
|
/** Output data after processing */
|
|
548
|
-
processedData?: any
|
|
548
|
+
processedData?: any
|
|
549
549
|
/** Quality score (0-100) */
|
|
550
|
-
quality?: number
|
|
550
|
+
quality?: number
|
|
551
551
|
/** Whether result is from cache */
|
|
552
|
-
cached?: boolean
|
|
552
|
+
cached?: boolean
|
|
553
553
|
/** Processing time in milliseconds */
|
|
554
|
-
duration?: number
|
|
554
|
+
duration?: number
|
|
555
555
|
/** Confidence score (0-100) */
|
|
556
|
-
confidence?: number
|
|
556
|
+
confidence?: number
|
|
557
557
|
/** Additional metadata */
|
|
558
|
-
metadata?: Record<string, any
|
|
558
|
+
metadata?: Record<string, any>
|
|
559
559
|
/** Icon type (defaults to "remix") */
|
|
560
|
-
iconType?: string
|
|
560
|
+
iconType?: string
|
|
561
561
|
/** Icon value (defaults to "function") */
|
|
562
|
-
iconValue?: string
|
|
562
|
+
iconValue?: string
|
|
563
563
|
/** Additional search keywords */
|
|
564
|
-
keyWords?: string[]
|
|
564
|
+
keyWords?: string[]
|
|
565
565
|
/** Plugin type (defaults to "data") */
|
|
566
|
-
pluginType?: string
|
|
566
|
+
pluginType?: string
|
|
567
567
|
}): IDataItem {
|
|
568
568
|
// Extract options with defaults for optional parameters
|
|
569
569
|
const {
|
|
@@ -579,11 +579,11 @@ export function createDataItem(options: {
|
|
|
579
579
|
duration,
|
|
580
580
|
confidence,
|
|
581
581
|
metadata,
|
|
582
|
-
iconType = 'remix',
|
|
583
|
-
iconValue = 'function',
|
|
584
|
-
keyWords = [],
|
|
585
|
-
pluginType = 'data'
|
|
586
|
-
} = options
|
|
582
|
+
iconType = 'remix', // Default to remix icon type
|
|
583
|
+
iconValue = 'function', // Default to function icon
|
|
584
|
+
keyWords = [], // Default to empty keywords array
|
|
585
|
+
pluginType = 'data', // Default to data plugin type
|
|
586
|
+
} = options
|
|
587
587
|
|
|
588
588
|
// Create and return the data item with all required and optional properties
|
|
589
589
|
return {
|
|
@@ -591,17 +591,16 @@ export function createDataItem(options: {
|
|
|
591
591
|
name,
|
|
592
592
|
desc,
|
|
593
593
|
icon: {
|
|
594
|
-
type: iconType,
|
|
594
|
+
type: (iconType === 'remix' || iconType === 'base64' ? 'url' : (iconType === 'file' || iconType === 'emoji' ? iconType : 'emoji')) as TuffIconType,
|
|
595
595
|
value: iconValue,
|
|
596
|
-
init: async () => {} // Required by ITuffIcon interface
|
|
597
596
|
},
|
|
598
|
-
push: false,
|
|
599
|
-
names: [name],
|
|
600
|
-
keyWords: [name, ...keyWords],
|
|
597
|
+
push: false, // Data items don't support push mode
|
|
598
|
+
names: [name], // Include name in searchable names
|
|
599
|
+
keyWords: [name, ...keyWords], // Combine name with additional keywords
|
|
601
600
|
pluginType,
|
|
602
|
-
type: 'plugin',
|
|
603
|
-
value: pluginName,
|
|
604
|
-
amo: 0,
|
|
601
|
+
type: 'plugin', // All plugin-generated items have type 'plugin'
|
|
602
|
+
value: pluginName, // Link to source plugin
|
|
603
|
+
amo: 0, // Initialize usage counter
|
|
605
604
|
|
|
606
605
|
// Data-specific properties
|
|
607
606
|
source,
|
|
@@ -612,8 +611,8 @@ export function createDataItem(options: {
|
|
|
612
611
|
cached,
|
|
613
612
|
duration,
|
|
614
613
|
confidence,
|
|
615
|
-
metadata
|
|
616
|
-
}
|
|
614
|
+
metadata,
|
|
615
|
+
}
|
|
617
616
|
}
|
|
618
617
|
|
|
619
618
|
/**
|
|
@@ -672,25 +671,25 @@ export function createDataItem(options: {
|
|
|
672
671
|
*/
|
|
673
672
|
export function createSearchItem(options: {
|
|
674
673
|
/** Display name of the search result */
|
|
675
|
-
name: string
|
|
674
|
+
name: string
|
|
676
675
|
/** Description or subtitle text */
|
|
677
|
-
desc: string
|
|
676
|
+
desc: string
|
|
678
677
|
/** Icon configuration object */
|
|
679
|
-
icon: ITuffIcon
|
|
678
|
+
icon: ITuffIcon
|
|
680
679
|
/** Name of the plugin creating this item */
|
|
681
|
-
pluginName: string
|
|
680
|
+
pluginName: string
|
|
682
681
|
/** Plugin type (defaults to "feature") */
|
|
683
|
-
pluginType?: string
|
|
682
|
+
pluginType?: string
|
|
684
683
|
/** General type (defaults to "plugin") */
|
|
685
|
-
type?: string
|
|
684
|
+
type?: string
|
|
686
685
|
/** Push mode support (defaults to false) */
|
|
687
|
-
push?: boolean
|
|
686
|
+
push?: boolean
|
|
688
687
|
/** List of available commands */
|
|
689
|
-
commands?: IFeatureCommand[]
|
|
688
|
+
commands?: IFeatureCommand[]
|
|
690
689
|
/** Additional search keywords */
|
|
691
|
-
keyWords?: string[]
|
|
690
|
+
keyWords?: string[]
|
|
692
691
|
/** Any additional properties to include */
|
|
693
|
-
[key: string]: any
|
|
692
|
+
[key: string]: any
|
|
694
693
|
}): ISearchItem {
|
|
695
694
|
// Extract options with defaults for optional parameters
|
|
696
695
|
const {
|
|
@@ -698,13 +697,13 @@ export function createSearchItem(options: {
|
|
|
698
697
|
desc,
|
|
699
698
|
icon,
|
|
700
699
|
pluginName,
|
|
701
|
-
pluginType = 'feature',
|
|
702
|
-
type = 'plugin',
|
|
703
|
-
push = false,
|
|
704
|
-
commands = [],
|
|
705
|
-
keyWords = [],
|
|
706
|
-
...extra
|
|
707
|
-
} = options
|
|
700
|
+
pluginType = 'feature', // Default to feature type
|
|
701
|
+
type = 'plugin', // Default to plugin type
|
|
702
|
+
push = false, // Default to no push mode
|
|
703
|
+
commands = [], // Default to empty commands array
|
|
704
|
+
keyWords = [], // Default to empty keywords array
|
|
705
|
+
...extra // Capture any additional properties
|
|
706
|
+
} = options
|
|
708
707
|
|
|
709
708
|
// Create and return the search item with all properties
|
|
710
709
|
return {
|
|
@@ -714,14 +713,14 @@ export function createSearchItem(options: {
|
|
|
714
713
|
icon,
|
|
715
714
|
push,
|
|
716
715
|
commands,
|
|
717
|
-
names: [name],
|
|
718
|
-
keyWords: [name, ...keyWords],
|
|
716
|
+
names: [name], // Include name in searchable names
|
|
717
|
+
keyWords: [name, ...keyWords], // Combine name with additional keywords
|
|
719
718
|
pluginType,
|
|
720
719
|
type,
|
|
721
|
-
value: pluginName,
|
|
722
|
-
amo: 0,
|
|
720
|
+
value: pluginName, // Link to source plugin
|
|
721
|
+
amo: 0, // Initialize usage counter
|
|
723
722
|
|
|
724
723
|
// Spread any additional properties provided
|
|
725
|
-
...extra
|
|
726
|
-
}
|
|
724
|
+
...extra,
|
|
725
|
+
}
|
|
727
726
|
}
|
package/service/index.ts
CHANGED
|
@@ -2,26 +2,26 @@ export interface IService {
|
|
|
2
2
|
/**
|
|
3
3
|
* service id
|
|
4
4
|
*/
|
|
5
|
-
id:
|
|
5
|
+
id: symbol
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* service name
|
|
9
9
|
*/
|
|
10
|
-
name: string
|
|
10
|
+
name: string
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* service description
|
|
14
14
|
*/
|
|
15
|
-
description: string
|
|
15
|
+
description: string
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface IServiceEvent {
|
|
19
19
|
|
|
20
|
-
service: IService
|
|
20
|
+
service: IService
|
|
21
21
|
|
|
22
|
-
setCancelled(cancelled: boolean)
|
|
22
|
+
setCancelled: (cancelled: boolean) => void
|
|
23
23
|
|
|
24
|
-
isCancelled()
|
|
24
|
+
isCancelled: () => boolean
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export interface IServiceHandler {
|
|
@@ -38,7 +38,7 @@ export interface IServiceHandler {
|
|
|
38
38
|
* Handle the service data
|
|
39
39
|
* @param data service data
|
|
40
40
|
*/
|
|
41
|
-
handle(event: IServiceEvent, data: object)
|
|
41
|
+
handle: (event: IServiceEvent, data: object) => any
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface IServiceCenter {
|
|
@@ -48,14 +48,14 @@ export interface IServiceCenter {
|
|
|
48
48
|
* @param handler service handler
|
|
49
49
|
* @returns register result (true: success, false: fail)
|
|
50
50
|
*/
|
|
51
|
-
regService(service: IService, handler: IServiceHandler)
|
|
51
|
+
regService: (service: IService, handler: IServiceHandler) => boolean
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* The service center will unregister the service
|
|
55
55
|
* @param service will be unregistered service
|
|
56
56
|
* @returns unregister result (true: success, false: fail)
|
|
57
57
|
*/
|
|
58
|
-
unRegService(service: IService)
|
|
58
|
+
unRegService: (service: IService) => boolean
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Get the service by service id
|
|
@@ -64,5 +64,5 @@ export interface IServiceCenter {
|
|
|
64
64
|
*/
|
|
65
65
|
// getService(id: symbol): IService;
|
|
66
66
|
|
|
67
|
-
useService(service: IService, data: object)
|
|
68
|
-
}
|
|
67
|
+
useService: (service: IService, data: object) => Promise<boolean> | boolean
|
|
68
|
+
}
|