@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
package/types/icon.ts CHANGED
@@ -11,8 +11,9 @@
11
11
  * - emoji: Emoji characters (e.g., "🚀")
12
12
  * - url: Remote URL (http/https) or Data URL (data:image/...)
13
13
  * - file: Local file path (relative to plugin root directory)
14
+ * - class: Class name (e.g., "i-ri-rocket-line")
14
15
  */
15
- export type TuffIconType = 'emoji' | 'url' | 'file'
16
+ export type TuffIconType = 'emoji' | 'url' | 'file' | 'class'
16
17
 
17
18
  /**
18
19
  * Icon status enumeration
package/types/index.ts CHANGED
@@ -1,3 +1,5 @@
1
- export * from './touch-app-core'
1
+ export * from './division-box'
2
+ export * from './intelligence'
2
3
  export * from './modules'
3
4
  export * from './storage'
5
+ export * from './touch-app-core'
@@ -0,0 +1,413 @@
1
+ export enum AiProviderType {
2
+ OPENAI = 'openai',
3
+ ANTHROPIC = 'anthropic',
4
+ DEEPSEEK = 'deepseek',
5
+ SILICONFLOW = 'siliconflow',
6
+ LOCAL = 'local',
7
+ CUSTOM = 'custom',
8
+ }
9
+
10
+ export enum AiCapabilityType {
11
+ CHAT = 'chat',
12
+ COMPLETION = 'completion',
13
+ EMBEDDING = 'embedding',
14
+ SUMMARIZE = 'summarize',
15
+ TRANSLATE = 'translate',
16
+ TTS = 'tts',
17
+ STT = 'stt',
18
+ VISION = 'vision',
19
+ }
20
+
21
+ export interface AiProviderRateLimit {
22
+ requestsPerMinute?: number
23
+ requestsPerDay?: number
24
+ tokensPerMinute?: number
25
+ tokensPerDay?: number
26
+ }
27
+
28
+ export interface AiVisionImageSource {
29
+ type: 'data-url' | 'file' | 'base64'
30
+ dataUrl?: string
31
+ filePath?: string
32
+ base64?: string
33
+ }
34
+
35
+ export interface AiVisionOcrBlock {
36
+ id?: string
37
+ text: string
38
+ language?: string
39
+ confidence?: number
40
+ boundingBox?: [number, number, number, number]
41
+ polygon?: Array<[number, number]>
42
+ type?: 'word' | 'line' | 'paragraph' | 'region'
43
+ children?: AiVisionOcrBlock[]
44
+ }
45
+
46
+ export interface AiVisionOcrResult {
47
+ text: string
48
+ confidence?: number
49
+ language?: string
50
+ keywords?: string[]
51
+ suggestions?: string[]
52
+ blocks?: AiVisionOcrBlock[]
53
+ raw?: any
54
+ }
55
+
56
+ export interface AiVisionOcrPayload {
57
+ source: AiVisionImageSource
58
+ language?: string
59
+ prompt?: string
60
+ metadata?: Record<string, any>
61
+ includeLayout?: boolean
62
+ includeKeywords?: boolean
63
+ }
64
+
65
+ export interface AiProviderConfig {
66
+ id: string
67
+ type: AiProviderType
68
+ name: string
69
+ enabled: boolean
70
+ apiKey?: string
71
+ baseUrl?: string
72
+ rateLimit?: AiProviderRateLimit
73
+ models?: string[]
74
+ defaultModel?: string
75
+ instructions?: string
76
+ timeout?: number
77
+ priority?: number
78
+ capabilities?: string[]
79
+ metadata?: Record<string, any>
80
+ }
81
+
82
+ export interface AiMessage {
83
+ role: 'system' | 'user' | 'assistant'
84
+ content: string
85
+ name?: string
86
+ }
87
+
88
+ export interface AiInvokeOptions {
89
+ strategy?: string
90
+ modelPreference?: string[]
91
+ costCeiling?: number
92
+ latencyTarget?: number
93
+ timeout?: number
94
+ stream?: boolean
95
+ preferredProviderId?: string
96
+ allowedProviderIds?: string[]
97
+ metadata?: Record<string, any>
98
+ testRun?: boolean
99
+ }
100
+
101
+ export interface AiInvokeContext {
102
+ source?: string
103
+ locale?: string
104
+ userId?: string
105
+ sessionId?: string
106
+ }
107
+
108
+ export interface AiUsageInfo {
109
+ promptTokens: number
110
+ completionTokens: number
111
+ totalTokens: number
112
+ cost?: number
113
+ }
114
+
115
+ export interface AiInvokeResult<T = any> {
116
+ result: T
117
+ usage: AiUsageInfo
118
+ model: string
119
+ latency: number
120
+ traceId: string
121
+ provider: string
122
+ }
123
+
124
+ export interface AiStreamChunk {
125
+ delta: string
126
+ done: boolean
127
+ usage?: AiUsageInfo
128
+ }
129
+
130
+ export interface AiCapabilityDescriptor {
131
+ id: string
132
+ type: AiCapabilityType
133
+ name: string
134
+ description: string
135
+ inputSchema?: any
136
+ outputSchema?: any
137
+ defaultStrategy?: string
138
+ supportedProviders: AiProviderType[]
139
+ metadata?: Record<string, any>
140
+ }
141
+
142
+ export interface AiChatPayload {
143
+ messages: AiMessage[]
144
+ context?: AiInvokeContext
145
+ temperature?: number
146
+ maxTokens?: number
147
+ topP?: number
148
+ frequencyPenalty?: number
149
+ presencePenalty?: number
150
+ stop?: string[]
151
+ }
152
+
153
+ export interface AiEmbeddingPayload {
154
+ text: string | string[]
155
+ model?: string
156
+ }
157
+
158
+ export interface AiTranslatePayload {
159
+ text: string
160
+ sourceLang?: string
161
+ targetLang: string
162
+ }
163
+
164
+ export interface AiSummarizePayload {
165
+ text: string
166
+ maxLength?: number
167
+ style?: 'concise' | 'detailed' | 'bullet-points'
168
+ }
169
+
170
+ export interface AiSDKConfig {
171
+ providers: AiProviderConfig[]
172
+ defaultStrategy: string
173
+ enableAudit: boolean
174
+ enableCache: boolean
175
+ cacheExpiration?: number
176
+ capabilities?: Record<string, AiCapabilityRoutingConfig>
177
+ }
178
+
179
+ export interface AiStrategyConfig {
180
+ id: string
181
+ name: string
182
+ type: 'rule-based' | 'adaptive' | 'custom'
183
+ rules?: any
184
+ priority?: number
185
+ }
186
+
187
+ export interface AiAuditLog {
188
+ traceId: string
189
+ timestamp: number
190
+ capabilityId: string
191
+ provider: string
192
+ model: string
193
+ promptHash?: string
194
+ caller?: string
195
+ usage: AiUsageInfo
196
+ latency: number
197
+ success: boolean
198
+ error?: string
199
+ }
200
+
201
+ export interface AiCapabilityProviderBinding {
202
+ providerId: string
203
+ models?: string[]
204
+ priority?: number
205
+ enabled?: boolean
206
+ metadata?: Record<string, any>
207
+ }
208
+
209
+ export interface AiCapabilityRoutingConfig {
210
+ label?: string
211
+ description?: string
212
+ providers: AiCapabilityProviderBinding[]
213
+ promptTemplate?: string
214
+ testResourceDir?: string
215
+ metadata?: Record<string, any>
216
+ }
217
+
218
+ export interface AiSDKPersistedConfig {
219
+ providers: AiProviderConfig[]
220
+ globalConfig: {
221
+ defaultStrategy: string
222
+ enableAudit: boolean
223
+ enableCache: boolean
224
+ cacheExpiration?: number
225
+ }
226
+ capabilities?: Record<string, AiCapabilityRoutingConfig>
227
+ version: number
228
+ }
229
+
230
+ export interface AiProviderAdapter {
231
+ readonly type: AiProviderType
232
+ getConfig: () => AiProviderConfig
233
+ updateConfig: (config: Partial<AiProviderConfig>) => void
234
+ isEnabled: () => boolean
235
+ chat: (payload: AiChatPayload, options: AiInvokeOptions) => Promise<AiInvokeResult<string>>
236
+ chatStream: (
237
+ payload: AiChatPayload,
238
+ options: AiInvokeOptions,
239
+ ) => AsyncGenerator<AiStreamChunk>
240
+ embedding: (payload: AiEmbeddingPayload, options: AiInvokeOptions) => Promise<AiInvokeResult<number[]>>
241
+ translate: (payload: AiTranslatePayload, options: AiInvokeOptions) => Promise<AiInvokeResult<string>>
242
+ visionOcr: (
243
+ payload: AiVisionOcrPayload,
244
+ options: AiInvokeOptions,
245
+ ) => Promise<AiInvokeResult<AiVisionOcrResult>>
246
+ }
247
+
248
+ export interface ProviderManagerAdapter {
249
+ clear: () => void
250
+ registerFromConfig: (config: AiProviderConfig) => AiProviderAdapter
251
+ getEnabled: () => AiProviderAdapter[]
252
+ get: (providerId: string) => AiProviderAdapter | undefined
253
+ createProviderInstance: (config: AiProviderConfig) => AiProviderAdapter
254
+ }
255
+
256
+ export interface AISDKGlobalConfig {
257
+ defaultStrategy: string
258
+ enableAudit: boolean
259
+ enableCache: boolean
260
+ cacheExpiration?: number
261
+ maxRetries?: number
262
+ defaultTimeout?: number
263
+ enableLogging?: boolean
264
+ logLevel?: 'debug' | 'info' | 'warn' | 'error'
265
+ enableCaching?: boolean
266
+ cacheSize?: number
267
+ fallbackStrategy?: 'next-available' | 'fail-fast' | 'round-robin'
268
+ parallelRequests?: boolean
269
+ }
270
+
271
+ export interface TestResult {
272
+ success: boolean
273
+ message?: string
274
+ latency?: number
275
+ timestamp: number
276
+ }
277
+
278
+ export interface AISDKCapabilityConfig {
279
+ id: string
280
+ label: string
281
+ description?: string
282
+ providers: AiCapabilityProviderBinding[]
283
+ promptTemplate?: string
284
+ testResourceDir?: string
285
+ metadata?: Record<string, any>
286
+ }
287
+
288
+ export interface AISDKStorageData {
289
+ providers: AiProviderConfig[]
290
+ globalConfig: AISDKGlobalConfig
291
+ capabilities: Record<string, AISDKCapabilityConfig>
292
+ version: number
293
+ }
294
+
295
+ export const DEFAULT_PROVIDERS: AiProviderConfig[] = [
296
+ {
297
+ id: 'openai-default',
298
+ type: AiProviderType.OPENAI,
299
+ name: 'OpenAI',
300
+ enabled: false,
301
+ priority: 1,
302
+ models: ['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo'],
303
+ defaultModel: 'gpt-4o-mini',
304
+ timeout: 30000,
305
+ rateLimit: {},
306
+ },
307
+ {
308
+ id: 'anthropic-default',
309
+ type: AiProviderType.ANTHROPIC,
310
+ name: 'Anthropic',
311
+ enabled: false,
312
+ priority: 2,
313
+ models: ['claude-3-5-sonnet-20241022', 'claude-3-opus-20240229', 'claude-3-haiku-20240307'],
314
+ defaultModel: 'claude-3-5-sonnet-20241022',
315
+ timeout: 30000,
316
+ rateLimit: {},
317
+ },
318
+ {
319
+ id: 'deepseek-default',
320
+ type: AiProviderType.DEEPSEEK,
321
+ name: 'DeepSeek',
322
+ enabled: false,
323
+ priority: 2,
324
+ models: ['deepseek-chat', 'deepseek-coder'],
325
+ defaultModel: 'deepseek-chat',
326
+ timeout: 30000,
327
+ rateLimit: {},
328
+ },
329
+ {
330
+ id: 'siliconflow-default',
331
+ type: AiProviderType.SILICONFLOW,
332
+ name: 'SiliconFlow',
333
+ enabled: false,
334
+ priority: 2,
335
+ baseUrl: 'https://api.siliconflow.cn/v1',
336
+ models: [
337
+ 'deepseek-ai/DeepSeek-R1-0528-Qwen3-8B',
338
+ 'tencent/Hunyuan-MT-7B',
339
+ 'TeleAI/TeleSpeechASR',
340
+ 'THUDM/GLM-4.1V-9B-Thinking',
341
+ 'deepseek-ai/DeepSeek-R1-Distill-Qwen-7B',
342
+ 'BAAI/bge-reranker-v2-m3',
343
+ 'netease-youdao/bce-embedding-base_v1',
344
+ 'Kwai-Kolors/Kolors',
345
+ 'BAAI/bge-m3',
346
+ ],
347
+ defaultModel: 'deepseek-ai/DeepSeek-R1-0528-Qwen3-8B',
348
+ timeout: 30000,
349
+ rateLimit: {},
350
+ },
351
+ {
352
+ id: 'local-default',
353
+ type: AiProviderType.LOCAL,
354
+ name: 'Local Model',
355
+ enabled: false,
356
+ priority: 3,
357
+ models: [],
358
+ baseUrl: 'http://localhost:11434',
359
+ timeout: 60000,
360
+ rateLimit: {},
361
+ },
362
+ ]
363
+
364
+ export const DEFAULT_GLOBAL_CONFIG: AISDKGlobalConfig = {
365
+ defaultStrategy: 'adaptive-default',
366
+ enableAudit: false,
367
+ enableCache: true,
368
+ cacheExpiration: 3600,
369
+ }
370
+
371
+ export const DEFAULT_CAPABILITIES: Record<string, AISDKCapabilityConfig> = {
372
+ 'text.chat': {
373
+ id: 'text.chat',
374
+ label: '对话 / Chat',
375
+ description: '默认用于系统对话、翻译、总结等文本任务的模型集合',
376
+ providers: [
377
+ { providerId: 'openai-default', priority: 1, enabled: true },
378
+ { providerId: 'anthropic-default', priority: 2, enabled: true },
379
+ { providerId: 'deepseek-default', priority: 3, enabled: true },
380
+ { providerId: 'siliconflow-default', priority: 4, enabled: true },
381
+ ],
382
+ },
383
+ 'embedding.generate': {
384
+ id: 'embedding.generate',
385
+ label: 'Embedding',
386
+ description: '为向量检索/摘要生成 embedding',
387
+ providers: [
388
+ {
389
+ providerId: 'siliconflow-default',
390
+ models: ['netease-youdao/bce-embedding-base_v1', 'BAAI/bge-m3'],
391
+ priority: 1,
392
+ enabled: true,
393
+ },
394
+ ],
395
+ },
396
+ 'vision.ocr': {
397
+ id: 'vision.ocr',
398
+ label: '图像 OCR',
399
+ description: '识别截图、图片中的文字并生成关键词',
400
+ promptTemplate:
401
+ '你是 OCR 助手,识别图片所有文本,生成 keywords 数组(5 个以内)辅助搜索。',
402
+ testResourceDir: 'intelligence/test-capability/ocr',
403
+ providers: [
404
+ {
405
+ providerId: 'siliconflow-default',
406
+ models: ['deepseek-ai/DeepSeek-OCR', 'deepseek-ai/DeepSeek-R1-0528-Qwen3-8B'],
407
+ priority: 1,
408
+ enabled: true,
409
+ metadata: { defaultVisionModel: 'deepseek-ai/DeepSeek-OCR' },
410
+ },
411
+ ],
412
+ },
413
+ }
@@ -2,13 +2,13 @@
2
2
  * Unique key for a module.
3
3
  * @public
4
4
  */
5
- export type ModuleKey = symbol;
5
+ export type ModuleKey = symbol
6
6
 
7
7
  /**
8
8
  * Utility type representing a synchronous or asynchronous value.
9
9
  * @public
10
10
  */
11
- export type MaybePromise<T> = T | Promise<T>;
11
+ export type MaybePromise<T> = T | Promise<T>
12
12
 
13
13
  /**
14
14
  * Declarative file/directory configuration for a module (input).
@@ -31,21 +31,21 @@ export interface ModuleFileConfig {
31
31
  *
32
32
  * @defaultValue false
33
33
  */
34
- create?: boolean;
34
+ create?: boolean
35
35
 
36
36
  /**
37
37
  * Optional custom directory name (basename only, no slashes).
38
38
  *
39
39
  * @example "clipboard"
40
40
  */
41
- dirName?: string;
41
+ dirName?: string
42
42
 
43
43
  /**
44
44
  * Optional absolute root path under which the module directory will be created.
45
45
  *
46
46
  * @example "/var/app/modules"
47
47
  */
48
- root?: string;
48
+ root?: string
49
49
  }
50
50
 
51
51
  /**
@@ -66,17 +66,17 @@ export interface ResolvedModuleFileConfig {
66
66
  /**
67
67
  * Final boolean indicating if the module has a dedicated directory.
68
68
  */
69
- create: boolean;
69
+ create: boolean
70
70
 
71
71
  /**
72
72
  * Final directory name (basename), if a directory is created.
73
73
  */
74
- dirName?: string;
74
+ dirName?: string
75
75
 
76
76
  /**
77
77
  * Final absolute path to the module directory, if a directory is created.
78
78
  */
79
- dirPath?: string;
79
+ dirPath?: string
80
80
  }
81
81
 
82
82
  /**
@@ -93,7 +93,7 @@ export interface ModuleDirectory {
93
93
  /**
94
94
  * Absolute path to the module directory.
95
95
  */
96
- readonly path: string;
96
+ readonly path: string
97
97
 
98
98
  /**
99
99
  * Joins one or more path segments to the module directory path. Does not touch the filesystem.
@@ -101,24 +101,24 @@ export interface ModuleDirectory {
101
101
  * @param segments - One or more relative path segments.
102
102
  * @returns The combined absolute path string.
103
103
  */
104
- join(...segments: string[]): string;
104
+ join: (...segments: string[]) => string
105
105
 
106
106
  /**
107
107
  * Ensures the directory exists, creating it if necessary.
108
108
  */
109
- ensure(): MaybePromise<void>;
109
+ ensure: () => MaybePromise<void>
110
110
 
111
111
  /**
112
112
  * Checks whether the directory exists.
113
113
  */
114
- exists(): MaybePromise<boolean>;
114
+ exists: () => MaybePromise<boolean>
115
115
 
116
116
  /**
117
117
  * Lists entries in the directory (filenames/subdirectory names).
118
118
  *
119
119
  * @returns An array of entry names (not absolute paths).
120
120
  */
121
- list(): MaybePromise<string[]>;
121
+ list: () => MaybePromise<string[]>
122
122
 
123
123
  /**
124
124
  * Reads a file within the module directory.
@@ -126,7 +126,7 @@ export interface ModuleDirectory {
126
126
  * @param relativePath - Path relative to the module directory.
127
127
  * @returns File contents as a Buffer or string (implementation-dependent).
128
128
  */
129
- readFile(relativePath: string): MaybePromise<Buffer | string>;
129
+ readFile: (relativePath: string) => MaybePromise<Buffer | string>
130
130
 
131
131
  /**
132
132
  * Writes a file within the module directory, creating parent folders if needed.
@@ -134,7 +134,7 @@ export interface ModuleDirectory {
134
134
  * @param relativePath - Path relative to the module directory.
135
135
  * @param data - File content.
136
136
  */
137
- writeFile(relativePath: string, data: string | Uint8Array): MaybePromise<void>;
137
+ writeFile: (relativePath: string, data: string | Uint8Array) => MaybePromise<void>
138
138
 
139
139
  /**
140
140
  * Removes a file or subdirectory within the module directory.
@@ -142,5 +142,5 @@ export interface ModuleDirectory {
142
142
  * @param relativePath - Path relative to the module directory. If omitted, implementations
143
143
  * may remove the entire directory (use with caution).
144
144
  */
145
- remove(relativePath?: string): MaybePromise<void>;
145
+ remove: (relativePath?: string) => MaybePromise<void>
146
146
  }
@@ -1,4 +1,4 @@
1
1
  export * from './base'
2
- export * from './module-lifecycle'
3
2
  export * from './module'
3
+ export * from './module-lifecycle'
4
4
  export * from './module-manager'
@@ -1,7 +1,7 @@
1
- import { ITouchEventBus } from "../../eventbus";
2
- import { ModuleKey } from ".";
3
- import { TalexTouch } from "../touch-app-core";
4
- import { ModuleDirectory, ResolvedModuleFileConfig } from "./base";
1
+ import type { ModuleKey } from '.'
2
+ import type { ITouchEventBus } from '../../eventbus'
3
+ import type { TalexTouch } from '../touch-app-core'
4
+ import type { ModuleDirectory, ResolvedModuleFileConfig } from './base'
5
5
 
6
6
  /**
7
7
  * Base context available to all lifecycle phases.
@@ -13,17 +13,17 @@ export interface ModuleBaseContext<E> {
13
13
  /**
14
14
  * The application root object (TalexTouch).
15
15
  */
16
- app: TalexTouch.TouchApp;
16
+ app: TalexTouch.TouchApp
17
17
 
18
18
  /**
19
19
  * The module manager controlling creation, lifecycle, and lookup.
20
20
  */
21
- manager: TalexTouch.IModuleManager<E>;
21
+ manager: TalexTouch.IModuleManager<E>
22
22
 
23
23
  /**
24
24
  * The unique key for the current module (same as the module's `name`).
25
25
  */
26
- moduleKey: ModuleKey;
26
+ moduleKey: ModuleKey
27
27
 
28
28
  /**
29
29
  * Optional configuration accessor bound to the application or module.
@@ -31,12 +31,12 @@ export interface ModuleBaseContext<E> {
31
31
  * @param key - Configuration key.
32
32
  * @returns The typed configuration value.
33
33
  */
34
- config?<T = unknown>(key: string): T;
34
+ config?: <T = unknown>(key: string) => T
35
35
 
36
36
  /**
37
37
  * Optional event bus bound to the application or module layer.
38
38
  */
39
- events?: ITouchEventBus<E>;
39
+ events?: ITouchEventBus<E>
40
40
 
41
41
  /**
42
42
  * The module's directory instance if a directory was created; otherwise `undefined`.
@@ -44,7 +44,7 @@ export interface ModuleBaseContext<E> {
44
44
  * @remarks
45
45
  * **Single-directory rule**: Each module can expose at most one `ModuleDirectory` instance here.
46
46
  */
47
- directory?: ModuleDirectory;
47
+ directory?: ModuleDirectory
48
48
  }
49
49
 
50
50
  /**
@@ -57,18 +57,18 @@ export interface ModuleCreateContext<E> extends ModuleBaseContext<E> {
57
57
  /**
58
58
  * Resolved file/directory configuration for the module.
59
59
  */
60
- file: ResolvedModuleFileConfig;
60
+ file: ResolvedModuleFileConfig
61
61
 
62
62
  /**
63
63
  * Fully resolved module entry file path if a custom path was provided,
64
64
  * or a default path computed by the manager; otherwise `undefined`.
65
65
  */
66
- resolvedPath?: string;
66
+ resolvedPath?: string
67
67
 
68
68
  /**
69
69
  * Indicates whether this load is part of a hot-reload/replace cycle.
70
70
  */
71
- hot?: boolean;
71
+ hot?: boolean
72
72
  }
73
73
 
74
74
  /**
@@ -81,12 +81,12 @@ export interface ModuleInitContext<E> extends ModuleBaseContext<E> {
81
81
  /**
82
82
  * Optional hint that dependencies have been verified and are ready.
83
83
  */
84
- depsReady?: boolean;
84
+ depsReady?: boolean
85
85
 
86
86
  /**
87
87
  * Resolved file/directory configuration for the module.
88
88
  */
89
- file: ResolvedModuleFileConfig;
89
+ file: ResolvedModuleFileConfig
90
90
  }
91
91
 
92
92
  /**
@@ -99,12 +99,12 @@ export interface ModuleStartContext<E> extends ModuleBaseContext<E> {
99
99
  /**
100
100
  * Optional startup arguments or mode flags.
101
101
  */
102
- startArgs?: Record<string, unknown>;
102
+ startArgs?: Record<string, unknown>
103
103
 
104
104
  /**
105
105
  * Resolved file/directory configuration for the module.
106
106
  */
107
- file: ResolvedModuleFileConfig;
107
+ file: ResolvedModuleFileConfig
108
108
  }
109
109
 
110
110
  /**
@@ -121,12 +121,12 @@ export interface ModuleStopContext<E> extends ModuleBaseContext<E> {
121
121
  * - `"hot-reload"`: Stop as part of a hot reload / replacement cycle.
122
122
  * - `string`: Custom reason.
123
123
  */
124
- reason?: "normal" | "error" | "hot-reload" | string;
124
+ reason?: 'normal' | 'error' | 'hot-reload' | string
125
125
 
126
126
  /**
127
127
  * Resolved file/directory configuration for the module.
128
128
  */
129
- file: ResolvedModuleFileConfig;
129
+ file: ResolvedModuleFileConfig
130
130
  }
131
131
 
132
132
  /**
@@ -139,10 +139,10 @@ export interface ModuleDestroyContext<E> extends ModuleBaseContext<E> {
139
139
  /**
140
140
  * Indicates the module is being destroyed as part of application shutdown.
141
141
  */
142
- appClosing?: boolean;
142
+ appClosing?: boolean
143
143
 
144
144
  /**
145
145
  * Resolved file/directory configuration for the module.
146
146
  */
147
- file: ResolvedModuleFileConfig;
147
+ file: ResolvedModuleFileConfig
148
148
  }