foliko 1.0.87 → 1.1.1

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 (259) hide show
  1. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
  2. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
  3. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
  4. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
  5. package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
  6. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
  7. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
  8. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  9. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  10. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  11. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  12. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  13. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  14. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  15. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
  16. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  17. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  18. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  19. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  20. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
  21. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
  22. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  23. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  24. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
  25. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  26. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  27. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
  28. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
  29. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
  30. package/.agent/ARCHITECTURE.md +288 -0
  31. package/.agent/agents/ambient-agent.md +57 -0
  32. package/.agent/agents/debugger.md +55 -0
  33. package/.agent/agents/email-assistant.md +49 -0
  34. package/.agent/agents/file-manager.md +42 -0
  35. package/.agent/agents/python-developer.md +60 -0
  36. package/.agent/agents/scheduler.md +59 -0
  37. package/.agent/agents/web-developer.md +45 -0
  38. package/.agent/data/default.json +325 -21
  39. package/.agent/data/plugins-state.json +194 -162
  40. package/.agent/data/puppeteer-sessions/undefined.json +6 -0
  41. package/.agent/mcp_config.json +0 -1
  42. package/.agent/mcp_config_updated.json +12 -0
  43. package/.agent/plugins/poster-plugin/README.md +304 -0
  44. package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
  45. package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
  46. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
  47. 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
  48. package/.agent/plugins/poster-plugin/index.js +13 -0
  49. package/.agent/plugins/poster-plugin/package.json +28 -0
  50. package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
  51. package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
  52. package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
  53. package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
  54. package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
  55. package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
  56. package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
  57. package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
  58. package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
  59. package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
  60. package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
  61. package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
  62. package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
  63. package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
  64. package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
  65. package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
  66. package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
  67. package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
  68. package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
  69. package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
  70. package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
  71. package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
  72. package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
  73. package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
  74. package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
  75. package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
  76. package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
  77. package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
  78. package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
  79. package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
  80. package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
  81. package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
  82. package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
  83. package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
  84. package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
  85. package/.agent/plugins/poster-plugin/src/elements/polygon.js +63 -0
  86. package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
  87. package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
  88. package/.agent/plugins/poster-plugin/src/elements/text.js +107 -0
  89. package/.agent/plugins/poster-plugin/src/fonts.js +233 -0
  90. package/.agent/plugins/poster-plugin/src/index.js +1658 -0
  91. package/.agent/plugins/poster-plugin/src/presets.js +36 -0
  92. package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
  93. package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
  94. package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
  95. package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
  96. package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
  97. package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
  98. package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
  99. package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/index.js +1 -1
  100. package/.agent/plugins.json +5 -11
  101. package/.agent/rules/GEMINI.md +273 -0
  102. package/.agent/rules/allow-rule.md +77 -0
  103. package/.agent/rules/log-rule.md +83 -0
  104. package/.agent/rules/security-rule.md +93 -0
  105. package/.agent/scripts/auto_preview.py +148 -0
  106. package/.agent/scripts/checklist.py +217 -0
  107. package/.agent/scripts/session_manager.py +120 -0
  108. package/.agent/scripts/verify_all.py +327 -0
  109. package/.agent/sessions/cli_default.json +419 -0
  110. package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +2195 -0
  111. package/.agent/skills/api-patterns/SKILL.md +81 -0
  112. package/.agent/skills/api-patterns/api-style.md +42 -0
  113. package/.agent/skills/api-patterns/auth.md +24 -0
  114. package/.agent/skills/api-patterns/documentation.md +26 -0
  115. package/.agent/skills/api-patterns/graphql.md +41 -0
  116. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  117. package/.agent/skills/api-patterns/response.md +37 -0
  118. package/.agent/skills/api-patterns/rest.md +40 -0
  119. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  120. package/.agent/skills/api-patterns/security-testing.md +122 -0
  121. package/.agent/skills/api-patterns/trpc.md +41 -0
  122. package/.agent/skills/api-patterns/versioning.md +22 -0
  123. package/.agent/skills/app-builder/SKILL.md +75 -0
  124. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  125. package/.agent/skills/app-builder/feature-building.md +53 -0
  126. package/.agent/skills/app-builder/project-detection.md +34 -0
  127. package/.agent/skills/app-builder/scaffolding.md +118 -0
  128. package/.agent/skills/app-builder/tech-stack.md +40 -0
  129. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  130. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  131. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  132. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  133. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  134. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  135. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  136. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  137. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  138. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  139. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  140. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  141. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  142. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  143. package/.agent/skills/architecture/SKILL.md +55 -0
  144. package/.agent/skills/architecture/context-discovery.md +43 -0
  145. package/.agent/skills/architecture/examples.md +94 -0
  146. package/.agent/skills/architecture/pattern-selection.md +68 -0
  147. package/.agent/skills/architecture/patterns-reference.md +50 -0
  148. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  149. package/.agent/skills/clean-code/SKILL.md +201 -0
  150. package/.agent/skills/doc.md +177 -0
  151. package/.agent/skills/frontend-design/SKILL.md +418 -0
  152. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  153. package/.agent/skills/frontend-design/color-system.md +311 -0
  154. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  155. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  156. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  157. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  158. package/.agent/skills/frontend-design/typography-system.md +345 -0
  159. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  160. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  161. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  162. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  163. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  164. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  165. package/.agent/workflows/brainstorm.md +113 -0
  166. package/.agent/workflows/create.md +59 -0
  167. package/.agent/workflows/debug.md +103 -0
  168. package/.agent/workflows/deploy.md +176 -0
  169. package/.agent/workflows/enhance.md +63 -0
  170. package/.agent/workflows/orchestrate.md +237 -0
  171. package/.agent/workflows/plan.md +89 -0
  172. package/.agent/workflows/preview.md +81 -0
  173. package/.agent/workflows/simple-test.md +42 -0
  174. package/.agent/workflows/status.md +86 -0
  175. package/.agent/workflows/structured-orchestrate.md +180 -0
  176. package/.agent/workflows/test.md +144 -0
  177. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  178. package/.claude/settings.local.json +20 -8
  179. package/.env.example +56 -56
  180. package/CLAUDE.md +144 -108
  181. package/README.md +441 -441
  182. package/calc_tokens_weixin.js +81 -0
  183. package/cli/src/commands/chat.js +2 -1
  184. package/docs/CONTEXT_DESIGN.md +1596 -0
  185. package/examples/test-concurrent-chat.js +60 -60
  186. package/foliko-creative-3.png +0 -0
  187. package/foliko-creative-4.png +0 -0
  188. package/foliko-creative-5.png +0 -0
  189. package/package.json +2 -2
  190. package/plugins/default-plugins.js +2 -1
  191. package/plugins/extension-executor-plugin.js +91 -2
  192. package/plugins/file-system-plugin.js +2 -2
  193. package/plugins/memory-plugin.js +984 -0
  194. package/plugins/session-plugin.js +57 -1
  195. package/plugins/weixin-plugin.js +33 -23
  196. package/skills/find-skills/AGENTS.md +162 -162
  197. package/skills/find-skills/SKILL.md +133 -133
  198. package/skills/poster-guide/SKILL.md +1059 -0
  199. package/skills/python-plugin-dev/SKILL.md +238 -238
  200. package/skills/skill-guide/SKILL.md +130 -108
  201. package/src/capabilities/skill-manager.js +99 -0
  202. package/src/core/agent-chat.js +620 -141
  203. package/src/core/agent-context.js +188 -0
  204. package/src/core/agent.js +6 -2
  205. package/src/core/context-manager.js +283 -0
  206. package/src/core/framework.js +264 -3
  207. package/src/core/plugin-manager.js +79 -2
  208. package/src/core/request-context.js +98 -0
  209. package/src/core/session-context.js +341 -0
  210. package/src/core/session-storage.js +274 -0
  211. package/src/executors/mcp-executor.js +2 -2
  212. package/src/utils/index.js +239 -67
  213. package/src/utils/plugin-helpers.js +17 -0
  214. package/story-cover-book-v2.png +0 -0
  215. package/story-cover-japanese-1.png +0 -0
  216. package/story-cover-japanese-2.png +0 -0
  217. package/story-cover-japanese-3.png +0 -0
  218. package/story-cover-moran.png +0 -0
  219. package/undefined.png +0 -0
  220. package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
  221. package/.agent/agents/code-assistant.json +0 -14
  222. package/.agent/agents/email-assistant.json +0 -14
  223. package/.agent/agents/file-assistant.json +0 -15
  224. package/.agent/agents/system-assistant.json +0 -15
  225. package/.agent/agents/web-assistant.json +0 -12
  226. package/.agent/data/ambient/goals.json +0 -50
  227. package/.agent/data/ambient/memories.json +0 -7
  228. package/.agent/data/scheduler/tasks.json +0 -1
  229. package/.agent/package.json +0 -8
  230. package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
  231. package/.agent/plugins/daytona/README.md +0 -89
  232. package/.agent/plugins/daytona/index.js +0 -377
  233. package/.agent/plugins/daytona/package.json +0 -12
  234. package/.agent/plugins/marknative/README.md +0 -134
  235. package/.agent/plugins/marknative/index.js +0 -228
  236. package/.agent/plugins/marknative/package.json +0 -12
  237. package/.agent/plugins/marknative/update-readme.js +0 -134
  238. package/.agent/plugins/system-info/index.js +0 -387
  239. package/.agent/plugins/system-info/package.json +0 -4
  240. package/.agent/plugins/system-info/test.js +0 -40
  241. package/.agent/plugins/temp-repo/LICENSE +0 -201
  242. package/.agent/plugins/test_plugin.py +0 -304
  243. package/.agent/python-scripts/test_sample.py +0 -24
  244. package/.agent/skills/agent-browser/SKILL.md +0 -311
  245. package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
  246. package/.agent/skills/sysinfo/SKILL.md +0 -38
  247. package/.agent/skills/sysinfo/system-info.sh +0 -130
  248. package/.agent/skills/workflow/SKILL.md +0 -324
  249. package/.agent/workflows/email-digest.json +0 -50
  250. package/.agent/workflows/file-backup.json +0 -21
  251. package/.agent/workflows/get-ip-notify.json +0 -32
  252. package/.agent/workflows/news-aggregator.json +0 -93
  253. package/.agent/workflows/news-dashboard-v2.json +0 -94
  254. package/.agent/workflows/notification-batch.json +0 -32
  255. package/examples/test-chat-debug.js +0 -102
  256. package/examples/test-chat-result.js +0 -76
  257. package/examples/test-chat-stream-diff.js +0 -63
  258. /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/README.md +0 -0
  259. /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/package.json +0 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * 徽章/标签组件
3
+ */
4
+
5
+ const paper = require('paper')
6
+
7
+ /**
8
+ * 创建徽章组件
9
+ *
10
+ * @param {Object} project - Paper.js 项目
11
+ * @param {Object} canvas - 画布对象
12
+ * @param {Object} args - 组件参数
13
+ * @param {number} args.x - X坐标(居中时使用)
14
+ * @param {number} args.y - Y坐标
15
+ * @param {string} args.text - 徽章文字
16
+ * @param {string} args.background - 背景色
17
+ * @param {string} args.color - 文字颜色
18
+ * @param {string} args.border - 边框颜色
19
+ * @param {number} args.fontSize - 字体大小
20
+ * @param {string} args.align - 对齐方式: left, center, right
21
+ * @param {number} args.padding - 内边距
22
+ * @param {number} args.radius - 圆角半径
23
+ */
24
+ function createBadge(project, canvas, args) {
25
+ const {
26
+ x, y,
27
+ text,
28
+ background = '#007bff',
29
+ color = '#ffffff',
30
+ border,
31
+ fontSize = 18,
32
+ align = 'center',
33
+ padding = 15,
34
+ radius = 4,
35
+ } = args
36
+
37
+ const elements = []
38
+
39
+ // 计算文字宽度(估算)
40
+ const textWidth = text.length * fontSize * 0.6
41
+ const badgeWidth = textWidth + padding * 2
42
+ const badgeHeight = fontSize + padding * 2
43
+
44
+ // 计算X位置
45
+ let badgeX = x
46
+ if (align === 'center') {
47
+ badgeX = x - badgeWidth / 2
48
+ } else if (align === 'right') {
49
+ badgeX = x - badgeWidth
50
+ }
51
+
52
+ // 绘制徽章背景
53
+ const badge = new paper.Path.Rectangle({
54
+ point: [badgeX, y],
55
+ size: [badgeWidth, badgeHeight],
56
+ radius: radius,
57
+ })
58
+ badge.fillColor = new paper.Color(background)
59
+
60
+ if (border) {
61
+ badge.strokeColor = new paper.Color(border)
62
+ badge.strokeWidth = 1
63
+ }
64
+
65
+ elements.push({ type: 'rectangle', id: badge.id })
66
+
67
+ // 绘制文字
68
+ const badgeText = new paper.PointText({
69
+ point: [badgeX + badgeWidth / 2, y + badgeHeight / 2 + fontSize / 3],
70
+ content: text,
71
+ fontSize: fontSize,
72
+ fillColor: new paper.Color(color),
73
+ justification: 'center',
74
+ })
75
+ elements.push({ type: 'text', id: badgeText.id })
76
+
77
+ return {
78
+ success: true,
79
+ elements,
80
+ width: badgeWidth,
81
+ height: badgeHeight,
82
+ }
83
+ }
84
+
85
+ module.exports = createBadge
@@ -0,0 +1,88 @@
1
+ /**
2
+ * 卡片组件
3
+ */
4
+
5
+ const paper = require('paper')
6
+
7
+ /**
8
+ * 创建卡片组件
9
+ *
10
+ * @param {Object} project - Paper.js 项目
11
+ * @param {Object} canvas - 画布对象
12
+ * @param {Object} args - 组件参数
13
+ * @param {number} args.x - 卡片X坐标
14
+ * @param {number} args.y - 卡片Y坐标
15
+ * @param {number} args.width - 卡片宽度
16
+ * @param {number} args.height - 卡片高度
17
+ * @param {string} args.background - 背景色
18
+ * @param {string} args.border - 边框颜色
19
+ * @param {number} args.borderWidth - 边框宽度
20
+ * @param {number} args.radius - 圆角半径
21
+ * @param {string} args.title - 标题文字
22
+ * @param {number} args.titleSize - 标题字体大小
23
+ * @param {string} args.titleColor - 标题颜色
24
+ * @param {string} args.subtitle - 副标题
25
+ * @param {number} args.subtitleSize - 副标题字体大小
26
+ * @param {string} args.subtitleColor - 副标题颜色
27
+ * @param {number} args.padding - 内边距
28
+ */
29
+ function createCard(project, canvas, args) {
30
+ const {
31
+ x, y, width, height,
32
+ background, border, borderWidth, radius,
33
+ title, titleSize, titleColor,
34
+ subtitle, subtitleSize, subtitleColor,
35
+ padding = 20,
36
+ } = args
37
+
38
+ const elements = []
39
+
40
+ // 绘制卡片背景
41
+ const card = new paper.Path.Rectangle({
42
+ point: [x, y],
43
+ size: [width, height],
44
+ radius: radius || 0,
45
+ })
46
+
47
+ if (background) {
48
+ card.fillColor = new paper.Color(background)
49
+ } else {
50
+ card.fillColor = new paper.Color('#ffffff')
51
+ }
52
+
53
+ if (border) {
54
+ card.strokeColor = new paper.Color(border)
55
+ card.strokeWidth = borderWidth || 1
56
+ }
57
+
58
+ elements.push({ type: 'rectangle', id: card.id })
59
+
60
+ // 绘制标题
61
+ if (title) {
62
+ const titleText = new paper.PointText({
63
+ point: [x + padding, y + padding + (titleSize || 24)],
64
+ content: title,
65
+ fontSize: titleSize || 24,
66
+ fillColor: new paper.Color(titleColor || '#000000'),
67
+ justification: 'left',
68
+ })
69
+ elements.push({ type: 'text', id: titleText.id })
70
+ }
71
+
72
+ // 绘制副标题
73
+ if (subtitle) {
74
+ const titleHeight = title ? (titleSize || 24) + padding : padding
75
+ const subtitleText = new paper.PointText({
76
+ point: [x + padding, y + titleHeight + (subtitleSize || 16) + 10],
77
+ content: subtitle,
78
+ fontSize: subtitleSize || 16,
79
+ fillColor: new paper.Color(subtitleColor || '#666666'),
80
+ justification: 'left',
81
+ })
82
+ elements.push({ type: 'text', id: subtitleText.id })
83
+ }
84
+
85
+ return { success: true, elements }
86
+ }
87
+
88
+ module.exports = createCard
@@ -0,0 +1,127 @@
1
+ /**
2
+ * 图表组件
3
+ */
4
+
5
+ const paper = require('paper')
6
+
7
+ /**
8
+ * 创建图表组件
9
+ */
10
+ function createChart(project, canvas, params) {
11
+ const {
12
+ type = 'bar',
13
+ x,
14
+ y,
15
+ width,
16
+ height,
17
+ data = [],
18
+ barColor = '#3b82f6',
19
+ showLabels = true,
20
+ showValues = true,
21
+ barGap = 4
22
+ } = params
23
+
24
+ const elements = []
25
+
26
+ if (type === 'bar' && data.length > 0) {
27
+ const maxValue = Math.max(...data.map(d => d.value))
28
+ const barCount = data.length
29
+ const totalGap = barGap * (barCount - 1)
30
+ const barWidth = (width - totalGap) / barCount
31
+ const labelHeight = showLabels ? 24 : 0
32
+ const valueHeight = showValues ? 20 : 0
33
+ const chartHeight = height - labelHeight - valueHeight - 10
34
+
35
+ data.forEach((item, index) => {
36
+ const barHeight = (item.value / maxValue) * chartHeight
37
+ const barX = x + index * (barWidth + barGap)
38
+ const barY = y + height - labelHeight - valueHeight - barHeight - 5
39
+ const color = item.color || barColor
40
+
41
+ const bar = new paper.Path.Rectangle({
42
+ point: [barX, barY],
43
+ size: [barWidth, barHeight],
44
+ radius: [4, 4, 0, 0]
45
+ })
46
+ bar.fillColor = new paper.Color(color)
47
+ if (project && project.activeLayer) {
48
+ project.activeLayer.addChild(bar)
49
+ }
50
+ elements.push({ type: 'path', id: bar.id })
51
+
52
+ if (showValues) {
53
+ const valueText = new paper.PointText({
54
+ point: [barX + barWidth / 2, barY - 8],
55
+ content: String(item.value),
56
+ fontSize: 12,
57
+ fillColor: new paper.Color('#666666'),
58
+ justification: 'center'
59
+ })
60
+ if (project && project.activeLayer) {
61
+ project.activeLayer.addChild(valueText)
62
+ }
63
+ elements.push({ type: 'text', id: valueText.id })
64
+ }
65
+
66
+ if (showLabels) {
67
+ const labelText = new paper.PointText({
68
+ point: [barX + barWidth / 2, y + height - 8],
69
+ content: item.label || '',
70
+ fontSize: 11,
71
+ fillColor: new paper.Color('#333333'),
72
+ justification: 'center'
73
+ })
74
+ if (project && project.activeLayer) {
75
+ project.activeLayer.addChild(labelText)
76
+ }
77
+ elements.push({ type: 'text', id: labelText.id })
78
+ }
79
+ })
80
+ } else if (type === 'pie' && data.length > 0) {
81
+ const cx = x + width / 2
82
+ const cy = y + height / 2
83
+ const radius = Math.min(width, height) / 2 - 10
84
+ const total = data.reduce((sum, d) => sum + d.value, 0)
85
+ let currentAngle = -90
86
+ const colors = ['#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899', '#06b6d4', '#84cc16']
87
+
88
+ data.forEach((item, index) => {
89
+ const percentage = item.value / total
90
+ const endAngle = currentAngle + percentage * 360
91
+ const path = new paper.Path()
92
+ path.moveTo(cx, cy)
93
+ path.arc([cx, cy], radius, currentAngle * Math.PI / 180, endAngle * Math.PI / 180)
94
+ path.closePath()
95
+ path.fillColor = new paper.Color(item.color || colors[index % colors.length])
96
+ if (project && project.activeLayer) {
97
+ project.activeLayer.addChild(path)
98
+ }
99
+ elements.push({ type: 'path', id: path.id })
100
+
101
+ if (showLabels && percentage > 0.05) {
102
+ const midAngle = (currentAngle + endAngle) / 2
103
+ const midRad = midAngle * Math.PI / 180
104
+ const labelX = cx + radius * 0.7 * Math.cos(midRad)
105
+ const labelY = cy + radius * 0.7 * Math.sin(midRad)
106
+ const labelText = new paper.PointText({
107
+ point: [labelX, labelY + 4],
108
+ content: `${Math.round(percentage * 100)}%`,
109
+ fontSize: 11,
110
+ fillColor: new paper.Color('#ffffff'),
111
+ justification: 'center',
112
+ fontWeight: 'bold'
113
+ })
114
+ if (project && project.activeLayer) {
115
+ project.activeLayer.addChild(labelText)
116
+ }
117
+ elements.push({ type: 'text', id: labelText.id })
118
+ }
119
+
120
+ currentAngle = endAngle
121
+ })
122
+ }
123
+
124
+ return { success: true, elements, type: 'chart' }
125
+ }
126
+
127
+ module.exports = createChart
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Chip 标签组件
3
+ */
4
+
5
+ const paper = require('paper')
6
+
7
+ /**
8
+ * 创建 Chip 标签组件
9
+ */
10
+ function createChip(project, canvas, params) {
11
+ const {
12
+ x,
13
+ y,
14
+ text,
15
+ background = '#e0e0e0',
16
+ color = '#333333',
17
+ borderColor,
18
+ fontSize = 12,
19
+ padding = 12,
20
+ radius = 16,
21
+ icon
22
+ } = params
23
+
24
+ const elements = []
25
+
26
+ // 计算尺寸
27
+ const textWidth = text.length * fontSize * 0.6
28
+ const iconWidth = icon ? fontSize : 0
29
+ const totalWidth = padding * 2 + textWidth + iconWidth + 4
30
+ const height = fontSize + padding * 2
31
+ const rectX = x - totalWidth / 2
32
+ const rectY = y - height / 2
33
+
34
+ // 绘制背景
35
+ const bg = new paper.Path.Rectangle({
36
+ point: [rectX, rectY],
37
+ size: [totalWidth, height],
38
+ radius: radius
39
+ })
40
+ bg.fillColor = new paper.Color(background)
41
+ if (borderColor) {
42
+ bg.strokeColor = new paper.Color(borderColor)
43
+ bg.strokeWidth = 1
44
+ }
45
+ if (project && project.activeLayer) {
46
+ project.activeLayer.addChild(bg)
47
+ }
48
+ elements.push({ type: 'path', id: bg.id })
49
+
50
+ // 绘制图标
51
+ if (icon) {
52
+ const iconText = new paper.PointText({
53
+ point: [rectX + padding + iconWidth / 2, y + fontSize / 3],
54
+ content: icon,
55
+ fontSize: fontSize + 2,
56
+ fillColor: new paper.Color(color),
57
+ justification: 'center'
58
+ })
59
+ if (project && project.activeLayer) {
60
+ project.activeLayer.addChild(iconText)
61
+ }
62
+ elements.push({ type: 'text', id: iconText.id })
63
+ }
64
+
65
+ // 绘制文字
66
+ const textX = icon ? rectX + padding + iconWidth + 4 + textWidth / 2 : x
67
+ const label = new paper.PointText({
68
+ point: [textX, y + fontSize / 3],
69
+ content: text,
70
+ fontSize: fontSize,
71
+ fillColor: new paper.Color(color),
72
+ justification: 'center'
73
+ })
74
+ if (project && project.activeLayer) {
75
+ project.activeLayer.addChild(label)
76
+ }
77
+ elements.push({ type: 'text', id: label.id })
78
+
79
+ return {
80
+ success: true,
81
+ elements,
82
+ width: totalWidth,
83
+ height,
84
+ type: 'chip'
85
+ }
86
+ }
87
+
88
+ module.exports = createChip
@@ -0,0 +1,107 @@
1
+ /**
2
+ * 分栏布局组件
3
+ * 支持左右分栏、三栏、四栏等多种布局
4
+ */
5
+
6
+ const createColumns = (ctx) => ({
7
+ /**
8
+ * @param {Object} params
9
+ * @param {number} params.x - 起始X坐标
10
+ * @param {number} params.y - 起始Y坐标
11
+ * @param {number} params.width - 总宽度
12
+ * @param {number} params.height - 总高度
13
+ * @param {number} [params.columns=2] - 列数
14
+ * @param {number} [params.gap=20] - 列间距
15
+ * @param {string} [params.background] - 背景色
16
+ * @param {string} [params.borderColor] - 边框颜色
17
+ * @param {number} [params.borderWidth] - 边框宽度
18
+ * @param {number} [params.radius=0] - 圆角
19
+ * @param {Array} [params.items] - 列内容配置 [{widthRatio, content}]
20
+ * @param {string} [params.direction='horizontal'] - 排列方向: horizontal, vertical
21
+ * @param {string} [params.align='top'] - 垂直对齐: top, center, bottom
22
+ */
23
+ draw({
24
+ x,
25
+ y,
26
+ width,
27
+ height,
28
+ columns = 2,
29
+ gap = 20,
30
+ background,
31
+ borderColor,
32
+ borderWidth = 1,
33
+ radius = 0,
34
+ items = [],
35
+ direction = 'horizontal',
36
+ align = 'top'
37
+ }) {
38
+ const elements = []
39
+
40
+ // 计算每列宽度
41
+ const totalGap = gap * (columns - 1)
42
+ const columnWidth = (width - totalGap) / columns
43
+
44
+ // 绘制背景
45
+ if (background) {
46
+ const bg = new ctx.Path.Rectangle({
47
+ point: [x, y],
48
+ size: [width, height],
49
+ radius: radius
50
+ })
51
+ bg.fillColor = new ctx.Color(background)
52
+ elements.push({ type: 'rectangle', id: bg.id })
53
+ }
54
+
55
+ // 绘制边框
56
+ if (borderColor && borderWidth > 0) {
57
+ const border = new ctx.Path.Rectangle({
58
+ point: [x, y],
59
+ size: [width, height],
60
+ radius: radius
61
+ })
62
+ border.fillColor = new ctx.Color('transparent')
63
+ border.strokeColor = new ctx.Color(borderColor)
64
+ border.strokeWidth = borderWidth
65
+ elements.push({ type: 'rectangle', id: border.id })
66
+ }
67
+
68
+ // 生成分割线
69
+ for (let i = 1; i < columns; i++) {
70
+ const lineX = x + columnWidth * i + gap * (i - 1) + gap / 2
71
+ const line = new ctx.Path.Line({
72
+ from: [lineX, y + 20],
73
+ to: [lineX, y + height - 20]
74
+ })
75
+ line.strokeColor = new ctx.Color('#e0e0e0')
76
+ line.strokeWidth = 1
77
+ elements.push({ type: 'line', id: line.id })
78
+ }
79
+
80
+ // 返回列位置信息
81
+ const columnPositions = []
82
+ for (let i = 0; i < columns; i++) {
83
+ const colX = x + (columnWidth + gap) * i
84
+ const colY = align === 'center' ? y + (height - height) / 2 : align === 'bottom' ? y + height - height : y
85
+
86
+ columnPositions.push({
87
+ index: i,
88
+ x: colX,
89
+ y: colY,
90
+ width: columnWidth,
91
+ height: height
92
+ })
93
+ }
94
+
95
+ return {
96
+ success: true,
97
+ elements,
98
+ columnPositions,
99
+ columnWidth,
100
+ totalWidth: width,
101
+ totalHeight: height,
102
+ type: 'columns'
103
+ }
104
+ }
105
+ })
106
+
107
+ module.exports = createColumns
@@ -0,0 +1,85 @@
1
+ /**
2
+ * CTA(行动号召)按钮组件
3
+ */
4
+
5
+ const paper = require('paper')
6
+
7
+ /**
8
+ * 创建 CTA 按钮
9
+ *
10
+ * @param {Object} project - Paper.js 项目
11
+ * @param {Object} canvas - 画布对象
12
+ * @param {Object} args - 组件参数
13
+ * @param {number} args.x - X坐标(居中)
14
+ * @param {number} args.y - Y坐标
15
+ * @param {string} args.text - 按钮文字
16
+ * @param {string} args.background - 背景色
17
+ * @param {string} args.color - 文字颜色
18
+ * @param {string} args.border - 边框颜色
19
+ * @param {number} args.fontSize - 字体大小
20
+ * @param {number} args.padding - 内边距
21
+ * @param {number} args.radius - 圆角半径
22
+ * @param {Object} args.shadow - 阴影设置
23
+ */
24
+ function createCTA(project, canvas, args) {
25
+ const {
26
+ x, y,
27
+ text,
28
+ background = '#007bff',
29
+ color = '#ffffff',
30
+ border,
31
+ fontSize = 20,
32
+ padding = 25,
33
+ radius = 8,
34
+ shadow,
35
+ } = args
36
+
37
+ const elements = []
38
+
39
+ // 计算按钮尺寸
40
+ const textWidth = text.length * fontSize * 0.7
41
+ const btnWidth = textWidth + padding * 2
42
+ const btnHeight = fontSize + padding * 2
43
+
44
+ const btnX = x - btnWidth / 2
45
+
46
+ // 绘制按钮背景
47
+ const button = new paper.Path.Rectangle({
48
+ point: [btnX, y],
49
+ size: [btnWidth, btnHeight],
50
+ radius: radius,
51
+ })
52
+ button.fillColor = new paper.Color(background)
53
+
54
+ if (border) {
55
+ button.strokeColor = new paper.Color(border)
56
+ button.strokeWidth = 1
57
+ }
58
+
59
+ if (shadow) {
60
+ button.shadowColor = new paper.Color(shadow.color || 'rgba(0,0,0,0.3)')
61
+ button.shadowBlur = shadow.blur || 10
62
+ button.shadowOffset = new paper.Point(shadow.offsetX || 0, shadow.offsetY || 4)
63
+ }
64
+
65
+ elements.push({ type: 'rectangle', id: button.id })
66
+
67
+ // 绘制文字
68
+ const buttonText = new paper.PointText({
69
+ point: [x, y + btnHeight / 2 + fontSize / 3],
70
+ content: text,
71
+ fontSize: fontSize,
72
+ fillColor: new paper.Color(color),
73
+ justification: 'center',
74
+ })
75
+ elements.push({ type: 'text', id: buttonText.id })
76
+
77
+ return {
78
+ success: true,
79
+ elements,
80
+ width: btnWidth,
81
+ height: btnHeight,
82
+ }
83
+ }
84
+
85
+ module.exports = createCTA
@@ -0,0 +1,55 @@
1
+ /**
2
+ * 分隔线组件
3
+ */
4
+
5
+ const paper = require('paper')
6
+
7
+ /**
8
+ * 创建分隔线
9
+ *
10
+ * @param {Object} project - Paper.js 项目
11
+ * @param {Object} canvas - 画布对象
12
+ * @param {Object} args - 组件参数
13
+ * @param {number} args.x - X坐标
14
+ * @param {number} args.y - Y坐标
15
+ * @param {number} args.width - 宽度
16
+ * @param {string} args.color - 颜色
17
+ * @param {number} args.thickness - 厚度
18
+ * @param {string} args.style - 样式: solid, dashed
19
+ * @param {string} args.align - 对齐: left, center, right
20
+ */
21
+ function createDivider(project, canvas, args) {
22
+ const {
23
+ x, y, width,
24
+ color = '#00d9ff',
25
+ thickness = 1,
26
+ style = 'solid',
27
+ align = 'center',
28
+ } = args
29
+
30
+ let startX = x
31
+ let endX = x + width
32
+
33
+ if (align === 'center') {
34
+ startX = x - width / 2
35
+ endX = x + width / 2
36
+ } else if (align === 'right') {
37
+ startX = x - width
38
+ endX = x
39
+ }
40
+
41
+ const line = new paper.Path.Line({
42
+ from: [startX, y],
43
+ to: [endX, y],
44
+ strokeColor: new paper.Color(color),
45
+ strokeWidth: thickness,
46
+ })
47
+
48
+ if (style === 'dashed') {
49
+ line.dashArray = [10, 5]
50
+ }
51
+
52
+ return { success: true, id: line.id, type: 'line' }
53
+ }
54
+
55
+ module.exports = createDivider