@talex-touch/utils 1.0.39 → 1.0.40
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/core-box/tuff/tuff-dsl.ts +69 -55
- package/package.json +1 -1
- package/plugin/index.ts +5 -0
- package/plugin/sdk/README.md +54 -6
- package/plugin/sdk/clipboard.ts +196 -23
- package/plugin/sdk/enum/bridge-event.ts +1 -0
- package/plugin/sdk/feature-sdk.ts +85 -6
- package/plugin/sdk/flow.ts +246 -0
- package/plugin/sdk/hooks/bridge.ts +18 -1
- package/plugin/sdk/index.ts +2 -0
- package/plugin/sdk/performance.ts +201 -0
- package/plugin/widget.ts +5 -0
- package/renderer/storage/base-storage.ts +98 -15
- package/renderer/storage/storage-subscription.ts +17 -9
- package/search/fuzzy-match.ts +254 -0
- package/types/flow.ts +283 -0
- package/types/index.ts +1 -0
package/types/flow.ts
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow Transfer Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core types for the plugin-to-plugin data flow transfer system.
|
|
5
|
+
* Enables plugins to share structured data with other plugins' features.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { TuffQuery } from '../core-box/tuff/tuff-dsl'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Flow payload types
|
|
12
|
+
*/
|
|
13
|
+
export type FlowPayloadType = 'text' | 'image' | 'files' | 'json' | 'html' | 'custom'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Flow session states
|
|
17
|
+
*/
|
|
18
|
+
export type FlowSessionState =
|
|
19
|
+
| 'INIT'
|
|
20
|
+
| 'TARGET_SELECTING'
|
|
21
|
+
| 'TARGET_SELECTED'
|
|
22
|
+
| 'DELIVERING'
|
|
23
|
+
| 'DELIVERED'
|
|
24
|
+
| 'PROCESSING'
|
|
25
|
+
| 'ACKED'
|
|
26
|
+
| 'FAILED'
|
|
27
|
+
| 'CANCELLED'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Flow error codes
|
|
31
|
+
*/
|
|
32
|
+
export enum FlowErrorCode {
|
|
33
|
+
SENDER_NOT_ALLOWED = 'SENDER_NOT_ALLOWED',
|
|
34
|
+
TARGET_NOT_FOUND = 'TARGET_NOT_FOUND',
|
|
35
|
+
TARGET_OFFLINE = 'TARGET_OFFLINE',
|
|
36
|
+
PAYLOAD_INVALID = 'PAYLOAD_INVALID',
|
|
37
|
+
PAYLOAD_TOO_LARGE = 'PAYLOAD_TOO_LARGE',
|
|
38
|
+
TYPE_NOT_SUPPORTED = 'TYPE_NOT_SUPPORTED',
|
|
39
|
+
PERMISSION_DENIED = 'PERMISSION_DENIED',
|
|
40
|
+
TIMEOUT = 'TIMEOUT',
|
|
41
|
+
CANCELLED = 'CANCELLED',
|
|
42
|
+
INTERNAL_ERROR = 'INTERNAL_ERROR'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Flow error
|
|
47
|
+
*/
|
|
48
|
+
export interface FlowError {
|
|
49
|
+
code: FlowErrorCode
|
|
50
|
+
message: string
|
|
51
|
+
details?: Record<string, any>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Flow payload context
|
|
56
|
+
*/
|
|
57
|
+
export interface FlowPayloadContext {
|
|
58
|
+
/** Source plugin ID */
|
|
59
|
+
sourcePluginId: string
|
|
60
|
+
|
|
61
|
+
/** Source feature ID (optional) */
|
|
62
|
+
sourceFeatureId?: string
|
|
63
|
+
|
|
64
|
+
/** Original query (if triggered from CoreBox) */
|
|
65
|
+
originalQuery?: TuffQuery
|
|
66
|
+
|
|
67
|
+
/** Custom metadata */
|
|
68
|
+
metadata?: Record<string, any>
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Flow payload - data being transferred
|
|
73
|
+
*/
|
|
74
|
+
export interface FlowPayload {
|
|
75
|
+
/** Payload type */
|
|
76
|
+
type: FlowPayloadType
|
|
77
|
+
|
|
78
|
+
/** Main data content */
|
|
79
|
+
data: string | object
|
|
80
|
+
|
|
81
|
+
/** MIME type (optional) */
|
|
82
|
+
mimeType?: string
|
|
83
|
+
|
|
84
|
+
/** Context information */
|
|
85
|
+
context?: FlowPayloadContext
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Flow target capabilities
|
|
90
|
+
*/
|
|
91
|
+
export interface FlowTargetCapabilities {
|
|
92
|
+
/** Whether authentication is required */
|
|
93
|
+
requiresAuth?: boolean
|
|
94
|
+
|
|
95
|
+
/** Allowed sender plugin IDs (whitelist) */
|
|
96
|
+
allowedSenders?: string[]
|
|
97
|
+
|
|
98
|
+
/** Maximum payload size in bytes */
|
|
99
|
+
maxPayloadSize?: number
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Flow target - declared in plugin manifest
|
|
104
|
+
*/
|
|
105
|
+
export interface FlowTarget {
|
|
106
|
+
/** Target unique ID (unique within plugin) */
|
|
107
|
+
id: string
|
|
108
|
+
|
|
109
|
+
/** Display name */
|
|
110
|
+
name: string
|
|
111
|
+
|
|
112
|
+
/** Description */
|
|
113
|
+
description?: string
|
|
114
|
+
|
|
115
|
+
/** Supported payload types */
|
|
116
|
+
supportedTypes: FlowPayloadType[]
|
|
117
|
+
|
|
118
|
+
/** Icon (iconify format) */
|
|
119
|
+
icon?: string
|
|
120
|
+
|
|
121
|
+
/** Associated feature ID (optional) */
|
|
122
|
+
featureId?: string
|
|
123
|
+
|
|
124
|
+
/** Associated action ID (optional) */
|
|
125
|
+
actionId?: string
|
|
126
|
+
|
|
127
|
+
/** Whether user confirmation is required */
|
|
128
|
+
requireConfirm?: boolean
|
|
129
|
+
|
|
130
|
+
/** Capability requirements */
|
|
131
|
+
capabilities?: FlowTargetCapabilities
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Flow target info - runtime information
|
|
136
|
+
*/
|
|
137
|
+
export interface FlowTargetInfo extends FlowTarget {
|
|
138
|
+
/** Full target ID (pluginId.targetId) */
|
|
139
|
+
fullId: string
|
|
140
|
+
|
|
141
|
+
/** Plugin ID */
|
|
142
|
+
pluginId: string
|
|
143
|
+
|
|
144
|
+
/** Plugin name */
|
|
145
|
+
pluginName?: string
|
|
146
|
+
|
|
147
|
+
/** Plugin icon */
|
|
148
|
+
pluginIcon?: string
|
|
149
|
+
|
|
150
|
+
/** Whether the plugin is currently enabled */
|
|
151
|
+
isEnabled: boolean
|
|
152
|
+
|
|
153
|
+
/** Recent usage count */
|
|
154
|
+
usageCount?: number
|
|
155
|
+
|
|
156
|
+
/** Last used timestamp */
|
|
157
|
+
lastUsed?: number
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Flow session - a complete flow operation
|
|
162
|
+
*/
|
|
163
|
+
export interface FlowSession {
|
|
164
|
+
/** Session unique ID */
|
|
165
|
+
sessionId: string
|
|
166
|
+
|
|
167
|
+
/** Session state */
|
|
168
|
+
state: FlowSessionState
|
|
169
|
+
|
|
170
|
+
/** Sender plugin ID */
|
|
171
|
+
senderId: string
|
|
172
|
+
|
|
173
|
+
/** Target plugin ID */
|
|
174
|
+
targetPluginId: string
|
|
175
|
+
|
|
176
|
+
/** Target endpoint ID */
|
|
177
|
+
targetId: string
|
|
178
|
+
|
|
179
|
+
/** Full target ID (pluginId.targetId) */
|
|
180
|
+
fullTargetId: string
|
|
181
|
+
|
|
182
|
+
/** Payload data */
|
|
183
|
+
payload: FlowPayload
|
|
184
|
+
|
|
185
|
+
/** Creation timestamp */
|
|
186
|
+
createdAt: number
|
|
187
|
+
|
|
188
|
+
/** Update timestamp */
|
|
189
|
+
updatedAt: number
|
|
190
|
+
|
|
191
|
+
/** Acknowledgment payload (if any) */
|
|
192
|
+
ackPayload?: any
|
|
193
|
+
|
|
194
|
+
/** Error information (if failed) */
|
|
195
|
+
error?: FlowError
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Flow dispatch options
|
|
200
|
+
*/
|
|
201
|
+
export interface FlowDispatchOptions {
|
|
202
|
+
/** Display title (for selector panel) */
|
|
203
|
+
title?: string
|
|
204
|
+
|
|
205
|
+
/** Display description */
|
|
206
|
+
description?: string
|
|
207
|
+
|
|
208
|
+
/** Preferred target (bundleId.targetId or tuffItemId) */
|
|
209
|
+
preferredTarget?: string
|
|
210
|
+
|
|
211
|
+
/** Skip selector panel (requires preferredTarget) */
|
|
212
|
+
skipSelector?: boolean
|
|
213
|
+
|
|
214
|
+
/** Timeout in milliseconds (default: 30000) */
|
|
215
|
+
timeout?: number
|
|
216
|
+
|
|
217
|
+
/** Fallback action on failure */
|
|
218
|
+
fallbackAction?: 'copy' | 'none'
|
|
219
|
+
|
|
220
|
+
/** Whether acknowledgment is required */
|
|
221
|
+
requireAck?: boolean
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Flow dispatch result
|
|
226
|
+
*/
|
|
227
|
+
export interface FlowDispatchResult {
|
|
228
|
+
/** Session ID */
|
|
229
|
+
sessionId: string
|
|
230
|
+
|
|
231
|
+
/** Final state */
|
|
232
|
+
state: FlowSessionState
|
|
233
|
+
|
|
234
|
+
/** Acknowledgment payload */
|
|
235
|
+
ackPayload?: any
|
|
236
|
+
|
|
237
|
+
/** Error (if failed) */
|
|
238
|
+
error?: FlowError
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Flow session update event
|
|
243
|
+
*/
|
|
244
|
+
export interface FlowSessionUpdate {
|
|
245
|
+
/** Session ID */
|
|
246
|
+
sessionId: string
|
|
247
|
+
|
|
248
|
+
/** Previous state */
|
|
249
|
+
previousState: FlowSessionState
|
|
250
|
+
|
|
251
|
+
/** Current state */
|
|
252
|
+
currentState: FlowSessionState
|
|
253
|
+
|
|
254
|
+
/** Timestamp */
|
|
255
|
+
timestamp: number
|
|
256
|
+
|
|
257
|
+
/** Additional data */
|
|
258
|
+
data?: any
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* IPC channels for Flow operations
|
|
263
|
+
*/
|
|
264
|
+
export enum FlowIPCChannel {
|
|
265
|
+
DISPATCH = 'flow:dispatch',
|
|
266
|
+
GET_TARGETS = 'flow:get-targets',
|
|
267
|
+
CANCEL = 'flow:cancel',
|
|
268
|
+
ACKNOWLEDGE = 'flow:acknowledge',
|
|
269
|
+
REPORT_ERROR = 'flow:report-error',
|
|
270
|
+
SESSION_UPDATE = 'flow:session-update',
|
|
271
|
+
DELIVER = 'flow:deliver'
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Flow manifest configuration (in plugin manifest.json)
|
|
276
|
+
*/
|
|
277
|
+
export interface FlowManifestConfig {
|
|
278
|
+
/** Whether this plugin can send flows */
|
|
279
|
+
flowSender?: boolean
|
|
280
|
+
|
|
281
|
+
/** Flow targets this plugin can receive */
|
|
282
|
+
flowTargets?: FlowTarget[]
|
|
283
|
+
}
|