foliko 1.1.8 → 1.1.9

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 (306) hide show
  1. package/.agent/agents/code-assistant.json +17 -0
  2. package/.agent/agents/email-assistant.json +14 -0
  3. package/.agent/agents/file-assistant.json +18 -0
  4. package/.agent/agents/orchestrator-demo.md +53 -0
  5. package/.agent/agents/orchestrator.json +7 -0
  6. package/.agent/agents/poster-expert.md +228 -0
  7. package/.agent/agents/system-assistant.json +15 -0
  8. package/.agent/agents/web-assistant.json +12 -0
  9. package/.agent/data/default.json +5 -404
  10. package/.agent/data/email/processed-emails.json +1 -0
  11. package/.agent/data/plugins-state.json +173 -172
  12. package/.agent/data/scheduler/tasks.json +1 -0
  13. package/.agent/data/web/web-config.json +5 -0
  14. package/.agent/mcp_config.json +0 -14
  15. package/.agent/package.json +8 -0
  16. package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
  17. package/.agent/plugins/daytona/README.md +89 -0
  18. package/.agent/plugins/daytona/index.js +377 -0
  19. package/.agent/plugins/daytona/package.json +12 -0
  20. package/.agent/plugins/marknative/README.md +134 -0
  21. package/.agent/plugins/marknative/fonts.zip +0 -0
  22. package/.agent/plugins/marknative/index.js +256 -0
  23. package/.agent/plugins/marknative/package.json +12 -0
  24. package/.agent/plugins/system-info/index.js +387 -0
  25. package/.agent/plugins/system-info/package.json +4 -0
  26. package/.agent/plugins/system-info/test.js +40 -0
  27. package/.agent/plugins/test-plugin.py +123 -0
  28. package/.agent/plugins/test_nested_plugin.py +85 -0
  29. package/.agent/plugins.json +11 -5
  30. package/.agent/python-scripts/test_sample.py +24 -0
  31. package/.agent/sessions/cli_default.json +96 -249
  32. package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +189 -0
  33. package/.agent/skills/agent-browser/SKILL.md +311 -0
  34. package/.agent/skills/agent-browser/TEST_PLAN.md +200 -0
  35. package/.agent/skills/sysinfo/SKILL.md +38 -0
  36. package/.agent/skills/sysinfo/system-info.sh +130 -0
  37. package/.agent/skills/workflow/SKILL.md +324 -0
  38. package/.agent/test-agent.js +35 -0
  39. package/.agent/weixin.json +6 -0
  40. package/.agent/workflows/email-digest.json +50 -0
  41. package/.agent/workflows/file-backup.json +21 -0
  42. package/.agent/workflows/get-ip-notify.json +32 -0
  43. package/.agent/workflows/news-aggregator.json +93 -0
  44. package/.agent/workflows/news-dashboard-v2.json +94 -0
  45. package/.agent/workflows/notification-batch.json +32 -0
  46. package/.claude/settings.local.json +9 -1
  47. package/.env.example +56 -56
  48. package/README.md +441 -441
  49. package/cli/src/ui/chat-ui.js +32 -21
  50. package/foliko_poster.png +0 -0
  51. package/output/business_poster_final.png +0 -0
  52. package/output/emoji_test_v2.png +0 -0
  53. package/output/foliko-ai-launch-poster.png +0 -0
  54. package/output/foliko-poster.png +0 -0
  55. package/output/muji_style_poster.png +0 -0
  56. package/output/new_product_launch.png +0 -0
  57. package/output/news_poster_625yi_subsidy.png +0 -0
  58. package/output/tech_future_2026.png +0 -0
  59. package/output/tech_future_poster.png +0 -0
  60. package/package.json +1 -2
  61. package/plugins/default-plugins.js +58 -6
  62. package/plugins/extension-executor-plugin.js +8 -21
  63. package/plugins/python-plugin-loader.js +461 -40
  64. package/plugins/python-plugin-loader.js.bak +856 -0
  65. package/plugins/subagent-plugin.js +0 -121
  66. package/plugins/weixin-plugin.js +38 -29
  67. package/poster.png +0 -0
  68. package/skills/find-skills/AGENTS.md +162 -162
  69. package/skills/find-skills/SKILL.md +133 -133
  70. package/skills/foliko-dev/SKILL.md +6 -0
  71. package/skills/python-plugin-dev/SKILL.md +124 -2
  72. package/src/core/agent-chat.js +220 -281
  73. package/src/core/agent.js +10 -0
  74. package/src/utils/plugin-helpers.js +22 -4
  75. package/system.md +1678 -1574
  76. package/test-scan.js +18 -0
  77. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
  78. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
  79. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
  80. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
  81. package/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
  82. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
  83. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
  84. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
  85. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
  86. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
  87. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
  88. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
  89. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
  90. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
  91. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
  92. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
  93. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
  94. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
  95. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
  96. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
  97. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
  98. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
  99. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
  100. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
  101. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  102. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  103. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +0 -258
  104. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
  105. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
  106. package/.agent/ARCHITECTURE.md +0 -288
  107. package/.agent/agents/ambient-agent.md +0 -57
  108. package/.agent/agents/debugger.md +0 -55
  109. package/.agent/agents/email-assistant.md +0 -49
  110. package/.agent/agents/file-manager.md +0 -42
  111. package/.agent/agents/python-developer.md +0 -60
  112. package/.agent/agents/scheduler.md +0 -59
  113. package/.agent/agents/web-developer.md +0 -45
  114. package/.agent/data/puppeteer-sessions/undefined.json +0 -6
  115. package/.agent/data/weixin-media/2026-04-08/img_1775618677512.jpg +0 -0
  116. package/.agent/data/weixin-media/2026-04-08/img_1775619073340.jpg +0 -0
  117. package/.agent/data/weixin-media/2026-04-08/img_1775619097536.jpg +0 -0
  118. package/.agent/data/weixin-media/2026-04-08/img_1775619209388.jpg +0 -0
  119. package/.agent/memory/feedback/mnrdvj5i-ca3dkd.md +0 -9
  120. package/.agent/memory/feedback/mnre365e-7s4zax.md +0 -9
  121. package/.agent/memory/feedback/mnre36jn-nkfgmp.md +0 -9
  122. package/.agent/memory/feedback/mnre3805-kjiq6h.md +0 -9
  123. package/.agent/memory/feedback/mnsf66kp-b10rcd.md +0 -9
  124. package/.agent/memory/feedback/mnsi3sz8-p5g2cw.md +0 -9
  125. package/.agent/memory/feedback/mnsibe47-sv2ni1.md +0 -9
  126. package/.agent/memory/feedback/mnsic89w-nn228o.md +0 -9
  127. package/.agent/memory/feedback/mnsj1xe9-x83ba0.md +0 -9
  128. package/.agent/memory/feedback/mnsj21iv-wnwelx.md +0 -9
  129. package/.agent/memory/feedback/mnsj2g4a-cog7a2.md +0 -9
  130. package/.agent/memory/feedback/mnsj4js7-lktjp6.md +0 -9
  131. package/.agent/memory/feedback/mnsj5d4y-uglwvp.md +0 -9
  132. package/.agent/memory/feedback/mnslkuo9-uous66.md +0 -24
  133. package/.agent/memory/feedback/mnsm3vq0-megoil.md +0 -9
  134. package/.agent/memory/feedback/mnsnn5x2-sxcihd.md +0 -9
  135. package/.agent/memory/feedback/mnsnq17s-nabrn9.md +0 -9
  136. package/.agent/memory/feedback/mnsnybet-wz7rn3.md +0 -9
  137. package/.agent/memory/feedback/mnsrw0s7-7s9e30.md +0 -9
  138. package/.agent/memory/feedback/mnu5hpnd-tlm16q.md +0 -9
  139. package/.agent/memory/feedback/mnu60uqe-xuoxp4.md +0 -9
  140. package/.agent/memory/project/mnqx54u5-loqtoe.md +0 -9
  141. package/.agent/memory/project/mnqx84cv-mx6dmd.md +0 -9
  142. package/.agent/memory/project/mnsacuyr-hgtk5n.md +0 -20
  143. package/.agent/memory/project/mnu5hy2x-bjsg7u.md +0 -9
  144. package/.agent/memory/reference/mnre3cww-penbo1.md +0 -9
  145. package/.agent/memory/reference/mns9wn48-luerua.md +0 -14
  146. package/.agent/memory/reference/mns9yz5c-thc2s0.md +0 -16
  147. package/.agent/memory/reference/mnsfy4um-910f1o.md +0 -23
  148. package/.agent/memory/reference/mnsg37dp-lmfj18.md +0 -32
  149. package/.agent/memory/reference/mnsll60q-0j911u.md +0 -36
  150. package/.agent/memory/reference/mnsmlb5y-nej31u.md +0 -16
  151. package/.agent/memory/reference/mnssle72-yrot96.md +0 -9
  152. package/.agent/memory/user/mnsfuon6-l416q1.md +0 -21
  153. package/.agent/memory/user/mnsg9kut-95m7rf.md +0 -20
  154. package/.agent/memory/user/mnu2eo1v-yy6fhe.md +0 -9
  155. package/.agent/memory/user/mnu2etuo-8u8jk8.md +0 -9
  156. package/.agent/plugins/poster-plugin/README.md +0 -304
  157. package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
  158. package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
  159. package/.agent/plugins/poster-plugin/fonts/Symbola_hint.ttf +0 -0
  160. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
  161. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221/347/262/227/344/275/223.ttf +0 -0
  162. package/.agent/plugins/poster-plugin/index.js +0 -13
  163. package/.agent/plugins/poster-plugin/package.json +0 -29
  164. package/.agent/plugins/poster-plugin/src/canvas.js +0 -232
  165. package/.agent/plugins/poster-plugin/src/components/arrow.js +0 -84
  166. package/.agent/plugins/poster-plugin/src/components/avatar.js +0 -71
  167. package/.agent/plugins/poster-plugin/src/components/badge.js +0 -85
  168. package/.agent/plugins/poster-plugin/src/components/barcode.js +0 -123
  169. package/.agent/plugins/poster-plugin/src/components/bubble.js +0 -154
  170. package/.agent/plugins/poster-plugin/src/components/button.js +0 -168
  171. package/.agent/plugins/poster-plugin/src/components/card.js +0 -88
  172. package/.agent/plugins/poster-plugin/src/components/chart.js +0 -127
  173. package/.agent/plugins/poster-plugin/src/components/chip.js +0 -88
  174. package/.agent/plugins/poster-plugin/src/components/columns.js +0 -121
  175. package/.agent/plugins/poster-plugin/src/components/cta.js +0 -87
  176. package/.agent/plugins/poster-plugin/src/components/divider.js +0 -55
  177. package/.agent/plugins/poster-plugin/src/components/feature.js +0 -85
  178. package/.agent/plugins/poster-plugin/src/components/featureGrid.js +0 -117
  179. package/.agent/plugins/poster-plugin/src/components/frame.js +0 -230
  180. package/.agent/plugins/poster-plugin/src/components/grid.js +0 -130
  181. package/.agent/plugins/poster-plugin/src/components/highlightText.js +0 -145
  182. package/.agent/plugins/poster-plugin/src/components/icon.js +0 -94
  183. package/.agent/plugins/poster-plugin/src/components/imageFrame.js +0 -205
  184. package/.agent/plugins/poster-plugin/src/components/index.js +0 -81
  185. package/.agent/plugins/poster-plugin/src/components/listItem.js +0 -147
  186. package/.agent/plugins/poster-plugin/src/components/notification.js +0 -123
  187. package/.agent/plugins/poster-plugin/src/components/progress.js +0 -79
  188. package/.agent/plugins/poster-plugin/src/components/progressCircle.js +0 -117
  189. package/.agent/plugins/poster-plugin/src/components/qrcode.js +0 -74
  190. package/.agent/plugins/poster-plugin/src/components/quote.js +0 -169
  191. package/.agent/plugins/poster-plugin/src/components/rating.js +0 -85
  192. package/.agent/plugins/poster-plugin/src/components/ribbon.js +0 -197
  193. package/.agent/plugins/poster-plugin/src/components/seal.js +0 -148
  194. package/.agent/plugins/poster-plugin/src/components/star.js +0 -70
  195. package/.agent/plugins/poster-plugin/src/components/statCard.js +0 -105
  196. package/.agent/plugins/poster-plugin/src/components/stepper.js +0 -118
  197. package/.agent/plugins/poster-plugin/src/components/table.js +0 -167
  198. package/.agent/plugins/poster-plugin/src/components/tagCloud.js +0 -85
  199. package/.agent/plugins/poster-plugin/src/components/timeline.js +0 -117
  200. package/.agent/plugins/poster-plugin/src/components/watermark.js +0 -54
  201. package/.agent/plugins/poster-plugin/src/composer.js +0 -2314
  202. package/.agent/plugins/poster-plugin/src/elements/artText.js +0 -69
  203. package/.agent/plugins/poster-plugin/src/elements/background.js +0 -99
  204. package/.agent/plugins/poster-plugin/src/elements/circle.js +0 -31
  205. package/.agent/plugins/poster-plugin/src/elements/image.js +0 -28
  206. package/.agent/plugins/poster-plugin/src/elements/index.js +0 -28
  207. package/.agent/plugins/poster-plugin/src/elements/line.js +0 -23
  208. package/.agent/plugins/poster-plugin/src/elements/polygon.js +0 -63
  209. package/.agent/plugins/poster-plugin/src/elements/rectangle.js +0 -32
  210. package/.agent/plugins/poster-plugin/src/elements/richText.js +0 -283
  211. package/.agent/plugins/poster-plugin/src/elements/svg.js +0 -108
  212. package/.agent/plugins/poster-plugin/src/elements/text.js +0 -112
  213. package/.agent/plugins/poster-plugin/src/fonts.js +0 -674
  214. package/.agent/plugins/poster-plugin/src/index.js +0 -2126
  215. package/.agent/plugins/poster-plugin/src/presets.js +0 -36
  216. package/.agent/plugins/poster-plugin/src/templates/business.js +0 -60
  217. package/.agent/plugins/poster-plugin/src/templates/gradient.js +0 -64
  218. package/.agent/plugins/poster-plugin/src/templates/index.js +0 -43
  219. package/.agent/plugins/poster-plugin/src/templates/modern.js +0 -69
  220. package/.agent/plugins/poster-plugin/src/templates/simple.js +0 -58
  221. package/.agent/plugins/poster-plugin/src/templates/social.js +0 -62
  222. package/.agent/plugins/poster-plugin/src/templates/tech.js +0 -84
  223. package/.agent/plugins/poster-plugin/src/utils/imageLoader.js +0 -84
  224. package/.agent/plugins/poster-plugin/yarn.lock +0 -837
  225. package/.agent/plugins/puppeteer-plugin/README.md +0 -147
  226. package/.agent/plugins/puppeteer-plugin/index.js +0 -1422
  227. package/.agent/plugins/puppeteer-plugin/package.json +0 -9
  228. package/.agent/rules/GEMINI.md +0 -273
  229. package/.agent/rules/allow-rule.md +0 -77
  230. package/.agent/rules/log-rule.md +0 -83
  231. package/.agent/rules/security-rule.md +0 -93
  232. package/.agent/scripts/auto_preview.py +0 -148
  233. package/.agent/scripts/checklist.py +0 -217
  234. package/.agent/scripts/session_manager.py +0 -120
  235. package/.agent/scripts/verify_all.py +0 -327
  236. package/.agent/skills/api-patterns/SKILL.md +0 -81
  237. package/.agent/skills/api-patterns/api-style.md +0 -42
  238. package/.agent/skills/api-patterns/auth.md +0 -24
  239. package/.agent/skills/api-patterns/documentation.md +0 -26
  240. package/.agent/skills/api-patterns/graphql.md +0 -41
  241. package/.agent/skills/api-patterns/rate-limiting.md +0 -31
  242. package/.agent/skills/api-patterns/response.md +0 -37
  243. package/.agent/skills/api-patterns/rest.md +0 -40
  244. package/.agent/skills/api-patterns/scripts/api_validator.py +0 -211
  245. package/.agent/skills/api-patterns/security-testing.md +0 -122
  246. package/.agent/skills/api-patterns/trpc.md +0 -41
  247. package/.agent/skills/api-patterns/versioning.md +0 -22
  248. package/.agent/skills/app-builder/SKILL.md +0 -75
  249. package/.agent/skills/app-builder/agent-coordination.md +0 -71
  250. package/.agent/skills/app-builder/feature-building.md +0 -53
  251. package/.agent/skills/app-builder/project-detection.md +0 -34
  252. package/.agent/skills/app-builder/scaffolding.md +0 -118
  253. package/.agent/skills/app-builder/tech-stack.md +0 -40
  254. package/.agent/skills/app-builder/templates/SKILL.md +0 -39
  255. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +0 -76
  256. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +0 -92
  257. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +0 -88
  258. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +0 -88
  259. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +0 -83
  260. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +0 -90
  261. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +0 -90
  262. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +0 -122
  263. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +0 -122
  264. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +0 -169
  265. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +0 -134
  266. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +0 -83
  267. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +0 -119
  268. package/.agent/skills/architecture/SKILL.md +0 -55
  269. package/.agent/skills/architecture/context-discovery.md +0 -43
  270. package/.agent/skills/architecture/examples.md +0 -94
  271. package/.agent/skills/architecture/pattern-selection.md +0 -68
  272. package/.agent/skills/architecture/patterns-reference.md +0 -50
  273. package/.agent/skills/architecture/trade-off-analysis.md +0 -77
  274. package/.agent/skills/clean-code/SKILL.md +0 -201
  275. package/.agent/skills/doc.md +0 -177
  276. package/.agent/skills/frontend-design/SKILL.md +0 -418
  277. package/.agent/skills/frontend-design/animation-guide.md +0 -331
  278. package/.agent/skills/frontend-design/color-system.md +0 -311
  279. package/.agent/skills/frontend-design/decision-trees.md +0 -418
  280. package/.agent/skills/frontend-design/motion-graphics.md +0 -306
  281. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +0 -183
  282. package/.agent/skills/frontend-design/scripts/ux_audit.py +0 -722
  283. package/.agent/skills/frontend-design/typography-system.md +0 -345
  284. package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
  285. package/.agent/skills/frontend-design/visual-effects.md +0 -383
  286. package/.agent/skills/i18n-localization/SKILL.md +0 -154
  287. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +0 -241
  288. package/.agent/skills/mcp-builder/SKILL.md +0 -176
  289. package/.agent/skills/poster-design/SKILL.md +0 -385
  290. package/.agent/skills/web-design-guidelines/SKILL.md +0 -57
  291. package/.agent/workflows/brainstorm.md +0 -113
  292. package/.agent/workflows/create.md +0 -59
  293. package/.agent/workflows/debug.md +0 -103
  294. package/.agent/workflows/deploy.md +0 -176
  295. package/.agent/workflows/enhance.md +0 -63
  296. package/.agent/workflows/orchestrate.md +0 -237
  297. package/.agent/workflows/plan.md +0 -89
  298. package/.agent/workflows/preview.md +0 -81
  299. package/.agent/workflows/simple-test.md +0 -42
  300. package/.agent/workflows/status.md +0 -86
  301. package/.agent/workflows/structured-orchestrate.md +0 -180
  302. package/.agent/workflows/test.md +0 -144
  303. package/.agent/workflows/ui-ux-pro-max.md +0 -296
  304. package/outputs/emoji-font-showcase.png +0 -0
  305. package/outputs/foliko-muji-style.png +0 -0
  306. /package/.agent/plugins/{poster-plugin → marknative}/fonts/SegoeUI Emoji.ttf +0 -0
@@ -1,2126 +0,0 @@
1
- /**
2
- * Poster Plugin - 海报制作插件 (重构版)
3
- *
4
- * 模块化架构,支持组件化海报生成
5
- */
6
-
7
- const { z } = require('zod')
8
- const path = require('path')
9
- const fs = require('fs')
10
-
11
- // 导入模块
12
- const PRESETS = require('./presets')
13
- const CanvasManager = require('./canvas')
14
- const { createFromConfig, COMPONENT_TYPES } = require('./composer')
15
- const { applyTemplate, getAvailableTemplates } = require('./templates')
16
- const {
17
- addRectangle,
18
- addCircle,
19
- addLine,
20
- addPolygon,
21
- addImage,
22
- addText,
23
- addArtText,
24
- addRichText,
25
- addBackground,
26
- addSVG,
27
- } = require('./elements')
28
-
29
- // 字体管理
30
- const { listAllFonts, getDefaultFont, getDefaultFontFamily, isEmojiFont } = require('./fonts')
31
- const {
32
- createCard,
33
- createBadge,
34
- createCTA,
35
- createFeature,
36
- createFeatureGrid,
37
- createDivider,
38
- createAvatar,
39
- createProgress,
40
- createRating,
41
- createQuote,
42
- createStatCard,
43
- createTagCloud,
44
- createStepper,
45
- createTimeline,
46
- createListItem,
47
- createNotification,
48
- createImageFrame,
49
- createColumns,
50
- createGrid,
51
- createStar,
52
- createArrow,
53
- createProgressCircle,
54
- createChip,
55
- createChart,
56
- createWatermark,
57
- createTable,
58
- createButton,
59
- createIcon,
60
- createQRCode,
61
- createFrame,
62
- createBubble,
63
- createRibbon,
64
- createSeal,
65
- createHighlightText,
66
- createBarcode,
67
- } = require('./components')
68
-
69
- module.exports = function (Plugin) {
70
- return class PosterPlugin extends Plugin {
71
- constructor(config = {}) {
72
- super()
73
- this.name = 'poster'
74
- this.version = '1.1.0'
75
- this.description = '海报制作插件 - 支持组件化海报生成'
76
- this.priority = 15
77
-
78
- this._framework = null
79
- this._canvasManager = new CanvasManager()
80
- }
81
-
82
-
83
-
84
- // ==================== 工具定义 ====================
85
-
86
- tools = {
87
- // ==================== 画布管理 ====================
88
-
89
- /**
90
- * 列出预设尺寸
91
- */
92
- list_poster_presets: {
93
- description: '列出所有可用的海报/Banner预设尺寸',
94
- inputSchema: z.object({}),
95
- execute: async () => ({
96
- success: true,
97
- presets: Object.entries(PRESETS).map(([key, value]) => ({ key, ...value })),
98
- }),
99
- },
100
-
101
- // ==================== 字体管理 ====================
102
-
103
- /**
104
- * 列出所有已注册的字体
105
- */
106
- list_poster_fonts: {
107
- description: '列出所有已注册字体的列表(包括字体名称、路径、是否默认等)',
108
- inputSchema: z.object({
109
- filter: z.enum(['all', 'emoji', 'regular']).optional().describe('字体过滤类型'),
110
- }),
111
- execute: async (args) => {
112
- try {
113
- const fontData = listAllFonts()
114
-
115
- let fonts = fontData.fonts
116
- let regular = fontData.regular
117
- let emoji = fontData.emoji
118
-
119
- // 根据过滤类型筛选
120
- if (args.filter === 'emoji') {
121
- fonts = fonts.filter(f => f.isEmoji)
122
- regular = []
123
- emoji = fonts.map(f => f.name)
124
- } else if (args.filter === 'regular') {
125
- fonts = fonts.filter(f => !f.isEmoji)
126
- regular = fonts.map(f => f.name)
127
- emoji = []
128
- }
129
-
130
- return {
131
- success: true,
132
- fonts,
133
- default: fontData.default,
134
- regular,
135
- emoji,
136
- total: fonts.length,
137
- }
138
- } catch (err) {
139
- return { success: false, error: err.message }
140
- }
141
- },
142
- },
143
-
144
- /**
145
- * 创建画布
146
- */
147
- create_poster_canvas: {
148
- description: '创建新画布,支持预设尺寸或自定义尺寸',
149
- inputSchema: z.object({
150
- preset: z.string().optional().describe('预设尺寸key'),
151
- width: z.number().optional().describe('自定义宽度'),
152
- height: z.number().optional().describe('自定义高度'),
153
- background: z.union([z.string(), z.object({
154
- image: z.string()
155
- })]).optional().describe('背景颜色或图片路径'),
156
- }),
157
- execute: async (args) => {
158
- try {
159
- const result = await this._canvasManager.create(args)
160
- return { success: true, ...result }
161
- } catch (err) {
162
- return { success: false, error: err.message }
163
- }
164
- },
165
- },
166
-
167
- /**
168
- * 获取画布信息
169
- */
170
- get_poster_canvas_info: {
171
- description: '获取当前画布信息',
172
- inputSchema: z.object({}),
173
- execute: async () => {
174
- if (!this._canvasManager.isCreated()) {
175
- return { success: false, error: 'No canvas created' }
176
- }
177
- const size = this._canvasManager.getSize()
178
- return {
179
- success: true,
180
- ...size,
181
- elementCount: this._canvasManager.getElementCount(),
182
- }
183
- },
184
- },
185
-
186
- /**
187
- * 清除画布
188
- */
189
- clear_poster_canvas: {
190
- description: '清除画布上的所有元素',
191
- inputSchema: z.object({}),
192
- execute: async () => {
193
- if (!this._canvasManager.isCreated()) {
194
- return { success: false, error: 'No canvas created' }
195
- }
196
- this._canvasManager.clear()
197
- return { success: true, message: 'Canvas cleared' }
198
- },
199
- },
200
-
201
- // ==================== 基础元素 ====================
202
-
203
- /**
204
- * 添加背景
205
- */
206
- add_poster_background: {
207
- description: '为画布添加纯色、渐变或图片背景',
208
- inputSchema: z.object({
209
- color: z.string().optional().describe('纯色背景'),
210
- gradient: z.object({
211
- type: z.enum(['linear', 'radial']).describe('渐变类型'),
212
- colors: z.array(z.string()).describe('颜色数组'),
213
- direction: z.number().optional().describe('方向角度,默认45'),
214
- }).optional(),
215
- image: z.string().optional().describe('背景图片路径(本地路径或URL)'),
216
- }),
217
- execute: async (args) => {
218
- try {
219
- if (!this._canvasManager.isCreated()) {
220
- return { success: false, error: 'No canvas created' }
221
- }
222
- return await addBackground(
223
- this._canvasManager.getProject(),
224
- this._canvasManager.getCanvas(),
225
- args
226
- )
227
- } catch (err) {
228
- return { success: false, error: err.message }
229
- }
230
- },
231
- },
232
-
233
- /**
234
- * 添加矩形
235
- */
236
- add_poster_rectangle: {
237
- description: '在画布上添加矩形',
238
- inputSchema: z.object({
239
- x: z.number().describe('X坐标'),
240
- y: z.number().describe('Y坐标'),
241
- width: z.number().describe('宽度'),
242
- height: z.number().describe('高度'),
243
- fill: z.string().optional().describe('填充颜色'),
244
- stroke: z.string().optional().describe('边框颜色'),
245
- strokeWidth: z.number().optional().describe('边框宽度'),
246
- radius: z.number().optional().describe('圆角半径'),
247
- opacity: z.number().optional().describe('透明度 0-1'),
248
- }),
249
- execute: async (args) => {
250
- try {
251
- if (!this._canvasManager.isCreated()) {
252
- return { success: false, error: 'No canvas created' }
253
- }
254
- return addRectangle(this._canvasManager.getProject(), args)
255
- } catch (err) {
256
- return { success: false, error: err.message }
257
- }
258
- },
259
- },
260
-
261
- /**
262
- * 添加圆形
263
- */
264
- add_poster_circle: {
265
- description: '在画布上添加圆形或椭圆',
266
- inputSchema: z.object({
267
- cx: z.number().describe('圆心X坐标'),
268
- cy: z.number().describe('圆心Y坐标'),
269
- rx: z.number().describe('X轴半径'),
270
- ry: z.number().optional().describe('Y轴半径'),
271
- fill: z.string().optional().describe('填充颜色'),
272
- stroke: z.string().optional().describe('边框颜色'),
273
- strokeWidth: z.number().optional().describe('边框宽度'),
274
- opacity: z.number().optional().describe('透明度 0-1'),
275
- }),
276
- execute: async (args) => {
277
- try {
278
- if (!this._canvasManager.isCreated()) {
279
- return { success: false, error: 'No canvas created' }
280
- }
281
- return addCircle(this._canvasManager.getProject(), args)
282
- } catch (err) {
283
- return { success: false, error: err.message }
284
- }
285
- },
286
- },
287
-
288
- /**
289
- * 添加线条
290
- */
291
- add_poster_line: {
292
- description: '在画布上添加线条',
293
- inputSchema: z.object({
294
- x1: z.number().describe('起点X'),
295
- y1: z.number().describe('起点Y'),
296
- x2: z.number().describe('终点X'),
297
- y2: z.number().describe('终点Y'),
298
- stroke: z.string().optional().describe('线条颜色'),
299
- strokeWidth: z.number().optional().describe('线条宽度'),
300
- }),
301
- execute: async (args) => {
302
- try {
303
- if (!this._canvasManager.isCreated()) {
304
- return { success: false, error: 'No canvas created' }
305
- }
306
- return addLine(this._canvasManager.getProject(), args)
307
- } catch (err) {
308
- return { success: false, error: err.message }
309
- }
310
- },
311
- },
312
-
313
- /**
314
- * 添加多边形
315
- */
316
- add_poster_polygon: {
317
- description: '在画布上添加多边形',
318
- inputSchema: z.object({
319
- cx: z.number().describe('中心X坐标'),
320
- cy: z.number().describe('中心Y坐标'),
321
- radius: z.number().describe('外接圆半径'),
322
- sides: z.number().describe('边数'),
323
- fill: z.string().optional().describe('填充颜色'),
324
- stroke: z.string().optional().describe('边框颜色'),
325
- strokeWidth: z.number().optional().describe('边框宽度'),
326
- opacity: z.number().optional().describe('透明度 0-1'),
327
- }),
328
- execute: async (args) => {
329
- try {
330
- if (!this._canvasManager.isCreated()) {
331
- return { success: false, error: 'No canvas created' }
332
- }
333
- return addPolygon(this._canvasManager.getProject(), args)
334
- } catch (err) {
335
- return { success: false, error: err.message }
336
- }
337
- },
338
- },
339
-
340
- /**
341
- * 添加文字
342
- */
343
- add_poster_text: {
344
- description: '在画布上添加文字',
345
- inputSchema: z.object({
346
- text: z.string().describe('文字内容'),
347
- x: z.number().describe('X坐标'),
348
- y: z.number().describe('Y坐标'),
349
- fontSize: z.number().optional().describe('字体大小,默认48'),
350
- fontFamily: z.string().optional().describe('字体名称'),
351
- color: z.string().optional().describe('文字颜色'),
352
- align: z.enum(['left', 'center', 'right']).optional().describe('对齐方式'),
353
- shadow: z.object({
354
- color: z.string().describe('阴影颜色'),
355
- blur: z.number().optional(),
356
- offsetX: z.number().optional(),
357
- offsetY: z.number().optional(),
358
- }).optional(),
359
- }),
360
- execute: async (args) => {
361
- try {
362
- if (!this._canvasManager.isCreated()) {
363
- return { success: false, error: 'No canvas created' }
364
- }
365
- return addText(this._canvasManager.getProject(), args)
366
- } catch (err) {
367
- return { success: false, error: err.message }
368
- }
369
- },
370
- },
371
-
372
- /**
373
- * 添加艺术文字
374
- */
375
- add_poster_art_text: {
376
- description: '添加艺术文字,支持渐变填充和描边',
377
- inputSchema: z.object({
378
- text: z.string().describe('文字内容'),
379
- x: z.number().describe('X坐标'),
380
- y: z.number().describe('Y坐标'),
381
- fontSize: z.number().optional().describe('字体大小,默认120'),
382
- fontFamily: z.string().optional().describe('字体名称'),
383
- gradient: z.object({
384
- colors: z.array(z.string()).describe('渐变颜色数组'),
385
- direction: z.number().optional().describe('方向角度'),
386
- }).optional(),
387
- strokeColor: z.string().optional().describe('描边颜色'),
388
- strokeWidth: z.number().optional().describe('描边宽度'),
389
- shadow: z.object({
390
- color: z.string().describe('阴影颜色'),
391
- blur: z.number().optional(),
392
- offsetX: z.number().optional(),
393
- offsetY: z.number().optional(),
394
- }).optional(),
395
- }),
396
- execute: async (args) => {
397
- try {
398
- if (!this._canvasManager.isCreated()) {
399
- return { success: false, error: 'No canvas created' }
400
- }
401
- return addArtText(this._canvasManager.getProject(), args)
402
- } catch (err) {
403
- return { success: false, error: err.message }
404
- }
405
- },
406
- },
407
-
408
- /**
409
- * 添加富文本(支持旋转和多种样式)
410
- */
411
- add_poster_rich_text: {
412
- description: '添加富文本,支持旋转、描边、渐变、阴影等多种样式',
413
- inputSchema: z.object({
414
- // 位置和尺寸
415
- x: z.number().describe('X坐标'),
416
- y: z.number().describe('Y坐标'),
417
- width: z.number().optional().describe('文本区域宽度(用于自动换行)'),
418
-
419
- // 文本内容
420
- text: z.string().describe('文字内容'),
421
-
422
- // 字体样式
423
- fontSize: z.number().optional().describe('字体大小,默认48'),
424
- fontFamily: z.string().optional().describe('字体名称'),
425
- fontWeight: z.union([z.string(), z.number()]).optional().describe('字重 normal/bold 或 100-900'),
426
- fontStyle: z.enum(['normal', 'italic', 'oblique']).optional().describe('字体风格'),
427
- bold: z.boolean().optional().describe('粗体'),
428
- italic: z.boolean().optional().describe('斜体'),
429
-
430
- // 文字装饰
431
- underline: z.boolean().optional().describe('下划线'),
432
- strikethrough: z.boolean().optional().describe('删除线'),
433
-
434
- // 颜色
435
- color: z.string().optional().describe('文字颜色,默认#ffffff'),
436
- backgroundColor: z.string().optional().describe('文字背景色'),
437
- gradient: z.object({
438
- colors: z.array(z.string()).describe('渐变颜色数组'),
439
- direction: z.number().optional().describe('方向角度'),
440
- }).optional().describe('渐变填充'),
441
-
442
- // 描边
443
- strokeColor: z.string().optional().describe('描边颜色'),
444
- strokeWidth: z.number().optional().describe('描边宽度'),
445
-
446
- // 阴影
447
- shadow: z.object({
448
- color: z.string().optional().describe('阴影颜色'),
449
- blur: z.number().optional().describe('模糊度'),
450
- offsetX: z.number().optional().describe('X偏移'),
451
- offsetY: z.number().optional().describe('Y偏移'),
452
- }).optional(),
453
-
454
- // 间距
455
- letterSpacing: z.number().optional().describe('字间距'),
456
- lineSpacing: z.number().optional().describe('行间距增量'),
457
- lineHeight: z.number().optional().describe('行高'),
458
-
459
- // 对齐
460
- align: z.enum(['left', 'center', 'right', 'justify']).optional().describe('对齐方式'),
461
-
462
- // 变换
463
- rotation: z.number().optional().describe('旋转角度(度)'),
464
- scale: z.union([z.number(), z.object({
465
- x: z.number().optional(),
466
- y: z.number().optional()
467
- })]).optional().describe('缩放'),
468
-
469
- // 透明度
470
- opacity: z.number().optional().describe('透明度 0-1,默认1'),
471
- }),
472
- execute: async (args) => {
473
- try {
474
- if (!this._canvasManager.isCreated()) {
475
- return { success: false, error: 'No canvas created' }
476
- }
477
- return addRichText(this._canvasManager.getProject(), args)
478
- } catch (err) {
479
- return { success: false, error: err.message }
480
- }
481
- },
482
- },
483
-
484
- /**
485
- * 添加图片
486
- */
487
- add_poster_image: {
488
- description: '在画布上添加图片',
489
- inputSchema: z.object({
490
- src: z.string().describe('图片路径或URL'),
491
- x: z.number().describe('X坐标'),
492
- y: z.number().describe('Y坐标'),
493
- width: z.number().optional().describe('图片宽度'),
494
- height: z.number().optional().describe('图片高度'),
495
- opacity: z.number().optional().describe('透明度 0-1'),
496
- }),
497
- execute: async (args) => {
498
- try {
499
- if (!this._canvasManager.isCreated()) {
500
- return { success: false, error: 'No canvas created' }
501
- }
502
- return await addImage(this._canvasManager.getProject(), args)
503
- } catch (err) {
504
- return { success: false, error: err.message }
505
- }
506
- },
507
- },
508
-
509
- // ==================== SVG 支持 ====================
510
-
511
- /**
512
- * 导入 SVG 文件或内容
513
- */
514
- add_poster_svg: {
515
- description: '在画布上添加 SVG(支持文件路径或 SVG 字符串)',
516
- inputSchema: z.object({
517
- src: z.string().describe('SVG 文件路径或 SVG 字符串'),
518
- x: z.number().describe('X坐标'),
519
- y: z.number().describe('Y坐标'),
520
- width: z.number().optional().describe('宽度'),
521
- height: z.number().optional().describe('高度'),
522
- opacity: z.number().optional().describe('透明度 0-1'),
523
- }),
524
- execute: async (args) => {
525
- try {
526
- if (!this._canvasManager.isCreated()) {
527
- return { success: false, error: 'No canvas created' }
528
- }
529
- return addSVG(this._canvasManager.getProject(), args)
530
- } catch (err) {
531
- return { success: false, error: err.message }
532
- }
533
- },
534
- },
535
-
536
- /**
537
- * 导出为 SVG 格式
538
- */
539
- export_poster_svg: {
540
- description: '导出画布为 SVG 格式',
541
- inputSchema: z.object({
542
- filename: z.string().describe('文件名(不含扩展名)'),
543
- outputDir: z.string().optional().describe('输出目录'),
544
- }),
545
- execute: async (args) => {
546
- try {
547
- if (!this._canvasManager.isCreated()) {
548
- return { success: false, error: 'No canvas created' }
549
- }
550
-
551
- const outputDir = args.outputDir || '.'
552
- const filename = `${args.filename}.svg`
553
- await fs.promises.mkdir(outputDir, { recursive: true })
554
- const filepath = path.join(outputDir, filename)
555
-
556
- const svg = this._canvasManager.getProject().exportSVG({
557
- asString: true,
558
- bounds: 'content',
559
- })
560
-
561
- await fs.promises.writeFile(filepath, svg)
562
-
563
- return {
564
- success: true,
565
- filepath,
566
- filename,
567
- format: 'svg',
568
- size: Buffer.byteLength(svg),
569
- }
570
- } catch (err) {
571
- return { success: false, error: err.message }
572
- }
573
- },
574
- },
575
-
576
- /**
577
- * 导出为 SVG Base64
578
- */
579
- export_poster_svg_base64: {
580
- description: '导出画布为 SVG Base64 编码',
581
- inputSchema: z.object({}),
582
- execute: async () => {
583
- try {
584
- if (!this._canvasManager.isCreated()) {
585
- return { success: false, error: 'No canvas created' }
586
- }
587
-
588
- const svg = this._canvasManager.getProject().exportSVG({
589
- asString: true,
590
- bounds: 'content',
591
- })
592
-
593
- const base64 = Buffer.from(svg).toString('base64')
594
-
595
- return {
596
- success: true,
597
- base64,
598
- svg,
599
- mimeType: 'image/svg+xml',
600
- }
601
- } catch (err) {
602
- return { success: false, error: err.message }
603
- }
604
- },
605
- },
606
-
607
- // ==================== 高级组件 ====================
608
-
609
- /**
610
- * 添加卡片组件
611
- */
612
- add_poster_card: {
613
- description: '添加卡片组件(带背景、标题、副标题)',
614
- inputSchema: z.object({
615
- x: z.number().describe('X坐标'),
616
- y: z.number().describe('Y坐标'),
617
- width: z.number().describe('卡片宽度'),
618
- height: z.number().describe('卡片高度'),
619
- background: z.string().optional().describe('背景色'),
620
- border: z.string().optional().describe('边框颜色'),
621
- borderWidth: z.number().optional().describe('边框宽度'),
622
- radius: z.number().optional().describe('圆角半径'),
623
- title: z.string().optional().describe('标题文字'),
624
- titleSize: z.number().optional().describe('标题字体大小'),
625
- titleColor: z.string().optional().describe('标题颜色'),
626
- subtitle: z.string().optional().describe('副标题'),
627
- subtitleSize: z.number().optional().describe('副标题字体大小'),
628
- subtitleColor: z.string().optional().describe('副标题颜色'),
629
- padding: z.number().optional().describe('内边距'),
630
- }),
631
- execute: async (args) => {
632
- try {
633
- if (!this._canvasManager.isCreated()) {
634
- return { success: false, error: 'No canvas created' }
635
- }
636
- return createCard(
637
- this._canvasManager.getProject(),
638
- this._canvasManager.getCanvas(),
639
- args
640
- )
641
- } catch (err) {
642
- return { success: false, error: err.message }
643
- }
644
- },
645
- },
646
-
647
- /**
648
- * 添加徽章组件
649
- */
650
- add_poster_badge: {
651
- description: '添加徽章/标签组件',
652
- inputSchema: z.object({
653
- x: z.number().describe('X坐标(居中)'),
654
- y: z.number().describe('Y坐标'),
655
- text: z.string().describe('徽章文字'),
656
- background: z.string().optional().describe('背景色'),
657
- color: z.string().optional().describe('文字颜色'),
658
- border: z.string().optional().describe('边框颜色'),
659
- fontSize: z.number().optional().describe('字体大小'),
660
- padding: z.number().optional().describe('内边距'),
661
- radius: z.number().optional().describe('圆角半径'),
662
- }),
663
- execute: async (args) => {
664
- try {
665
- if (!this._canvasManager.isCreated()) {
666
- return { success: false, error: 'No canvas created' }
667
- }
668
- return createBadge(
669
- this._canvasManager.getProject(),
670
- this._canvasManager.getCanvas(),
671
- args
672
- )
673
- } catch (err) {
674
- return { success: false, error: err.message }
675
- }
676
- },
677
- },
678
-
679
- /**
680
- * 添加 CTA 按钮
681
- */
682
- add_poster_cta: {
683
- description: '添加行动号召按钮',
684
- inputSchema: z.object({
685
- x: z.number().describe('X坐标(居中)'),
686
- y: z.number().describe('Y坐标'),
687
- text: z.string().describe('按钮文字'),
688
- background: z.string().optional().describe('背景色'),
689
- color: z.string().optional().describe('文字颜色'),
690
- border: z.string().optional().describe('边框颜色'),
691
- fontSize: z.number().optional().describe('字体大小'),
692
- padding: z.number().optional().describe('内边距'),
693
- radius: z.number().optional().describe('圆角半径'),
694
- shadow: z.object({
695
- color: z.string().optional(),
696
- blur: z.number().optional(),
697
- offsetX: z.number().optional(),
698
- offsetY: z.number().optional(),
699
- }).optional(),
700
- }),
701
- execute: async (args) => {
702
- try {
703
- if (!this._canvasManager.isCreated()) {
704
- return { success: false, error: 'No canvas created' }
705
- }
706
- return createCTA(
707
- this._canvasManager.getProject(),
708
- this._canvasManager.getCanvas(),
709
- args
710
- )
711
- } catch (err) {
712
- return { success: false, error: err.message }
713
- }
714
- },
715
- },
716
-
717
- /**
718
- * 添加特性展示
719
- */
720
- add_poster_feature: {
721
- description: '添加特性展示块',
722
- inputSchema: z.object({
723
- x: z.number().describe('X坐标'),
724
- y: z.number().describe('Y坐标'),
725
- width: z.number().describe('宽度'),
726
- icon: z.string().optional().describe('图标 emoji'),
727
- title: z.string().optional().describe('标题'),
728
- description: z.string().optional().describe('描述'),
729
- iconColor: z.string().optional().describe('图标颜色'),
730
- titleColor: z.string().optional().describe('标题颜色'),
731
- descColor: z.string().optional().describe('描述颜色'),
732
- iconSize: z.number().optional().describe('图标大小'),
733
- titleSize: z.number().optional().describe('标题大小'),
734
- descSize: z.number().optional().describe('描述大小'),
735
- }),
736
- execute: async (args) => {
737
- try {
738
- if (!this._canvasManager.isCreated()) {
739
- return { success: false, error: 'No canvas created' }
740
- }
741
- return createFeature(
742
- this._canvasManager.getProject(),
743
- this._canvasManager.getCanvas(),
744
- args
745
- )
746
- } catch (err) {
747
- return { success: false, error: err.message }
748
- }
749
- },
750
- },
751
-
752
- /**
753
- * 添加特性网格
754
- */
755
- add_poster_feature_grid: {
756
- description: '添加特性网格布局',
757
- inputSchema: z.object({
758
- x: z.number().describe('X坐标'),
759
- y: z.number().describe('Y坐标'),
760
- columns: z.number().optional().describe('列数,默认3'),
761
- itemWidth: z.number().optional().describe('每个特性宽度,默认200'),
762
- itemHeight: z.number().optional().describe('每个特性高度,默认120'),
763
- gap: z.number().optional().describe('间距,默认20'),
764
- items: z.array(z.object({
765
- icon: z.string().optional(),
766
- title: z.string().optional(),
767
- description: z.string().optional(),
768
- iconColor: z.string().optional(),
769
- titleColor: z.string().optional(),
770
- descColor: z.string().optional(),
771
- })).describe('特性数组'),
772
- background: z.string().optional().describe('背景色'),
773
- borderColor: z.string().optional().describe('边框颜色'),
774
- radius: z.number().optional().describe('圆角半径'),
775
- }),
776
- execute: async (args) => {
777
- try {
778
- if (!this._canvasManager.isCreated()) {
779
- return { success: false, error: 'No canvas created' }
780
- }
781
- return createFeatureGrid(
782
- this._canvasManager.getProject(),
783
- this._canvasManager.getCanvas(),
784
- args
785
- )
786
- } catch (err) {
787
- return { success: false, error: err.message }
788
- }
789
- },
790
- },
791
-
792
- /**
793
- * 添加分隔线
794
- */
795
- add_poster_divider: {
796
- description: '添加分隔线',
797
- inputSchema: z.object({
798
- x: z.number().describe('X坐标'),
799
- y: z.number().describe('Y坐标'),
800
- width: z.number().describe('宽度'),
801
- color: z.string().optional().describe('颜色'),
802
- thickness: z.number().optional().describe('厚度'),
803
- style: z.enum(['solid', 'dashed']).optional().describe('样式'),
804
- align: z.enum(['left', 'center', 'right']).optional().describe('对齐'),
805
- }),
806
- execute: async (args) => {
807
- try {
808
- if (!this._canvasManager.isCreated()) {
809
- return { success: false, error: 'No canvas created' }
810
- }
811
- return createDivider(
812
- this._canvasManager.getProject(),
813
- this._canvasManager.getCanvas(),
814
- args
815
- )
816
- } catch (err) {
817
- return { success: false, error: err.message }
818
- }
819
- },
820
- },
821
-
822
- /**
823
- * 添加头像
824
- */
825
- add_poster_avatar: {
826
- description: '添加头像组件',
827
- inputSchema: z.object({
828
- x: z.number().describe('圆心X坐标'),
829
- y: z.number().describe('圆心Y坐标'),
830
- size: z.number().optional().describe('头像大小'),
831
- initials: z.string().optional().describe('首字母'),
832
- background: z.string().optional().describe('背景色'),
833
- border: z.string().optional().describe('边框颜色'),
834
- borderWidth: z.number().optional().describe('边框宽度'),
835
- color: z.string().optional().describe('文字颜色'),
836
- }),
837
- execute: async (args) => {
838
- try {
839
- if (!this._canvasManager.isCreated()) {
840
- return { success: false, error: 'No canvas created' }
841
- }
842
- return createAvatar(
843
- this._canvasManager.getProject(),
844
- this._canvasManager.getCanvas(),
845
- args
846
- )
847
- } catch (err) {
848
- return { success: false, error: err.message }
849
- }
850
- },
851
- },
852
-
853
- /**
854
- * 添加进度条
855
- */
856
- add_poster_progress: {
857
- description: '添加进度条组件',
858
- inputSchema: z.object({
859
- x: z.number().describe('X坐标'),
860
- y: z.number().describe('Y坐标'),
861
- width: z.number().optional().describe('进度条宽度'),
862
- height: z.number().optional().describe('进度条高度'),
863
- value: z.number().optional().describe('进度值 0-100'),
864
- trackColor: z.string().optional().describe('轨道颜色'),
865
- fillColor: z.string().optional().describe('填充颜色'),
866
- radius: z.number().optional().describe('圆角半径'),
867
- showLabel: z.boolean().optional().describe('是否显示标签'),
868
- label: z.string().optional().describe('标签文字'),
869
- }),
870
- execute: async (args) => {
871
- try {
872
- if (!this._canvasManager.isCreated()) {
873
- return { success: false, error: 'No canvas created' }
874
- }
875
- return createProgress(
876
- this._canvasManager.getProject(),
877
- this._canvasManager.getCanvas(),
878
- args
879
- )
880
- } catch (err) {
881
- return { success: false, error: err.message }
882
- }
883
- },
884
- },
885
-
886
- /**
887
- * 添加星级评分
888
- */
889
- add_poster_rating: {
890
- description: '添加星级评分组件',
891
- inputSchema: z.object({
892
- x: z.number().describe('X坐标'),
893
- y: z.number().describe('Y坐标'),
894
- value: z.number().optional().describe('评分值 0-5'),
895
- max: z.number().optional().describe('最大值'),
896
- size: z.number().optional().describe('星星大小'),
897
- filledColor: z.string().optional().describe('填充颜色'),
898
- emptyColor: z.string().optional().describe('空心颜色'),
899
- gap: z.number().optional().describe('星星间距'),
900
- }),
901
- execute: async (args) => {
902
- try {
903
- if (!this._canvasManager.isCreated()) {
904
- return { success: false, error: 'No canvas created' }
905
- }
906
- return createRating(
907
- this._canvasManager.getProject(),
908
- this._canvasManager.getCanvas(),
909
- args
910
- )
911
- } catch (err) {
912
- return { success: false, error: err.message }
913
- }
914
- },
915
- },
916
-
917
- /**
918
- * 添加引用块
919
- */
920
- add_poster_quote: {
921
- description: '添加引用块组件',
922
- inputSchema: z.object({
923
- x: z.number().describe('X坐标'),
924
- y: z.number().describe('Y坐标'),
925
- width: z.number().optional().describe('宽度'),
926
- text: z.string().describe('引用文字'),
927
- author: z.string().optional().describe('作者'),
928
- background: z.string().optional().describe('背景色'),
929
- borderColor: z.string().optional().describe('左边框颜色'),
930
- padding: z.number().optional().describe('内边距'),
931
- radius: z.number().optional().describe('圆角半径'),
932
- textColor: z.string().optional().describe('文字颜色'),
933
- authorColor: z.string().optional().describe('作者颜色'),
934
- fontSize: z.number().optional().describe('字体大小'),
935
- }),
936
- execute: async (args) => {
937
- try {
938
- if (!this._canvasManager.isCreated()) {
939
- return { success: false, error: 'No canvas created' }
940
- }
941
- return createQuote(
942
- this._canvasManager.getProject(),
943
- this._canvasManager.getCanvas(),
944
- args
945
- )
946
- } catch (err) {
947
- return { success: false, error: err.message }
948
- }
949
- },
950
- },
951
-
952
- /**
953
- * 添加统计卡片
954
- */
955
- add_poster_stat_card: {
956
- description: '添加统计卡片组件',
957
- inputSchema: z.object({
958
- x: z.number().describe('X坐标'),
959
- y: z.number().describe('Y坐标'),
960
- width: z.number().optional().describe('宽度'),
961
- height: z.number().optional().describe('高度'),
962
- label: z.string().optional().describe('标签'),
963
- value: z.string().optional().describe('数值'),
964
- change: z.string().optional().describe('变化值'),
965
- positive: z.boolean().optional().describe('变化是否为正'),
966
- icon: z.string().optional().describe('图标'),
967
- iconColor: z.string().optional().describe('图标颜色'),
968
- background: z.string().optional().describe('背景色'),
969
- border: z.string().optional().describe('边框颜色'),
970
- radius: z.number().optional().describe('圆角半径'),
971
- }),
972
- execute: async (args) => {
973
- try {
974
- if (!this._canvasManager.isCreated()) {
975
- return { success: false, error: 'No canvas created' }
976
- }
977
- return createStatCard(
978
- this._canvasManager.getProject(),
979
- this._canvasManager.getCanvas(),
980
- args
981
- )
982
- } catch (err) {
983
- return { success: false, error: err.message }
984
- }
985
- },
986
- },
987
-
988
- /**
989
- * 添加标签云
990
- */
991
- add_poster_tag_cloud: {
992
- description: '添加标签云组件',
993
- inputSchema: z.object({
994
- x: z.number().describe('X坐标'),
995
- y: z.number().describe('Y坐标'),
996
- tags: z.array(z.object({
997
- text: z.string(),
998
- color: z.string().optional(),
999
- bgColor: z.string().optional(),
1000
- })).describe('标签数组'),
1001
- fontSize: z.number().optional().describe('字体大小'),
1002
- padding: z.number().optional().describe('标签内边距'),
1003
- gap: z.number().optional().describe('标签间距'),
1004
- maxWidth: z.number().optional().describe('最大宽度'),
1005
- }),
1006
- execute: async (args) => {
1007
- try {
1008
- if (!this._canvasManager.isCreated()) {
1009
- return { success: false, error: 'No canvas created' }
1010
- }
1011
- return createTagCloud(
1012
- this._canvasManager.getProject(),
1013
- this._canvasManager.getCanvas(),
1014
- args
1015
- )
1016
- } catch (err) {
1017
- return { success: false, error: err.message }
1018
- }
1019
- },
1020
- },
1021
-
1022
- /**
1023
- * 添加步骤指示器
1024
- */
1025
- add_poster_stepper: {
1026
- description: '添加步骤指示器组件',
1027
- inputSchema: z.object({
1028
- x: z.number().describe('X坐标'),
1029
- y: z.number().describe('Y坐标'),
1030
- width: z.number().optional().describe('总宽度'),
1031
- steps: z.array(z.object({
1032
- title: z.string(),
1033
- description: z.string().optional(),
1034
- })).describe('步骤数组'),
1035
- currentStep: z.number().optional().describe('当前步骤'),
1036
- activeColor: z.string().optional().describe('激活颜色'),
1037
- inactiveColor: z.string().optional().describe('未激活颜色'),
1038
- completedColor: z.string().optional().describe('已完成颜色'),
1039
- circleSize: z.number().optional().describe('圆圈大小'),
1040
- }),
1041
- execute: async (args) => {
1042
- try {
1043
- if (!this._canvasManager.isCreated()) {
1044
- return { success: false, error: 'No canvas created' }
1045
- }
1046
- return createStepper(
1047
- this._canvasManager.getProject(),
1048
- this._canvasManager.getCanvas(),
1049
- args
1050
- )
1051
- } catch (err) {
1052
- return { success: false, error: err.message }
1053
- }
1054
- },
1055
- },
1056
-
1057
- /**
1058
- * 添加时间线
1059
- */
1060
- add_poster_timeline: {
1061
- description: '添加时间线组件',
1062
- inputSchema: z.object({
1063
- x: z.number().describe('X坐标'),
1064
- y: z.number().describe('Y坐标'),
1065
- width: z.number().optional().describe('总宽度'),
1066
- items: z.array(z.object({
1067
- date: z.string().optional(),
1068
- title: z.string(),
1069
- description: z.string().optional(),
1070
- active: z.boolean().optional(),
1071
- })).describe('时间线项目数组'),
1072
- lineColor: z.string().optional().describe('线条颜色'),
1073
- dotColor: z.string().optional().describe('点颜色'),
1074
- dotSize: z.number().optional().describe('点大小'),
1075
- gap: z.number().optional().describe('项目间距'),
1076
- }),
1077
- execute: async (args) => {
1078
- try {
1079
- if (!this._canvasManager.isCreated()) {
1080
- return { success: false, error: 'No canvas created' }
1081
- }
1082
- return createTimeline(
1083
- this._canvasManager.getProject(),
1084
- this._canvasManager.getCanvas(),
1085
- args
1086
- )
1087
- } catch (err) {
1088
- return { success: false, error: err.message }
1089
- }
1090
- },
1091
- },
1092
-
1093
- /**
1094
- * 添加列表项
1095
- */
1096
- add_poster_list_item: {
1097
- description: '添加列表项组件',
1098
- inputSchema: z.object({
1099
- x: z.number().describe('X坐标'),
1100
- y: z.number().describe('Y坐标'),
1101
- width: z.number().optional().describe('宽度'),
1102
- icon: z.string().optional().describe('图标'),
1103
- title: z.string().optional().describe('标题'),
1104
- description: z.string().optional().describe('描述'),
1105
- badge: z.string().optional().describe('徽章文字'),
1106
- badgeColor: z.string().optional().describe('徽章颜色'),
1107
- iconColor: z.string().optional().describe('图标颜色'),
1108
- background: z.string().optional().describe('背景色'),
1109
- borderColor: z.string().optional().describe('边框颜色'),
1110
- height: z.number().optional().describe('高度'),
1111
- radius: z.number().optional().describe('圆角半径'),
1112
- }),
1113
- execute: async (args) => {
1114
- try {
1115
- if (!this._canvasManager.isCreated()) {
1116
- return { success: false, error: 'No canvas created' }
1117
- }
1118
- return createListItem(
1119
- this._canvasManager.getProject(),
1120
- this._canvasManager.getCanvas(),
1121
- args
1122
- )
1123
- } catch (err) {
1124
- return { success: false, error: err.message }
1125
- }
1126
- },
1127
- },
1128
-
1129
- /**
1130
- * 添加通知提示
1131
- */
1132
- add_poster_notification: {
1133
- description: '添加通知提示组件',
1134
- inputSchema: z.object({
1135
- x: z.number().describe('X坐标'),
1136
- y: z.number().describe('Y坐标'),
1137
- width: z.number().optional().describe('宽度'),
1138
- type: z.enum(['success', 'warning', 'error', 'info']).optional().describe('类型'),
1139
- title: z.string().optional().describe('标题'),
1140
- message: z.string().optional().describe('消息内容'),
1141
- showIcon: z.boolean().optional().describe('是否显示图标'),
1142
- radius: z.number().optional().describe('圆角半径'),
1143
- }),
1144
- execute: async (args) => {
1145
- try {
1146
- if (!this._canvasManager.isCreated()) {
1147
- return { success: false, error: 'No canvas created' }
1148
- }
1149
- return createNotification(
1150
- this._canvasManager.getProject(),
1151
- this._canvasManager.getCanvas(),
1152
- args
1153
- )
1154
- } catch (err) {
1155
- return { success: false, error: err.message }
1156
- }
1157
- },
1158
- },
1159
-
1160
- /**
1161
- * 添加图片框组件
1162
- */
1163
- add_poster_image_frame: {
1164
- description: '添加带装饰边框的图片框组件',
1165
- inputSchema: z.object({
1166
- src: z.string().describe('图片路径或URL'),
1167
- x: z.number().describe('X坐标'),
1168
- y: z.number().describe('Y坐标'),
1169
- width: z.number().describe('图片宽度'),
1170
- height: z.number().describe('图片高度'),
1171
- borderColor: z.string().optional().describe('边框颜色'),
1172
- borderWidth: z.number().optional().describe('边框宽度'),
1173
- outerColor: z.string().optional().describe('外边框颜色'),
1174
- outerWidth: z.number().optional().describe('外边框宽度'),
1175
- shadowBlur: z.number().optional().describe('阴影模糊'),
1176
- shadowOffsetX: z.number().optional().describe('阴影X偏移'),
1177
- shadowOffsetY: z.number().optional().describe('阴影Y偏移'),
1178
- shadowColor: z.string().optional().describe('阴影颜色'),
1179
- radius: z.number().optional().describe('圆角半径'),
1180
- overlayColor: z.string().optional().describe('叠加颜色'),
1181
- overlayOpacity: z.number().optional().describe('叠加透明度'),
1182
- fit: z.enum(['cover', 'contain', 'fill']).optional().describe('图片填充方式'),
1183
- }),
1184
- execute: async (args) => {
1185
- try {
1186
- if (!this._canvasManager.isCreated()) {
1187
- return { success: false, error: 'No canvas created' }
1188
- }
1189
- return createImageFrame(
1190
- this._canvasManager.getProject(),
1191
- this._canvasManager.getCanvas(),
1192
- args
1193
- )
1194
- } catch (err) {
1195
- return { success: false, error: err.message }
1196
- }
1197
- },
1198
- },
1199
-
1200
- /**
1201
- * 添加分栏布局组件
1202
- */
1203
- add_poster_columns: {
1204
- description: '添加分栏布局组件(左右分栏、三栏等)',
1205
- inputSchema: z.object({
1206
- x: z.number().describe('起始X坐标'),
1207
- y: z.number().describe('起始Y坐标'),
1208
- width: z.number().describe('总宽度'),
1209
- height: z.number().describe('总高度'),
1210
- columns: z.number().optional().describe('列数,默认2'),
1211
- gap: z.number().optional().describe('列间距,默认20'),
1212
- background: z.string().optional().describe('背景色'),
1213
- borderColor: z.string().optional().describe('边框颜色'),
1214
- borderWidth: z.number().optional().describe('边框宽度'),
1215
- radius: z.number().optional().describe('圆角半径'),
1216
- direction: z.enum(['horizontal', 'vertical']).optional().describe('排列方向'),
1217
- align: z.enum(['top', 'center', 'bottom']).optional().describe('垂直对齐'),
1218
- }),
1219
- execute: async (args) => {
1220
- try {
1221
- if (!this._canvasManager.isCreated()) {
1222
- return { success: false, error: 'No canvas created' }
1223
- }
1224
- return createColumns(
1225
- this._canvasManager.getProject(),
1226
- this._canvasManager.getCanvas(),
1227
- args
1228
- )
1229
- } catch (err) {
1230
- return { success: false, error: err.message }
1231
- }
1232
- },
1233
- },
1234
-
1235
- /**
1236
- * 添加网格布局组件
1237
- */
1238
- add_poster_grid: {
1239
- description: '添加网格布局组件(任意行列)',
1240
- inputSchema: z.object({
1241
- x: z.number().describe('起始X坐标'),
1242
- y: z.number().describe('起始Y坐标'),
1243
- width: z.number().describe('总宽度'),
1244
- height: z.number().describe('总高度'),
1245
- columns: z.number().optional().describe('列数,默认3'),
1246
- rows: z.number().optional().describe('行数,默认2'),
1247
- gapX: z.number().optional().describe('水平间距,默认20'),
1248
- gapY: z.number().optional().describe('垂直间距,默认20'),
1249
- background: z.string().optional().describe('背景色'),
1250
- borderColor: z.string().optional().describe('边框颜色'),
1251
- borderWidth: z.number().optional().describe('边框宽度'),
1252
- radius: z.number().optional().describe('圆角半径'),
1253
- direction: z.enum(['row', 'column']).optional().describe('排列方向'),
1254
- }),
1255
- execute: async (args) => {
1256
- try {
1257
- if (!this._canvasManager.isCreated()) {
1258
- return { success: false, error: 'No canvas created' }
1259
- }
1260
- return createGrid(
1261
- this._canvasManager.getProject(),
1262
- this._canvasManager.getCanvas(),
1263
- args
1264
- )
1265
- } catch (err) {
1266
- return { success: false, error: err.message }
1267
- }
1268
- },
1269
- },
1270
-
1271
- /**
1272
- * 添加星形组件
1273
- */
1274
- add_poster_star: {
1275
- description: '添加星形/多角形装饰',
1276
- inputSchema: z.object({
1277
- cx: z.number().describe('中心X坐标'),
1278
- cy: z.number().describe('中心Y坐标'),
1279
- points: z.number().optional().describe('星形点数,默认5'),
1280
- innerRadius: z.number().optional().describe('内半径'),
1281
- outerRadius: z.number().describe('外半径'),
1282
- fill: z.string().optional().describe('填充颜色'),
1283
- stroke: z.string().optional().describe('边框颜色'),
1284
- strokeWidth: z.number().optional().describe('边框宽度'),
1285
- opacity: z.number().optional().describe('透明度 0-1'),
1286
- rotation: z.number().optional().describe('旋转角度'),
1287
- }),
1288
- execute: async (args) => {
1289
- try {
1290
- if (!this._canvasManager.isCreated()) {
1291
- return { success: false, error: 'No canvas created' }
1292
- }
1293
- const project = this._canvasManager.getProject()
1294
- const result = createStar(project, this._canvasManager.getCanvas(), args)
1295
- // 强制将所有子元素添加到活动层
1296
- if (result && result.elements && project) {
1297
- // 收集所有新创建的 item
1298
- const allItems = project.getItems({})
1299
- const existingIds = new Set(allItems.map(i => i.id))
1300
-
1301
- // 从项目的所有层中获取新添加的 item
1302
- project.layers.forEach(layer => {
1303
- layer.children.forEach(item => {
1304
- if (item.id && !existingIds.has(item.id) || item.parent === layer) {
1305
- if (item.parent !== project.activeLayer) {
1306
- project.activeLayer.addChild(item)
1307
- }
1308
- }
1309
- })
1310
- })
1311
- }
1312
- return result
1313
- } catch (err) {
1314
- return { success: false, error: err.message }
1315
- }
1316
- },
1317
- },
1318
-
1319
- /**
1320
- * 添加箭头组件
1321
- */
1322
- add_poster_arrow: {
1323
- description: '添加箭头指示',
1324
- inputSchema: z.object({
1325
- x1: z.number().describe('起点X'),
1326
- y1: z.number().describe('起点Y'),
1327
- x2: z.number().describe('终点X'),
1328
- y2: z.number().describe('终点Y'),
1329
- color: z.string().optional().describe('箭头颜色'),
1330
- strokeWidth: z.number().optional().describe('线宽'),
1331
- headSize: z.number().optional().describe('箭头头部大小'),
1332
- style: z.enum(['solid', 'dashed']).optional().describe('样式'),
1333
- direction: z.enum(['end', 'start', 'both']).optional().describe('箭头方向'),
1334
- }),
1335
- execute: async (args) => {
1336
- try {
1337
- if (!this._canvasManager.isCreated()) {
1338
- return { success: false, error: 'No canvas created' }
1339
- }
1340
- const result = createArrow(
1341
- this._canvasManager.getProject(),
1342
- this._canvasManager.getCanvas(),
1343
- args
1344
- )
1345
- if (result && result.elements && this._canvasManager.getProject()) {
1346
- const project = this._canvasManager.getProject()
1347
- result.elements.forEach(el => {
1348
- if (el.id) {
1349
- const item = project.getItem({ id: el.id })
1350
- if (item) project.activeLayer.addChild(item)
1351
- }
1352
- })
1353
- }
1354
- return result
1355
- } catch (err) {
1356
- return { success: false, error: err.message }
1357
- }
1358
- },
1359
- },
1360
-
1361
- /**
1362
- * 添加环形进度条
1363
- */
1364
- add_poster_progress_circle: {
1365
- description: '添加环形进度条组件',
1366
- inputSchema: z.object({
1367
- cx: z.number().describe('圆心X坐标'),
1368
- cy: z.number().describe('圆心Y坐标'),
1369
- radius: z.number().describe('圆环半径'),
1370
- value: z.number().describe('进度值 0-100'),
1371
- strokeWidth: z.number().optional().describe('环宽度'),
1372
- trackColor: z.string().optional().describe('轨道颜色'),
1373
- fillColor: z.string().optional().describe('进度颜色'),
1374
- backgroundColor: z.string().optional().describe('背景填充色'),
1375
- showLabel: z.boolean().optional().describe('是否显示百分比标签'),
1376
- labelColor: z.string().optional().describe('标签颜色'),
1377
- }),
1378
- execute: async (args) => {
1379
- try {
1380
- if (!this._canvasManager.isCreated()) {
1381
- return { success: false, error: 'No canvas created' }
1382
- }
1383
- const result = createProgressCircle(
1384
- this._canvasManager.getProject(),
1385
- this._canvasManager.getCanvas(),
1386
- args
1387
- )
1388
- if (result && result.elements && this._canvasManager.getProject()) {
1389
- const project = this._canvasManager.getProject()
1390
- result.elements.forEach(el => {
1391
- if (el.id) {
1392
- const item = project.getItem({ id: el.id })
1393
- if (item) project.activeLayer.addChild(item)
1394
- }
1395
- })
1396
- }
1397
- return result
1398
- } catch (err) {
1399
- return { success: false, error: err.message }
1400
- }
1401
- },
1402
- },
1403
-
1404
- /**
1405
- * 添加 Chip 标签
1406
- */
1407
- add_poster_chip: {
1408
- description: '添加小型信息标签组件',
1409
- inputSchema: z.object({
1410
- x: z.number().describe('X坐标(居中)'),
1411
- y: z.number().describe('Y坐标'),
1412
- text: z.string().describe('标签文字'),
1413
- background: z.string().optional().describe('背景色'),
1414
- color: z.string().optional().describe('文字颜色'),
1415
- borderColor: z.string().optional().describe('边框颜色'),
1416
- fontSize: z.number().optional().describe('字体大小'),
1417
- padding: z.number().optional().describe('内边距'),
1418
- radius: z.number().optional().describe('圆角'),
1419
- icon: z.string().optional().describe('前置图标 emoji'),
1420
- }),
1421
- execute: async (args) => {
1422
- try {
1423
- if (!this._canvasManager.isCreated()) {
1424
- return { success: false, error: 'No canvas created' }
1425
- }
1426
- const result = createChip(
1427
- this._canvasManager.getProject(),
1428
- this._canvasManager.getCanvas(),
1429
- args
1430
- )
1431
- if (result && result.elements && this._canvasManager.getProject()) {
1432
- const project = this._canvasManager.getProject()
1433
- result.elements.forEach(el => {
1434
- if (el.id) {
1435
- const item = project.getItem({ id: el.id })
1436
- if (item) project.activeLayer.addChild(item)
1437
- }
1438
- })
1439
- }
1440
- return result
1441
- } catch (err) {
1442
- return { success: false, error: err.message }
1443
- }
1444
- },
1445
- },
1446
-
1447
- /**
1448
- * 添加图表组件
1449
- */
1450
- add_poster_chart: {
1451
- description: '添加图表组件(柱状图/饼图)',
1452
- inputSchema: z.object({
1453
- type: z.enum(['bar', 'pie']).describe('图表类型'),
1454
- x: z.number().describe('X坐标'),
1455
- y: z.number().describe('Y坐标'),
1456
- width: z.number().describe('宽度'),
1457
- height: z.number().describe('高度'),
1458
- data: z.array(z.object({
1459
- label: z.string().describe('标签'),
1460
- value: z.number().describe('数值'),
1461
- color: z.string().optional().describe('颜色'),
1462
- })).describe('数据'),
1463
- barColor: z.string().optional().describe('默认柱状颜色'),
1464
- showLabels: z.boolean().optional().describe('显示标签'),
1465
- showValues: z.boolean().optional().describe('显示数值'),
1466
- }),
1467
- execute: async (args) => {
1468
- try {
1469
- if (!this._canvasManager.isCreated()) {
1470
- return { success: false, error: 'No canvas created' }
1471
- }
1472
- const result = createChart(
1473
- this._canvasManager.getProject(),
1474
- this._canvasManager.getCanvas(),
1475
- args
1476
- )
1477
- if (result && result.elements && this._canvasManager.getProject()) {
1478
- const project = this._canvasManager.getProject()
1479
- result.elements.forEach(el => {
1480
- if (el.id) {
1481
- const item = project.getItem({ id: el.id })
1482
- if (item) project.activeLayer.addChild(item)
1483
- }
1484
- })
1485
- }
1486
- return result
1487
- } catch (err) {
1488
- return { success: false, error: err.message }
1489
- }
1490
- },
1491
- },
1492
-
1493
- /**
1494
- * 添加水印
1495
- */
1496
- add_poster_watermark: {
1497
- description: '添加水印文字',
1498
- inputSchema: z.object({
1499
- text: z.string().describe('水印文字'),
1500
- cx: z.number().describe('中心X坐标'),
1501
- cy: z.number().describe('中心Y坐标'),
1502
- color: z.string().optional().describe('水印颜色'),
1503
- fontSize: z.number().optional().describe('字体大小'),
1504
- fontFamily: z.string().optional().describe('字体'),
1505
- opacity: z.number().optional().describe('透明度'),
1506
- rotation: z.number().optional().describe('旋转角度'),
1507
- align: z.enum(['left', 'center', 'right']).optional().describe('对齐方式'),
1508
- }),
1509
- execute: async (args) => {
1510
- try {
1511
- if (!this._canvasManager.isCreated()) {
1512
- return { success: false, error: 'No canvas created' }
1513
- }
1514
- const result = createWatermark(
1515
- this._canvasManager.getProject(),
1516
- this._canvasManager.getCanvas(),
1517
- args
1518
- )
1519
- if (result && result.elements && this._canvasManager.getProject()) {
1520
- const project = this._canvasManager.getProject()
1521
- result.elements.forEach(el => {
1522
- if (el.id) {
1523
- const item = project.getItem({ id: el.id })
1524
- if (item) project.activeLayer.addChild(item)
1525
- }
1526
- })
1527
- }
1528
- return result
1529
- } catch (err) {
1530
- return { success: false, error: err.message }
1531
- }
1532
- },
1533
- },
1534
-
1535
- /**
1536
- * 添加表格组件
1537
- */
1538
- add_poster_table: {
1539
- description: '添加表格组件',
1540
- inputSchema: z.object({
1541
- x: z.number().describe('X坐标'),
1542
- y: z.number().describe('Y坐标'),
1543
- width: z.number().describe('表格宽度'),
1544
- columns: z.array(z.object({
1545
- title: z.string().describe('列标题'),
1546
- width: z.number().optional().describe('列宽'),
1547
- align: z.enum(['left', 'center', 'right']).optional().describe('对齐'),
1548
- })).describe('列配置'),
1549
- rows: z.array(z.array(z.string())).describe('行数据'),
1550
- rowHeight: z.number().optional().describe('行高'),
1551
- headerBg: z.string().optional().describe('表头背景色'),
1552
- headerColor: z.string().optional().describe('表头文字色'),
1553
- borderColor: z.string().optional().describe('边框颜色'),
1554
- fontSize: z.number().optional().describe('字体大小'),
1555
- striped: z.boolean().optional().describe('斑马纹'),
1556
- }),
1557
- execute: async (args) => {
1558
- try {
1559
- if (!this._canvasManager.isCreated()) {
1560
- return { success: false, error: 'No canvas created' }
1561
- }
1562
- const result = createTable(
1563
- this._canvasManager.getProject(),
1564
- this._canvasManager.getCanvas(),
1565
- args
1566
- )
1567
- if (result && result.elements && this._canvasManager.getProject()) {
1568
- const project = this._canvasManager.getProject()
1569
- result.elements.forEach(el => {
1570
- if (el.id) {
1571
- const item = project.getItem({ id: el.id })
1572
- if (item) project.activeLayer.addChild(item)
1573
- }
1574
- })
1575
- }
1576
- return result
1577
- } catch (err) {
1578
- return { success: false, error: err.message }
1579
- }
1580
- },
1581
- },
1582
-
1583
- /**
1584
- * 添加按钮
1585
- */
1586
- add_poster_button: {
1587
- description: '添加按钮组件',
1588
- inputSchema: z.object({
1589
- x: z.number().describe('X坐标'),
1590
- y: z.number().describe('Y坐标'),
1591
- width: z.number().optional().describe('宽度,默认200'),
1592
- height: z.number().optional().describe('高度,默认60'),
1593
- text: z.string().optional().describe('按钮文字'),
1594
- fontSize: z.number().optional().describe('字体大小'),
1595
- color: z.string().optional().describe('文字颜色'),
1596
- backgroundColor: z.string().optional().describe('背景色'),
1597
- borderColor: z.string().optional().describe('边框颜色'),
1598
- borderWidth: z.number().optional().describe('边框宽度'),
1599
- radius: z.number().optional().describe('圆角'),
1600
- shadow: z.object({
1601
- color: z.string().optional(),
1602
- blur: z.number().optional(),
1603
- offsetX: z.number().optional(),
1604
- offsetY: z.number().optional(),
1605
- }).optional(),
1606
- gradient: z.object({
1607
- colors: z.array(z.string()).describe('渐变颜色数组'),
1608
- }).optional(),
1609
- opacity: z.number().optional().describe('透明度'),
1610
- }),
1611
- execute: async (args) => {
1612
- try {
1613
- if (!this._canvasManager.isCreated()) {
1614
- return { success: false, error: 'No canvas created' }
1615
- }
1616
- return await createButton(
1617
- this._canvasManager.getProject(),
1618
- args
1619
- )
1620
- } catch (err) {
1621
- return { success: false, error: err.message }
1622
- }
1623
- },
1624
- },
1625
-
1626
- /**
1627
- * 添加图标
1628
- */
1629
- add_poster_icon: {
1630
- description: '添加图标(emoji或图片)',
1631
- inputSchema: z.object({
1632
- x: z.number().describe('X坐标'),
1633
- y: z.number().describe('Y坐标'),
1634
- size: z.number().optional().describe('图标大小,默认64'),
1635
- icon: z.string().describe('图标内容(emoji或图片URL)'),
1636
- color: z.string().optional().describe('颜色'),
1637
- backgroundColor: z.string().optional().describe('背景色'),
1638
- borderColor: z.string().optional().describe('边框颜色'),
1639
- borderWidth: z.number().optional().describe('边框宽度'),
1640
- radius: z.number().optional().describe('圆角'),
1641
- shadow: z.object({
1642
- color: z.string().optional(),
1643
- blur: z.number().optional(),
1644
- offsetX: z.number().optional(),
1645
- offsetY: z.number().optional(),
1646
- }).optional(),
1647
- opacity: z.number().optional().describe('透明度'),
1648
- }),
1649
- execute: async (args) => {
1650
- try {
1651
- if (!this._canvasManager.isCreated()) {
1652
- return { success: false, error: 'No canvas created' }
1653
- }
1654
- return await createIcon(
1655
- this._canvasManager.getProject(),
1656
- args
1657
- )
1658
- } catch (err) {
1659
- return { success: false, error: err.message }
1660
- }
1661
- },
1662
- },
1663
-
1664
- /**
1665
- * 添加二维码
1666
- */
1667
- // add_poster_qrcode: {
1668
- // description: '添加二维码',
1669
- // inputSchema: z.object({
1670
- // x: z.number().describe('X坐标'),
1671
- // y: z.number().describe('Y坐标'),
1672
- // size: z.number().optional().describe('二维码大小,默认200'),
1673
- // content: z.string().describe('二维码内容'),
1674
- // color: z.string().optional().describe('前景色'),
1675
- // backgroundColor: z.string().optional().describe('背景色'),
1676
- // logo: z.string().optional().describe('中间logo图片路径'),
1677
- // logoSize: z.number().optional().describe('logo大小'),
1678
- // opacity: z.number().optional().describe('透明度'),
1679
- // }),
1680
- // execute: async (args) => {
1681
- // try {
1682
- // if (!this._canvasManager.isCreated()) {
1683
- // return { success: false, error: 'No canvas created' }
1684
- // }
1685
- // return await createQRCode(
1686
- // this._canvasManager.getProject(),
1687
- // this._canvasManager.getCanvas(),
1688
- // args
1689
- // )
1690
- // } catch (err) {
1691
- // return { success: false, error: err.message }
1692
- // }
1693
- // },
1694
- // },
1695
-
1696
- /**
1697
- * 添加装饰边框
1698
- */
1699
- add_poster_frame: {
1700
- description: '添加装饰边框',
1701
- inputSchema: z.object({
1702
- x: z.number().describe('X坐标'),
1703
- y: z.number().describe('Y坐标'),
1704
- width: z.number().describe('宽度'),
1705
- height: z.number().describe('高度'),
1706
- style: z.enum(['simple', 'double', 'dashed', 'dotted', 'corner', 'vintage', 'modern', 'floral']).optional().describe('边框样式'),
1707
- color: z.string().optional().describe('边框颜色'),
1708
- borderWidth: z.number().optional().describe('边框宽度'),
1709
- radius: z.number().optional().describe('圆角'),
1710
- padding: z.number().optional().describe('内边距'),
1711
- opacity: z.number().optional().describe('透明度'),
1712
- }),
1713
- execute: async (args) => {
1714
- try {
1715
- if (!this._canvasManager.isCreated()) {
1716
- return { success: false, error: 'No canvas created' }
1717
- }
1718
- return await createFrame(
1719
- this._canvasManager.getProject(),
1720
- this._canvasManager.getCanvas(),
1721
- args
1722
- )
1723
- } catch (err) {
1724
- return { success: false, error: err.message }
1725
- }
1726
- },
1727
- },
1728
-
1729
- /**
1730
- * 添加对话气泡
1731
- */
1732
- add_poster_bubble: {
1733
- description: '添加对话气泡',
1734
- inputSchema: z.object({
1735
- x: z.number().describe('X坐标'),
1736
- y: z.number().describe('Y坐标'),
1737
- width: z.number().optional().describe('宽度,默认300'),
1738
- height: z.number().optional().describe('高度,默认100'),
1739
- text: z.string().describe('气泡文字'),
1740
- fontSize: z.number().optional().describe('字体大小'),
1741
- color: z.string().optional().describe('文字颜色'),
1742
- backgroundColor: z.string().optional().describe('背景色'),
1743
- borderColor: z.string().optional().describe('边框颜色'),
1744
- borderWidth: z.number().optional().describe('边框宽度'),
1745
- radius: z.number().optional().describe('圆角'),
1746
- tailDirection: z.enum(['bottom', 'top', 'left', 'right']).optional().describe('尾巴方向'),
1747
- tailPosition: z.enum(['left', 'center', 'right']).optional().describe('尾巴位置'),
1748
- shadow: z.object({
1749
- color: z.string().optional(),
1750
- blur: z.number().optional(),
1751
- offsetX: z.number().optional(),
1752
- offsetY: z.number().optional(),
1753
- }).optional(),
1754
- opacity: z.number().optional().describe('透明度'),
1755
- }),
1756
- execute: async (args) => {
1757
- try {
1758
- if (!this._canvasManager.isCreated()) {
1759
- return { success: false, error: 'No canvas created' }
1760
- }
1761
- return await createBubble(
1762
- this._canvasManager.getProject(),
1763
- this._canvasManager.getCanvas(),
1764
- args
1765
- )
1766
- } catch (err) {
1767
- return { success: false, error: err.message }
1768
- }
1769
- },
1770
- },
1771
-
1772
- /**
1773
- * 添加丝带
1774
- */
1775
- add_poster_ribbon: {
1776
- description: '添加丝带飘带',
1777
- inputSchema: z.object({
1778
- x: z.number().describe('X坐标'),
1779
- y: z.number().describe('Y坐标'),
1780
- width: z.number().optional().describe('宽度,默认300'),
1781
- text: z.string().optional().describe('丝带文字'),
1782
- fontSize: z.number().optional().describe('字体大小'),
1783
- color: z.string().optional().describe('文字颜色'),
1784
- backgroundColor: z.string().optional().describe('背景色'),
1785
- borderColor: z.string().optional().describe('边框颜色'),
1786
- borderWidth: z.number().optional().describe('边框宽度'),
1787
- style: z.enum(['fold', 'diagonal', 'corner']).optional().describe('丝带样式'),
1788
- shadow: z.object({
1789
- color: z.string().optional(),
1790
- blur: z.number().optional(),
1791
- offsetX: z.number().optional(),
1792
- offsetY: z.number().optional(),
1793
- }).optional(),
1794
- opacity: z.number().optional().describe('透明度'),
1795
- }),
1796
- execute: async (args) => {
1797
- try {
1798
- if (!this._canvasManager.isCreated()) {
1799
- return { success: false, error: 'No canvas created' }
1800
- }
1801
- return await createRibbon(
1802
- this._canvasManager.getProject(),
1803
- this._canvasManager.getCanvas(),
1804
- args
1805
- )
1806
- } catch (err) {
1807
- return { success: false, error: err.message }
1808
- }
1809
- },
1810
- },
1811
-
1812
- /**
1813
- * 添加印章
1814
- */
1815
- add_poster_seal: {
1816
- description: '添加印章效果',
1817
- inputSchema: z.object({
1818
- x: z.number().describe('X坐标'),
1819
- y: z.number().describe('Y坐标'),
1820
- size: z.number().optional().describe('印章大小,默认100'),
1821
- text: z.string().optional().describe('印章文字'),
1822
- fontSize: z.number().optional().describe('字体大小'),
1823
- color: z.string().optional().describe('印章颜色'),
1824
- style: z.enum(['circle', 'square', 'star', 'hexagon']).optional().describe('印章形状'),
1825
- borderWidth: z.number().optional().describe('边框宽度'),
1826
- opacity: z.number().optional().describe('透明度'),
1827
- }),
1828
- execute: async (args) => {
1829
- try {
1830
- if (!this._canvasManager.isCreated()) {
1831
- return { success: false, error: 'No canvas created' }
1832
- }
1833
- return await createSeal(
1834
- this._canvasManager.getProject(),
1835
- this._canvasManager.getCanvas(),
1836
- args
1837
- )
1838
- } catch (err) {
1839
- return { success: false, error: err.message }
1840
- }
1841
- },
1842
- },
1843
-
1844
- /**
1845
- * 添加高亮文字
1846
- */
1847
- add_poster_highlight_text: {
1848
- description: '添加高亮文字(荧光笔效果)',
1849
- inputSchema: z.object({
1850
- x: z.number().describe('X坐标'),
1851
- y: z.number().describe('Y坐标'),
1852
- text: z.string().describe('文字内容'),
1853
- fontSize: z.number().optional().describe('字体大小'),
1854
- color: z.string().optional().describe('文字颜色'),
1855
- highlightColor: z.string().optional().describe('高亮颜色'),
1856
- highlightStyle: z.enum(['marker', 'underline', 'background', 'stroke', 'neon']).optional().describe('高亮样式'),
1857
- strokeWidth: z.number().optional().describe('描边宽度'),
1858
- shadow: z.object({
1859
- color: z.string().optional(),
1860
- blur: z.number().optional(),
1861
- offsetX: z.number().optional(),
1862
- offsetY: z.number().optional(),
1863
- }).optional(),
1864
- opacity: z.number().optional().describe('透明度'),
1865
- }),
1866
- execute: async (args) => {
1867
- try {
1868
- if (!this._canvasManager.isCreated()) {
1869
- return { success: false, error: 'No canvas created' }
1870
- }
1871
- return await createHighlightText(
1872
- this._canvasManager.getProject(),
1873
- this._canvasManager.getCanvas(),
1874
- args
1875
- )
1876
- } catch (err) {
1877
- return { success: false, error: err.message }
1878
- }
1879
- },
1880
- },
1881
-
1882
- /**
1883
- * 添加条形码
1884
- */
1885
- // add_poster_barcode: {
1886
- // description: '添加条形码',
1887
- // inputSchema: z.object({
1888
- // x: z.number().describe('X坐标'),
1889
- // y: z.number().describe('Y坐标'),
1890
- // width: z.number().optional().describe('宽度,默认300'),
1891
- // height: z.number().optional().describe('高度,默认100'),
1892
- // content: z.string().describe('条形码内容'),
1893
- // color: z.string().optional().describe('条形码颜色'),
1894
- // showText: z.boolean().optional().describe('是否显示文字'),
1895
- // textColor: z.string().optional().describe('文字颜色'),
1896
- // fontSize: z.number().optional().describe('字体大小'),
1897
- // opacity: z.number().optional().describe('透明度'),
1898
- // }),
1899
- // execute: async (args) => {
1900
- // try {
1901
- // if (!this._canvasManager.isCreated()) {
1902
- // return { success: false, error: 'No canvas created' }
1903
- // }
1904
- // return await createBarcode(
1905
- // this._canvasManager.getProject(),
1906
- // this._canvasManager.getCanvas(),
1907
- // args
1908
- // )
1909
- // } catch (err) {
1910
- // return { success: false, error: err.message }
1911
- // }
1912
- // },
1913
- // },
1914
-
1915
- // ==================== 组件化海报生成 ====================
1916
-
1917
- /**
1918
- * 组件化生成海报
1919
- */
1920
- compose_poster: {
1921
- description: '使用组件配置一次性生成海报',
1922
- inputSchema: z.object({
1923
- components: z.array(z.object({
1924
- type: z.enum([
1925
- 'background', 'rectangle', 'circle', 'line', 'polygon',
1926
- 'text', 'artText', 'richText', 'image', 'svg', 'imageFrame',
1927
- 'columns', 'grid', 'star', 'arrow', 'progressCircle', 'chip', 'chart', 'watermark', 'table',
1928
- 'card', 'badge', 'cta', 'feature', 'featureGrid', 'divider',
1929
- 'avatar', 'progress', 'rating', 'quote', 'statCard',
1930
- 'tagCloud', 'stepper', 'timeline', 'listItem', 'notification',
1931
- 'button', 'icon', 'qrcode', 'frame', 'bubble', 'ribbon', 'seal', 'highlightText', 'barcode',
1932
- ]).describe('组件类型'),
1933
- })).describe('组件配置数组'),
1934
- }),
1935
- execute: async (args) => {
1936
- try {
1937
- if (!this._canvasManager.isCreated()) {
1938
- return { success: false, error: 'No canvas created' }
1939
- }
1940
- return createFromConfig(
1941
- this._canvasManager.getProject(),
1942
- this._canvasManager.getCanvas(),
1943
- args
1944
- )
1945
- } catch (err) {
1946
- return { success: false, error: err.message }
1947
- }
1948
- },
1949
- },
1950
-
1951
- /**
1952
- * 获取可用组件类型
1953
- */
1954
- list_poster_components: {
1955
- description: '列出所有可用的组件类型',
1956
- inputSchema: z.object({}),
1957
- execute: async () => ({
1958
- success: true,
1959
- components: Object.keys(COMPONENT_TYPES),
1960
- }),
1961
- },
1962
-
1963
- // ==================== 模板 ====================
1964
-
1965
- /**
1966
- * 一键生成海报
1967
- */
1968
- generate_poster: {
1969
- description: '使用预设模板一键生成海报',
1970
- inputSchema: z.object({
1971
- template: z.enum(['modern', 'business', 'social', 'simple', 'tech', 'gradient']).describe('模板类型'),
1972
- title: z.string().describe('主标题'),
1973
- subtitle: z.string().optional().describe('副标题'),
1974
- background: z.string().optional().describe('背景色'),
1975
- accentColor: z.string().optional().describe('强调色'),
1976
- output: z.string().describe('输出文件名'),
1977
- outputDir: z.string().optional().describe('输出目录'),
1978
- }),
1979
- execute: async (args) => {
1980
- try {
1981
- if (!this._canvasManager.isCreated()) {
1982
- return { success: false, error: 'No canvas created' }
1983
- }
1984
-
1985
- // 应用模板
1986
- applyTemplate(
1987
- this._canvasManager.getProject(),
1988
- this._canvasManager.getCanvas(),
1989
- args.template,
1990
- args
1991
- )
1992
-
1993
- // 导出
1994
- const format = 'png'
1995
- const outputDir = args.outputDir || '.'
1996
- const filename = `${args.output}.${format}`
1997
- await fs.promises.mkdir(outputDir, { recursive: true })
1998
- const filepath = path.join(outputDir, filename)
1999
- const buffer = this._canvasManager.toBuffer(format)
2000
- await fs.promises.writeFile(filepath, buffer)
2001
-
2002
- return {
2003
- success: true,
2004
- filepath,
2005
- template: args.template,
2006
- size: buffer.length,
2007
- }
2008
- } catch (err) {
2009
- return { success: false, error: err.message }
2010
- }
2011
- },
2012
- },
2013
-
2014
- /**
2015
- * 列出可用模板
2016
- */
2017
- list_poster_templates: {
2018
- description: '列出所有可用的海报模板',
2019
- inputSchema: z.object({}),
2020
- execute: async () => ({
2021
- success: true,
2022
- templates: getAvailableTemplates(),
2023
- }),
2024
- },
2025
-
2026
- // ==================== 导出 ====================
2027
-
2028
- /**
2029
- * 导出为文件
2030
- */
2031
- export_poster_canvas: {
2032
- description: '导出画布为图片文件',
2033
- inputSchema: z.object({
2034
- filename: z.string().describe('文件名(不含扩展名)'),
2035
- format: z.enum(['png', 'jpg']).optional().describe('格式,默认png'),
2036
- quality: z.number().optional().describe('JPEG质量'),
2037
- outputDir: z.string().optional().describe('输出目录'),
2038
- }),
2039
- execute: async (args) => {
2040
- try {
2041
- if (!this._canvasManager.isCreated()) {
2042
- return { success: false, error: 'No canvas created' }
2043
- }
2044
-
2045
- const format = args.format || 'png'
2046
- const outputDir = args.outputDir || '.'
2047
- const filename = `${args.filename}.${format}`
2048
- await fs.promises.mkdir(outputDir, { recursive: true })
2049
- const filepath = path.join(outputDir, filename)
2050
- const buffer = this._canvasManager.toBuffer(format, args.quality)
2051
- await fs.promises.writeFile(filepath, buffer)
2052
-
2053
- return {
2054
- success: true,
2055
- filepath,
2056
- filename,
2057
- format,
2058
- size: buffer.length,
2059
- }
2060
- } catch (err) {
2061
- return { success: false, error: err.message }
2062
- }
2063
- },
2064
- },
2065
-
2066
- /**
2067
- * 导出为 Base64
2068
- */
2069
- export_poster_base64: {
2070
- description: '导出画布为 Base64 编码',
2071
- inputSchema: z.object({
2072
- format: z.enum(['png', 'jpg']).optional().describe('格式'),
2073
- quality: z.number().optional().describe('JPEG质量'),
2074
- }),
2075
- execute: async (args) => {
2076
- try {
2077
- if (!this._canvasManager.isCreated()) {
2078
- return { success: false, error: 'No canvas created' }
2079
- }
2080
-
2081
- const format = args.format || 'png'
2082
- const base64 = this._canvasManager.toBase64(format, args.quality)
2083
- const mimeType = format === 'jpg' ? 'image/jpeg' : 'image/png'
2084
-
2085
- return {
2086
- success: true,
2087
- base64,
2088
- format,
2089
- mimeType,
2090
- }
2091
- } catch (err) {
2092
- return { success: false, error: err.message }
2093
- }
2094
- },
2095
- },
2096
- }
2097
-
2098
-
2099
- async install(framework) {
2100
- this._framework = framework
2101
- console.log('[poster] Poster plugin installed (v1.1.0)')
2102
- console.log('[poster] Components:', Object.keys(COMPONENT_TYPES).join(', '))
2103
-
2104
- return this
2105
- }
2106
-
2107
- start(framework) {
2108
- // Object.keys(this.all_tools).map(key=>{
2109
- // this._framework.registerTool({...this.all_tools[key],name:key})
2110
- // })
2111
- console.log('[poster] Poster plugin started')
2112
- }
2113
-
2114
-
2115
- reload(framework) {
2116
- console.log('[poster] Reloading poster plugin')
2117
- this._framework = framework
2118
- }
2119
-
2120
- uninstall(framework) {
2121
- this._canvasManager.reset()
2122
- this._framework = null
2123
- console.log('[poster] Poster plugin uninstalled')
2124
- }
2125
- }
2126
- }