myagent-ai 1.0.0

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 (486) hide show
  1. package/Dockerfile +30 -0
  2. package/README.md +333 -0
  3. package/agents/__init__.py +6 -0
  4. package/agents/__pycache__/main_agent.cpython-312.pyc +0 -0
  5. package/agents/base.py +115 -0
  6. package/agents/main_agent.py +695 -0
  7. package/agents/memory_agent.py +313 -0
  8. package/agents/tool_agent.py +248 -0
  9. package/chatbot/__init__.py +5 -0
  10. package/chatbot/base.py +124 -0
  11. package/chatbot/discord_bot.py +146 -0
  12. package/chatbot/feishu_bot.py +548 -0
  13. package/chatbot/manager.py +164 -0
  14. package/chatbot/qq_bot.py +189 -0
  15. package/chatbot/telegram_bot.py +167 -0
  16. package/chatbot/wechat_bot.py +558 -0
  17. package/communication/__init__.py +66 -0
  18. package/communication/channel.py +576 -0
  19. package/communication/crypto.py +347 -0
  20. package/communication/manager.py +397 -0
  21. package/communication/peer.py +156 -0
  22. package/config.py +464 -0
  23. package/core/__init__.py +10 -0
  24. package/core/config_broadcast.py +276 -0
  25. package/core/llm.py +878 -0
  26. package/core/logger.py +241 -0
  27. package/core/task_queue.py +362 -0
  28. package/core/utils.py +184 -0
  29. package/executor/__init__.py +4 -0
  30. package/executor/__pycache__/engine.cpython-312.pyc +0 -0
  31. package/executor/engine.py +1215 -0
  32. package/groups/__init__.py +15 -0
  33. package/groups/manager.py +724 -0
  34. package/knowledge/__init__.py +4 -0
  35. package/knowledge/rag.py +444 -0
  36. package/main.py +801 -0
  37. package/memory/__init__.py +4 -0
  38. package/memory/manager.py +840 -0
  39. package/organization/__init__.py +4 -0
  40. package/organization/manager.py +350 -0
  41. package/package.json +58 -0
  42. package/requirements.txt +59 -0
  43. package/setup.py +40 -0
  44. package/skills/ASR/LICENSE.txt +21 -0
  45. package/skills/ASR/SKILL.md +580 -0
  46. package/skills/ASR/scripts/asr.ts +27 -0
  47. package/skills/LLM/LICENSE.txt +21 -0
  48. package/skills/LLM/SKILL.md +856 -0
  49. package/skills/LLM/scripts/chat.ts +32 -0
  50. package/skills/TTS/LICENSE.txt +21 -0
  51. package/skills/TTS/SKILL.md +735 -0
  52. package/skills/TTS/tts.ts +25 -0
  53. package/skills/VLM/LICENSE.txt +21 -0
  54. package/skills/VLM/SKILL.md +588 -0
  55. package/skills/VLM/scripts/vlm.ts +57 -0
  56. package/skills/__init__.py +5 -0
  57. package/skills/agent-browser/SKILL.md +328 -0
  58. package/skills/ai-news-collectors/SKILL.md +157 -0
  59. package/skills/ai-news-collectors/_meta.json +6 -0
  60. package/skills/ai-news-collectors/references/sources.md +128 -0
  61. package/skills/aminer-open-academic/SKILL.md +312 -0
  62. package/skills/aminer-open-academic/_meta.json +6 -0
  63. package/skills/aminer-open-academic/evals/evals.json +46 -0
  64. package/skills/aminer-open-academic/references/api-catalog.md +1032 -0
  65. package/skills/aminer-open-academic/scripts/__pycache__/aminer_client.cpython-312.pyc +0 -0
  66. package/skills/aminer-open-academic/scripts/aminer_client.py +875 -0
  67. package/skills/auto-target-tracker/SKILL.md +317 -0
  68. package/skills/base.py +147 -0
  69. package/skills/blog-writer/2024-02-17-radical-transparency-sales.md +35 -0
  70. package/skills/blog-writer/2024-02-17-raycast-spotlight-superpowers.md +33 -0
  71. package/skills/blog-writer/2024-02-17-short-form-content-marketing.md +47 -0
  72. package/skills/blog-writer/2024-02-17-typing-speed-benefits.md +33 -0
  73. package/skills/blog-writer/2024-03-14-effective-ai-prompts.md +55 -0
  74. package/skills/blog-writer/2024-11-08-ai-revolutionizing-entry-level-sales.md +43 -0
  75. package/skills/blog-writer/2025-11-12-why-ai-art-is-useless.md +49 -0
  76. package/skills/blog-writer/README.md +2 -0
  77. package/skills/blog-writer/SKILL.md +158 -0
  78. package/skills/blog-writer/__pycache__/manage_examples.cpython-312.pyc +0 -0
  79. package/skills/blog-writer/_meta.json +6 -0
  80. package/skills/blog-writer/manage_examples.py +90 -0
  81. package/skills/blog-writer/style-guide.md +160 -0
  82. package/skills/browser_skill.py +146 -0
  83. package/skills/coding-agent/SKILL.md +120 -0
  84. package/skills/coding-agent/_meta.json +6 -0
  85. package/skills/coding-agent/criteria.md +48 -0
  86. package/skills/coding-agent/execution.md +42 -0
  87. package/skills/coding-agent/memory-template.md +38 -0
  88. package/skills/coding-agent/planning.md +31 -0
  89. package/skills/coding-agent/state.md +60 -0
  90. package/skills/coding-agent/verification.md +39 -0
  91. package/skills/content-strategy/SKILL.md +181 -0
  92. package/skills/content-strategy/_meta.json +6 -0
  93. package/skills/contentanalysis/ExtractWisdom/SKILL.md +229 -0
  94. package/skills/contentanalysis/ExtractWisdom/Workflows/Extract.md +60 -0
  95. package/skills/contentanalysis/SKILL.md +14 -0
  96. package/skills/docx/CHANGELOG.md +85 -0
  97. package/skills/docx/LICENSE.txt +30 -0
  98. package/skills/docx/SKILL.md +455 -0
  99. package/skills/docx/docx-js.md +681 -0
  100. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  101. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  102. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  103. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  104. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  105. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  106. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  107. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  108. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  109. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  110. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  111. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  112. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  113. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  114. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  115. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  116. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  117. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  118. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  119. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  120. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  121. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  122. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  123. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  124. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  125. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  126. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  127. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  128. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  129. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  130. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  131. package/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
  132. package/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  133. package/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  134. package/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  135. package/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  136. package/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  137. package/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  138. package/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  139. package/skills/docx/ooxml/scripts/__pycache__/pack.cpython-312.pyc +0 -0
  140. package/skills/docx/ooxml/scripts/__pycache__/unpack.cpython-312.pyc +0 -0
  141. package/skills/docx/ooxml/scripts/__pycache__/validate.cpython-312.pyc +0 -0
  142. package/skills/docx/ooxml/scripts/pack.py +159 -0
  143. package/skills/docx/ooxml/scripts/unpack.py +29 -0
  144. package/skills/docx/ooxml/scripts/validate.py +69 -0
  145. package/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
  146. package/skills/docx/ooxml/scripts/validation/__pycache__/__init__.cpython-312.pyc +0 -0
  147. package/skills/docx/ooxml/scripts/validation/__pycache__/base.cpython-312.pyc +0 -0
  148. package/skills/docx/ooxml/scripts/validation/__pycache__/docx.cpython-312.pyc +0 -0
  149. package/skills/docx/ooxml/scripts/validation/__pycache__/pptx.cpython-312.pyc +0 -0
  150. package/skills/docx/ooxml/scripts/validation/__pycache__/redlining.cpython-312.pyc +0 -0
  151. package/skills/docx/ooxml/scripts/validation/base.py +951 -0
  152. package/skills/docx/ooxml/scripts/validation/docx.py +274 -0
  153. package/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
  154. package/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
  155. package/skills/docx/ooxml.md +615 -0
  156. package/skills/docx/scripts/__init__.py +1 -0
  157. package/skills/docx/scripts/__pycache__/__init__.cpython-312.pyc +0 -0
  158. package/skills/docx/scripts/__pycache__/add_toc_placeholders.cpython-312.pyc +0 -0
  159. package/skills/docx/scripts/__pycache__/document.cpython-312.pyc +0 -0
  160. package/skills/docx/scripts/__pycache__/utilities.cpython-312.pyc +0 -0
  161. package/skills/docx/scripts/add_toc_placeholders.py +220 -0
  162. package/skills/docx/scripts/document.py +1302 -0
  163. package/skills/docx/scripts/templates/comments.xml +3 -0
  164. package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  165. package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  166. package/skills/docx/scripts/templates/commentsIds.xml +3 -0
  167. package/skills/docx/scripts/templates/people.xml +3 -0
  168. package/skills/docx/scripts/utilities.py +374 -0
  169. package/skills/dream-interpreter/SKILL.md +88 -0
  170. package/skills/dream-interpreter/assets/example_asset.txt +24 -0
  171. package/skills/dream-interpreter/references/api_reference.md +34 -0
  172. package/skills/dream-interpreter/references/interpretation-guide.md +83 -0
  173. package/skills/dream-interpreter/references/output-schema.md +65 -0
  174. package/skills/dream-interpreter/references/questioning-strategy.md +62 -0
  175. package/skills/dream-interpreter/references/visual-mapping.md +81 -0
  176. package/skills/dream-interpreter/scripts/__pycache__/example.cpython-312.pyc +0 -0
  177. package/skills/dream-interpreter/scripts/example.py +19 -0
  178. package/skills/dream-interpreter/skill.json +7 -0
  179. package/skills/file_skill.py +246 -0
  180. package/skills/finance/Finance_API_Doc.md +445 -0
  181. package/skills/finance/SKILL.md +53 -0
  182. package/skills/fullstack-dev/SKILL.md +205 -0
  183. package/skills/get-fortune-analysis/SKILL.md +370 -0
  184. package/skills/get-fortune-analysis/lunar_python.py +91 -0
  185. package/skills/gift-evaluator/SKILL.md +83 -0
  186. package/skills/gift-evaluator/__pycache__/html_tools.cpython-312.pyc +0 -0
  187. package/skills/gift-evaluator/html_tools.py +268 -0
  188. package/skills/image-edit/LICENSE.txt +21 -0
  189. package/skills/image-edit/SKILL.md +896 -0
  190. package/skills/image-edit/scripts/image-edit.ts +36 -0
  191. package/skills/image-generation/LICENSE.txt +21 -0
  192. package/skills/image-generation/SKILL.md +583 -0
  193. package/skills/image-generation/scripts/image-generation.ts +28 -0
  194. package/skills/image-understand/LICENSE.txt +21 -0
  195. package/skills/image-understand/SKILL.md +855 -0
  196. package/skills/image-understand/scripts/image-understand.ts +41 -0
  197. package/skills/interview-designer/README.md +70 -0
  198. package/skills/interview-designer/SKILL.md +53 -0
  199. package/skills/interview-designer/_meta.json +6 -0
  200. package/skills/interview-designer/references/design_rationale.md +43 -0
  201. package/skills/interview-designer/templates/interview_guide_template.md +62 -0
  202. package/skills/market-research-reports/SKILL.md +901 -0
  203. package/skills/market-research-reports/assets/FORMATTING_GUIDE.md +428 -0
  204. package/skills/market-research-reports/assets/market_report_template.tex +1380 -0
  205. package/skills/market-research-reports/assets/market_research.sty +564 -0
  206. package/skills/market-research-reports/references/data_analysis_patterns.md +548 -0
  207. package/skills/market-research-reports/references/report_structure_guide.md +999 -0
  208. package/skills/market-research-reports/references/visual_generation_guide.md +1077 -0
  209. package/skills/market-research-reports/scripts/__pycache__/generate_market_visuals.cpython-312.pyc +0 -0
  210. package/skills/market-research-reports/scripts/generate_market_visuals.py +529 -0
  211. package/skills/marketing-mode/README.md +49 -0
  212. package/skills/marketing-mode/SKILL.md +693 -0
  213. package/skills/marketing-mode/_meta.json +6 -0
  214. package/skills/marketing-mode/mode-prompt.md +39 -0
  215. package/skills/marketing-mode/skill.json +51 -0
  216. package/skills/mindfulness-meditation/SKILL.md +65 -0
  217. package/skills/mindfulness-meditation/_meta.json +6 -0
  218. package/skills/multi-search-engine/CHANGELOG.md +15 -0
  219. package/skills/multi-search-engine/CHANNELLOG.md +48 -0
  220. package/skills/multi-search-engine/SKILL.md +78 -0
  221. package/skills/multi-search-engine/_meta.json +6 -0
  222. package/skills/multi-search-engine/config.json +14 -0
  223. package/skills/multi-search-engine/metadata.json +7 -0
  224. package/skills/multi-search-engine/references/international-search.md +651 -0
  225. package/skills/pdf/LICENSE.txt +30 -0
  226. package/skills/pdf/SKILL.md +1534 -0
  227. package/skills/pdf/forms.md +205 -0
  228. package/skills/pdf/reference.md +765 -0
  229. package/skills/pdf/scripts/__pycache__/add_zai_metadata.cpython-312.pyc +0 -0
  230. package/skills/pdf/scripts/__pycache__/check_bounding_boxes.cpython-312.pyc +0 -0
  231. package/skills/pdf/scripts/__pycache__/check_bounding_boxes_test.cpython-312.pyc +0 -0
  232. package/skills/pdf/scripts/__pycache__/check_fillable_fields.cpython-312.pyc +0 -0
  233. package/skills/pdf/scripts/__pycache__/convert_pdf_to_images.cpython-312.pyc +0 -0
  234. package/skills/pdf/scripts/__pycache__/create_validation_image.cpython-312.pyc +0 -0
  235. package/skills/pdf/scripts/__pycache__/extract_form_field_info.cpython-312.pyc +0 -0
  236. package/skills/pdf/scripts/__pycache__/fill_fillable_fields.cpython-312.pyc +0 -0
  237. package/skills/pdf/scripts/__pycache__/fill_pdf_form_with_annotations.cpython-312.pyc +0 -0
  238. package/skills/pdf/scripts/__pycache__/sanitize_code.cpython-312.pyc +0 -0
  239. package/skills/pdf/scripts/add_zai_metadata.py +172 -0
  240. package/skills/pdf/scripts/check_bounding_boxes.py +70 -0
  241. package/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
  242. package/skills/pdf/scripts/check_fillable_fields.py +12 -0
  243. package/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
  244. package/skills/pdf/scripts/create_validation_image.py +41 -0
  245. package/skills/pdf/scripts/extract_form_field_info.py +152 -0
  246. package/skills/pdf/scripts/fill_fillable_fields.py +114 -0
  247. package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
  248. package/skills/pdf/scripts/sanitize_code.py +110 -0
  249. package/skills/podcast-generate/LICENSE.txt +21 -0
  250. package/skills/podcast-generate/SKILL.md +198 -0
  251. package/skills/podcast-generate/generate.ts +661 -0
  252. package/skills/podcast-generate/package.json +30 -0
  253. package/skills/podcast-generate/readme.md +177 -0
  254. package/skills/podcast-generate/test_data/segments.jsonl +3 -0
  255. package/skills/podcast-generate/tsconfig.json +26 -0
  256. package/skills/pptx/LICENSE.txt +30 -0
  257. package/skills/pptx/SKILL.md +507 -0
  258. package/skills/pptx/html2pptx.md +625 -0
  259. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  260. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  261. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  262. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  263. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  264. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  265. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  266. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  267. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  268. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  269. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  270. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  271. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  272. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  273. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  274. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  275. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  276. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  277. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  278. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  279. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  280. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  281. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  282. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  283. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  284. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  285. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  286. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  287. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  288. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  289. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  290. package/skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
  291. package/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  292. package/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  293. package/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  294. package/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  295. package/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  296. package/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  297. package/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  298. package/skills/pptx/ooxml/scripts/__pycache__/pack.cpython-312.pyc +0 -0
  299. package/skills/pptx/ooxml/scripts/__pycache__/unpack.cpython-312.pyc +0 -0
  300. package/skills/pptx/ooxml/scripts/__pycache__/validate.cpython-312.pyc +0 -0
  301. package/skills/pptx/ooxml/scripts/pack.py +159 -0
  302. package/skills/pptx/ooxml/scripts/unpack.py +29 -0
  303. package/skills/pptx/ooxml/scripts/validate.py +69 -0
  304. package/skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
  305. package/skills/pptx/ooxml/scripts/validation/__pycache__/__init__.cpython-312.pyc +0 -0
  306. package/skills/pptx/ooxml/scripts/validation/__pycache__/base.cpython-312.pyc +0 -0
  307. package/skills/pptx/ooxml/scripts/validation/__pycache__/docx.cpython-312.pyc +0 -0
  308. package/skills/pptx/ooxml/scripts/validation/__pycache__/pptx.cpython-312.pyc +0 -0
  309. package/skills/pptx/ooxml/scripts/validation/__pycache__/redlining.cpython-312.pyc +0 -0
  310. package/skills/pptx/ooxml/scripts/validation/base.py +951 -0
  311. package/skills/pptx/ooxml/scripts/validation/docx.py +274 -0
  312. package/skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
  313. package/skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
  314. package/skills/pptx/ooxml.md +427 -0
  315. package/skills/pptx/scripts/__pycache__/inventory.cpython-312.pyc +0 -0
  316. package/skills/pptx/scripts/__pycache__/inventory.cpython-313.pyc +0 -0
  317. package/skills/pptx/scripts/__pycache__/rearrange.cpython-312.pyc +0 -0
  318. package/skills/pptx/scripts/__pycache__/replace.cpython-312.pyc +0 -0
  319. package/skills/pptx/scripts/__pycache__/thumbnail.cpython-312.pyc +0 -0
  320. package/skills/pptx/scripts/html2pptx.js +1044 -0
  321. package/skills/pptx/scripts/inventory.py +1020 -0
  322. package/skills/pptx/scripts/rearrange.py +231 -0
  323. package/skills/pptx/scripts/replace.py +385 -0
  324. package/skills/pptx/scripts/thumbnail.py +450 -0
  325. package/skills/qingyan-research/SKILL.md +294 -0
  326. package/skills/qingyan-research/__pycache__/generate_html.cpython-312.pyc +0 -0
  327. package/skills/qingyan-research/generate_html.py +33 -0
  328. package/skills/registry.py +344 -0
  329. package/skills/search_skill.py +228 -0
  330. package/skills/seo-content-writer/SKILL.md +661 -0
  331. package/skills/seo-content-writer/_meta.json +6 -0
  332. package/skills/seo-content-writer/references/content-structure-templates.md +875 -0
  333. package/skills/seo-content-writer/references/title-formulas.md +339 -0
  334. package/skills/skill-creator/LICENSE.txt +202 -0
  335. package/skills/skill-creator/SKILL.md +485 -0
  336. package/skills/skill-creator/agents/analyzer.md +274 -0
  337. package/skills/skill-creator/agents/comparator.md +202 -0
  338. package/skills/skill-creator/agents/grader.md +223 -0
  339. package/skills/skill-creator/assets/eval_review.html +146 -0
  340. package/skills/skill-creator/eval-viewer/__pycache__/generate_review.cpython-312.pyc +0 -0
  341. package/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  342. package/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  343. package/skills/skill-creator/references/schemas.md +430 -0
  344. package/skills/skill-creator/scripts/__init__.py +0 -0
  345. package/skills/skill-creator/scripts/__pycache__/__init__.cpython-312.pyc +0 -0
  346. package/skills/skill-creator/scripts/__pycache__/aggregate_benchmark.cpython-312.pyc +0 -0
  347. package/skills/skill-creator/scripts/__pycache__/generate_report.cpython-312.pyc +0 -0
  348. package/skills/skill-creator/scripts/__pycache__/improve_description.cpython-312.pyc +0 -0
  349. package/skills/skill-creator/scripts/__pycache__/package_skill.cpython-312.pyc +0 -0
  350. package/skills/skill-creator/scripts/__pycache__/quick_validate.cpython-312.pyc +0 -0
  351. package/skills/skill-creator/scripts/__pycache__/run_eval.cpython-312.pyc +0 -0
  352. package/skills/skill-creator/scripts/__pycache__/run_loop.cpython-312.pyc +0 -0
  353. package/skills/skill-creator/scripts/__pycache__/utils.cpython-312.pyc +0 -0
  354. package/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  355. package/skills/skill-creator/scripts/generate_report.py +326 -0
  356. package/skills/skill-creator/scripts/improve_description.py +236 -0
  357. package/skills/skill-creator/scripts/package_skill.py +136 -0
  358. package/skills/skill-creator/scripts/quick_validate.py +103 -0
  359. package/skills/skill-creator/scripts/run_eval.py +310 -0
  360. package/skills/skill-creator/scripts/run_loop.py +328 -0
  361. package/skills/skill-creator/scripts/utils.py +47 -0
  362. package/skills/skill-finder-cn/SKILL.md +66 -0
  363. package/skills/skill-finder-cn/_meta.json +6 -0
  364. package/skills/skill-finder-cn/package.json +5 -0
  365. package/skills/skill-finder-cn/scripts/search.sh +15 -0
  366. package/skills/skill-vetter/SKILL.md +137 -0
  367. package/skills/stock-analysis-skill/SKILL.md +156 -0
  368. package/skills/stock-analysis-skill/package.json +21 -0
  369. package/skills/stock-analysis-skill/src/analyzer.ts +264 -0
  370. package/skills/stock-analysis-skill/src/dataFetcher.ts +130 -0
  371. package/skills/stock-analysis-skill/src/dividend.ts +226 -0
  372. package/skills/stock-analysis-skill/src/index.ts +327 -0
  373. package/skills/stock-analysis-skill/src/rumorScanner.ts +200 -0
  374. package/skills/stock-analysis-skill/src/types.ts +167 -0
  375. package/skills/stock-analysis-skill/src/watchlist.ts +292 -0
  376. package/skills/stock-analysis-skill/tsconfig.json +15 -0
  377. package/skills/storyboard-manager/SKILL.md +532 -0
  378. package/skills/storyboard-manager/index.js +9 -0
  379. package/skills/storyboard-manager/package.json +11 -0
  380. package/skills/storyboard-manager/references/character_development.md +232 -0
  381. package/skills/storyboard-manager/references/story_structures.md +148 -0
  382. package/skills/storyboard-manager/scripts/__pycache__/consistency_checker.cpython-312.pyc +0 -0
  383. package/skills/storyboard-manager/scripts/__pycache__/timeline_tracker.cpython-312.pyc +0 -0
  384. package/skills/storyboard-manager/scripts/consistency_checker.py +391 -0
  385. package/skills/storyboard-manager/scripts/timeline_tracker.py +352 -0
  386. package/skills/system_skill.py +249 -0
  387. package/skills/ui-ux-pro-max/SKILL.md +43 -0
  388. package/skills/ui-ux-pro-max/_meta.json +6 -0
  389. package/skills/ui-ux-pro-max/assets/data/charts.csv +26 -0
  390. package/skills/ui-ux-pro-max/assets/data/colors.csv +97 -0
  391. package/skills/ui-ux-pro-max/assets/data/icons.csv +101 -0
  392. package/skills/ui-ux-pro-max/assets/data/landing.csv +31 -0
  393. package/skills/ui-ux-pro-max/assets/data/products.csv +97 -0
  394. package/skills/ui-ux-pro-max/assets/data/react-performance.csv +45 -0
  395. package/skills/ui-ux-pro-max/assets/data/stacks/astro.csv +54 -0
  396. package/skills/ui-ux-pro-max/assets/data/stacks/flutter.csv +53 -0
  397. package/skills/ui-ux-pro-max/assets/data/stacks/html-tailwind.csv +56 -0
  398. package/skills/ui-ux-pro-max/assets/data/stacks/jetpack-compose.csv +53 -0
  399. package/skills/ui-ux-pro-max/assets/data/stacks/nextjs.csv +53 -0
  400. package/skills/ui-ux-pro-max/assets/data/stacks/nuxt-ui.csv +51 -0
  401. package/skills/ui-ux-pro-max/assets/data/stacks/nuxtjs.csv +59 -0
  402. package/skills/ui-ux-pro-max/assets/data/stacks/react-native.csv +52 -0
  403. package/skills/ui-ux-pro-max/assets/data/stacks/react.csv +54 -0
  404. package/skills/ui-ux-pro-max/assets/data/stacks/shadcn.csv +61 -0
  405. package/skills/ui-ux-pro-max/assets/data/stacks/svelte.csv +54 -0
  406. package/skills/ui-ux-pro-max/assets/data/stacks/swiftui.csv +51 -0
  407. package/skills/ui-ux-pro-max/assets/data/stacks/vue.csv +50 -0
  408. package/skills/ui-ux-pro-max/assets/data/styles.csv +68 -0
  409. package/skills/ui-ux-pro-max/assets/data/typography.csv +58 -0
  410. package/skills/ui-ux-pro-max/assets/data/ui-reasoning.csv +101 -0
  411. package/skills/ui-ux-pro-max/assets/data/ux-guidelines.csv +100 -0
  412. package/skills/ui-ux-pro-max/assets/data/web-interface.csv +31 -0
  413. package/skills/ui-ux-pro-max/data/charts.csv +26 -0
  414. package/skills/ui-ux-pro-max/data/colors.csv +97 -0
  415. package/skills/ui-ux-pro-max/data/icons.csv +101 -0
  416. package/skills/ui-ux-pro-max/data/landing.csv +31 -0
  417. package/skills/ui-ux-pro-max/data/products.csv +97 -0
  418. package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  419. package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  420. package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  421. package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  422. package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  423. package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  424. package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  425. package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  426. package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  427. package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  428. package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  429. package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  430. package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  431. package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  432. package/skills/ui-ux-pro-max/data/styles.csv +68 -0
  433. package/skills/ui-ux-pro-max/data/typography.csv +58 -0
  434. package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  435. package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  436. package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  437. package/skills/ui-ux-pro-max/references/upstream-README.md +488 -0
  438. package/skills/ui-ux-pro-max/references/upstream-skill-content.md +288 -0
  439. package/skills/ui-ux-pro-max/scripts/__init__.py +0 -0
  440. package/skills/ui-ux-pro-max/scripts/__pycache__/__init__.cpython-312.pyc +0 -0
  441. package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-312.pyc +0 -0
  442. package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-312.pyc +0 -0
  443. package/skills/ui-ux-pro-max/scripts/__pycache__/search.cpython-312.pyc +0 -0
  444. package/skills/ui-ux-pro-max/scripts/core.py +253 -0
  445. package/skills/ui-ux-pro-max/scripts/design_system.py +1071 -0
  446. package/skills/ui-ux-pro-max/scripts/search.py +111 -0
  447. package/skills/video-generation/LICENSE.txt +21 -0
  448. package/skills/video-generation/SKILL.md +1082 -0
  449. package/skills/video-generation/scripts/video.ts +168 -0
  450. package/skills/video-understand/LICENSE.txt +21 -0
  451. package/skills/video-understand/SKILL.md +916 -0
  452. package/skills/video-understand/scripts/video-understand.ts +41 -0
  453. package/skills/visual-design-foundations/SKILL.md +318 -0
  454. package/skills/visual-design-foundations/references/color-systems.md +417 -0
  455. package/skills/visual-design-foundations/references/spacing-iconography.md +425 -0
  456. package/skills/visual-design-foundations/references/typography-systems.md +432 -0
  457. package/skills/web-reader/LICENSE.txt +21 -0
  458. package/skills/web-reader/SKILL.md +1140 -0
  459. package/skills/web-reader/scripts/web-reader.ts +37 -0
  460. package/skills/web-search/LICENSE.txt +21 -0
  461. package/skills/web-search/SKILL.md +912 -0
  462. package/skills/web-search/scripts/web_search.ts +44 -0
  463. package/skills/web-shader-extractor/SKILL.md +145 -0
  464. package/skills/web-shader-extractor/references/config-extraction.md +50 -0
  465. package/skills/web-shader-extractor/references/encoded-definitions.md +53 -0
  466. package/skills/web-shader-extractor/references/extraction-workflow.md +61 -0
  467. package/skills/web-shader-extractor/references/porting-strategy.md +164 -0
  468. package/skills/web-shader-extractor/references/shader-injection.md +126 -0
  469. package/skills/web-shader-extractor/references/shaders-com.md +190 -0
  470. package/skills/web-shader-extractor/references/tech-signatures.md +54 -0
  471. package/skills/web-shader-extractor/references/tsl-extraction.md +41 -0
  472. package/skills/web-shader-extractor/references/unicorn-studio.md +353 -0
  473. package/skills/web-shader-extractor/scripts/fetch-rendered-dom.mjs +153 -0
  474. package/skills/web-shader-extractor/scripts/scan-bundle.sh +76 -0
  475. package/skills/writing-plans/SKILL.md +116 -0
  476. package/skills/writing-plans/_meta.json +6 -0
  477. package/skills/xlsx/LICENSE.txt +30 -0
  478. package/skills/xlsx/SKILL.md +496 -0
  479. package/skills/xlsx/__pycache__/recalc.cpython-312.pyc +0 -0
  480. package/skills/xlsx/recalc.py +178 -0
  481. package/start.sh +36 -0
  482. package/web/__init__.py +1 -0
  483. package/web/__pycache__/api_server.cpython-312.pyc +0 -0
  484. package/web/api_server.py +2043 -0
  485. package/web/ui/chat.html +3235 -0
  486. package/web/ui/index.html +458 -0
@@ -0,0 +1,1044 @@
1
+ /**
2
+ * html2pptx - Convert HTML slide to pptxgenjs slide with positioned elements
3
+ *
4
+ * USAGE:
5
+ * const pptx = new pptxgen();
6
+ * pptx.layout = 'LAYOUT_16x9'; // Must match HTML body dimensions
7
+ *
8
+ * const { slide, placeholders } = await html2pptx('slide.html', pptx);
9
+ * slide.addChart(pptx.charts.LINE, data, placeholders[0]);
10
+ *
11
+ * await pptx.writeFile('output.pptx');
12
+ *
13
+ * FEATURES:
14
+ * - Converts HTML to PowerPoint with accurate positioning
15
+ * - Supports text, images, shapes, and bullet lists
16
+ * - Extracts placeholder elements (class="placeholder") with positions
17
+ * - Handles CSS gradients, borders, and margins
18
+ *
19
+ * VALIDATION:
20
+ * - Uses body width/height from HTML for viewport sizing
21
+ * - Throws error if HTML dimensions don't match presentation layout
22
+ * - Throws error if content overflows body (with overflow details)
23
+ *
24
+ * RETURNS:
25
+ * { slide, placeholders } where placeholders is an array of { id, x, y, w, h }
26
+ */
27
+
28
+ const { chromium } = require('playwright');
29
+ const path = require('path');
30
+ const sharp = require('sharp');
31
+ const fs = require('fs');
32
+
33
+ const PT_PER_PX = 0.75;
34
+ const PX_PER_IN = 96;
35
+ const EMU_PER_IN = 914400;
36
+
37
+ // Helper: Fix image path if file extension doesn't match actual format
38
+ function fixImageExtension(imagePath, tmpDir) {
39
+ try {
40
+ const fd = fs.openSync(imagePath, 'r');
41
+ const buf = Buffer.alloc(12);
42
+ fs.readSync(fd, buf, 0, 12, 0);
43
+ fs.closeSync(fd);
44
+
45
+ let actualExt = null;
46
+ if (buf[0] === 0xFF && buf[1] === 0xD8) actualExt = '.jpg';
47
+ else if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4E && buf[3] === 0x47) actualExt = '.png';
48
+ else if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) actualExt = '.gif';
49
+ else if (buf[0] === 0x52 && buf[1] === 0x49 && buf[8] === 0x57 && buf[9] === 0x45) actualExt = '.webp';
50
+
51
+ if (!actualExt) return imagePath;
52
+
53
+ const currentExt = path.extname(imagePath).toLowerCase();
54
+ if (currentExt === actualExt || (currentExt === '.jpeg' && actualExt === '.jpg') || (currentExt === '.jpg' && actualExt === '.jpeg')) {
55
+ return imagePath;
56
+ }
57
+
58
+ // Extension mismatch: copy with correct extension
59
+ const fixedPath = path.join(tmpDir, path.basename(imagePath, currentExt) + actualExt);
60
+ fs.copyFileSync(imagePath, fixedPath);
61
+ return fixedPath;
62
+ } catch (e) {
63
+ return imagePath;
64
+ }
65
+ }
66
+
67
+ // Helper: Get body dimensions and check for overflow
68
+ async function getBodyDimensions(page) {
69
+ const bodyDimensions = await page.evaluate(() => {
70
+ const body = document.body;
71
+ const style = window.getComputedStyle(body);
72
+
73
+ return {
74
+ width: parseFloat(style.width),
75
+ height: parseFloat(style.height),
76
+ scrollWidth: body.scrollWidth,
77
+ scrollHeight: body.scrollHeight
78
+ };
79
+ });
80
+
81
+ const errors = [];
82
+ const widthOverflowPx = Math.max(0, bodyDimensions.scrollWidth - bodyDimensions.width - 1);
83
+ const heightOverflowPx = Math.max(0, bodyDimensions.scrollHeight - bodyDimensions.height - 1);
84
+
85
+ const widthOverflowPt = widthOverflowPx * PT_PER_PX;
86
+ const heightOverflowPt = heightOverflowPx * PT_PER_PX;
87
+
88
+ if (widthOverflowPt > 0 || heightOverflowPt > 0) {
89
+ const directions = [];
90
+ if (widthOverflowPt > 0) directions.push(`${widthOverflowPt.toFixed(1)}pt horizontally`);
91
+ if (heightOverflowPt > 0) directions.push(`${heightOverflowPt.toFixed(1)}pt vertically`);
92
+ const reminder = heightOverflowPt > 0 ? ' (Remember: leave 0.5" margin at bottom of slide)' : '';
93
+ errors.push(`HTML content overflows body by ${directions.join(' and ')}${reminder}`);
94
+ }
95
+
96
+ return { ...bodyDimensions, errors };
97
+ }
98
+
99
+ // Helper: Validate dimensions match presentation layout
100
+ function validateDimensions(bodyDimensions, pres) {
101
+ const errors = [];
102
+ const widthInches = bodyDimensions.width / PX_PER_IN;
103
+ const heightInches = bodyDimensions.height / PX_PER_IN;
104
+
105
+ if (pres.presLayout) {
106
+ const layoutWidth = pres.presLayout.width / EMU_PER_IN;
107
+ const layoutHeight = pres.presLayout.height / EMU_PER_IN;
108
+
109
+ if (Math.abs(layoutWidth - widthInches) > 0.1 || Math.abs(layoutHeight - heightInches) > 0.1) {
110
+ errors.push(
111
+ `HTML dimensions (${widthInches.toFixed(1)}" × ${heightInches.toFixed(1)}") ` +
112
+ `don't match presentation layout (${layoutWidth.toFixed(1)}" × ${layoutHeight.toFixed(1)}")`
113
+ );
114
+ }
115
+ }
116
+ return errors;
117
+ }
118
+
119
+ function validateTextBoxPosition(slideData, bodyDimensions) {
120
+ const errors = [];
121
+ const slideHeightInches = bodyDimensions.height / PX_PER_IN;
122
+ const minBottomMargin = 0.5; // 0.5 inches from bottom
123
+
124
+ for (const el of slideData.elements) {
125
+ // Check text elements (p, h1-h6, list)
126
+ if (['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'list'].includes(el.type)) {
127
+ const fontSize = el.style?.fontSize || 0;
128
+ const bottomEdge = el.position.y + el.position.h;
129
+ const distanceFromBottom = slideHeightInches - bottomEdge;
130
+
131
+ if (fontSize > 12 && distanceFromBottom < minBottomMargin) {
132
+ const getText = () => {
133
+ if (typeof el.text === 'string') return el.text;
134
+ if (Array.isArray(el.text)) return el.text.find(t => t.text)?.text || '';
135
+ if (Array.isArray(el.items)) return el.items.find(item => item.text)?.text || '';
136
+ return '';
137
+ };
138
+ const textPrefix = getText().substring(0, 50) + (getText().length > 50 ? '...' : '');
139
+
140
+ errors.push(
141
+ `Text box "${textPrefix}" ends too close to bottom edge ` +
142
+ `(${distanceFromBottom.toFixed(2)}" from bottom, minimum ${minBottomMargin}" required)`
143
+ );
144
+ }
145
+ }
146
+ }
147
+
148
+ return errors;
149
+ }
150
+
151
+ // Helper: Add background to slide
152
+ async function addBackground(slideData, targetSlide, tmpDir) {
153
+ if (slideData.background.type === 'image' && slideData.background.path) {
154
+ let imagePath = slideData.background.path.startsWith('file://')
155
+ ? slideData.background.path.replace('file://', '')
156
+ : slideData.background.path;
157
+ targetSlide.background = { path: fixImageExtension(imagePath, tmpDir) };
158
+ } else if (slideData.background.type === 'color' && slideData.background.value) {
159
+ targetSlide.background = { color: slideData.background.value };
160
+ }
161
+ }
162
+
163
+ // Helper: Add elements to slide
164
+ function addElements(slideData, targetSlide, pres, tmpDir) {
165
+ for (const el of slideData.elements) {
166
+ if (el.type === 'image') {
167
+ let imagePath = el.src.startsWith('file://') ? el.src.replace('file://', '') : el.src;
168
+ targetSlide.addImage({
169
+ path: fixImageExtension(imagePath, tmpDir),
170
+ x: el.position.x,
171
+ y: el.position.y,
172
+ w: el.position.w,
173
+ h: el.position.h
174
+ });
175
+ } else if (el.type === 'line') {
176
+ targetSlide.addShape(pres.ShapeType.line, {
177
+ x: el.x1,
178
+ y: el.y1,
179
+ w: el.x2 - el.x1,
180
+ h: el.y2 - el.y1,
181
+ line: { color: el.color, width: el.width }
182
+ });
183
+ } else if (el.type === 'shape') {
184
+ const shapeOptions = {
185
+ x: el.position.x,
186
+ y: el.position.y,
187
+ w: el.position.w,
188
+ h: el.position.h,
189
+ shape: el.shape.rectRadius > 0 ? pres.ShapeType.roundRect : pres.ShapeType.rect
190
+ };
191
+
192
+ if (el.shape.fill) {
193
+ shapeOptions.fill = { color: el.shape.fill };
194
+ if (el.shape.transparency != null) shapeOptions.fill.transparency = el.shape.transparency;
195
+ }
196
+ if (el.shape.line) shapeOptions.line = el.shape.line;
197
+ if (el.shape.rectRadius > 0) shapeOptions.rectRadius = el.shape.rectRadius;
198
+ if (el.shape.shadow) shapeOptions.shadow = el.shape.shadow;
199
+
200
+ targetSlide.addText(el.text || '', shapeOptions);
201
+ } else if (el.type === 'list') {
202
+ const listOptions = {
203
+ x: el.position.x,
204
+ y: el.position.y,
205
+ w: el.position.w,
206
+ h: el.position.h,
207
+ fontSize: el.style.fontSize,
208
+ fontFace: el.style.fontFace,
209
+ color: el.style.color,
210
+ align: el.style.align,
211
+ valign: 'top',
212
+ charSpacing: el.style.charSpacing,
213
+ lineSpacing: el.style.lineSpacing,
214
+ paraSpaceBefore: el.style.paraSpaceBefore,
215
+ paraSpaceAfter: el.style.paraSpaceAfter,
216
+ margin: el.style.margin
217
+ };
218
+ if (el.style.margin) listOptions.margin = el.style.margin;
219
+ targetSlide.addText(el.items, listOptions);
220
+ } else {
221
+ // Check if text is single-line (height suggests one line)
222
+ const lineHeight = el.style.lineSpacing || el.style.fontSize * 1.2;
223
+ const isSingleLine = el.position.h <= lineHeight * 1.5;
224
+
225
+ let adjustedX = el.position.x;
226
+ let adjustedW = el.position.w;
227
+
228
+ // Headings (h1-h6): widen by 10% to prevent wrapping from font metric differences
229
+ const isHeading = /^h[1-6]$/.test(el.type);
230
+ if (isHeading) {
231
+ const widthIncrease = el.position.w * 0.30;
232
+ const align = el.style.align;
233
+ if (align === 'center') {
234
+ adjustedX -= widthIncrease / 2;
235
+ adjustedW += widthIncrease;
236
+ } else if (align === 'right') {
237
+ adjustedX -= widthIncrease;
238
+ adjustedW += widthIncrease;
239
+ } else {
240
+ adjustedW += widthIncrease;
241
+ }
242
+ }
243
+
244
+ // Make single-line text 2% wider to account for underestimate
245
+ if (isSingleLine && !isHeading) {
246
+ const widthIncrease = el.position.w * 0.02;
247
+ const align = el.style.align;
248
+
249
+ if (align === 'center') {
250
+ // Center: expand both sides
251
+ adjustedX = el.position.x - (widthIncrease / 2);
252
+ adjustedW = el.position.w + widthIncrease;
253
+ } else if (align === 'right') {
254
+ // Right: expand to the left
255
+ adjustedX = el.position.x - widthIncrease;
256
+ adjustedW = el.position.w + widthIncrease;
257
+ } else {
258
+ // Left (default): expand to the right
259
+ adjustedW = el.position.w + widthIncrease;
260
+ }
261
+ }
262
+
263
+ // For centered headings, expand width symmetrically so PowerPoint center alignment works
264
+ // (browser bounding rect gives content-width boxes; PowerPoint needs wider boxes to center properly)
265
+ // Only apply to h1-h6 to avoid creating large text boxes that overlap with images
266
+ if (el.style.align === 'center' && /^h[1-6]$/.test(el.type)) {
267
+ const slideWidthIn = pres.presLayout ? pres.presLayout.width / EMU_PER_IN : 10;
268
+ const centerX = adjustedX + adjustedW / 2;
269
+ const margin = 0.3;
270
+ const maxExpand = Math.min(centerX - margin, slideWidthIn - centerX - margin);
271
+ if (maxExpand > adjustedW / 2) {
272
+ adjustedX = centerX - maxExpand;
273
+ adjustedW = maxExpand * 2;
274
+ }
275
+ }
276
+
277
+ const textOptions = {
278
+ x: adjustedX,
279
+ y: el.position.y,
280
+ w: adjustedW,
281
+ h: el.position.h,
282
+ fontSize: el.style.fontSize,
283
+ fontFace: el.style.fontFace,
284
+ color: el.style.color,
285
+ bold: el.style.bold,
286
+ italic: el.style.italic,
287
+ underline: el.style.underline,
288
+ valign: 'top',
289
+ charSpacing: el.style.charSpacing,
290
+ lineSpacing: el.style.lineSpacing,
291
+ paraSpaceBefore: el.style.paraSpaceBefore,
292
+ paraSpaceAfter: el.style.paraSpaceAfter,
293
+ inset: 0 // Remove default PowerPoint internal padding
294
+ };
295
+
296
+ if (el.style.align) textOptions.align = el.style.align;
297
+ if (el.style.margin) textOptions.margin = el.style.margin;
298
+ if (el.style.rotate !== undefined) textOptions.rotate = el.style.rotate;
299
+ if (el.style.transparency !== null && el.style.transparency !== undefined) textOptions.transparency = el.style.transparency;
300
+
301
+ targetSlide.addText(el.text, textOptions);
302
+ }
303
+ }
304
+ }
305
+
306
+ // Helper: Extract slide data from HTML page
307
+ async function extractSlideData(page) {
308
+ return await page.evaluate(() => {
309
+ const PT_PER_PX = 0.75;
310
+ const PX_PER_IN = 96;
311
+
312
+ // Fonts that are single-weight and should not have bold applied
313
+ // (applying bold causes PowerPoint to use faux bold which makes text wider)
314
+ const SINGLE_WEIGHT_FONTS = ['impact'];
315
+
316
+ // Helper: Check if a font should skip bold formatting
317
+ const shouldSkipBold = (fontFamily) => {
318
+ if (!fontFamily) return false;
319
+ const normalizedFont = fontFamily.toLowerCase().replace(/['"]/g, '').split(',')[0].trim();
320
+ return SINGLE_WEIGHT_FONTS.includes(normalizedFont);
321
+ };
322
+
323
+ // Unit conversion helpers
324
+ const pxToInch = (px) => px / PX_PER_IN;
325
+ const pxToPoints = (pxStr) => parseFloat(pxStr) * PT_PER_PX;
326
+ const rgbToHex = (rgbStr) => {
327
+ // Handle transparent backgrounds by defaulting to white
328
+ if (rgbStr === 'rgba(0, 0, 0, 0)' || rgbStr === 'transparent') return 'FFFFFF';
329
+
330
+ const match = rgbStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
331
+ if (!match) return 'FFFFFF';
332
+ return match.slice(1).map(n => parseInt(n).toString(16).padStart(2, '0')).join('');
333
+ };
334
+
335
+ const extractAlpha = (rgbStr) => {
336
+ const match = rgbStr.match(/rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)/);
337
+ if (!match || !match[4]) return null;
338
+ const alpha = parseFloat(match[4]);
339
+ return Math.round((1 - alpha) * 100);
340
+ };
341
+
342
+ const applyTextTransform = (text, textTransform) => {
343
+ if (textTransform === 'uppercase') return text.toUpperCase();
344
+ if (textTransform === 'lowercase') return text.toLowerCase();
345
+ if (textTransform === 'capitalize') {
346
+ return text.replace(/\b\w/g, c => c.toUpperCase());
347
+ }
348
+ return text;
349
+ };
350
+
351
+ // Extract rotation angle from CSS transform and writing-mode
352
+ const getRotation = (transform, writingMode) => {
353
+ let angle = 0;
354
+
355
+ // Handle writing-mode first
356
+ // PowerPoint: 90° = text rotated 90° clockwise (reads top to bottom, letters upright)
357
+ // PowerPoint: 270° = text rotated 270° clockwise (reads bottom to top, letters upright)
358
+ if (writingMode === 'vertical-rl') {
359
+ // vertical-rl alone = text reads top to bottom = 90° in PowerPoint
360
+ angle = 90;
361
+ } else if (writingMode === 'vertical-lr') {
362
+ // vertical-lr alone = text reads bottom to top = 270° in PowerPoint
363
+ angle = 270;
364
+ }
365
+
366
+ // Then add any transform rotation
367
+ if (transform && transform !== 'none') {
368
+ // Try to match rotate() function
369
+ const rotateMatch = transform.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/);
370
+ if (rotateMatch) {
371
+ angle += parseFloat(rotateMatch[1]);
372
+ } else {
373
+ // Browser may compute as matrix - extract rotation from matrix
374
+ const matrixMatch = transform.match(/matrix\(([^)]+)\)/);
375
+ if (matrixMatch) {
376
+ const values = matrixMatch[1].split(',').map(parseFloat);
377
+ // matrix(a, b, c, d, e, f) where rotation = atan2(b, a)
378
+ const matrixAngle = Math.atan2(values[1], values[0]) * (180 / Math.PI);
379
+ angle += Math.round(matrixAngle);
380
+ }
381
+ }
382
+ }
383
+
384
+ // Normalize to 0-359 range
385
+ angle = angle % 360;
386
+ if (angle < 0) angle += 360;
387
+
388
+ return angle === 0 ? null : angle;
389
+ };
390
+
391
+ // Get position/dimensions accounting for rotation
392
+ const getPositionAndSize = (el, rect, rotation) => {
393
+ if (rotation === null) {
394
+ return { x: rect.left, y: rect.top, w: rect.width, h: rect.height };
395
+ }
396
+
397
+ // For 90° or 270° rotations, swap width and height
398
+ // because PowerPoint applies rotation to the original (unrotated) box
399
+ const isVertical = rotation === 90 || rotation === 270;
400
+
401
+ if (isVertical) {
402
+ // The browser shows us the rotated dimensions (tall box for vertical text)
403
+ // But PowerPoint needs the pre-rotation dimensions (wide box that will be rotated)
404
+ // So we swap: browser's height becomes PPT's width, browser's width becomes PPT's height
405
+ const centerX = rect.left + rect.width / 2;
406
+ const centerY = rect.top + rect.height / 2;
407
+
408
+ return {
409
+ x: centerX - rect.height / 2,
410
+ y: centerY - rect.width / 2,
411
+ w: rect.height,
412
+ h: rect.width
413
+ };
414
+ }
415
+
416
+ // For other rotations, use element's offset dimensions
417
+ const centerX = rect.left + rect.width / 2;
418
+ const centerY = rect.top + rect.height / 2;
419
+ return {
420
+ x: centerX - el.offsetWidth / 2,
421
+ y: centerY - el.offsetHeight / 2,
422
+ w: el.offsetWidth,
423
+ h: el.offsetHeight
424
+ };
425
+ };
426
+
427
+ // Parse CSS box-shadow into PptxGenJS shadow properties
428
+ const parseBoxShadow = (boxShadow) => {
429
+ if (!boxShadow || boxShadow === 'none') return null;
430
+
431
+ // Browser computed style format: "rgba(0, 0, 0, 0.3) 2px 2px 8px 0px [inset]"
432
+ // CSS format: "[inset] 2px 2px 8px 0px rgba(0, 0, 0, 0.3)"
433
+
434
+ const insetMatch = boxShadow.match(/inset/);
435
+
436
+ // IMPORTANT: PptxGenJS/PowerPoint doesn't properly support inset shadows
437
+ // Only process outer shadows to avoid file corruption
438
+ if (insetMatch) return null;
439
+
440
+ // Extract color first (rgba or rgb at start)
441
+ const colorMatch = boxShadow.match(/rgba?\([^)]+\)/);
442
+
443
+ // Extract numeric values (handles both px and pt units)
444
+ const parts = boxShadow.match(/([-\d.]+)(px|pt)/g);
445
+
446
+ if (!parts || parts.length < 2) return null;
447
+
448
+ const offsetX = parseFloat(parts[0]);
449
+ const offsetY = parseFloat(parts[1]);
450
+ const blur = parts.length > 2 ? parseFloat(parts[2]) : 0;
451
+
452
+ // Calculate angle from offsets (in degrees, 0 = right, 90 = down)
453
+ let angle = 0;
454
+ if (offsetX !== 0 || offsetY !== 0) {
455
+ angle = Math.atan2(offsetY, offsetX) * (180 / Math.PI);
456
+ if (angle < 0) angle += 360;
457
+ }
458
+
459
+ // Calculate offset distance (hypotenuse)
460
+ const offset = Math.sqrt(offsetX * offsetX + offsetY * offsetY) * PT_PER_PX;
461
+
462
+ // Extract opacity from rgba
463
+ let opacity = 0.5;
464
+ if (colorMatch) {
465
+ const opacityMatch = colorMatch[0].match(/[\d.]+\)$/);
466
+ if (opacityMatch) {
467
+ opacity = parseFloat(opacityMatch[0].replace(')', ''));
468
+ }
469
+ }
470
+
471
+ return {
472
+ type: 'outer',
473
+ angle: Math.round(angle),
474
+ blur: blur * 0.75, // Convert to points
475
+ color: colorMatch ? rgbToHex(colorMatch[0]) : '000000',
476
+ offset: offset,
477
+ opacity
478
+ };
479
+ };
480
+
481
+ // Parse inline formatting tags (<b>, <i>, <u>, <strong>, <em>, <span>) into text runs
482
+ const parseInlineFormatting = (element, baseOptions = {}, runs = [], baseTextTransform = (x) => x) => {
483
+ let prevNodeIsText = false;
484
+
485
+ element.childNodes.forEach((node) => {
486
+ let textTransform = baseTextTransform;
487
+
488
+ const isText = node.nodeType === Node.TEXT_NODE || node.tagName === 'BR';
489
+ if (isText) {
490
+ const text = node.tagName === 'BR' ? '\n' : textTransform(node.textContent.replace(/\s+/g, ' '));
491
+ const prevRun = runs[runs.length - 1];
492
+ if (prevNodeIsText && prevRun) {
493
+ prevRun.text += text;
494
+ } else {
495
+ runs.push({ text, options: { ...baseOptions } });
496
+ }
497
+
498
+ } else if (node.nodeType === Node.ELEMENT_NODE && node.textContent.trim()) {
499
+ const options = { ...baseOptions };
500
+ const computed = window.getComputedStyle(node);
501
+
502
+ // Handle inline elements with computed styles
503
+ if (node.tagName === 'SPAN' || node.tagName === 'B' || node.tagName === 'STRONG' || node.tagName === 'I' || node.tagName === 'EM' || node.tagName === 'U') {
504
+ const isBold = computed.fontWeight === 'bold' || parseInt(computed.fontWeight) >= 600;
505
+ if (isBold && !shouldSkipBold(computed.fontFamily)) options.bold = true;
506
+ if (computed.fontStyle === 'italic') options.italic = true;
507
+ if (computed.textDecoration && computed.textDecoration.includes('underline')) options.underline = true;
508
+ if (computed.color && computed.color !== 'rgb(0, 0, 0)') {
509
+ options.color = rgbToHex(computed.color);
510
+ const transparency = extractAlpha(computed.color);
511
+ if (transparency !== null) options.transparency = transparency;
512
+ }
513
+ if (computed.fontSize) options.fontSize = pxToPoints(computed.fontSize);
514
+ if (computed.letterSpacing && computed.letterSpacing !== 'normal') options.charSpacing = pxToPoints(computed.letterSpacing);
515
+
516
+ // Apply text-transform on the span element itself
517
+ if (computed.textTransform && computed.textTransform !== 'none') {
518
+ const transformStr = computed.textTransform;
519
+ textTransform = (text) => applyTextTransform(text, transformStr);
520
+ }
521
+
522
+ // Validate: Check for margins on inline elements
523
+ if (computed.marginLeft && parseFloat(computed.marginLeft) > 0) {
524
+ errors.push(`Inline element <${node.tagName.toLowerCase()}> has margin-left which is not supported in PowerPoint. Remove margin from inline elements.`);
525
+ }
526
+ if (computed.marginRight && parseFloat(computed.marginRight) > 0) {
527
+ errors.push(`Inline element <${node.tagName.toLowerCase()}> has margin-right which is not supported in PowerPoint. Remove margin from inline elements.`);
528
+ }
529
+ if (computed.marginTop && parseFloat(computed.marginTop) > 0) {
530
+ errors.push(`Inline element <${node.tagName.toLowerCase()}> has margin-top which is not supported in PowerPoint. Remove margin from inline elements.`);
531
+ }
532
+ if (computed.marginBottom && parseFloat(computed.marginBottom) > 0) {
533
+ errors.push(`Inline element <${node.tagName.toLowerCase()}> has margin-bottom which is not supported in PowerPoint. Remove margin from inline elements.`);
534
+ }
535
+
536
+ // Recursively process the child node. This will flatten nested spans into multiple runs.
537
+ parseInlineFormatting(node, options, runs, textTransform);
538
+ }
539
+ }
540
+
541
+ prevNodeIsText = isText;
542
+ });
543
+
544
+ // Trim leading space from first run and trailing space from last run
545
+ if (runs.length > 0) {
546
+ runs[0].text = runs[0].text.replace(/^\s+/, '');
547
+ runs[runs.length - 1].text = runs[runs.length - 1].text.replace(/\s+$/, '');
548
+ }
549
+
550
+ return runs.filter(r => r.text.length > 0);
551
+ };
552
+
553
+ // Extract background from body (image or color)
554
+ const body = document.body;
555
+ const bodyStyle = window.getComputedStyle(body);
556
+ const bgImage = bodyStyle.backgroundImage;
557
+ const bgColor = bodyStyle.backgroundColor;
558
+
559
+ // Collect validation errors
560
+ const errors = [];
561
+
562
+ // Validate: Check for CSS gradients
563
+ if (bgImage && (bgImage.includes('linear-gradient') || bgImage.includes('radial-gradient'))) {
564
+ errors.push(
565
+ 'CSS gradients are not supported. Use Sharp to rasterize gradients as PNG images first, ' +
566
+ 'then reference with background-image: url(\'gradient.png\')'
567
+ );
568
+ }
569
+
570
+ let background;
571
+ if (bgImage && bgImage !== 'none') {
572
+ // Extract URL from url("...") or url(...)
573
+ const urlMatch = bgImage.match(/url\(["']?([^"')]+)["']?\)/);
574
+ if (urlMatch) {
575
+ background = {
576
+ type: 'image',
577
+ path: urlMatch[1]
578
+ };
579
+ } else {
580
+ background = {
581
+ type: 'color',
582
+ value: rgbToHex(bgColor)
583
+ };
584
+ }
585
+ } else {
586
+ background = {
587
+ type: 'color',
588
+ value: rgbToHex(bgColor)
589
+ };
590
+ }
591
+
592
+ // Process all elements
593
+ const elements = [];
594
+ const placeholders = [];
595
+ const textTags = ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'UL', 'OL', 'LI'];
596
+ const processed = new Set();
597
+
598
+ document.querySelectorAll('*').forEach((el) => {
599
+ if (processed.has(el)) return;
600
+
601
+ // Validate text elements don't have backgrounds, borders, or shadows
602
+ if (textTags.includes(el.tagName)) {
603
+ const computed = window.getComputedStyle(el);
604
+ const hasBg = computed.backgroundColor && computed.backgroundColor !== 'rgba(0, 0, 0, 0)';
605
+ const hasBorder = (computed.borderWidth && parseFloat(computed.borderWidth) > 0) ||
606
+ (computed.borderTopWidth && parseFloat(computed.borderTopWidth) > 0) ||
607
+ (computed.borderRightWidth && parseFloat(computed.borderRightWidth) > 0) ||
608
+ (computed.borderBottomWidth && parseFloat(computed.borderBottomWidth) > 0) ||
609
+ (computed.borderLeftWidth && parseFloat(computed.borderLeftWidth) > 0);
610
+ const hasShadow = computed.boxShadow && computed.boxShadow !== 'none';
611
+
612
+ if (hasBg || hasBorder || hasShadow) {
613
+ errors.push(
614
+ `Text element <${el.tagName.toLowerCase()}> has ${hasBg ? 'background' : hasBorder ? 'border' : 'shadow'}. ` +
615
+ 'Backgrounds, borders, and shadows are only supported on <div> elements, not text elements.'
616
+ );
617
+ return;
618
+ }
619
+ }
620
+
621
+ // Extract placeholder elements (for charts, etc.)
622
+ if (el.className && el.className.includes('placeholder')) {
623
+ const rect = el.getBoundingClientRect();
624
+ if (rect.width === 0 || rect.height === 0) {
625
+ errors.push(
626
+ `Placeholder "${el.id || 'unnamed'}" has ${rect.width === 0 ? 'width: 0' : 'height: 0'}. Check the layout CSS.`
627
+ );
628
+ } else {
629
+ placeholders.push({
630
+ id: el.id || `placeholder-${placeholders.length}`,
631
+ x: pxToInch(rect.left),
632
+ y: pxToInch(rect.top),
633
+ w: pxToInch(rect.width),
634
+ h: pxToInch(rect.height)
635
+ });
636
+ }
637
+ processed.add(el);
638
+ return;
639
+ }
640
+
641
+ // Extract images
642
+ if (el.tagName === 'IMG') {
643
+ const rect = el.getBoundingClientRect();
644
+ if (rect.width > 0 && rect.height > 0) {
645
+ elements.push({
646
+ type: 'image',
647
+ src: el.src,
648
+ position: {
649
+ x: pxToInch(rect.left),
650
+ y: pxToInch(rect.top),
651
+ w: pxToInch(rect.width),
652
+ h: pxToInch(rect.height)
653
+ }
654
+ });
655
+ processed.add(el);
656
+ return;
657
+ }
658
+ }
659
+
660
+ // Extract DIVs with backgrounds/borders as shapes
661
+ const isContainer = el.tagName === 'DIV' && !textTags.includes(el.tagName);
662
+ if (isContainer) {
663
+ const computed = window.getComputedStyle(el);
664
+ const hasBg = computed.backgroundColor && computed.backgroundColor !== 'rgba(0, 0, 0, 0)';
665
+
666
+ // Validate: Check for unwrapped text content in DIV
667
+ for (const node of el.childNodes) {
668
+ if (node.nodeType === Node.TEXT_NODE) {
669
+ const text = node.textContent.trim();
670
+ if (text) {
671
+ errors.push(
672
+ `DIV element contains unwrapped text "${text.substring(0, 50)}${text.length > 50 ? '...' : ''}". ` +
673
+ 'All text must be wrapped in <p>, <h1>-<h6>, <ul>, or <ol> tags to appear in PowerPoint.'
674
+ );
675
+ }
676
+ }
677
+ }
678
+
679
+ // Check for background images on shapes
680
+ const bgImage = computed.backgroundImage;
681
+ if (bgImage && bgImage !== 'none') {
682
+ errors.push(
683
+ 'Background images on DIV elements are not supported. ' +
684
+ 'Use solid colors or borders for shapes, or use slide.addImage() in PptxGenJS to layer images.'
685
+ );
686
+ return;
687
+ }
688
+
689
+ // Check for borders - both uniform and partial
690
+ const borderTop = computed.borderTopWidth;
691
+ const borderRight = computed.borderRightWidth;
692
+ const borderBottom = computed.borderBottomWidth;
693
+ const borderLeft = computed.borderLeftWidth;
694
+ const borders = [borderTop, borderRight, borderBottom, borderLeft].map(b => parseFloat(b) || 0);
695
+ const hasBorder = borders.some(b => b > 0);
696
+ const hasUniformBorder = hasBorder && borders.every(b => b === borders[0]);
697
+ const borderLines = [];
698
+
699
+ if (hasBorder && !hasUniformBorder) {
700
+ const rect = el.getBoundingClientRect();
701
+ const x = pxToInch(rect.left);
702
+ const y = pxToInch(rect.top);
703
+ const w = pxToInch(rect.width);
704
+ const h = pxToInch(rect.height);
705
+
706
+ // Collect lines to add after shape (inset by half the line width to center on edge)
707
+ if (parseFloat(borderTop) > 0) {
708
+ const widthPt = pxToPoints(borderTop);
709
+ const inset = (widthPt / 72) / 2; // Convert points to inches, then half
710
+ borderLines.push({
711
+ type: 'line',
712
+ x1: x, y1: y + inset, x2: x + w, y2: y + inset,
713
+ width: widthPt,
714
+ color: rgbToHex(computed.borderTopColor)
715
+ });
716
+ }
717
+ if (parseFloat(borderRight) > 0) {
718
+ const widthPt = pxToPoints(borderRight);
719
+ const inset = (widthPt / 72) / 2;
720
+ borderLines.push({
721
+ type: 'line',
722
+ x1: x + w - inset, y1: y, x2: x + w - inset, y2: y + h,
723
+ width: widthPt,
724
+ color: rgbToHex(computed.borderRightColor)
725
+ });
726
+ }
727
+ if (parseFloat(borderBottom) > 0) {
728
+ const widthPt = pxToPoints(borderBottom);
729
+ const inset = (widthPt / 72) / 2;
730
+ borderLines.push({
731
+ type: 'line',
732
+ x1: x, y1: y + h - inset, x2: x + w, y2: y + h - inset,
733
+ width: widthPt,
734
+ color: rgbToHex(computed.borderBottomColor)
735
+ });
736
+ }
737
+ if (parseFloat(borderLeft) > 0) {
738
+ const widthPt = pxToPoints(borderLeft);
739
+ const inset = (widthPt / 72) / 2;
740
+ borderLines.push({
741
+ type: 'line',
742
+ x1: x + inset, y1: y, x2: x + inset, y2: y + h,
743
+ width: widthPt,
744
+ color: rgbToHex(computed.borderLeftColor)
745
+ });
746
+ }
747
+ }
748
+
749
+ if (hasBg || hasBorder) {
750
+ const rect = el.getBoundingClientRect();
751
+ if (rect.width > 0 && rect.height > 0) {
752
+ const shadow = parseBoxShadow(computed.boxShadow);
753
+
754
+ // Only add shape if there's background or uniform border
755
+ if (hasBg || hasUniformBorder) {
756
+ elements.push({
757
+ type: 'shape',
758
+ text: '', // Shape only - child text elements render on top
759
+ position: {
760
+ x: pxToInch(rect.left),
761
+ y: pxToInch(rect.top),
762
+ w: pxToInch(rect.width),
763
+ h: pxToInch(rect.height)
764
+ },
765
+ shape: {
766
+ fill: hasBg ? rgbToHex(computed.backgroundColor) : null,
767
+ transparency: hasBg ? extractAlpha(computed.backgroundColor) : null,
768
+ line: hasUniformBorder ? {
769
+ color: rgbToHex(computed.borderColor),
770
+ width: pxToPoints(computed.borderWidth)
771
+ } : null,
772
+ // Convert border-radius to rectRadius (in inches)
773
+ // % values: 50%+ = circle (1), <50% = percentage of min dimension
774
+ // pt values: divide by 72 (72pt = 1 inch)
775
+ // px values: divide by 96 (96px = 1 inch)
776
+ rectRadius: (() => {
777
+ const radius = computed.borderRadius;
778
+ const radiusValue = parseFloat(radius);
779
+ if (radiusValue === 0) return 0;
780
+
781
+ if (radius.includes('%')) {
782
+ if (radiusValue >= 50) return 1;
783
+ // Calculate percentage of smaller dimension
784
+ const minDim = Math.min(rect.width, rect.height);
785
+ return (radiusValue / 100) * pxToInch(minDim);
786
+ }
787
+
788
+ if (radius.includes('pt')) return radiusValue / 72;
789
+ return radiusValue / PX_PER_IN;
790
+ })(),
791
+ shadow: shadow
792
+ }
793
+ });
794
+ }
795
+
796
+ // Add partial border lines
797
+ elements.push(...borderLines);
798
+
799
+ processed.add(el);
800
+ return;
801
+ }
802
+ }
803
+ }
804
+
805
+ // Extract bullet lists as single text block
806
+ if (el.tagName === 'UL' || el.tagName === 'OL') {
807
+ const rect = el.getBoundingClientRect();
808
+ if (rect.width === 0 || rect.height === 0) return;
809
+
810
+ const liElements = Array.from(el.querySelectorAll('li'));
811
+ const items = [];
812
+ const ulComputed = window.getComputedStyle(el);
813
+ const ulPaddingLeftPt = pxToPoints(ulComputed.paddingLeft);
814
+
815
+ // Split: margin-left for bullet position, indent for text position
816
+ // margin-left + indent = ul padding-left
817
+ const marginLeft = ulPaddingLeftPt * 0.5;
818
+ const textIndent = ulPaddingLeftPt * 0.5;
819
+
820
+ liElements.forEach((li, idx) => {
821
+ const isLast = idx === liElements.length - 1;
822
+ const runs = parseInlineFormatting(li, { breakLine: false });
823
+ // Clean manual bullets from first run
824
+ if (runs.length > 0) {
825
+ runs[0].text = runs[0].text.replace(/^[•\-\*▪▸]\s*/, '');
826
+ runs[0].options.bullet = { indent: textIndent };
827
+ }
828
+ // Set breakLine on last run
829
+ if (runs.length > 0 && !isLast) {
830
+ runs[runs.length - 1].options.breakLine = true;
831
+ }
832
+ items.push(...runs);
833
+ });
834
+
835
+ const computed = window.getComputedStyle(liElements[0] || el);
836
+
837
+ elements.push({
838
+ type: 'list',
839
+ items: items,
840
+ position: {
841
+ x: pxToInch(rect.left),
842
+ y: pxToInch(rect.top),
843
+ w: pxToInch(rect.width),
844
+ h: pxToInch(rect.height)
845
+ },
846
+ style: {
847
+ fontSize: pxToPoints(computed.fontSize),
848
+ fontFace: computed.fontFamily.split(',')[0].replace(/['"]/g, '').trim(),
849
+ color: rgbToHex(computed.color),
850
+ transparency: extractAlpha(computed.color),
851
+ align: computed.textAlign === 'start' ? 'left' : computed.textAlign,
852
+ lineSpacing: computed.lineHeight && computed.lineHeight !== 'normal' ? pxToPoints(computed.lineHeight) : null,
853
+ paraSpaceBefore: 0,
854
+ paraSpaceAfter: pxToPoints(computed.marginBottom),
855
+ // PptxGenJS margin array is [left, right, bottom, top]
856
+ margin: [marginLeft, 0, 0, 0]
857
+ }
858
+ });
859
+
860
+ liElements.forEach(li => processed.add(li));
861
+ processed.add(el);
862
+ return;
863
+ }
864
+
865
+ // Extract text elements (P, H1, H2, etc.)
866
+ if (!textTags.includes(el.tagName)) return;
867
+
868
+ const rect = el.getBoundingClientRect();
869
+ const text = el.textContent.trim();
870
+ if (rect.width === 0 || rect.height === 0 || !text) return;
871
+
872
+ // Validate: Check for manual bullet symbols in text elements (not in lists)
873
+ if (el.tagName !== 'LI' && /^[•\-\*▪▸○●◆◇■□]\s/.test(text.trimStart())) {
874
+ errors.push(
875
+ `Text element <${el.tagName.toLowerCase()}> starts with bullet symbol "${text.substring(0, 20)}...". ` +
876
+ 'Use <ul> or <ol> lists instead of manual bullet symbols.'
877
+ );
878
+ return;
879
+ }
880
+
881
+ const computed = window.getComputedStyle(el);
882
+ const rotation = getRotation(computed.transform, computed.writingMode);
883
+ const { x, y, w, h } = getPositionAndSize(el, rect, rotation);
884
+
885
+ const baseStyle = {
886
+ fontSize: pxToPoints(computed.fontSize),
887
+ fontFace: computed.fontFamily.split(',')[0].replace(/['"]/g, '').trim(),
888
+ color: rgbToHex(computed.color),
889
+ align: computed.textAlign === 'start' ? 'left' : computed.textAlign,
890
+ charSpacing: computed.letterSpacing && computed.letterSpacing !== 'normal' ? pxToPoints(computed.letterSpacing) : undefined,
891
+ lineSpacing: pxToPoints(computed.lineHeight),
892
+ paraSpaceBefore: pxToPoints(computed.marginTop),
893
+ paraSpaceAfter: pxToPoints(computed.marginBottom),
894
+ // PptxGenJS margin array is [left, right, bottom, top] (not [top, right, bottom, left] as documented)
895
+ margin: [
896
+ pxToPoints(computed.paddingLeft),
897
+ pxToPoints(computed.paddingRight),
898
+ pxToPoints(computed.paddingBottom),
899
+ pxToPoints(computed.paddingTop)
900
+ ]
901
+ };
902
+
903
+ const transparency = extractAlpha(computed.color);
904
+ if (transparency !== null) baseStyle.transparency = transparency;
905
+
906
+ if (rotation !== null) baseStyle.rotate = rotation;
907
+
908
+ const hasFormatting = el.querySelector('b, i, u, strong, em, span, br');
909
+
910
+ if (hasFormatting) {
911
+ // Text with inline formatting
912
+ const transformStr = computed.textTransform;
913
+ const runs = parseInlineFormatting(el, {}, [], (str) => applyTextTransform(str, transformStr));
914
+
915
+ // Adjust lineSpacing based on largest fontSize in runs
916
+ const adjustedStyle = { ...baseStyle };
917
+ if (adjustedStyle.lineSpacing) {
918
+ const maxFontSize = Math.max(
919
+ adjustedStyle.fontSize,
920
+ ...runs.map(r => r.options?.fontSize || 0)
921
+ );
922
+ if (maxFontSize > adjustedStyle.fontSize) {
923
+ const lineHeightMultiplier = adjustedStyle.lineSpacing / adjustedStyle.fontSize;
924
+ adjustedStyle.lineSpacing = maxFontSize * lineHeightMultiplier;
925
+ }
926
+ }
927
+
928
+ elements.push({
929
+ type: el.tagName.toLowerCase(),
930
+ text: runs,
931
+ position: { x: pxToInch(x), y: pxToInch(y), w: pxToInch(w), h: pxToInch(h) },
932
+ style: adjustedStyle
933
+ });
934
+ } else {
935
+ // Plain text - inherit CSS formatting
936
+ const textTransform = computed.textTransform;
937
+ const transformedText = applyTextTransform(text, textTransform);
938
+
939
+ const isBold = computed.fontWeight === 'bold' || parseInt(computed.fontWeight) >= 600;
940
+
941
+ elements.push({
942
+ type: el.tagName.toLowerCase(),
943
+ text: transformedText,
944
+ position: { x: pxToInch(x), y: pxToInch(y), w: pxToInch(w), h: pxToInch(h) },
945
+ style: {
946
+ ...baseStyle,
947
+ bold: isBold && !shouldSkipBold(computed.fontFamily),
948
+ italic: computed.fontStyle === 'italic',
949
+ underline: computed.textDecoration.includes('underline')
950
+ }
951
+ });
952
+ }
953
+
954
+ processed.add(el);
955
+ });
956
+
957
+ return { background, elements, placeholders, errors };
958
+ });
959
+ }
960
+
961
+ async function html2pptx(htmlFile, pres, options = {}) {
962
+ const {
963
+ tmpDir = process.env.TMPDIR || '/tmp',
964
+ slide = null
965
+ } = options;
966
+
967
+ try {
968
+ // Use Chrome on macOS, default Chromium on Unix
969
+ const launchOptions = { env: { TMPDIR: tmpDir } };
970
+ if (process.platform === 'darwin') {
971
+ launchOptions.channel = 'chrome';
972
+ }
973
+
974
+ const browser = await chromium.launch(launchOptions);
975
+
976
+ let bodyDimensions;
977
+ let slideData;
978
+
979
+ const filePath = path.isAbsolute(htmlFile) ? htmlFile : path.join(process.cwd(), htmlFile);
980
+ const validationErrors = [];
981
+
982
+ try {
983
+ const page = await browser.newPage();
984
+ page.on('console', (msg) => {
985
+ // Log the message text to your test runner's console
986
+ console.log(`Browser console: ${msg.text()}`);
987
+ });
988
+
989
+ await page.goto(`file://${filePath}`);
990
+
991
+ bodyDimensions = await getBodyDimensions(page);
992
+
993
+ await page.setViewportSize({
994
+ width: Math.round(bodyDimensions.width),
995
+ height: Math.round(bodyDimensions.height)
996
+ });
997
+
998
+ slideData = await extractSlideData(page);
999
+ } finally {
1000
+ await browser.close();
1001
+ }
1002
+
1003
+ // Collect all validation errors
1004
+ if (bodyDimensions.errors && bodyDimensions.errors.length > 0) {
1005
+ validationErrors.push(...bodyDimensions.errors);
1006
+ }
1007
+
1008
+ // const dimensionErrors = validateDimensions(bodyDimensions, pres);
1009
+ // if (dimensionErrors.length > 0) {
1010
+ // validationErrors.push(...dimensionErrors);
1011
+ // }
1012
+
1013
+ // const textBoxPositionErrors = validateTextBoxPosition(slideData, bodyDimensions);
1014
+ // if (textBoxPositionErrors.length > 0) {
1015
+ // validationErrors.push(...textBoxPositionErrors);
1016
+ // }
1017
+
1018
+ if (slideData.errors && slideData.errors.length > 0) {
1019
+ validationErrors.push(...slideData.errors);
1020
+ }
1021
+
1022
+ // Throw all errors at once if any exist
1023
+ if (validationErrors.length > 0) {
1024
+ const errorMessage = validationErrors.length === 1
1025
+ ? validationErrors[0]
1026
+ : `Multiple validation errors found:\n${validationErrors.map((e, i) => ` ${i + 1}. ${e}`).join('\n')}`;
1027
+ throw new Error(errorMessage);
1028
+ }
1029
+
1030
+ const targetSlide = slide || pres.addSlide();
1031
+
1032
+ await addBackground(slideData, targetSlide, tmpDir);
1033
+ addElements(slideData, targetSlide, pres, tmpDir);
1034
+
1035
+ return { slide: targetSlide, placeholders: slideData.placeholders };
1036
+ } catch (error) {
1037
+ if (!error.message.startsWith(htmlFile)) {
1038
+ throw new Error(`${htmlFile}: ${error.message}`);
1039
+ }
1040
+ throw error;
1041
+ }
1042
+ }
1043
+
1044
+ module.exports = html2pptx;