mulby-cli 1.1.5

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 (59) hide show
  1. package/PLUGIN_DEVELOP_PROMPT.md +1164 -0
  2. package/README.md +852 -0
  3. package/assets/default-icon.png +0 -0
  4. package/dist/commands/ai-session.js +44 -0
  5. package/dist/commands/build.js +111 -0
  6. package/dist/commands/config-ai.js +291 -0
  7. package/dist/commands/config.js +53 -0
  8. package/dist/commands/create/ai-create.js +183 -0
  9. package/dist/commands/create/assets.js +53 -0
  10. package/dist/commands/create/basic.js +72 -0
  11. package/dist/commands/create/index.js +73 -0
  12. package/dist/commands/create/react.js +136 -0
  13. package/dist/commands/create/templates/basic.js +383 -0
  14. package/dist/commands/create/templates/react/backend.js +72 -0
  15. package/dist/commands/create/templates/react/config.js +166 -0
  16. package/dist/commands/create/templates/react/docs.js +78 -0
  17. package/dist/commands/create/templates/react/hooks.js +469 -0
  18. package/dist/commands/create/templates/react/index.js +41 -0
  19. package/dist/commands/create/templates/react/types.js +1228 -0
  20. package/dist/commands/create/templates/react/ui.js +528 -0
  21. package/dist/commands/create/templates/react.js +1888 -0
  22. package/dist/commands/dev.js +141 -0
  23. package/dist/commands/pack.js +160 -0
  24. package/dist/commands/resume.js +97 -0
  25. package/dist/commands/test-ui.js +50 -0
  26. package/dist/index.js +71 -0
  27. package/dist/services/ai/PLUGIN_API.md +1102 -0
  28. package/dist/services/ai/PLUGIN_DEVELOP_PROMPT.md +1164 -0
  29. package/dist/services/ai/context-manager.js +639 -0
  30. package/dist/services/ai/index.js +88 -0
  31. package/dist/services/ai/knowledge.js +52 -0
  32. package/dist/services/ai/prompts.js +114 -0
  33. package/dist/services/ai/providers/base.js +38 -0
  34. package/dist/services/ai/providers/claude.js +284 -0
  35. package/dist/services/ai/providers/deepseek.js +28 -0
  36. package/dist/services/ai/providers/gemini.js +191 -0
  37. package/dist/services/ai/providers/glm.js +31 -0
  38. package/dist/services/ai/providers/minimax.js +27 -0
  39. package/dist/services/ai/providers/openai.js +177 -0
  40. package/dist/services/ai/tools.js +204 -0
  41. package/dist/services/ai-generator.js +968 -0
  42. package/dist/services/config-manager.js +117 -0
  43. package/dist/services/dependency-manager.js +236 -0
  44. package/dist/services/file-writer.js +66 -0
  45. package/dist/services/plan-adapter.js +244 -0
  46. package/dist/services/plan-command-handler.js +172 -0
  47. package/dist/services/plan-manager.js +502 -0
  48. package/dist/services/session-manager.js +113 -0
  49. package/dist/services/task-analyzer.js +136 -0
  50. package/dist/services/tui/index.js +57 -0
  51. package/dist/services/tui/store.js +123 -0
  52. package/dist/types/ai.js +172 -0
  53. package/dist/types/plan.js +2 -0
  54. package/dist/ui/Terminal.js +56 -0
  55. package/dist/ui/components/InputArea.js +176 -0
  56. package/dist/ui/components/LogArea.js +19 -0
  57. package/dist/ui/components/PlanPanel.js +69 -0
  58. package/dist/ui/components/SelectArea.js +13 -0
  59. package/package.json +45 -0
@@ -0,0 +1,469 @@
1
+ "use strict";
2
+ /**
3
+ * React 插件模板 - Hooks 代码生成器
4
+ * 包含:useMulby.ts
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.buildUseMulby = buildUseMulby;
8
+ /**
9
+ * 生成 useMulby.ts Hook 内容
10
+ */
11
+ function buildUseMulby() {
12
+ return `import { useMemo } from 'react'
13
+
14
+ export function useMulby(pluginId?: string) {
15
+ return useMemo(() => ({
16
+ // Clipboard API
17
+ clipboard: {
18
+ readText: () => window.mulby?.clipboard?.readText(),
19
+ writeText: (text: string) => window.mulby?.clipboard?.writeText(text),
20
+ readImage: () => window.mulby?.clipboard?.readImage(),
21
+ writeImage: (image: string | ArrayBuffer) => window.mulby?.clipboard?.writeImage(image),
22
+ readFiles: () => window.mulby?.clipboard?.readFiles(),
23
+ writeFiles: (files: string | string[]) => window.mulby?.clipboard?.writeFiles(files),
24
+ getFormat: () => window.mulby?.clipboard?.getFormat(),
25
+ },
26
+
27
+ // Clipboard History API
28
+ clipboardHistory: {
29
+ query: (options?: {
30
+ type?: 'text' | 'image' | 'files'
31
+ search?: string
32
+ favorite?: boolean
33
+ limit?: number
34
+ offset?: number
35
+ }) => window.mulby?.clipboardHistory?.query(options),
36
+ get: (id: string) => window.mulby?.clipboardHistory?.get(id),
37
+ copy: (id: string) => window.mulby?.clipboardHistory?.copy(id),
38
+ toggleFavorite: (id: string) => window.mulby?.clipboardHistory?.toggleFavorite(id),
39
+ delete: (id: string) => window.mulby?.clipboardHistory?.delete(id),
40
+ clear: () => window.mulby?.clipboardHistory?.clear(),
41
+ stats: () => window.mulby?.clipboardHistory?.stats(),
42
+ },
43
+
44
+ // Input API
45
+ input: {
46
+ hideMainWindowPasteText: (text: string) => window.mulby?.input?.hideMainWindowPasteText(text),
47
+ hideMainWindowPasteImage: (image: string | ArrayBuffer) => window.mulby?.input?.hideMainWindowPasteImage(image),
48
+ hideMainWindowPasteFile: (filePaths: string | string[]) => window.mulby?.input?.hideMainWindowPasteFile(filePaths),
49
+ hideMainWindowTypeString: (text: string) => window.mulby?.input?.hideMainWindowTypeString(text),
50
+ restoreWindows: () => window.mulby?.input?.restoreWindows(),
51
+ simulateKeyboardTap: (key: string, ...modifiers: string[]) =>
52
+ window.mulby?.input?.simulateKeyboardTap(key, ...modifiers),
53
+ simulateMouseMove: (x: number, y: number) => window.mulby?.input?.simulateMouseMove(x, y),
54
+ simulateMouseClick: (x: number, y: number) => window.mulby?.input?.simulateMouseClick(x, y),
55
+ simulateMouseDoubleClick: (x: number, y: number) => window.mulby?.input?.simulateMouseDoubleClick(x, y),
56
+ simulateMouseRightClick: (x: number, y: number) => window.mulby?.input?.simulateMouseRightClick(x, y),
57
+ },
58
+
59
+ // Storage API
60
+ storage: {
61
+ get: (key: string) => window.mulby?.storage?.get(key, pluginId),
62
+ set: (key: string, value: unknown) => window.mulby?.storage?.set(key, value, pluginId),
63
+ remove: (key: string) => window.mulby?.storage?.remove(key, pluginId),
64
+ },
65
+
66
+ // AI API
67
+ ai: {
68
+ // option 参数支持:
69
+ // - model: 模型 ID
70
+ // - messages: 消息数组
71
+ // - tools: 工具定义数组
72
+ // - capabilities/internalTools/toolingPolicy: 内置工具能力控制
73
+ // - mcp: MCP 选择策略(off/manual/auto + server/tool 限制)
74
+ // - skills: 技能选择策略
75
+ // - params: 模型参数
76
+ // - toolContext: 工具上下文(插件名与 MCP 作用域)
77
+ // - maxToolSteps: 工具调用的最大步骤数(默认 20,最大 100)
78
+ call: (option: any, onChunk?: (chunk: any) => void) => window.mulby?.ai?.call(option, onChunk),
79
+ allModels: () => window.mulby?.ai?.allModels?.(),
80
+ abort: (requestId: string) => window.mulby?.ai?.abort?.(requestId),
81
+ skills: {
82
+ list: () => window.mulby?.ai?.skills?.list?.(),
83
+ refresh: () => window.mulby?.ai?.skills?.refresh?.(),
84
+ listEnabled: () => window.mulby?.ai?.skills?.listEnabled?.(),
85
+ get: (skillId: string) => window.mulby?.ai?.skills?.get?.(skillId),
86
+ listCreateModels: () => window.mulby?.ai?.skills?.listCreateModels?.(),
87
+ createWithAi: (input: any) => window.mulby?.ai?.skills?.createWithAi?.(input),
88
+ createWithAiStream: (input: any, onChunk: (chunk: any) => void) =>
89
+ window.mulby?.ai?.skills?.createWithAiStream?.(input, onChunk),
90
+ create: (input: any) => window.mulby?.ai?.skills?.create?.(input),
91
+ install: (input: any) => window.mulby?.ai?.skills?.install?.(input),
92
+ importFromJson: (input: any) => window.mulby?.ai?.skills?.importFromJson?.(input),
93
+ update: (skillId: string, patch: any) => window.mulby?.ai?.skills?.update?.(skillId, patch),
94
+ remove: (skillId: string) => window.mulby?.ai?.skills?.remove?.(skillId),
95
+ enable: (skillId: string) => window.mulby?.ai?.skills?.enable?.(skillId),
96
+ disable: (skillId: string) => window.mulby?.ai?.skills?.disable?.(skillId),
97
+ preview: (input: any) => window.mulby?.ai?.skills?.preview?.(input),
98
+ resolve: (option: any) => window.mulby?.ai?.skills?.resolve?.(option),
99
+ },
100
+ tokens: {
101
+ estimate: (input: any) => window.mulby?.ai?.tokens?.estimate(input),
102
+ },
103
+ attachments: {
104
+ upload: (input: any) => window.mulby?.ai?.attachments?.upload(input),
105
+ get: (attachmentId: string) => window.mulby?.ai?.attachments?.get(attachmentId),
106
+ delete: (attachmentId: string) => window.mulby?.ai?.attachments?.delete(attachmentId),
107
+ uploadToProvider: (input: any) => window.mulby?.ai?.attachments?.uploadToProvider(input),
108
+ },
109
+ images: {
110
+ generate: (input: any) => window.mulby?.ai?.images?.generate(input),
111
+ generateStream: (input: any, onChunk: (chunk: any) => void) =>
112
+ window.mulby?.ai?.images?.generateStream(input, onChunk),
113
+ edit: (input: any) => window.mulby?.ai?.images?.edit(input),
114
+ },
115
+ models: {
116
+ fetch: (input: any) => window.mulby?.ai?.models?.fetch(input),
117
+ },
118
+ testConnection: (input?: any) => window.mulby?.ai?.testConnection?.(input),
119
+ testConnectionStream: (input: any, onChunk: (chunk: any) => void) =>
120
+ window.mulby?.ai?.testConnectionStream?.(input, onChunk),
121
+ settings: {
122
+ get: () => window.mulby?.ai?.settings?.get(),
123
+ update: (next: any) => window.mulby?.ai?.settings?.update(next),
124
+ },
125
+ mcp: {
126
+ listServers: () => window.mulby?.ai?.mcp?.listServers?.(),
127
+ getServer: (serverId: string) => window.mulby?.ai?.mcp?.getServer?.(serverId),
128
+ upsertServer: (server: any) => window.mulby?.ai?.mcp?.upsertServer?.(server),
129
+ removeServer: (serverId: string) => window.mulby?.ai?.mcp?.removeServer?.(serverId),
130
+ activateServer: (serverId: string) => window.mulby?.ai?.mcp?.activateServer?.(serverId),
131
+ deactivateServer: (serverId: string) => window.mulby?.ai?.mcp?.deactivateServer?.(serverId),
132
+ restartServer: (serverId: string) => window.mulby?.ai?.mcp?.restartServer?.(serverId),
133
+ checkServer: (serverId: string) => window.mulby?.ai?.mcp?.checkServer?.(serverId),
134
+ listTools: (serverId: string) => window.mulby?.ai?.mcp?.listTools?.(serverId),
135
+ abort: (callId: string) => window.mulby?.ai?.mcp?.abort?.(callId),
136
+ getLogs: (serverId: string) => window.mulby?.ai?.mcp?.getLogs?.(serverId),
137
+ },
138
+ },
139
+
140
+ // Messaging API
141
+ messaging: {
142
+ send: (targetPluginId: string, type: string, payload: unknown) =>
143
+ window.mulby?.messaging?.send(targetPluginId, type, payload),
144
+ broadcast: (type: string, payload: unknown) =>
145
+ window.mulby?.messaging?.broadcast(type, payload),
146
+ on: (callback: (message: {
147
+ id: string
148
+ from: string
149
+ to?: string
150
+ type: string
151
+ payload: unknown
152
+ timestamp: number
153
+ }) => void | Promise<void>) => window.mulby?.messaging?.on(callback),
154
+ off: (callback?: (message: any) => void) => window.mulby?.messaging?.off(callback),
155
+ },
156
+
157
+ // Scheduler API
158
+ scheduler: {
159
+ schedule: (task: {
160
+ name: string
161
+ type: 'once' | 'repeat' | 'delay'
162
+ callback: string
163
+ time?: number
164
+ cron?: string
165
+ delay?: number
166
+ payload?: any
167
+ maxRetries?: number
168
+ retryDelay?: number
169
+ timeout?: number
170
+ }) => window.mulby?.scheduler?.schedule(task),
171
+ cancelTask: (taskId: string) => window.mulby?.scheduler?.cancelTask(taskId),
172
+ pauseTask: (taskId: string) => window.mulby?.scheduler?.pauseTask(taskId),
173
+ resumeTask: (taskId: string) => window.mulby?.scheduler?.resumeTask(taskId),
174
+ listTasks: (filter?: { status?: string; type?: string; limit?: number; offset?: number }) => window.mulby?.scheduler?.listTasks(filter),
175
+ getTaskCount: (filter?: { status?: string; type?: string }) => window.mulby?.scheduler?.getTaskCount(filter),
176
+ getTask: (taskId: string) => window.mulby?.scheduler?.getTask(taskId),
177
+ deleteTasks: (taskIds: string[]) => window.mulby?.scheduler?.deleteTasks(taskIds),
178
+ cleanupTasks: (olderThan?: number) => window.mulby?.scheduler?.cleanupTasks(olderThan),
179
+ getExecutions: (taskId: string, limit?: number) => window.mulby?.scheduler?.getExecutions(taskId, limit),
180
+ validateCron: (expression: string) => window.mulby?.scheduler?.validateCron(expression),
181
+ getNextCronTime: (expression: string, after?: Date) => window.mulby?.scheduler?.getNextCronTime(expression, after),
182
+ describeCron: (expression: string) => window.mulby?.scheduler?.describeCron(expression),
183
+ },
184
+
185
+ // Notification API
186
+ notification: {
187
+ show: (message: string, type?: 'info' | 'success' | 'warning' | 'error') =>
188
+ window.mulby?.notification?.show(message, type),
189
+ },
190
+
191
+ // Window API
192
+ window: {
193
+ setSize: (width: number, height: number) => window.mulby?.window?.setSize(width, height),
194
+ setExpendHeight: (height: number) => window.mulby?.window?.setExpendHeight?.(height),
195
+ center: () => window.mulby?.window?.center?.(),
196
+ hide: (isRestorePreWindow?: boolean) => window.mulby?.window?.hide?.(isRestorePreWindow),
197
+ show: () => window.mulby?.window?.show(),
198
+ close: () => window.mulby?.window?.close(),
199
+ create: (url: string, options?: { width?: number; height?: number; title?: string }) =>
200
+ window.mulby?.window?.create(url, options),
201
+ detach: () => window.mulby?.window?.detach?.(),
202
+ setAlwaysOnTop: (flag: boolean) => window.mulby?.window?.setAlwaysOnTop?.(flag),
203
+ getMode: () => window.mulby?.window?.getMode?.(),
204
+ getWindowType: () => window.mulby?.window?.getWindowType?.(),
205
+ minimize: () => window.mulby?.window?.minimize?.(),
206
+ maximize: () => window.mulby?.window?.maximize?.(),
207
+ getState: () => window.mulby?.window?.getState?.(),
208
+ reload: () => window.mulby?.window?.reload?.(),
209
+ sendToParent: (channel: string, ...args: unknown[]) =>
210
+ window.mulby?.window?.sendToParent?.(channel, ...args),
211
+ onChildMessage: (callback: (channel: string, ...args: unknown[]) => void) =>
212
+ window.mulby?.window?.onChildMessage?.(callback),
213
+ findInPage: (text: string, options?: { forward?: boolean; findNext?: boolean; matchCase?: boolean }) =>
214
+ window.mulby?.window?.findInPage?.(text, options),
215
+ stopFindInPage: (action?: 'clearSelection' | 'keepSelection' | 'activateSelection') =>
216
+ window.mulby?.window?.stopFindInPage?.(action),
217
+ startDrag: (filePath: string | string[]) => window.mulby?.window?.startDrag?.(filePath),
218
+ },
219
+
220
+ // SubInput API
221
+ subInput: {
222
+ set: (placeholder?: string, isFocus?: boolean) => window.mulby?.subInput?.set?.(placeholder, isFocus),
223
+ remove: () => window.mulby?.subInput?.remove?.(),
224
+ setValue: (text: string) => window.mulby?.subInput?.setValue?.(text),
225
+ focus: () => window.mulby?.subInput?.focus?.(),
226
+ blur: () => window.mulby?.subInput?.blur?.(),
227
+ select: () => window.mulby?.subInput?.select?.(),
228
+ onChange: (callback: (data: { text: string }) => void) => window.mulby?.subInput?.onChange?.(callback),
229
+ },
230
+
231
+ // Plugin API
232
+ plugin: {
233
+ getAll: () => window.mulby?.plugin?.getAll?.(),
234
+ search: (query: string) => window.mulby?.plugin?.search?.(query),
235
+ run: (name: string, featureCode: string, input?: string) => window.mulby?.plugin?.run?.(name, featureCode, input),
236
+ install: (filePath: string) => window.mulby?.plugin?.install?.(filePath),
237
+ uninstall: (name: string) => window.mulby?.plugin?.uninstall?.(name),
238
+ getReadme: (name: string) => window.mulby?.plugin?.getReadme?.(name),
239
+ redirect: (label: string | [string, string], payload?: unknown) =>
240
+ window.mulby?.plugin?.redirect?.(label, payload),
241
+ outPlugin: (isKill?: boolean) => window.mulby?.plugin?.outPlugin?.(isKill),
242
+ enable: (name: string) => window.mulby?.plugin?.enable?.(name),
243
+ disable: (name: string) => window.mulby?.plugin?.disable?.(name),
244
+ listBackground: () => window.mulby?.plugin?.listBackground?.(),
245
+ startBackground: (pluginId: string) => window.mulby?.plugin?.startBackground?.(pluginId),
246
+ stopBackground: (pluginId: string) => window.mulby?.plugin?.stopBackground?.(pluginId),
247
+ getBackgroundInfo: (pluginId: string) => window.mulby?.plugin?.getBackgroundInfo?.(pluginId),
248
+ stopPlugin: (pluginId: string) => window.mulby?.plugin?.stopPlugin?.(pluginId),
249
+ },
250
+
251
+ // HTTP API
252
+ http: {
253
+ request: (options: {
254
+ url: string
255
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD'
256
+ headers?: Record<string, string>
257
+ body?: unknown
258
+ timeout?: number
259
+ }) => window.mulby?.http?.request(options),
260
+ get: (url: string, headers?: Record<string, string>) => window.mulby?.http?.get(url, headers),
261
+ post: (url: string, body?: unknown, headers?: Record<string, string>) =>
262
+ window.mulby?.http?.post(url, body, headers),
263
+ put: (url: string, body?: unknown, headers?: Record<string, string>) =>
264
+ window.mulby?.http?.put(url, body, headers),
265
+ delete: (url: string, headers?: Record<string, string>) => window.mulby?.http?.delete(url, headers),
266
+ },
267
+
268
+ // Filesystem API
269
+ filesystem: {
270
+ readFile: (path: string, encoding?: 'utf-8' | 'base64') => window.mulby?.filesystem?.readFile(path, encoding),
271
+ writeFile: (path: string, data: string | ArrayBuffer, encoding?: 'utf-8' | 'base64') =>
272
+ window.mulby?.filesystem?.writeFile(path, data, encoding),
273
+ exists: (path: string) => window.mulby?.filesystem?.exists(path),
274
+ readdir: (path: string) => window.mulby?.filesystem?.readdir(path),
275
+ mkdir: (path: string) => window.mulby?.filesystem?.mkdir(path),
276
+ stat: (path: string) => window.mulby?.filesystem?.stat(path),
277
+ copy: (src: string, dest: string) => window.mulby?.filesystem?.copy(src, dest),
278
+ move: (src: string, dest: string) => window.mulby?.filesystem?.move(src, dest),
279
+ unlink: (path: string) => window.mulby?.filesystem?.unlink(path),
280
+ },
281
+
282
+ // Screen API
283
+ screen: {
284
+ getAllDisplays: () => window.mulby?.screen?.getAllDisplays(),
285
+ getPrimaryDisplay: () => window.mulby?.screen?.getPrimaryDisplay(),
286
+ getCursorScreenPoint: () => window.mulby?.screen?.getCursorScreenPoint(),
287
+ getDisplayNearestPoint: (point: { x: number; y: number }) =>
288
+ window.mulby?.screen?.getDisplayNearestPoint?.(point),
289
+ getDisplayMatching: (rect: { x: number; y: number; width: number; height: number }) =>
290
+ window.mulby?.screen?.getDisplayMatching?.(rect),
291
+ getSources: (options?: { types?: ('screen' | 'window')[]; thumbnailSize?: { width: number; height: number } }) =>
292
+ window.mulby?.screen?.getSources(options),
293
+ capture: (options?: { sourceId?: string; format?: 'png' | 'jpeg'; quality?: number }) =>
294
+ window.mulby?.screen?.capture(options),
295
+ captureRegion: (region: { x: number; y: number; width: number; height: number }, options?: { format?: 'png' | 'jpeg'; quality?: number }) =>
296
+ window.mulby?.screen?.captureRegion(region, options),
297
+ screenCapture: () => window.mulby?.screen?.screenCapture(),
298
+ colorPick: () => window.mulby?.screen?.colorPick?.(),
299
+ },
300
+
301
+ // Shell API
302
+ shell: {
303
+ openPath: (path: string) => window.mulby?.shell?.openPath(path),
304
+ openExternal: (url: string) => window.mulby?.shell?.openExternal(url),
305
+ showItemInFolder: (path: string) => window.mulby?.shell?.showItemInFolder(path),
306
+ openFolder: (path: string) => window.mulby?.shell?.openFolder(path),
307
+ trashItem: (path: string) => window.mulby?.shell?.trashItem(path),
308
+ beep: () => window.mulby?.shell?.beep(),
309
+ },
310
+
311
+ // Dialog API
312
+ dialog: {
313
+ showOpenDialog: (options?: {
314
+ title?: string
315
+ defaultPath?: string
316
+ filters?: { name: string; extensions: string[] }[]
317
+ properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles')[]
318
+ }) => window.mulby?.dialog?.showOpenDialog(options),
319
+ showSaveDialog: (options?: {
320
+ title?: string
321
+ defaultPath?: string
322
+ filters?: { name: string; extensions: string[] }[]
323
+ }) => window.mulby?.dialog?.showSaveDialog(options),
324
+ showMessageBox: (options: {
325
+ type?: 'none' | 'info' | 'error' | 'question' | 'warning'
326
+ title?: string
327
+ message: string
328
+ detail?: string
329
+ buttons?: string[]
330
+ }) => window.mulby?.dialog?.showMessageBox(options),
331
+ },
332
+
333
+ // System API
334
+ system: {
335
+ getSystemInfo: () => window.mulby?.system?.getSystemInfo(),
336
+ getAppInfo: () => window.mulby?.system?.getAppInfo(),
337
+ getPath: (name: string) => window.mulby?.system?.getPath(name as any),
338
+ getEnv: (name: string) => window.mulby?.system?.getEnv(name),
339
+ getIdleTime: () => window.mulby?.system?.getIdleTime(),
340
+ getFileIcon: (filePath: string) => window.mulby?.system?.getFileIcon?.(filePath),
341
+ getNativeId: () => window.mulby?.system?.getNativeId?.(),
342
+ isDev: () => window.mulby?.system?.isDev?.(),
343
+ isMacOS: () => window.mulby?.system?.isMacOS?.(),
344
+ isWindows: () => window.mulby?.system?.isWindows?.(),
345
+ isLinux: () => window.mulby?.system?.isLinux?.(),
346
+ },
347
+
348
+ // Permission API
349
+ permission: {
350
+ getStatus: (type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar') =>
351
+ window.mulby?.permission?.getStatus(type),
352
+ request: (type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar') =>
353
+ window.mulby?.permission?.request(type),
354
+ canRequest: (type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar') =>
355
+ window.mulby?.permission?.canRequest(type),
356
+ openSystemSettings: (type: 'geolocation' | 'camera' | 'microphone' | 'notifications' | 'screen' | 'accessibility' | 'contacts' | 'calendar') =>
357
+ window.mulby?.permission?.openSystemSettings(type),
358
+ isAccessibilityTrusted: () => window.mulby?.permission?.isAccessibilityTrusted()
359
+ },
360
+
361
+ // Power API
362
+ power: {
363
+ getSystemIdleTime: () => window.mulby?.power?.getSystemIdleTime(),
364
+ getSystemIdleState: (threshold: number) => window.mulby?.power?.getSystemIdleState(threshold),
365
+ isOnBatteryPower: () => window.mulby?.power?.isOnBatteryPower(),
366
+ getCurrentThermalState: () => window.mulby?.power?.getCurrentThermalState(),
367
+ },
368
+
369
+ // Network API
370
+ network: {
371
+ isOnline: () => window.mulby?.network?.isOnline(),
372
+ },
373
+
374
+ // Geolocation API
375
+ geolocation: {
376
+ getAccessStatus: () => window.mulby?.geolocation?.getAccessStatus(),
377
+ requestAccess: () => window.mulby?.geolocation?.requestAccess(),
378
+ canGetPosition: () => window.mulby?.geolocation?.canGetPosition(),
379
+ openSettings: () => window.mulby?.geolocation?.openSettings(),
380
+ getCurrentPosition: () => window.mulby?.geolocation?.getCurrentPosition(),
381
+ },
382
+
383
+ // TTS API
384
+ tts: {
385
+ speak: (text: string, options?: { lang?: string; rate?: number; pitch?: number; volume?: number }) =>
386
+ window.mulby?.tts?.speak(text, options),
387
+ stop: () => window.mulby?.tts?.stop(),
388
+ pause: () => window.mulby?.tts?.pause(),
389
+ resume: () => window.mulby?.tts?.resume(),
390
+ getVoices: () => window.mulby?.tts?.getVoices(),
391
+ isSpeaking: () => window.mulby?.tts?.isSpeaking(),
392
+ },
393
+
394
+ // Media API
395
+ media: {
396
+ getAccessStatus: (type: 'camera' | 'microphone') => window.mulby?.media?.getAccessStatus(type),
397
+ askForAccess: (type: 'camera' | 'microphone') => window.mulby?.media?.askForAccess(type),
398
+ hasCameraAccess: () => window.mulby?.media?.hasCameraAccess(),
399
+ hasMicrophoneAccess: () => window.mulby?.media?.hasMicrophoneAccess(),
400
+ },
401
+
402
+ // Shortcut API
403
+ shortcut: {
404
+ register: (accelerator: string) => window.mulby?.shortcut?.register(accelerator),
405
+ unregister: (accelerator: string) => window.mulby?.shortcut?.unregister(accelerator),
406
+ unregisterAll: () => window.mulby?.shortcut?.unregisterAll(),
407
+ isRegistered: (accelerator: string) => window.mulby?.shortcut?.isRegistered(accelerator),
408
+ },
409
+
410
+ // Security API
411
+ security: {
412
+ isEncryptionAvailable: () => window.mulby?.security?.isEncryptionAvailable(),
413
+ encryptString: (text: string) => window.mulby?.security?.encryptString(text),
414
+ decryptString: (data: ArrayBuffer) => window.mulby?.security?.decryptString(data),
415
+ },
416
+
417
+ // Tray API
418
+ tray: {
419
+ create: (options: { icon: string; tooltip?: string; title?: string }) =>
420
+ window.mulby?.tray?.create(options),
421
+ destroy: () => window.mulby?.tray?.destroy(),
422
+ setIcon: (icon: string) => window.mulby?.tray?.setIcon(icon),
423
+ setTooltip: (tooltip: string) => window.mulby?.tray?.setTooltip(tooltip),
424
+ setTitle: (title: string) => window.mulby?.tray?.setTitle(title),
425
+ exists: () => window.mulby?.tray?.exists(),
426
+ },
427
+
428
+ // Menu API
429
+ menu: {
430
+ showContextMenu: (items: {
431
+ label?: string
432
+ type?: 'normal' | 'separator' | 'checkbox' | 'radio'
433
+ checked?: boolean
434
+ enabled?: boolean
435
+ id?: string
436
+ submenu?: unknown[]
437
+ }[]) => window.mulby?.menu?.showContextMenu(items as Parameters<typeof window.mulby.menu.showContextMenu>[0]),
438
+ },
439
+
440
+ // Theme API
441
+ theme: {
442
+ get: () => window.mulby?.theme?.get(),
443
+ set: (mode: 'light' | 'dark' | 'system') => window.mulby?.theme?.set(mode),
444
+ getActual: () => window.mulby?.theme?.getActual(),
445
+ },
446
+
447
+ // Host API
448
+ host: {
449
+ invoke: (method: string, ...args: unknown[]) =>
450
+ window.mulby?.host?.invoke(pluginId || '', method, ...args),
451
+ call: (method: string, ...args: unknown[]) =>
452
+ window.mulby?.host?.call?.(pluginId || '', method, ...args),
453
+ status: () => window.mulby?.host?.status(pluginId || ''),
454
+ restart: () => window.mulby?.host?.restart(pluginId || ''),
455
+ },
456
+
457
+ // InBrowser API
458
+ inbrowser: window.mulby?.inbrowser,
459
+
460
+ // Sharp API
461
+ sharp: window.mulby?.sharp,
462
+ getSharpVersion: () => window.mulby?.getSharpVersion?.(),
463
+
464
+ // FFmpeg API
465
+ ffmpeg: window.mulby?.ffmpeg,
466
+ }), [pluginId])
467
+ }
468
+ `;
469
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * React 插件模板 - 统一导出入口
4
+ *
5
+ * 将原 react.ts 拆分为多个模块文件,便于维护和 AI 阅读:
6
+ * - config.ts - 配置文件生成器(manifest, package.json, tsconfig 等)
7
+ * - backend.ts - 后端代码生成器(main.ts)
8
+ * - ui.ts - UI 代码生成器(index.html, main.tsx, App.tsx, styles.css)
9
+ * - hooks.ts - Hooks 代码生成器(useMulby.ts)
10
+ * - types.ts - 类型定义生成器(mulby.d.ts)
11
+ * - docs.ts - 文档生成器(README.md)
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.buildReactReadme = exports.buildMulbyTypes = exports.buildUseMulby = exports.buildStylesCss = exports.buildAppTsx = exports.buildMainTsx = exports.buildIndexHtml = exports.buildBackendMain = exports.buildGitignore = exports.buildTailwindConfig = exports.buildPostcssConfig = exports.buildViteConfig = exports.buildTsConfig = exports.buildReactPackageJson = exports.buildReactManifest = void 0;
15
+ // 配置文件
16
+ var config_js_1 = require("./config.js");
17
+ Object.defineProperty(exports, "buildReactManifest", { enumerable: true, get: function () { return config_js_1.buildReactManifest; } });
18
+ Object.defineProperty(exports, "buildReactPackageJson", { enumerable: true, get: function () { return config_js_1.buildReactPackageJson; } });
19
+ Object.defineProperty(exports, "buildTsConfig", { enumerable: true, get: function () { return config_js_1.buildTsConfig; } });
20
+ Object.defineProperty(exports, "buildViteConfig", { enumerable: true, get: function () { return config_js_1.buildViteConfig; } });
21
+ Object.defineProperty(exports, "buildPostcssConfig", { enumerable: true, get: function () { return config_js_1.buildPostcssConfig; } });
22
+ Object.defineProperty(exports, "buildTailwindConfig", { enumerable: true, get: function () { return config_js_1.buildTailwindConfig; } });
23
+ Object.defineProperty(exports, "buildGitignore", { enumerable: true, get: function () { return config_js_1.buildGitignore; } });
24
+ // 后端代码
25
+ var backend_js_1 = require("./backend.js");
26
+ Object.defineProperty(exports, "buildBackendMain", { enumerable: true, get: function () { return backend_js_1.buildBackendMain; } });
27
+ // UI 代码
28
+ var ui_js_1 = require("./ui.js");
29
+ Object.defineProperty(exports, "buildIndexHtml", { enumerable: true, get: function () { return ui_js_1.buildIndexHtml; } });
30
+ Object.defineProperty(exports, "buildMainTsx", { enumerable: true, get: function () { return ui_js_1.buildMainTsx; } });
31
+ Object.defineProperty(exports, "buildAppTsx", { enumerable: true, get: function () { return ui_js_1.buildAppTsx; } });
32
+ Object.defineProperty(exports, "buildStylesCss", { enumerable: true, get: function () { return ui_js_1.buildStylesCss; } });
33
+ // Hooks 代码
34
+ var hooks_js_1 = require("./hooks.js");
35
+ Object.defineProperty(exports, "buildUseMulby", { enumerable: true, get: function () { return hooks_js_1.buildUseMulby; } });
36
+ // 类型定义
37
+ var types_js_1 = require("./types.js");
38
+ Object.defineProperty(exports, "buildMulbyTypes", { enumerable: true, get: function () { return types_js_1.buildMulbyTypes; } });
39
+ // 文档
40
+ var docs_js_1 = require("./docs.js");
41
+ Object.defineProperty(exports, "buildReactReadme", { enumerable: true, get: function () { return docs_js_1.buildReactReadme; } });