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 {number} args.width - 总宽度
16
+ * @param {string} args.icon - 图标(emoji)
17
+ * @param {string} args.title - 标题
18
+ * @param {string} args.description - 描述
19
+ * @param {string} args.iconColor - 图标颜色
20
+ * @param {string} args.titleColor - 标题颜色
21
+ * @param {string} args.descColor - 描述颜色
22
+ * @param {number} args.iconSize - 图标大小
23
+ * @param {number} args.titleSize - 标题大小
24
+ * @param {number} args.descSize - 描述大小
25
+ */
26
+ function createFeature(project, canvas, args) {
27
+ const {
28
+ x, y, width,
29
+ icon,
30
+ title,
31
+ description,
32
+ iconColor = '#007bff',
33
+ titleColor = '#ffffff',
34
+ descColor = '#aaaaaa',
35
+ iconSize = 32,
36
+ titleSize = 20,
37
+ descSize = 14,
38
+ } = args
39
+
40
+ const elements = []
41
+ const padding = 15
42
+ let currentY = y
43
+
44
+ // 绘制图标
45
+ if (icon) {
46
+ const iconText = new paper.PointText({
47
+ point: [x + padding, currentY + iconSize],
48
+ content: icon,
49
+ fontSize: iconSize,
50
+ fillColor: new paper.Color(iconColor),
51
+ justification: 'left',
52
+ })
53
+ elements.push({ type: 'text', id: iconText.id })
54
+ }
55
+
56
+ // 绘制标题
57
+ if (title) {
58
+ currentY += icon ? iconSize + 5 : 0
59
+ const titleText = new paper.PointText({
60
+ point: [x + padding, currentY + titleSize],
61
+ content: title,
62
+ fontSize: titleSize,
63
+ fillColor: new paper.Color(titleColor),
64
+ justification: 'left',
65
+ })
66
+ elements.push({ type: 'text', id: titleText.id })
67
+ }
68
+
69
+ // 绘制描述
70
+ if (description) {
71
+ currentY += title ? titleSize + 5 : 0
72
+ const descText = new paper.PointText({
73
+ point: [x + padding, currentY + descSize],
74
+ content: description,
75
+ fontSize: descSize,
76
+ fillColor: new paper.Color(descColor),
77
+ justification: 'left',
78
+ })
79
+ elements.push({ type: 'text', id: descText.id })
80
+ }
81
+
82
+ return { success: true, elements }
83
+ }
84
+
85
+ module.exports = createFeature
@@ -0,0 +1,112 @@
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.columns - 列数
16
+ * @param {number} args.itemWidth - 每个特性宽度
17
+ * @param {number} args.itemHeight - 每个特性高度
18
+ * @param {number} args.gap - 间距
19
+ * @param {Array} args.items - 特性数组 [{icon, title, description}]
20
+ * @param {string} args.background - 背景色
21
+ * @param {string} args.borderColor - 边框颜色
22
+ * @param {number} args.radius - 圆角半径
23
+ */
24
+ function createFeatureGrid(project, canvas, args) {
25
+ const {
26
+ x, y,
27
+ columns = 3,
28
+ itemWidth = 200,
29
+ itemHeight = 120,
30
+ gap = 20,
31
+ items = [],
32
+ background = '#1a1a2e',
33
+ borderColor = '#00d9ff',
34
+ radius = 8,
35
+ } = args
36
+
37
+ const elements = []
38
+ const rows = Math.ceil(items.length / columns)
39
+
40
+ for (let i = 0; i < items.length; i++) {
41
+ const item = items[i]
42
+ const col = i % columns
43
+ const row = Math.floor(i / columns)
44
+
45
+ const itemX = x + col * (itemWidth + gap)
46
+ const itemY = y + row * (itemHeight + gap)
47
+
48
+ // 绘制每个特性的背景
49
+ const bg = new paper.Path.Rectangle({
50
+ point: [itemX, itemY],
51
+ size: [itemWidth, itemHeight],
52
+ radius: radius,
53
+ })
54
+ bg.fillColor = new paper.Color(background)
55
+ bg.strokeColor = new paper.Color(borderColor)
56
+ bg.strokeWidth = 0.5
57
+ bg.opacity = 0.8
58
+ elements.push({ type: 'rectangle', id: bg.id })
59
+
60
+ const padding = 15
61
+ let itemYOffset = itemY + padding
62
+
63
+ // 绘制图标
64
+ if (item.icon) {
65
+ const iconText = new paper.PointText({
66
+ point: [itemX + padding, itemYOffset + 24],
67
+ content: item.icon,
68
+ fontSize: 28,
69
+ fillColor: new paper.Color(item.iconColor || '#00ff88'),
70
+ justification: 'left',
71
+ })
72
+ elements.push({ type: 'text', id: iconText.id })
73
+ itemYOffset += 35
74
+ }
75
+
76
+ // 绘制标题
77
+ if (item.title) {
78
+ const titleText = new paper.PointText({
79
+ point: [itemX + padding, itemYOffset + 18],
80
+ content: item.title,
81
+ fontSize: 16,
82
+ fillColor: new paper.Color(item.titleColor || '#ffffff'),
83
+ justification: 'left',
84
+ })
85
+ elements.push({ type: 'text', id: titleText.id })
86
+ itemYOffset += 22
87
+ }
88
+
89
+ // 绘制描述
90
+ if (item.description) {
91
+ const descText = new paper.PointText({
92
+ point: [itemX + padding, itemYOffset + 14],
93
+ content: item.description,
94
+ fontSize: 12,
95
+ fillColor: new paper.Color(item.descColor || '#888888'),
96
+ justification: 'left',
97
+ })
98
+ elements.push({ type: 'text', id: descText.id })
99
+ }
100
+ }
101
+
102
+ return {
103
+ success: true,
104
+ elements,
105
+ width: columns * itemWidth + (columns - 1) * gap,
106
+ height: rows * itemHeight + (rows - 1) * gap,
107
+ rows,
108
+ cols: columns,
109
+ }
110
+ }
111
+
112
+ module.exports = createFeatureGrid
@@ -0,0 +1,118 @@
1
+ /**
2
+ * 网格布局组件
3
+ * 支持任意行列的网格布局
4
+ */
5
+
6
+ const createGrid = (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=3] - 列数
14
+ * @param {number} [params.rows=2] - 行数
15
+ * @param {number} [params.gapX=20] - 水平间距
16
+ * @param {number} [params.gapY=20] - 垂直间距
17
+ * @param {string} [params.background] - 背景色
18
+ * @param {string} [params.borderColor] - 边框颜色
19
+ * @param {number} [params.borderWidth] - 边框宽度
20
+ * @param {number} [params.radius=0] - 圆角
21
+ * @param {string} [params.direction='row'] - 排列方向: row(行优先), column(列优先)
22
+ */
23
+ draw({
24
+ x,
25
+ y,
26
+ width,
27
+ height,
28
+ columns = 3,
29
+ rows = 2,
30
+ gapX = 20,
31
+ gapY = 20,
32
+ background,
33
+ borderColor,
34
+ borderWidth = 1,
35
+ radius = 0,
36
+ direction = 'row'
37
+ }) {
38
+ const elements = []
39
+
40
+ // 计算单元格尺寸
41
+ const totalGapX = gapX * (columns - 1)
42
+ const totalGapY = gapY * (rows - 1)
43
+ const cellWidth = (width - totalGapX) / columns
44
+ const cellHeight = (height - totalGapY) / rows
45
+
46
+ // 绘制背景
47
+ if (background) {
48
+ const bg = new ctx.Path.Rectangle({
49
+ point: [x, y],
50
+ size: [width, height],
51
+ radius: radius
52
+ })
53
+ bg.fillColor = new ctx.Color(background)
54
+ elements.push({ type: 'rectangle', id: bg.id })
55
+ }
56
+
57
+ // 绘制边框
58
+ if (borderColor && borderWidth > 0) {
59
+ const border = new ctx.Path.Rectangle({
60
+ point: [x, y],
61
+ size: [width, height],
62
+ radius: radius
63
+ })
64
+ border.fillColor = new ctx.Color('transparent')
65
+ border.strokeColor = new ctx.Color(borderColor)
66
+ border.strokeWidth = borderWidth
67
+ elements.push({ type: 'rectangle', id: border.id })
68
+ }
69
+
70
+ // 生成网格位置信息
71
+ const cellPositions = []
72
+ const totalCells = columns * rows
73
+
74
+ for (let i = 0; i < totalCells; i++) {
75
+ let col, row
76
+
77
+ if (direction === 'row') {
78
+ col = i % columns
79
+ row = Math.floor(i / columns)
80
+ } else {
81
+ row = i % rows
82
+ col = Math.floor(i / rows)
83
+ }
84
+
85
+ const cellX = x + col * (cellWidth + gapX)
86
+ const cellY = y + row * (cellHeight + gapY)
87
+
88
+ cellPositions.push({
89
+ index: i,
90
+ column: col,
91
+ row: row,
92
+ x: cellX,
93
+ y: cellY,
94
+ width: cellWidth,
95
+ height: cellHeight,
96
+ centerX: cellX + cellWidth / 2,
97
+ centerY: cellY + cellHeight / 2
98
+ })
99
+ }
100
+
101
+ // 返回网格布局信息
102
+ return {
103
+ success: true,
104
+ elements,
105
+ cellPositions,
106
+ cellWidth,
107
+ cellHeight,
108
+ columns,
109
+ rows,
110
+ totalCells,
111
+ totalWidth: width,
112
+ totalHeight: height,
113
+ type: 'grid'
114
+ }
115
+ }
116
+ })
117
+
118
+ module.exports = createGrid
@@ -0,0 +1,155 @@
1
+ /**
2
+ * 图片框组件 - 带装饰边框的图片
3
+ */
4
+ const createImageFrame = (ctx) => ({
5
+ /**
6
+ * @param {Object} params
7
+ * @param {string} params.src - 图片路径或URL
8
+ * @param {number} params.x - X坐标
9
+ * @param {number} params.y - Y坐标
10
+ * @param {number} params.width - 图片宽度
11
+ * @param {number} params.height - 图片高度
12
+ * @param {string} [params.borderColor='#ffffff'] - 边框颜色
13
+ * @param {number} [params.borderWidth=3] - 边框宽度
14
+ * @param {string} [params.outerColor='#1a1a2e'] - 外边框颜色
15
+ * @param {number} [params.outerWidth=6] - 外边框宽度
16
+ * @param {number} [params.shadowBlur=0] - 阴影模糊
17
+ * @param {number} [params.shadowOffsetX=0] - 阴影X偏移
18
+ * @param {number} [params.shadowOffsetY=0] - 阴影Y偏移
19
+ * @param {string} [params.shadowColor='rgba(0,0,0,0.3)'] - 阴影颜色
20
+ * @param {number} [params.radius=0] - 圆角半径
21
+ * @param {string} [params.overlayColor] - 叠加颜色
22
+ * @param {number} [params.overlayOpacity=0] - 叠加透明度
23
+ * @param {string} [params.fit='cover'] - 图片填充方式: cover, contain, fill
24
+ */
25
+ async draw({
26
+ src,
27
+ x,
28
+ y,
29
+ width,
30
+ height,
31
+ borderColor = '#ffffff',
32
+ borderWidth = 3,
33
+ outerColor = '#1a1a2e',
34
+ outerWidth = 6,
35
+ shadowBlur = 0,
36
+ shadowOffsetX = 0,
37
+ shadowOffsetY = 0,
38
+ shadowColor = 'rgba(0,0,0,0.3)',
39
+ radius = 0,
40
+ overlayColor,
41
+ overlayOpacity = 0,
42
+ fit = 'cover'
43
+ }) {
44
+ // 绘制外边框(装饰层)
45
+ if (outerWidth > 0) {
46
+ ctx.fillStyle = outerColor
47
+ await _roundRect(ctx, x - outerWidth, y - outerWidth, width + outerWidth * 2, height + outerWidth * 2, radius + outerWidth)
48
+ ctx.fill()
49
+ }
50
+
51
+ // 绘制内边框
52
+ if (borderWidth > 0) {
53
+ ctx.fillStyle = borderColor
54
+ await _roundRect(ctx, x - borderWidth, y - borderWidth, width + borderWidth * 2, height + borderWidth * 2, radius + borderWidth)
55
+ ctx.fill()
56
+ }
57
+
58
+ // 绘制阴影
59
+ if (shadowBlur > 0) {
60
+ ctx.shadowColor = shadowColor
61
+ ctx.shadowBlur = shadowBlur
62
+ ctx.shadowOffsetX = shadowOffsetX
63
+ ctx.shadowOffsetY = shadowOffsetY
64
+ }
65
+
66
+ // 加载并绘制图片
67
+ const image = await _loadImage(src)
68
+ const imgWidth = image.width
69
+ const imgHeight = image.height
70
+ const imgRatio = imgWidth / imgHeight
71
+ const boxRatio = width / height
72
+
73
+ let drawX = x, drawY = y, drawW = width, drawH = height
74
+
75
+ if (fit === 'cover') {
76
+ if (imgRatio > boxRatio) {
77
+ drawH = height
78
+ drawW = height * imgRatio
79
+ drawX = x - (drawW - width) / 2
80
+ } else {
81
+ drawW = width
82
+ drawH = width / imgRatio
83
+ drawY = y - (drawH - height) / 2
84
+ }
85
+ } else if (fit === 'contain') {
86
+ if (imgRatio > boxRatio) {
87
+ drawW = width
88
+ drawH = width / imgRatio
89
+ drawY = y + (height - drawH) / 2
90
+ } else {
91
+ drawH = height
92
+ drawW = height * imgRatio
93
+ drawX = x + (width - drawW) / 2
94
+ }
95
+ }
96
+
97
+ // 裁剪并绘制图片
98
+ ctx.save()
99
+ await _roundRect(ctx, x, y, width, height, radius)
100
+ ctx.clip()
101
+ ctx.drawImage(image, drawX, drawY, drawW, drawH)
102
+ ctx.restore()
103
+
104
+ // 重置阴影
105
+ ctx.shadowColor = 'transparent'
106
+ ctx.shadowBlur = 0
107
+ ctx.shadowOffsetX = 0
108
+ ctx.shadowOffsetY = 0
109
+
110
+ // 叠加颜色
111
+ if (overlayColor && overlayOpacity > 0) {
112
+ ctx.fillStyle = overlayColor
113
+ ctx.globalAlpha = overlayOpacity
114
+ await _roundRect(ctx, x, y, width, height, radius)
115
+ ctx.fill()
116
+ ctx.globalAlpha = 1
117
+ }
118
+ }
119
+ })
120
+
121
+ // 辅助函数:圆角矩形
122
+ async function _roundRect(ctx, x, y, width, height, radius) {
123
+ const r = Math.min(radius, width / 2, height / 2)
124
+ ctx.beginPath()
125
+ ctx.moveTo(x + r, y)
126
+ ctx.lineTo(x + width - r, y)
127
+ ctx.quadraticCurveTo(x + width, y, x + width, y + r)
128
+ ctx.lineTo(x + width, y + height - r)
129
+ ctx.quadraticCurveTo(x + width, y + height, x + width - r, y + height)
130
+ ctx.lineTo(x + r, y + height)
131
+ ctx.quadraticCurveTo(x, y + height, x, y + height - r)
132
+ ctx.lineTo(x, y + r)
133
+ ctx.quadraticCurveTo(x, y, x + r, y)
134
+ ctx.closePath()
135
+ }
136
+
137
+ // 辅助函数:加载图片
138
+ async function _loadImage(src) {
139
+ return new Promise((resolve, reject) => {
140
+ const img = new Image()
141
+ img.crossOrigin = 'anonymous'
142
+ img.onload = () => resolve(img)
143
+ img.onerror = (e) => {
144
+ // 尝试 data URL 格式
145
+ if (src.startsWith('data:')) {
146
+ img.src = src
147
+ } else {
148
+ reject(new Error(`Failed to load image: ${src}`))
149
+ }
150
+ }
151
+ img.src = src
152
+ })
153
+ }
154
+
155
+ module.exports = createImageFrame
@@ -0,0 +1,62 @@
1
+ /**
2
+ * 高级组件模块导出
3
+ */
4
+
5
+ const createCard = require('./card')
6
+ const createBadge = require('./badge')
7
+ const createCTA = require('./cta')
8
+ const createFeature = require('./feature')
9
+ const createFeatureGrid = require('./featureGrid')
10
+ const createDivider = require('./divider')
11
+ const createAvatar = require('./avatar')
12
+ const createProgress = require('./progress')
13
+ const createRating = require('./rating')
14
+ const createQuote = require('./quote')
15
+ const createStatCard = require('./statCard')
16
+ const createTagCloud = require('./tagCloud')
17
+ const createStepper = require('./stepper')
18
+ const createTimeline = require('./timeline')
19
+ const { createListItem, createList } = require('./listItem')
20
+ const createNotification = require('./notification')
21
+ const createImageFrame = require('./imageFrame')
22
+ const createColumns = require('./columns')
23
+ const createGrid = require('./grid')
24
+ const createStar = require('./star')
25
+ const createArrow = require('./arrow')
26
+ const createProgressCircle = require('./progressCircle')
27
+ const createChip = require('./chip')
28
+ const createChart = require('./chart')
29
+ const createWatermark = require('./watermark')
30
+ const createTable = require('./table')
31
+
32
+ module.exports = {
33
+ // 原有组件
34
+ createCard,
35
+ createBadge,
36
+ createCTA,
37
+ createFeature,
38
+ createFeatureGrid,
39
+ createDivider,
40
+ createAvatar,
41
+ createProgress,
42
+ createRating,
43
+ createQuote,
44
+ createStatCard,
45
+ createTagCloud,
46
+ createStepper,
47
+ createTimeline,
48
+ createListItem,
49
+ createList,
50
+ createNotification,
51
+ createImageFrame,
52
+ createColumns,
53
+ createGrid,
54
+ // 新增组件
55
+ createStar,
56
+ createArrow,
57
+ createProgressCircle,
58
+ createChip,
59
+ createChart,
60
+ createWatermark,
61
+ createTable,
62
+ }
@@ -0,0 +1,146 @@
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.icon - 图标
17
+ * @param {string} args.title - 标题
18
+ * @param {string} args.description - 描述
19
+ * @param {string} args.badge - 徽章文字
20
+ * @param {string} args.badgeColor - 徽章颜色
21
+ * @param {string} args.iconColor - 图标颜色
22
+ * @param {string} args.background - 背景色
23
+ * @param {string} args.borderColor - 边框颜色
24
+ * @param {number} args.height - 高度
25
+ * @param {number} args.radius - 圆角半径
26
+ */
27
+ function createListItem(project, canvas, args) {
28
+ const {
29
+ x, y,
30
+ width = 400,
31
+ icon = '→',
32
+ title,
33
+ description,
34
+ badge,
35
+ badgeColor = '#6366f1',
36
+ iconColor = '#6366f1',
37
+ background = '#ffffff',
38
+ borderColor = '#e5e7eb',
39
+ height = 60,
40
+ radius = 8,
41
+ } = args
42
+
43
+ const elements = []
44
+
45
+ // 绘制背景
46
+ const bg = new paper.Path.Rectangle({
47
+ point: [x, y],
48
+ size: [width, height],
49
+ radius: radius,
50
+ })
51
+ bg.fillColor = new paper.Color(background)
52
+ bg.strokeColor = new paper.Color(borderColor)
53
+ bg.strokeWidth = 1
54
+ elements.push({ type: 'rectangle', id: bg.id })
55
+
56
+ // 绘制图标
57
+ const iconText = new paper.PointText({
58
+ point: [x + 15, y + height / 2 + 6],
59
+ content: icon,
60
+ fontSize: 20,
61
+ fillColor: new paper.Color(iconColor),
62
+ justification: 'center',
63
+ })
64
+ elements.push({ type: 'text', id: iconText.id })
65
+
66
+ // 绘制标题
67
+ const titleText = new paper.PointText({
68
+ point: [x + 50, y + height / 2 - 5],
69
+ content: title || 'List Item',
70
+ fontSize: 16,
71
+ fillColor: new paper.Color('#1e293b'),
72
+ justification: 'left',
73
+ })
74
+ elements.push({ type: 'text', id: titleText.id })
75
+
76
+ // 绘制描述
77
+ if (description) {
78
+ const descText = new paper.PointText({
79
+ point: [x + 50, y + height / 2 + 15],
80
+ content: description,
81
+ fontSize: 12,
82
+ fillColor: new paper.Color('#64748b'),
83
+ justification: 'left',
84
+ })
85
+ elements.push({ type: 'text', id: descText.id })
86
+ }
87
+
88
+ // 绘制徽章
89
+ if (badge) {
90
+ const badgeWidth = badge.length * 10 + 20
91
+ const badgeX = x + width - badgeWidth - 15
92
+ const badgeY = y + (height - 24) / 2
93
+
94
+ const badgeBg = new paper.Path.Rectangle({
95
+ point: [badgeX, badgeY],
96
+ size: [badgeWidth, 24],
97
+ radius: 12,
98
+ })
99
+ badgeBg.fillColor = new paper.Color(badgeColor)
100
+ elements.push({ type: 'rectangle', id: badgeBg.id })
101
+
102
+ const badgeText = new paper.PointText({
103
+ point: [badgeX + badgeWidth / 2, badgeY + 16],
104
+ content: badge,
105
+ fontSize: 12,
106
+ fillColor: new paper.Color('#ffffff'),
107
+ justification: 'center',
108
+ })
109
+ elements.push({ type: 'text', id: badgeText.id })
110
+ }
111
+
112
+ return { success: true, elements }
113
+ }
114
+
115
+ /**
116
+ * 创建列表(多个列表项)
117
+ */
118
+ function createList(project, canvas, args) {
119
+ const {
120
+ x, y,
121
+ items = [],
122
+ gap = 10,
123
+ width = 400,
124
+ ...rest
125
+ } = args
126
+
127
+ const elements = []
128
+ let currentY = y
129
+
130
+ for (const item of items) {
131
+ const result = createListItem(project, canvas, {
132
+ x, y: currentY, width, ...item, ...rest,
133
+ })
134
+ elements.push(...result.elements)
135
+ currentY += 60 + gap
136
+ }
137
+
138
+ return {
139
+ success: true,
140
+ elements,
141
+ height: currentY - y,
142
+ }
143
+ }
144
+
145
+ module.exports = createListItem
146
+ module.exports.createList = createList