allyhub 0.15.0 → 0.15.2

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 (232) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
  3. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  4. package/dist/node_modules/@allyhub/browser/package.json +1 -1
  5. package/dist/node_modules/@allyhub/build/package.json +1 -1
  6. package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
  7. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  8. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  9. package/dist/node_modules/@allyhub/check/package.json +1 -1
  10. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  11. package/dist/node_modules/@allyhub/components/package.json +1 -1
  12. package/dist/node_modules/@allyhub/dev-server/dist/server.js +2 -2
  13. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  14. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  15. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  16. package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
  17. package/dist/node_modules/@allyhub/doc-print/dist/drawn.js +4 -4
  18. package/dist/node_modules/@allyhub/doc-print/dist/fonts.js +3 -3
  19. package/dist/node_modules/@allyhub/doc-print/dist/layout.js +4 -4
  20. package/dist/node_modules/@allyhub/doc-print/dist/pdf.js +4 -4
  21. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  22. package/dist/node_modules/@allyhub/export/package.json +1 -1
  23. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  24. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  25. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  26. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  27. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  28. package/dist/node_modules/@allyhub/image-extension/dist/cli.js +1 -1
  29. package/dist/node_modules/@allyhub/image-extension/dist/export.js +2 -2
  30. package/dist/node_modules/@allyhub/image-extension/package.json +1 -1
  31. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  32. package/dist/node_modules/@allyhub/image-psd/dist/ag-psd.js +2 -0
  33. package/dist/node_modules/@allyhub/image-psd/dist/read.js +12 -12
  34. package/dist/node_modules/@allyhub/image-psd/dist/write.js +1 -1
  35. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  36. package/dist/node_modules/@allyhub/image-render/dist/pdf.js +1 -1
  37. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  38. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  39. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  40. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  41. package/dist/node_modules/@allyhub/linkedin-extension/package.json +1 -1
  42. package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
  43. package/dist/node_modules/@allyhub/linkedin-view/dist/index.js +2 -1
  44. package/dist/node_modules/@allyhub/linkedin-view/dist/stage.js +65 -1
  45. package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
  46. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  47. package/dist/node_modules/@allyhub/media/package.json +1 -1
  48. package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
  49. package/dist/node_modules/@allyhub/model/package.json +1 -1
  50. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  51. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  52. package/dist/node_modules/@allyhub/project/package.json +1 -1
  53. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  54. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  55. package/dist/node_modules/@allyhub/render/dist/exports.js +2 -2
  56. package/dist/node_modules/@allyhub/render/package.json +1 -1
  57. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  58. package/dist/node_modules/@allyhub/runtimes/dist/index.d.ts +1 -1
  59. package/dist/node_modules/@allyhub/runtimes/dist/index.js +1 -1
  60. package/dist/node_modules/@allyhub/runtimes/dist/packages.d.ts +17 -0
  61. package/dist/node_modules/@allyhub/runtimes/dist/packages.js +3 -3
  62. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  63. package/dist/node_modules/@allyhub/runtimes/pins/ag-psd/package-lock.json +49 -0
  64. package/dist/node_modules/@allyhub/runtimes/pins/ag-psd/package.json +7 -0
  65. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-caladea/package-lock.json +24 -0
  66. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-caladea/package.json +23 -0
  67. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-carlito/package-lock.json +24 -0
  68. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-carlito/package.json +23 -0
  69. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-cousine/package-lock.json +24 -0
  70. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-cousine/package.json +23 -0
  71. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-lxgw-wenkai/package-lock.json +24 -0
  72. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-lxgw-wenkai/package.json +19 -0
  73. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-noto-color-emoji/package-lock.json +24 -0
  74. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-noto-color-emoji/package.json +17 -0
  75. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-noto-sans-sc/package-lock.json +24 -0
  76. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-noto-sans-sc/package.json +19 -0
  77. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-noto-serif-sc/package-lock.json +24 -0
  78. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-noto-serif-sc/package.json +19 -0
  79. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-tinos/package-lock.json +24 -0
  80. package/dist/node_modules/@allyhub/runtimes/pins/fontsource-tinos/package.json +23 -0
  81. package/dist/node_modules/@allyhub/runtimes/pins/mermaid/package-lock.json +19 -0
  82. package/dist/node_modules/@allyhub/runtimes/pins/mermaid/package.json +15 -0
  83. package/dist/node_modules/@allyhub/runtimes/pins/pdf-lib/package-lock.json +55 -0
  84. package/dist/node_modules/@allyhub/runtimes/pins/pdf-lib/package.json +7 -0
  85. package/dist/node_modules/@allyhub/runtimes/pins/pptxgenjs/package-lock.json +169 -0
  86. package/dist/node_modules/@allyhub/runtimes/pins/pptxgenjs/package.json +7 -0
  87. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  88. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  89. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  90. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  91. package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
  92. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  93. package/dist/node_modules/@allyhub/slides-extension/package.json +1 -1
  94. package/dist/node_modules/@allyhub/slides-pptx/dist/read/chart.js +2 -2
  95. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  96. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  97. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  98. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  99. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  100. package/dist/node_modules/@allyhub/telemetry/package.json +1 -1
  101. package/dist/node_modules/@allyhub/text-extension/package.json +1 -1
  102. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  103. package/dist/node_modules/@allyhub/video-extension/package.json +1 -1
  104. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  105. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  106. package/dist/node_modules/@allyhub/website/package.json +1 -1
  107. package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
  108. package/dist/node_modules/@allyhub/x-extension/package.json +1 -1
  109. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  110. package/dist/node_modules/@allyhub/x-view/dist/index.js +262 -1
  111. package/dist/node_modules/@allyhub/x-view/dist/stage.js +325 -1
  112. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  113. package/dist/package.json +12 -12
  114. package/editor-web/assets/{abnfDiagram-WEYOIA3C-BHI0AbUY.js → abnfDiagram-WEYOIA3C-9z0ZEYUq.js} +1 -1
  115. package/editor-web/assets/{architecture-WOLXFQ4H-BMQS-OKZ.js → architecture-WOLXFQ4H-ELMO_PA6.js} +1 -1
  116. package/editor-web/assets/{architectureDiagram-ZHVYKT53-DZp9CM6P.js → architectureDiagram-ZHVYKT53-C0yuCWU3.js} +1 -1
  117. package/editor-web/assets/article-DHFgHYjv.js +3 -0
  118. package/editor-web/assets/article-Dt9id9Y9.js +7 -0
  119. package/editor-web/assets/{blockDiagram-RJAE7QA3-h6LWaev4.js → blockDiagram-RJAE7QA3-vi6JOg4o.js} +1 -1
  120. package/editor-web/assets/{c4Diagram-XDPPPE54-BvSMs7J4.js → c4Diagram-XDPPPE54-Agf_H8uS.js} +1 -1
  121. package/editor-web/assets/channel-Dkg198L0.js +1 -0
  122. package/editor-web/assets/{chunk-2E7WHVMD-0EJTAmDF.js → chunk-2E7WHVMD-XalaZaha.js} +1 -1
  123. package/editor-web/assets/{chunk-4EMNKR2T-BeYB4AEY.js → chunk-4EMNKR2T-DUlRZkCS.js} +1 -1
  124. package/editor-web/assets/{chunk-55XCU76K-BPFOPTBe.js → chunk-55XCU76K-DTa7whGr.js} +1 -1
  125. package/editor-web/assets/{chunk-7S6XSTFO-CZ2C7ULu.js → chunk-7S6XSTFO-85zCPzj0.js} +1 -1
  126. package/editor-web/assets/{chunk-AQDTSKZB-B5RtsZkj.js → chunk-AQDTSKZB-CWBseIyh.js} +1 -1
  127. package/editor-web/assets/{chunk-DSNLSHJZ-_3G4hddj.js → chunk-DSNLSHJZ-BFnyvrWg.js} +1 -1
  128. package/editor-web/assets/{chunk-HAGFOTED-DO5b4ll2.js → chunk-HAGFOTED-DFWda2Rk.js} +1 -1
  129. package/editor-web/assets/{chunk-HNE4Q36P-C6XNI71Q.js → chunk-HNE4Q36P-aXibFitC.js} +1 -1
  130. package/editor-web/assets/{chunk-NQOKRVIF-nDCX29rQ.js → chunk-NQOKRVIF-CtJUuFdN.js} +1 -1
  131. package/editor-web/assets/{chunk-UHW7PFBP-CRCOiitq.js → chunk-UHW7PFBP-B6QKSKWE.js} +1 -1
  132. package/editor-web/assets/{chunk-VQ5W62QI-hNPKKjCN.js → chunk-VQ5W62QI-CF6Al55P.js} +1 -1
  133. package/editor-web/assets/{chunk-WQQL4CDK-KlnVtIDc.js → chunk-WQQL4CDK-w2TKLkyw.js} +1 -1
  134. package/editor-web/assets/{chunk-YZO67HFG-B76hDUrM.js → chunk-YZO67HFG-DVGOATM3.js} +1 -1
  135. package/editor-web/assets/{chunk-ZAUX2LTX-D9m1N0wI.js → chunk-ZAUX2LTX-Cq7MMjDP.js} +1 -1
  136. package/editor-web/assets/{chunk-ZCHMQSOR-443euxzo.js → chunk-ZCHMQSOR-GMW_lBh4.js} +1 -1
  137. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-Bbw-8Ons.js → classDiagram-v2-4MYWR3UA-C7AK5Bkj.js} +1 -1
  138. package/editor-web/assets/code-BID_OoRp.js +1 -0
  139. package/editor-web/assets/{cynefin-EF2NZ3EQ-C4E7TlUr.js → cynefin-EF2NZ3EQ-ZnDieQsN.js} +1 -1
  140. package/editor-web/assets/{cynefinDiagram-WF24UDRP-PBPGa_HS.js → cynefinDiagram-WF24UDRP-BrukKIBF.js} +1 -1
  141. package/editor-web/assets/{dagre-NK4GIZVX-DwXdEtQG.js → dagre-NK4GIZVX-DfO0S2p_.js} +1 -1
  142. package/editor-web/assets/{diagram-CBK3MWTC-BE3FwdX7.js → diagram-CBK3MWTC-D43RLesi.js} +1 -1
  143. package/editor-web/assets/{diagram-I5XIIV2D-BPl2ZY33.js → diagram-I5XIIV2D-bA1B1QQG.js} +1 -1
  144. package/editor-web/assets/{diagram-ODIL2UCW-BLVPYSzw.js → diagram-ODIL2UCW-DAdXBD2K.js} +1 -1
  145. package/editor-web/assets/{diagram-PFBEJUXE-BVZk62FO.js → diagram-PFBEJUXE-C_KyEaws.js} +1 -1
  146. package/editor-web/assets/{diagram-RJA3I4VV-Z75LSbxH.js → diagram-RJA3I4VV-oXTtENF7.js} +1 -1
  147. package/editor-web/assets/{diagram-TYUNFSNR-BynGqDAg.js → diagram-TYUNFSNR-Czupe6mO.js} +1 -1
  148. package/editor-web/assets/dist-2lNSE-G_.js +82 -0
  149. package/editor-web/assets/{dist-D_xVYGnk.js → dist-5HNrQ9AU.js} +3 -3
  150. package/editor-web/assets/dist-BPecIPz6.js +530 -0
  151. package/editor-web/assets/dist-BXJKASX4.js +24 -0
  152. package/editor-web/assets/{dist-CIQUbiAd.js → dist-BeDRTqQ8.js} +11 -11
  153. package/editor-web/assets/{dist-CxlIyluY.js → dist-BlL-4sl3.js} +1 -1
  154. package/editor-web/assets/dist-BtRMClDw.js +40 -0
  155. package/editor-web/assets/{dist-Ch34PllS.js → dist-BuqBg8k8.js} +1 -1
  156. package/editor-web/assets/{dist-cUeSwqws.js → dist-BwW08gSh.js} +1 -1
  157. package/editor-web/assets/{dist-VP4ECMOk.js → dist-C30Thvb3.js} +1 -1
  158. package/editor-web/assets/dist-Cj5AmpVb.js +5 -0
  159. package/editor-web/assets/dist-CjjnDOa8.js +3 -0
  160. package/editor-web/assets/dist-D7ur8721.js +6 -0
  161. package/editor-web/assets/{dist-Nc_h0Jye.js → dist-DOHhp09C.js} +1 -1
  162. package/editor-web/assets/{dist-UG2TIZxP.js → dist-LhFEYZza.js} +1 -1
  163. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-SwhqbeK4.js → ebnfDiagram-V4P3TTPT-BOhNZmtp.js} +1 -1
  164. package/editor-web/assets/{elk-QONTBCTQ-Bb1GSt2Z.js → elk-QONTBCTQ-DoZH3OoE.js} +1 -1
  165. package/editor-web/assets/{erDiagram-KYQIGQAA-qUy0NDKn.js → erDiagram-KYQIGQAA-Bv0KDJi4.js} +1 -1
  166. package/editor-web/assets/{eventmodeling-K75KTNOO-BYBYso_j.js → eventmodeling-K75KTNOO-C-_xzqfj.js} +1 -1
  167. package/editor-web/assets/flowDiagram-IUGLLWBU-C7ZmHJZW.js +1 -0
  168. package/editor-web/assets/{ganttDiagram-R7GPNTJY-Cw-BkZT8.js → ganttDiagram-R7GPNTJY-CAuJlaZX.js} +1 -1
  169. package/editor-web/assets/{gitGraph-VSP46ZUC-CTXzWPq_.js → gitGraph-VSP46ZUC-Dx2xLi5C.js} +1 -1
  170. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-Jd9HU3WA.js → gitGraphDiagram-PDYL7XHY-DHsk_UOT.js} +1 -1
  171. package/editor-web/assets/{index-CglHrLRS.js → index-BGAXezRR.js} +2 -2
  172. package/editor-web/assets/{info-OHQRW6UA-C4oj5BpF.js → info-OHQRW6UA-CnKQHx5m.js} +1 -1
  173. package/editor-web/assets/{infoDiagram-MVDRKAX5-D09aYJ28.js → infoDiagram-MVDRKAX5-ibAVFw_2.js} +1 -1
  174. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-BEdXoXb2.js → ishikawaDiagram-HPEHV2GE-C1OCHt3y.js} +1 -1
  175. package/editor-web/assets/{journeyDiagram-BOSHW7O7-DE-_0aww.js → journeyDiagram-BOSHW7O7-BDdqMOM1.js} +1 -1
  176. package/editor-web/assets/{kanban-definition-FNSA4HC5-Cn3_bvPS.js → kanban-definition-FNSA4HC5-CSAS_zGn.js} +1 -1
  177. package/editor-web/assets/lib-KOEbW83T.js +3 -0
  178. package/editor-web/assets/{mermaid-parser.core-BK52JMZH.js → mermaid-parser.core-DTLyYXbn.js} +3 -3
  179. package/editor-web/assets/{mermaid.core-CmfBU89G.js → mermaid.core-B8478wZ1.js} +4 -4
  180. package/editor-web/assets/{mindmap-definition-6OY57UG3-CtUhkv9I.js → mindmap-definition-6OY57UG3-DSWHcglH.js} +1 -1
  181. package/editor-web/assets/{packet-JDAUHWVQ-C7nciBNp.js → packet-JDAUHWVQ-_k1BF29s.js} +1 -1
  182. package/editor-web/assets/{pegDiagram-ECIUJNBX-DUkbAcTs.js → pegDiagram-ECIUJNBX-B22YyWAa.js} +1 -1
  183. package/editor-web/assets/{pie-XZMESJXO-BIGyKhav.js → pie-XZMESJXO-CSwV32hj.js} +1 -1
  184. package/editor-web/assets/{pieDiagram-GNMPY74T-DrYj-JeG.js → pieDiagram-GNMPY74T-rSFNeWnq.js} +1 -1
  185. package/editor-web/assets/{props-form-DrZYDmSM.js → props-form-B6mYjTgZ.js} +1 -1
  186. package/editor-web/assets/{quadrantDiagram-D57K4MC3-qkBoh1ep.js → quadrantDiagram-D57K4MC3-Xrntfg4j.js} +1 -1
  187. package/editor-web/assets/{radar-ABXABTNO-BkJmvR6a.js → radar-ABXABTNO-Dwq5qiNw.js} +1 -1
  188. package/editor-web/assets/{railroad-I3PHUGI6-BFH-ip4B.js → railroad-I3PHUGI6-sIUGWcZh.js} +1 -1
  189. package/editor-web/assets/{railroad-abnf-LNEFI6M7-BBlzHL6Z.js → railroad-abnf-LNEFI6M7-1rWlT9BX.js} +1 -1
  190. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-CCVsG0ui.js → railroad-ebnf-DWYD2UWJ-DWdkzEHc.js} +1 -1
  191. package/editor-web/assets/{railroad-peg-JR7BVNR7-Puo7BFPl.js → railroad-peg-JR7BVNR7-CME0JBbV.js} +1 -1
  192. package/editor-web/assets/{railroadDiagram-Y72NRBL7-DCwfkv35.js → railroadDiagram-Y72NRBL7-Ch4BpP22.js} +1 -1
  193. package/editor-web/assets/{requirementDiagram-EQYSW5RA-DSTcDj32.js → requirementDiagram-EQYSW5RA-CgE-x3wN.js} +1 -1
  194. package/editor-web/assets/{sankeyDiagram-SY24JHO5-Kqq4fCvG.js → sankeyDiagram-SY24JHO5-DBf4G6n3.js} +1 -1
  195. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-B1uodEgL.js → sequenceDiagram-BLEHNHQU-Bz07CoUS.js} +1 -1
  196. package/editor-web/assets/{split-Cu0fidVK.js → split-mDSkdQkd.js} +1 -1
  197. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-B6gG3vUm.js → stateDiagram-v2-A6IESKWZ-DuqAmDPP.js} +1 -1
  198. package/editor-web/assets/{swimlanes-B3ENRKFQ-CZayRtvU.js → swimlanes-B3ENRKFQ-C7sOL6rB.js} +1 -1
  199. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-CQ2aWYP-.js +8 -0
  200. package/editor-web/assets/syntax-BIEjjMZL.js +27 -0
  201. package/editor-web/assets/{tabs-B_K0Db1I.js → tabs-C0AHyuE5.js} +1 -1
  202. package/editor-web/assets/{timeline-definition-JXYKGLGB-5YoY8Xhw.js → timeline-definition-JXYKGLGB-CaLYz9mc.js} +1 -1
  203. package/editor-web/assets/{treeView-D4JQ5SDB-Brd_NUPx.js → treeView-D4JQ5SDB-D1P1Kyxc.js} +1 -1
  204. package/editor-web/assets/{treemap-SAJKECNS-DmfdnlWl.js → treemap-SAJKECNS-2YaFL53t.js} +1 -1
  205. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-lcAkMviI.js → usecaseDiagram-WPOLBNNX-uYdbUhUS.js} +1 -1
  206. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-DY_n48hQ.js → vennDiagram-Q3Y3IDCW-DHepmX4t.js} +1 -1
  207. package/editor-web/assets/{video-Bv3rETBU.js → video-Xl-OaXRc.js} +1 -1
  208. package/editor-web/assets/{wardley-7MLQ67FV-DzIFSBQz.js → wardley-7MLQ67FV-Dx0MOPV1.js} +1 -1
  209. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-CsXNajIg.js → wardleyDiagram-IVAIDKWA-BX8ElwDW.js} +1 -1
  210. package/editor-web/assets/words-B2FXYyeZ.js +263 -0
  211. package/editor-web/assets/words-DFIhHhHF.js +3 -0
  212. package/editor-web/assets/{xychartDiagram-4URNHDU4-DDpGFEum.js → xychartDiagram-4URNHDU4-DoWQRJUS.js} +1 -1
  213. package/editor-web/index.html +1 -1
  214. package/package.json +2 -19
  215. package/editor-web/assets/article-C_mBG5a1.js +0 -8
  216. package/editor-web/assets/article-DWBxNvX0.js +0 -7
  217. package/editor-web/assets/bookmark-Dfji3syX.js +0 -1
  218. package/editor-web/assets/channel-BFHB0S0f.js +0 -1
  219. package/editor-web/assets/dist--ijXGgvi.js +0 -5
  220. package/editor-web/assets/dist-C-yi9AAi.js +0 -274
  221. package/editor-web/assets/dist-D9N4Fxqr.js +0 -84
  222. package/editor-web/assets/dist-DWKEqAou.js +0 -6
  223. package/editor-web/assets/dist-DX0VLTRV.js +0 -3
  224. package/editor-web/assets/dist-xpAaABxb.js +0 -24
  225. package/editor-web/assets/flowDiagram-IUGLLWBU-BSCBBtP3.js +0 -1
  226. package/editor-web/assets/katex-UWCZofcd.js +0 -257
  227. package/editor-web/assets/play-DvMyq5xW.js +0 -1
  228. package/editor-web/assets/repeat-2-DfPmKp4w.js +0 -1
  229. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-B9tLTrym.js +0 -8
  230. package/editor-web/assets/syntax-PERQ2szW.js +0 -66
  231. package/editor-web/assets/words-BTRrBFUo.js +0 -2
  232. package/editor-web/assets/words-ll_94CD2.js +0 -3
@@ -1,18 +1,18 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{initializeCanvas as me,readPsd as Y}from"ag-psd";import{writePng as Q}from"@allyhub/measure";import{adjustmentRefusal as ge,refusalOf as be}from"@allyhub/piece";import{stringify as ye}from"yaml";import{blendOf as P,gradientOf as V,hexOf as X,justificationOf as we,pathOf as ee,pxOf as te,transformPath as ne}from"./map.js";const xe=e=>e.slice(e.lastIndexOf("/")+1);function ie(e,s,n){const t=o=>e.files.has(o)||(e.o.taken?.(o)??!1);let i=`${s}${n}`;for(let o=2;t(i);o++)i=`${s}-${String(o)}${n}`;return i}let se=!1;function oe(){if(se)return;me(()=>{throw new Error("ag-psd asked for a canvas: AllyHub reads pixels as data.")},(s,n)=>({width:s,height:n,data:new Uint8ClampedArray(s*n*4),colorSpace:"srgb"})),se=!0}export function keyOf(e,s,n){const t=e.normalize("NFKD").replace(/[̀-ͯ]/gu,"").toLowerCase().replace(/[^a-z0-9]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,48).replace(/-+$/u,"")||s;let i=t;for(let o=2;n.has(i);o++)i=`${t}-${String(o)}`;return n.add(i),i}const T=e=>e===void 0?void 0:Math.round(e*1e3)/10,j=e=>Math.round(e*1e3)/1e3,L=(e,s)=>Math.round(e/s*1e6)/1e6;export function fontOf(e){const[s=e,n=""]=e.split("-"),t=/italic|oblique/iu.test(n),i=n.toLowerCase().replace(/italic|oblique/gu,""),o=/thin|hairline/u.test(i)?100:/extralight|ultralight/u.test(i)?200:/semibold|demibold/u.test(i)?600:/extrabold|ultrabold/u.test(i)?800:/black|heavy/u.test(i)?900:i.includes("light")?300:i.includes("medium")?500:i.includes("bold")?700:400;return{family:s.replace(/(PS)?MT$|PS$/u,"").replace(/([a-z])([A-Z])/gu,"$1 $2").trim()||s,weight:o,italic:t}}const g=(e,s,n,t)=>{e.notes.push({how:s,what:n,board:e.board,...t===void 0?{}:{layer:t}})};function ke(e,s){const n=e.imageData;if(!n||n.width===0||n.height===0)return;const t=(e.left??0)-s.frame.left,i=(e.top??0)-s.frame.top,o=Math.max(0,t),a=Math.max(0,i),d=Math.min(s.frame.width,t+n.width),c=Math.min(s.frame.height,i+n.height);if(d<=o||c<=a)return;const m=d-o,l=c-a,u=new Uint8Array(m*l*4);let f=!1;for(let b=0;b<l;b++)for(let $=0;$<m;$++){const p=((b+a-i)*n.width+($+o-t))*4,x=(b*m+$)*4;u[x]=n.data[p]??0,u[x+1]=n.data[p+1]??0,u[x+2]=n.data[p+2]??0,u[x+3]=n.data[p+3]??0,u[x+3]!==0&&(f=!0)}if(f)return{img:{width:m,height:l,data:u},box:[o,a,m,l]}}function ae(e,s,n,t){const i=ie(e,`${e.board}-${s}${n}`,".png");e.files.set(i,new Uint8Array(Q(t)));let a=`${e.board} ${s} ${n}`.split(/[^A-Za-z0-9]+/u).filter(c=>c!=="").map((c,m)=>m===0?c.toLowerCase():c.charAt(0).toUpperCase()+c.slice(1)).join("");/^[A-Za-z_]/u.test(a)||(a=`_${a}`);const d=a;for(let c=2;e.imports.some(m=>m.name===a);c++)a=`${d}${String(c)}`;return e.imports.push({name:a,path:`./${i}`}),a}class U{name;constructor(s){this.name=s}}const $e=(e,s,n)=>[L(s[0]??0,n.frame.width),L(s[1]??0,n.frame.height),L(e.width,n.frame.width),L(e.height,n.frame.height)];function C(e,s,n){const t=X(s);return t.converted&&g(e,"approximate",`a ${t.converted} colour converted to sRGB without its profile`,n),t.hex}function re(e,s,n,t={}){if(!s||!("colorStops"in s))return;const i=V(s);i.converted&&g(e,"approximate",`a gradient's ${i.converted} colours converted to sRGB without a profile`,n);const o=t.style;return{stops:i.stops.length>=2?i.stops:[...i.stops,...i.stops].slice(0,2),...o===void 0||o==="linear"?{}:{style:o},...t.angle===void 0||t.angle===90?{}:{angle:j(t.angle)},...t.scale===void 0||Math.abs(t.scale-1)<1e-6?{}:{scale:Math.max(10,Math.min(1e3,Math.round(t.scale*100)))},...t.reverse===!0?{reverse:!0}:{}}}function de(e,s,n){if(s){if(s.type==="color")return{color:C(e,s.color,n)};if(s.type==="solid"){const t=re(e,s,n,{...s.style===void 0?{}:{style:s.style},...s.angle===void 0?{}:{angle:s.angle},...s.scale===void 0?{}:{scale:s.scale},...s.reverse===void 0?{}:{reverse:s.reverse}});return t?{gradient:t}:void 0}}}const Me=e=>e===void 0||e.name==="Linear"||Array.isArray(e.curve)&&e.curve.length<=2;function ve(e,s,n){const t={},i=e.ppi,o=s.scale??1,a=r=>{const y=te(r,i);return y===void 0?void 0:Math.max(0,Math.min(1e3,j(y*o)))},d=r=>r?.present===!1?void 0:r,c=r=>({...r.enabled===!1?{enabled:!1}:{},...P(r.blendMode)===void 0?{}:{blendMode:P(r.blendMode)},...r.opacity===void 0?{}:{opacity:T(r.opacity)}}),m=(r,y)=>{const O=y?.filter(h=>h.present!==!1);return O&&O.length>1&&g(e,"omitted",`${String(O.length-1)} more ${r} effects: AllyHub's layer has one of each`,n),O?.[0]},l=(r,y)=>{Me(y)||g(e,"omitted",`the ${r}'s contour (${y?.name??"custom"}): drawn linear`,n)},u=m("drop shadow",s.dropShadow);u&&(l("drop shadow",u.contour),t.dropShadow={...c(u),...u.color?{color:C(e,u.color,n)}:{},...u.angle===void 0?{}:{angle:j(u.angle)},...a(u.distance)===void 0?{}:{distance:a(u.distance)},...u.choke?{spread:Math.min(100,j(u.choke.value))}:{},...a(u.size)===void 0?{}:{size:a(u.size)}});const f=m("inner shadow",s.innerShadow);f&&(l("inner shadow",f.contour),t.innerShadow={...c(f),...f.color?{color:C(e,f.color,n)}:{},...f.angle===void 0?{}:{angle:j(f.angle)},...a(f.distance)===void 0?{}:{distance:a(f.distance)},...f.choke?{choke:Math.min(100,j(f.choke.value))}:{},...a(f.size)===void 0?{}:{size:a(f.size)}});const b=d(s.outerGlow);if(b){const r=b;l("outer glow",r.contour),r.gradient&&g(e,"omitted","the outer glow's gradient: drawn in its colour",n),t.outerGlow={...c(r),...r.color?{color:C(e,r.color,n)}:{},...r.choke?{spread:Math.min(100,j(r.choke.value))}:{},...a(r.size)===void 0?{}:{size:a(r.size)}}}const $=d(s.innerGlow);if($){const r=$;l("inner glow",r.contour),r.gradient&&g(e,"omitted","the inner glow's gradient: drawn in its colour",n),t.innerGlow={...c(r),...r.color?{color:C(e,r.color,n)}:{},...r.choke?{choke:Math.min(100,j(r.choke.value))}:{},...a(r.size)===void 0?{}:{size:a(r.size)},...r.source?{source:r.source}:{}}}const p=m("stroke",s.stroke);p&&(p.fillType!==void 0&&p.fillType!=="color"&&g(e,"approximate",`the stroke's ${p.fillType} fill: drawn in its first colour`,n),t.stroke={...c(p),...p.color?{color:C(e,p.color,n)}:{},...a(p.size)===void 0?{}:{size:a(p.size)},...p.position?{position:p.position}:{}});const x=m("colour overlay",s.solidFill);x&&(t.colorOverlay={...c(x),...x.color?{color:C(e,x.color,n)}:{}});const w=m("gradient overlay",s.gradientOverlay);if(w){const r=re(e,w.gradient,n,{...w.type===void 0?{}:{style:w.type},...w.angle===void 0?{}:{angle:w.angle},...w.scale===void 0?{}:{scale:w.scale},...w.reverse===void 0?{}:{reverse:w.reverse}});r?t.gradientOverlay={...c(w),gradient:r}:g(e,"omitted","a gradient overlay of a noise gradient",n)}d(s.patternOverlay)&&g(e,"omitted","the pattern overlay: its pattern's pixels are the file's, which ag-psd does not read out",n);const S=d(s.satin);if(S){const r=S;l("satin",r.contour),t.satin={...c(r),...r.color?{color:C(e,r.color,n)}:{},...r.angle===void 0?{}:{angle:j(r.angle)},...a(r.distance)===void 0?{}:{distance:a(r.distance)},...a(r.size)===void 0?{}:{size:a(r.size)},...r.invert===void 0?{}:{invert:r.invert}}}const M=d(s.bevel);if(M){const r=M,y=r.style===void 0?void 0:{"inner bevel":"innerBevel","outer bevel":"outerBevel",emboss:"emboss","pillow emboss":"pillowEmboss","stroke emboss":"strokeEmboss"}[r.style],O=r.technique===void 0?void 0:{smooth:"smooth","chisel hard":"chiselHard","chisel soft":"chiselSoft"}[r.technique];t.bevelEmboss={...r.enabled===!1?{enabled:!1}:{},...y?{style:y}:{},...O?{technique:O}:{},...r.strength===void 0?{}:{depth:Math.max(1,Math.min(1e3,Math.round(r.strength*100)))},...r.direction?{direction:r.direction}:{},...a(r.size)===void 0?{}:{size:a(r.size)},...a(r.soften)===void 0?{}:{soften:a(r.soften)},...r.angle===void 0?{}:{angle:j(r.angle)},...r.altitude===void 0?{}:{altitude:j(r.altitude)},...P(r.highlightBlendMode)?{highlightMode:P(r.highlightBlendMode)}:{},...r.highlightColor?{highlightColor:C(e,r.highlightColor,n)}:{},...r.highlightOpacity===void 0?{}:{highlightOpacity:T(r.highlightOpacity)},...P(r.shadowBlendMode)?{shadowMode:P(r.shadowBlendMode)}:{},...r.shadowColor?{shadowColor:C(e,r.shadowColor,n)}:{},...r.shadowOpacity===void 0?{}:{shadowOpacity:T(r.shadowOpacity)}}}if(s.disabled===!0)for(const r of Object.values(t))r.enabled=!1;return Object.keys(t).length>0?t:void 0}function Oe(e,s,n,t){const i={...s};for(let o=0;o<24;o++){const a=be(i,n);if(a===void 0)break;const d=/effects\.(\w+)/u.exec(a)?.[1],c=i.effects,m=/^effects\.(dropShadow|outerGlow)\.blendMode/u.exec(a)?.[1],l=m===void 0?void 0:c?.[m];if(m&&c&&typeof l=="object"&&l!==null){c[m]={...l,blendMode:"normal"},g(e,"approximate",`the ${m}'s blend mode: AllyHub draws an effect under its layer as normal (a layer's filter cannot read what lies under it), so it is written normal`,t);continue}if(d&&c&&d in c){const u=Object.fromEntries(Object.entries(c).filter(([f])=>f!==d));Object.keys(u).length>0?i.effects=u:delete i.effects,g(e,"omitted",`the ${d} effect: ${a}`,t);continue}if(a.startsWith("an adjustment has no effects")||c&&a.includes("stroke")){if(c&&a.includes("stroke")){const u=Object.fromEntries(Object.entries(c).filter(([f])=>f!=="stroke"));Object.keys(u).length>0?i.effects=u:delete i.effects,g(e,"omitted",`the stroke effect: ${a}`,t)}else delete i.effects,g(e,"omitted",`its effects: ${a}`,t);continue}if(a.includes("fillOpacity")&&i.fillOpacity!==void 0){g(e,"approximate",`its fill opacity ${JSON.stringify(i.fillOpacity)}: ${a}; drawn at 100`,t),delete i.fillOpacity;continue}if(a.includes("blendMode")&&i.blendMode!==void 0){g(e,"approximate",`its blend mode: ${a}; drawn as normal`,t),i.blendMode=n==="group"?"passThrough":"normal",n!=="group"&&delete i.blendMode;continue}g(e,"omitted",`its style: ${a}`,t),delete i.effects,delete i.blendMode,delete i.fillOpacity}return i}function H(e,s,n,t){const i=s.mask??s.realMask,o=i?.imageData&&i.imageData.width>0&&i.imageData.height>0?i:void 0,a=s.vectorMask&&s.vectorMask.paths.length>0?s.vectorMask:void 0,[d,c,m,l]=t.box.map(Math.round),u=(f,b,$)=>({...f===void 0||Math.abs(f-1)<1e-6?{}:{density:T(f)},...b===void 0||b===0?{}:{feather:Math.min(1e3,j(b))},...$===!0?{enabled:!1}:{}});if(o?.imageData){const f=o.imageData,b=new Uint8Array(m*l*4),$=o.defaultColor??0,p=(o.left??0)-e.frame.left,x=(o.top??0)-e.frame.top;for(let w=0;w<l;w++)for(let S=0;S<m;S++){const M=S+d-p,r=w+c-x,y=M>=0&&r>=0&&M<f.width&&r<f.height?f.data[(r*f.width+M)*4]??0:$,O=(w*m+S)*4;b[O]=y,b[O+1]=y,b[O+2]=y,b[O+3]=255}return a&&g(e,"omitted","its vector mask, beside its raster mask: AllyHub's layer has one mask",n),(o.userMaskFeather??0)>0&&g(e,"approximate","its mask's feather: Photoshop's radius taken as a Gaussian's standard deviation",n),{src:new U(ae(e,n,".mask",{width:m,height:l,data:b})),mode:"luminance",...u(o.userMaskDensity,o.userMaskFeather,o.disabled)}}if(a){const f=ne(ee(a.paths),[1,0,0,1,-e.frame.left-d,-e.frame.top-c]);return a.paths.length>1&&a.paths.some(b=>b.fillRule==="even-odd"||b.operation!==void 0&&b.operation!=="combine")&&g(e,"approximate","its vector mask's subpaths subtract, intersect or exclude, or fill even-odd: drawn as one path, non-zero",n),(s.mask?.vectorMaskFeather??0)>0&&g(e,"approximate","its vector mask's feather: Photoshop's radius taken as a Gaussian's standard deviation",n),{path:f,...a.invert===!0?{invert:!0}:{},...u(s.mask?.vectorMaskDensity,s.mask?.vectorMaskFeather,a.disable)}}}function R(e,s,n,t){const i=P(s.blendMode);s.blendMode!==void 0&&i===void 0&&g(e,"approximate",`its blend mode ${s.blendMode} (Photoshop's 3D): drawn as normal`,t);const o=T(s.opacity),a=T(s.fillOpacity),d=s.effects?ve(e,s.effects,t):void 0;return Oe(e,{...i===void 0||i===(n==="group"?"passThrough":"normal")?{}:{blendMode:i},...o===void 0||o===100?{}:{opacity:o},...a===void 0||a===100?{}:{fillOpacity:a},...s.clipping===!0?{clipping:!0}:{},...d?{effects:d}:{},...s.hidden===!0?{visible:!1}:{}},n,t)}function Se(e,s,n){const t=s.adjustment;if(!t)return;const i=o=>{g(e,"omitted",o,n)};switch(t.type){case"levels":{const o=["rgb","red","green","blue"],a={kind:"levels"};return(t.channels??[]).slice(0,4).forEach((d,c)=>{const m=o[c];if(!m)return;const l={...d.shadowInput===0?{}:{inputBlack:d.shadowInput},...d.highlightInput===255?{}:{inputWhite:d.highlightInput},...d.midtoneInput===1?{}:{gamma:Math.max(.1,Math.min(9.99,d.midtoneInput))},...d.shadowOutput===0?{}:{outputBlack:d.shadowOutput},...d.highlightOutput===255?{}:{outputWhite:d.highlightOutput}};Object.keys(l).length>0&&(a[m]=l)}),a}case"curves":{if(t.values?.some(d=>d.length>0)){i("a Curves drawn with the pencil (a table, not points): AllyHub's curves take points");return}const o=["rgb","red","green","blue"],a={kind:"curves"};return(t.channels??[]).slice(0,4).forEach((d,c)=>{const m=o[c];!m||d.length<2||(a[m]=d.slice(0,16).map(l=>[Math.round(l.input),Math.round(l.output)]))}),a}case"brightness/contrast":return t.useLegacy===!1&&g(e,"approximate","Brightness/Contrast's current algorithm, which Photoshop does not publish: drawn by the legacy one",n),{kind:"brightnessContrast",...t.brightness?{brightness:Math.max(-150,Math.min(150,t.brightness))}:{},...t.contrast?{contrast:Math.max(-50,Math.min(100,t.contrast))}:{}};case"hue/saturation":{if(t.colorize===!0){i("a colorizing Hue/Saturation: AllyHub does not draw colorize yet");return}["reds","yellows","greens","cyans","blues","magentas"].some(d=>{const c=t[d];return c!==void 0&&(c.hue!==0||c.saturation!==0||c.lightness!==0)})&&g(e,"omitted","Hue/Saturation's colour ranges: their own hue, saturation and lightness",n);const a=t.master;return{kind:"hueSaturation",...a?.hue?{hue:a.hue}:{},...a?.saturation?{saturation:a.saturation}:{},...a?.lightness?{lightness:a.lightness}:{}}}case"vibrance":return{kind:"vibrance",...t.vibrance?{vibrance:t.vibrance}:{},...t.saturation?{saturation:t.saturation}:{}};case"color balance":{const o=a=>a?[a.cyanRed,a.magentaGreen,a.yellowBlue]:void 0;return{kind:"colorBalance",...t.shadows?{shadows:o(t.shadows)}:{},...t.midtones?{midtones:o(t.midtones)}:{},...t.highlights?{highlights:o(t.highlights)}:{},...t.preserveLuminosity===!1?{preserveLuminosity:!1}:{}}}case"black & white":return t.useTint===!0&&g(e,"omitted","Black & White's tint",n),{kind:"blackAndWhite",...Object.fromEntries(["reds","yellows","greens","cyans","blues","magentas"].filter(o=>t[o]!==void 0).map(o=>[o,t[o]]))};case"photo filter":return{kind:"photoFilter",...t.color?{color:C(e,t.color,n)}:{},...t.density===void 0?{}:{density:T(t.density)},...t.preserveLuminosity===void 0?{}:{preserveLuminosity:t.preserveLuminosity}};case"invert":return{kind:"invert"};case"threshold":return{kind:"threshold",...t.level===void 0?{}:{level:Math.max(1,Math.min(255,Math.round(t.level)))}};case"gradient map":{if(t.gradientType!=="solid"||!t.colorStops){i("a Gradient Map of a noise gradient");return}const o=V({type:"solid",name:t.name??"",colorStops:t.colorStops.map(a=>({...a,location:a.location/4096})),opacityStops:(t.opacityStops??[]).map(a=>({...a,location:a.location/4096}))});return{kind:"gradientMap",gradient:{stops:o.stops.length>=2?o.stops:[...o.stops,...o.stops].slice(0,2)},...t.reverse===!0?{reverse:!0}:{}}}case"exposure":return{kind:"exposure",...t.exposure?{exposure:t.exposure}:{},...t.offset?{offset:t.offset}:{},...t.gamma!==void 0&&t.gamma!==1?{gammaCorrection:t.gamma}:{}};default:{i(`a ${t.type} adjustment: AllyHub's adjustments do not hold it`);return}}}function je(e,s,n){const t=s.text;if(!t)return;const i=e.ppi,o=I=>j(I*i/72),[a=1,d=0,c=0,m=1,l=0,u=0]=t.transform??[],f=Math.sqrt(a*a+d*d),b=Math.atan2(d,a)*180/Math.PI;(Math.abs(f-Math.sqrt(c*c+m*m))>.001||Math.abs(a*c+d*m)>.001)&&g(e,"approximate","its text is skewed or stretched: drawn at its average scale",n);const $=t.style??{};(t.styleRuns?.length??0)>1&&g(e,"approximate",`its ${String(t.styleRuns?.length??0)} style runs: drawn in its first style`,n),(t.paragraphStyleRuns?.length??0)>1&&g(e,"approximate","its paragraphs' own styles: drawn in the first paragraph's",n),t.orientation==="vertical"&&g(e,"approximate","its vertical text: drawn horizontal",n),t.warp?.style!==void 0&&t.warp.style!=="none"&&g(e,"omitted",`its warp (${t.warp.style})`,n);const p={...$,...t.styleRuns?.[0]?.style??{}},x=p.font?.name?fontOf(p.font.name):void 0,w=p.fontSize===void 0?void 0:o(p.fontSize*f);p.fauxBold===!0&&g(e,"approximate","its faux bold: drawn at weight 700",n),p.fauxItalic===!0&&g(e,"approximate","its faux italic: drawn italic",n),p.horizontalScale!==void 0&&Math.abs(p.horizontalScale-1)>.001&&g(e,"omitted","its horizontal scale",n);const S={...x?{font:x.family}:{},...x&&(x.weight!==400||p.fauxBold===!0)?{weight:p.fauxBold===!0?700:x.weight}:{},...x?.italic===!0||p.fauxItalic===!0?{italic:!0}:{},...w===void 0?{}:{size:Math.max(1,Math.min(4096,w))},...p.fillColor?{color:C(e,p.fillColor,n)}:{},...p.tracking?{tracking:Math.max(-1e3,Math.min(1e4,p.tracking))}:{},...p.autoLeading===!1&&p.leading!==void 0?{leading:o(p.leading*f)}:{},...p.fontCaps===2?{capitalization:"allCaps"}:p.fontCaps===1?{capitalization:"smallCaps"}:{},...p.underline===!0?{underline:!0}:{},...p.strikethrough===!0?{strikeThrough:!0}:{}},M={...t.paragraphStyle??{},...t.paragraphStyleRuns?.[0]?.style??{}},r=we(M.justification),y=I=>I===void 0||I===0?void 0:o(I*f),O={...r===void 0||r==="left"?{}:{justification:r},...y(M.firstLineIndent)===void 0?{}:{firstLineIndent:y(M.firstLineIndent)},...y(M.startIndent)===void 0?{}:{leftIndent:Math.max(0,y(M.startIndent)??0)},...y(M.endIndent)===void 0?{}:{rightIndent:Math.max(0,y(M.endIndent)??0)},...y(M.spaceBefore)===void 0?{}:{spaceBefore:y(M.spaceBefore)},...y(M.spaceAfter)===void 0?{}:{spaceAfter:y(M.spaceAfter)}};t.text.includes("")&&g(e,"approximate","its line breaks inside a paragraph: each starts a paragraph, with the paragraph's spacing",n);const h=t.text.replace(/\r\n?/gu,`
2
+ import{writePng as Q}from"@allyhub/measure";import{adjustmentRefusal as fe,refusalOf as pe}from"@allyhub/piece";import{stringify as me}from"yaml";import{psdLib as V}from"./ag-psd.js";import{blendOf as R,gradientOf as X,hexOf as ee,justificationOf as ge,pathOf as te,pxOf as ne,transformPath as ie}from"./map.js";const be=e=>e.slice(e.lastIndexOf("/")+1);function se(e,i,s){const t=n=>e.files.has(n)||(e.o.taken?.(n)??!1);let a=`${i}${s}`;for(let n=2;t(a);n++)a=`${i}-${String(n)}${s}`;return a}export function keyOf(e,i,s){const t=e.normalize("NFKD").replace(/[̀-ͯ]/gu,"").toLowerCase().replace(/[^a-z0-9]+/gu,"-").replace(/^-+|-+$/gu,"").slice(0,48).replace(/-+$/u,"")||i;let a=t;for(let n=2;s.has(a);n++)a=`${t}-${String(n)}`;return s.add(a),a}const T=e=>e===void 0?void 0:Math.round(e*1e3)/10,z=e=>Math.round(e*1e3)/1e3,L=(e,i)=>Math.round(e/i*1e6)/1e6;export function fontOf(e){const[i=e,s=""]=e.split("-"),t=/italic|oblique/iu.test(s),a=s.toLowerCase().replace(/italic|oblique/gu,""),n=/thin|hairline/u.test(a)?100:/extralight|ultralight/u.test(a)?200:/semibold|demibold/u.test(a)?600:/extrabold|ultrabold/u.test(a)?800:/black|heavy/u.test(a)?900:a.includes("light")?300:a.includes("medium")?500:a.includes("bold")?700:400;return{family:i.replace(/(PS)?MT$|PS$/u,"").replace(/([a-z])([A-Z])/gu,"$1 $2").trim()||i,weight:n,italic:t}}const g=(e,i,s,t)=>{e.notes.push({how:i,what:s,board:e.board,...t===void 0?{}:{layer:t}})};function ye(e,i){const s=e.imageData;if(!s||s.width===0||s.height===0)return;const t=(e.left??0)-i.frame.left,a=(e.top??0)-i.frame.top,n=Math.max(0,t),o=Math.max(0,a),d=Math.min(i.frame.width,t+s.width),c=Math.min(i.frame.height,a+s.height);if(d<=n||c<=o)return;const p=d-n,h=c-o,u=new Uint8Array(p*h*4);let l=!1;for(let b=0;b<h;b++)for(let v=0;v<p;v++){const f=((b+o-a)*s.width+(v+n-t))*4,x=(b*p+v)*4;u[x]=s.data[f]??0,u[x+1]=s.data[f+1]??0,u[x+2]=s.data[f+2]??0,u[x+3]=s.data[f+3]??0,u[x+3]!==0&&(l=!0)}if(l)return{img:{width:p,height:h,data:u},box:[n,o,p,h]}}function oe(e,i,s,t){const a=se(e,`${e.board}-${i}${s}`,".png");e.files.set(a,new Uint8Array(Q(t)));let o=`${e.board} ${i} ${s}`.split(/[^A-Za-z0-9]+/u).filter(c=>c!=="").map((c,p)=>p===0?c.toLowerCase():c.charAt(0).toUpperCase()+c.slice(1)).join("");/^[A-Za-z_]/u.test(o)||(o=`_${o}`);const d=o;for(let c=2;e.imports.some(p=>p.name===o);c++)o=`${d}${String(c)}`;return e.imports.push({name:o,path:`./${a}`}),o}class U{name;constructor(i){this.name=i}}const we=(e,i,s)=>[L(i[0]??0,s.frame.width),L(i[1]??0,s.frame.height),L(e.width,s.frame.width),L(e.height,s.frame.height)];function C(e,i,s){const t=ee(i);return t.converted&&g(e,"approximate",`a ${t.converted} colour converted to sRGB without its profile`,s),t.hex}function ae(e,i,s,t={}){if(!i||!("colorStops"in i))return;const a=X(i);a.converted&&g(e,"approximate",`a gradient's ${a.converted} colours converted to sRGB without a profile`,s);const n=t.style;return{stops:a.stops.length>=2?a.stops:[...a.stops,...a.stops].slice(0,2),...n===void 0||n==="linear"?{}:{style:n},...t.angle===void 0||t.angle===90?{}:{angle:z(t.angle)},...t.scale===void 0||Math.abs(t.scale-1)<1e-6?{}:{scale:Math.max(10,Math.min(1e3,Math.round(t.scale*100)))},...t.reverse===!0?{reverse:!0}:{}}}function re(e,i,s){if(i){if(i.type==="color")return{color:C(e,i.color,s)};if(i.type==="solid"){const t=ae(e,i,s,{...i.style===void 0?{}:{style:i.style},...i.angle===void 0?{}:{angle:i.angle},...i.scale===void 0?{}:{scale:i.scale},...i.reverse===void 0?{}:{reverse:i.reverse}});return t?{gradient:t}:void 0}}}const xe=e=>e===void 0||e.name==="Linear"||Array.isArray(e.curve)&&e.curve.length<=2;function ke(e,i,s){const t={},a=e.ppi,n=i.scale??1,o=r=>{const y=ne(r,a);return y===void 0?void 0:Math.max(0,Math.min(1e3,z(y*n)))},d=r=>r?.present===!1?void 0:r,c=r=>({...r.enabled===!1?{enabled:!1}:{},...R(r.blendMode)===void 0?{}:{blendMode:R(r.blendMode)},...r.opacity===void 0?{}:{opacity:T(r.opacity)}}),p=(r,y)=>{const O=y?.filter(B=>B.present!==!1);return O&&O.length>1&&g(e,"omitted",`${String(O.length-1)} more ${r} effects: AllyHub's layer has one of each`,s),O?.[0]},h=(r,y)=>{xe(y)||g(e,"omitted",`the ${r}'s contour (${y?.name??"custom"}): drawn linear`,s)},u=p("drop shadow",i.dropShadow);u&&(h("drop shadow",u.contour),t.dropShadow={...c(u),...u.color?{color:C(e,u.color,s)}:{},...u.angle===void 0?{}:{angle:z(u.angle)},...o(u.distance)===void 0?{}:{distance:o(u.distance)},...u.choke?{spread:Math.min(100,z(u.choke.value))}:{},...o(u.size)===void 0?{}:{size:o(u.size)}});const l=p("inner shadow",i.innerShadow);l&&(h("inner shadow",l.contour),t.innerShadow={...c(l),...l.color?{color:C(e,l.color,s)}:{},...l.angle===void 0?{}:{angle:z(l.angle)},...o(l.distance)===void 0?{}:{distance:o(l.distance)},...l.choke?{choke:Math.min(100,z(l.choke.value))}:{},...o(l.size)===void 0?{}:{size:o(l.size)}});const b=d(i.outerGlow);if(b){const r=b;h("outer glow",r.contour),r.gradient&&g(e,"omitted","the outer glow's gradient: drawn in its colour",s),t.outerGlow={...c(r),...r.color?{color:C(e,r.color,s)}:{},...r.choke?{spread:Math.min(100,z(r.choke.value))}:{},...o(r.size)===void 0?{}:{size:o(r.size)}}}const v=d(i.innerGlow);if(v){const r=v;h("inner glow",r.contour),r.gradient&&g(e,"omitted","the inner glow's gradient: drawn in its colour",s),t.innerGlow={...c(r),...r.color?{color:C(e,r.color,s)}:{},...r.choke?{choke:Math.min(100,z(r.choke.value))}:{},...o(r.size)===void 0?{}:{size:o(r.size)},...r.source?{source:r.source}:{}}}const f=p("stroke",i.stroke);f&&(f.fillType!==void 0&&f.fillType!=="color"&&g(e,"approximate",`the stroke's ${f.fillType} fill: drawn in its first colour`,s),t.stroke={...c(f),...f.color?{color:C(e,f.color,s)}:{},...o(f.size)===void 0?{}:{size:o(f.size)},...f.position?{position:f.position}:{}});const x=p("colour overlay",i.solidFill);x&&(t.colorOverlay={...c(x),...x.color?{color:C(e,x.color,s)}:{}});const k=p("gradient overlay",i.gradientOverlay);if(k){const r=ae(e,k.gradient,s,{...k.type===void 0?{}:{style:k.type},...k.angle===void 0?{}:{angle:k.angle},...k.scale===void 0?{}:{scale:k.scale},...k.reverse===void 0?{}:{reverse:k.reverse}});r?t.gradientOverlay={...c(k),gradient:r}:g(e,"omitted","a gradient overlay of a noise gradient",s)}d(i.patternOverlay)&&g(e,"omitted","the pattern overlay: its pattern's pixels are the file's, which ag-psd does not read out",s);const j=d(i.satin);if(j){const r=j;h("satin",r.contour),t.satin={...c(r),...r.color?{color:C(e,r.color,s)}:{},...r.angle===void 0?{}:{angle:z(r.angle)},...o(r.distance)===void 0?{}:{distance:o(r.distance)},...o(r.size)===void 0?{}:{size:o(r.size)},...r.invert===void 0?{}:{invert:r.invert}}}const $=d(i.bevel);if($){const r=$,y=r.style===void 0?void 0:{"inner bevel":"innerBevel","outer bevel":"outerBevel",emboss:"emboss","pillow emboss":"pillowEmboss","stroke emboss":"strokeEmboss"}[r.style],O=r.technique===void 0?void 0:{smooth:"smooth","chisel hard":"chiselHard","chisel soft":"chiselSoft"}[r.technique];t.bevelEmboss={...r.enabled===!1?{enabled:!1}:{},...y?{style:y}:{},...O?{technique:O}:{},...r.strength===void 0?{}:{depth:Math.max(1,Math.min(1e3,Math.round(r.strength*100)))},...r.direction?{direction:r.direction}:{},...o(r.size)===void 0?{}:{size:o(r.size)},...o(r.soften)===void 0?{}:{soften:o(r.soften)},...r.angle===void 0?{}:{angle:z(r.angle)},...r.altitude===void 0?{}:{altitude:z(r.altitude)},...R(r.highlightBlendMode)?{highlightMode:R(r.highlightBlendMode)}:{},...r.highlightColor?{highlightColor:C(e,r.highlightColor,s)}:{},...r.highlightOpacity===void 0?{}:{highlightOpacity:T(r.highlightOpacity)},...R(r.shadowBlendMode)?{shadowMode:R(r.shadowBlendMode)}:{},...r.shadowColor?{shadowColor:C(e,r.shadowColor,s)}:{},...r.shadowOpacity===void 0?{}:{shadowOpacity:T(r.shadowOpacity)}}}if(i.disabled===!0)for(const r of Object.values(t))r.enabled=!1;return Object.keys(t).length>0?t:void 0}function $e(e,i,s,t){const a={...i};for(let n=0;n<24;n++){const o=pe(a,s);if(o===void 0)break;const d=/effects\.(\w+)/u.exec(o)?.[1],c=a.effects,p=/^effects\.(dropShadow|outerGlow)\.blendMode/u.exec(o)?.[1],h=p===void 0?void 0:c?.[p];if(p&&c&&typeof h=="object"&&h!==null){c[p]={...h,blendMode:"normal"},g(e,"approximate",`the ${p}'s blend mode: AllyHub draws an effect under its layer as normal (a layer's filter cannot read what lies under it), so it is written normal`,t);continue}if(d&&c&&d in c){const u=Object.fromEntries(Object.entries(c).filter(([l])=>l!==d));Object.keys(u).length>0?a.effects=u:delete a.effects,g(e,"omitted",`the ${d} effect: ${o}`,t);continue}if(o.startsWith("an adjustment has no effects")||c&&o.includes("stroke")){if(c&&o.includes("stroke")){const u=Object.fromEntries(Object.entries(c).filter(([l])=>l!=="stroke"));Object.keys(u).length>0?a.effects=u:delete a.effects,g(e,"omitted",`the stroke effect: ${o}`,t)}else delete a.effects,g(e,"omitted",`its effects: ${o}`,t);continue}if(o.includes("fillOpacity")&&a.fillOpacity!==void 0){g(e,"approximate",`its fill opacity ${JSON.stringify(a.fillOpacity)}: ${o}; drawn at 100`,t),delete a.fillOpacity;continue}if(o.includes("blendMode")&&a.blendMode!==void 0){g(e,"approximate",`its blend mode: ${o}; drawn as normal`,t),a.blendMode=s==="group"?"passThrough":"normal",s!=="group"&&delete a.blendMode;continue}g(e,"omitted",`its style: ${o}`,t),delete a.effects,delete a.blendMode,delete a.fillOpacity}return a}function F(e,i,s,t){const a=i.mask??i.realMask,n=a?.imageData&&a.imageData.width>0&&a.imageData.height>0?a:void 0,o=i.vectorMask&&i.vectorMask.paths.length>0?i.vectorMask:void 0,[d,c,p,h]=t.box.map(Math.round),u=(l,b,v)=>({...l===void 0||Math.abs(l-1)<1e-6?{}:{density:T(l)},...b===void 0||b===0?{}:{feather:Math.min(1e3,z(b))},...v===!0?{enabled:!1}:{}});if(n?.imageData){const l=n.imageData,b=new Uint8Array(p*h*4),v=n.defaultColor??0,f=(n.left??0)-e.frame.left,x=(n.top??0)-e.frame.top;for(let k=0;k<h;k++)for(let j=0;j<p;j++){const $=j+d-f,r=k+c-x,y=$>=0&&r>=0&&$<l.width&&r<l.height?l.data[(r*l.width+$)*4]??0:v,O=(k*p+j)*4;b[O]=y,b[O+1]=y,b[O+2]=y,b[O+3]=255}return o&&g(e,"omitted","its vector mask, beside its raster mask: AllyHub's layer has one mask",s),(n.userMaskFeather??0)>0&&g(e,"approximate","its mask's feather: Photoshop's radius taken as a Gaussian's standard deviation",s),{src:new U(oe(e,s,".mask",{width:p,height:h,data:b})),mode:"luminance",...u(n.userMaskDensity,n.userMaskFeather,n.disabled)}}if(o){const l=ie(te(o.paths),[1,0,0,1,-e.frame.left-d,-e.frame.top-c]);return o.paths.length>1&&o.paths.some(b=>b.fillRule==="even-odd"||b.operation!==void 0&&b.operation!=="combine")&&g(e,"approximate","its vector mask's subpaths subtract, intersect or exclude, or fill even-odd: drawn as one path, non-zero",s),(i.mask?.vectorMaskFeather??0)>0&&g(e,"approximate","its vector mask's feather: Photoshop's radius taken as a Gaussian's standard deviation",s),{path:l,...o.invert===!0?{invert:!0}:{},...u(i.mask?.vectorMaskDensity,i.mask?.vectorMaskFeather,o.disable)}}}function G(e,i,s,t){const a=R(i.blendMode);i.blendMode!==void 0&&a===void 0&&g(e,"approximate",`its blend mode ${i.blendMode} (Photoshop's 3D): drawn as normal`,t);const n=T(i.opacity),o=T(i.fillOpacity),d=i.effects?ke(e,i.effects,t):void 0;return $e(e,{...a===void 0||a===(s==="group"?"passThrough":"normal")?{}:{blendMode:a},...n===void 0||n===100?{}:{opacity:n},...o===void 0||o===100?{}:{fillOpacity:o},...i.clipping===!0?{clipping:!0}:{},...d?{effects:d}:{},...i.hidden===!0?{visible:!1}:{}},s,t)}function Me(e,i,s){const t=i.adjustment;if(!t)return;const a=n=>{g(e,"omitted",n,s)};switch(t.type){case"levels":{const n=["rgb","red","green","blue"],o={kind:"levels"};return(t.channels??[]).slice(0,4).forEach((d,c)=>{const p=n[c];if(!p)return;const h={...d.shadowInput===0?{}:{inputBlack:d.shadowInput},...d.highlightInput===255?{}:{inputWhite:d.highlightInput},...d.midtoneInput===1?{}:{gamma:Math.max(.1,Math.min(9.99,d.midtoneInput))},...d.shadowOutput===0?{}:{outputBlack:d.shadowOutput},...d.highlightOutput===255?{}:{outputWhite:d.highlightOutput}};Object.keys(h).length>0&&(o[p]=h)}),o}case"curves":{if(t.values?.some(d=>d.length>0)){a("a Curves drawn with the pencil (a table, not points): AllyHub's curves take points");return}const n=["rgb","red","green","blue"],o={kind:"curves"};return(t.channels??[]).slice(0,4).forEach((d,c)=>{const p=n[c];!p||d.length<2||(o[p]=d.slice(0,16).map(h=>[Math.round(h.input),Math.round(h.output)]))}),o}case"brightness/contrast":return t.useLegacy===!1&&g(e,"approximate","Brightness/Contrast's current algorithm, which Photoshop does not publish: drawn by the legacy one",s),{kind:"brightnessContrast",...t.brightness?{brightness:Math.max(-150,Math.min(150,t.brightness))}:{},...t.contrast?{contrast:Math.max(-50,Math.min(100,t.contrast))}:{}};case"hue/saturation":{if(t.colorize===!0){a("a colorizing Hue/Saturation: AllyHub does not draw colorize yet");return}["reds","yellows","greens","cyans","blues","magentas"].some(d=>{const c=t[d];return c!==void 0&&(c.hue!==0||c.saturation!==0||c.lightness!==0)})&&g(e,"omitted","Hue/Saturation's colour ranges: their own hue, saturation and lightness",s);const o=t.master;return{kind:"hueSaturation",...o?.hue?{hue:o.hue}:{},...o?.saturation?{saturation:o.saturation}:{},...o?.lightness?{lightness:o.lightness}:{}}}case"vibrance":return{kind:"vibrance",...t.vibrance?{vibrance:t.vibrance}:{},...t.saturation?{saturation:t.saturation}:{}};case"color balance":{const n=o=>o?[o.cyanRed,o.magentaGreen,o.yellowBlue]:void 0;return{kind:"colorBalance",...t.shadows?{shadows:n(t.shadows)}:{},...t.midtones?{midtones:n(t.midtones)}:{},...t.highlights?{highlights:n(t.highlights)}:{},...t.preserveLuminosity===!1?{preserveLuminosity:!1}:{}}}case"black & white":return t.useTint===!0&&g(e,"omitted","Black & White's tint",s),{kind:"blackAndWhite",...Object.fromEntries(["reds","yellows","greens","cyans","blues","magentas"].filter(n=>t[n]!==void 0).map(n=>[n,t[n]]))};case"photo filter":return{kind:"photoFilter",...t.color?{color:C(e,t.color,s)}:{},...t.density===void 0?{}:{density:T(t.density)},...t.preserveLuminosity===void 0?{}:{preserveLuminosity:t.preserveLuminosity}};case"invert":return{kind:"invert"};case"threshold":return{kind:"threshold",...t.level===void 0?{}:{level:Math.max(1,Math.min(255,Math.round(t.level)))}};case"gradient map":{if(t.gradientType!=="solid"||!t.colorStops){a("a Gradient Map of a noise gradient");return}const n=X({type:"solid",name:t.name??"",colorStops:t.colorStops.map(o=>({...o,location:o.location/4096})),opacityStops:(t.opacityStops??[]).map(o=>({...o,location:o.location/4096}))});return{kind:"gradientMap",gradient:{stops:n.stops.length>=2?n.stops:[...n.stops,...n.stops].slice(0,2)},...t.reverse===!0?{reverse:!0}:{}}}case"exposure":return{kind:"exposure",...t.exposure?{exposure:t.exposure}:{},...t.offset?{offset:t.offset}:{},...t.gamma!==void 0&&t.gamma!==1?{gammaCorrection:t.gamma}:{}};default:{a(`a ${t.type} adjustment: AllyHub's adjustments do not hold it`);return}}}function ve(e,i,s){const t=i.text;if(!t)return;const a=e.ppi,n=S=>z(S*a/72),[o=1,d=0,c=0,p=1,h=0,u=0]=t.transform??[],l=Math.sqrt(o*o+d*d),b=Math.atan2(d,o)*180/Math.PI;(Math.abs(l-Math.sqrt(c*c+p*p))>.001||Math.abs(o*c+d*p)>.001)&&g(e,"approximate","its text is skewed or stretched: drawn at its average scale",s);const v=t.style??{};(t.styleRuns?.length??0)>1&&g(e,"approximate",`its ${String(t.styleRuns?.length??0)} style runs: drawn in its first style`,s),(t.paragraphStyleRuns?.length??0)>1&&g(e,"approximate","its paragraphs' own styles: drawn in the first paragraph's",s),t.orientation==="vertical"&&g(e,"approximate","its vertical text: drawn horizontal",s),t.warp?.style!==void 0&&t.warp.style!=="none"&&g(e,"omitted",`its warp (${t.warp.style})`,s);const f={...v,...t.styleRuns?.[0]?.style??{}},x=f.font?.name?fontOf(f.font.name):void 0,k=f.fontSize===void 0?void 0:n(f.fontSize*l);f.fauxBold===!0&&g(e,"approximate","its faux bold: drawn at weight 700",s),f.fauxItalic===!0&&g(e,"approximate","its faux italic: drawn italic",s),f.horizontalScale!==void 0&&Math.abs(f.horizontalScale-1)>.001&&g(e,"omitted","its horizontal scale",s);const j={...x?{font:x.family}:{},...x&&(x.weight!==400||f.fauxBold===!0)?{weight:f.fauxBold===!0?700:x.weight}:{},...x?.italic===!0||f.fauxItalic===!0?{italic:!0}:{},...k===void 0?{}:{size:Math.max(1,Math.min(4096,k))},...f.fillColor?{color:C(e,f.fillColor,s)}:{},...f.tracking?{tracking:Math.max(-1e3,Math.min(1e4,f.tracking))}:{},...f.autoLeading===!1&&f.leading!==void 0?{leading:n(f.leading*l)}:{},...f.fontCaps===2?{capitalization:"allCaps"}:f.fontCaps===1?{capitalization:"smallCaps"}:{},...f.underline===!0?{underline:!0}:{},...f.strikethrough===!0?{strikeThrough:!0}:{}},$={...t.paragraphStyle??{},...t.paragraphStyleRuns?.[0]?.style??{}},r=ge($.justification),y=S=>S===void 0||S===0?void 0:n(S*l),O={...r===void 0||r==="left"?{}:{justification:r},...y($.firstLineIndent)===void 0?{}:{firstLineIndent:y($.firstLineIndent)},...y($.startIndent)===void 0?{}:{leftIndent:Math.max(0,y($.startIndent)??0)},...y($.endIndent)===void 0?{}:{rightIndent:Math.max(0,y($.endIndent)??0)},...y($.spaceBefore)===void 0?{}:{spaceBefore:y($.spaceBefore)},...y($.spaceAfter)===void 0?{}:{spaceAfter:y($.spaceAfter)}};t.text.includes("")&&g(e,"approximate","its line breaks inside a paragraph: each starts a paragraph, with the paragraph's spacing",s);const B=t.text.replace(/\r\n?/gu,`
3
3
  `).replaceAll("",`
4
- `),k=`${e.o.id.replace(/\//gu,".")}.${e.board}.${n}`;(e.script[e.board]??={})[n]=h,g(e,"approximate","type: Chrome draws its words in the font of its name where the project has it, by CSS's line breaking: Photoshop's composer and its fallback fonts may set them otherwise",n);const v=(I,B)=>[a*I+c*B+l-e.frame.left,d*I+m*B+u-e.frame.top],z=e.frame.width,A=e.frame.height,D={};if(t.shapeType==="box"&&t.boxBounds&&t.boxBounds.length>=4){const[I=0,B=0,E=0,pe=0]=t.boxBounds,[F,G]=v(I,B),_=(E-I)*f,K=(pe-B)*f,N=Math.max(0,F),J=Math.max(0,G),q=Math.min(z,F+_),Z=Math.min(A,G+K);(N!==F||J!==G||q!==F+_||Z!==G+K)&&g(e,"approximate","its text box reaches past the board: cut to it",n),q>N&&Z>J&&(D.box=[L(N,z),L(J,A),L(q-N,z),L(Z-J,A)])}else{const[I,B]=v(0,0),E=B-(w??12)*.9;g(e,"approximate","point text: its first baseline put 0.9 of its size under the top AllyHub places it from",n),D.position=[L(Math.max(0,Math.min(z,I)),z),L(Math.max(0,Math.min(A,E)),A)]}return Math.abs(b)>.001&&(D.transform={rotation:j(b)}),{textItem:{contents:new U(`ctx.s(${JSON.stringify(k)})`),...Object.keys(S).length>0?{characterStyle:S}:{},...Object.keys(O).length>0?{paragraphStyle:O}:{}},...D}}function ze(e,s,n){const t=s.vectorMask?.paths??[];if(t.length===0)return;const i=s.vectorStroke,a=i?.fillEnabled!==!1?de(e,s.vectorFill,n):null;if(a===void 0||a&&"gradient"in a&&(a.gradient.style==="angle"||a.gradient.style==="diamond"))return;let d=null;if(i?.strokeEnabled===!0){const c=i.content?.type==="color"?C(e,i.content.color,n):void 0;i.content&&i.content.type!=="color"&&g(e,"approximate","its stroke's gradient or pattern: drawn black",n);const m=te(i.lineWidth,e.ppi);d={...c===void 0?{}:{color:c},...m===void 0?{}:{width:Math.min(1e3,j(m))},...i.lineAlignment?{alignment:i.lineAlignment}:{},...i.lineDashSet&&i.lineDashSet.length>0?{dashes:i.lineDashSet.slice(0,8).map(l=>Math.min(1e3,j(l.value)))}:{},...i.lineCapType?{cap:i.lineCapType}:{},...i.lineJoinType?{join:i.lineJoinType}:{},...i.opacity===void 0||i.opacity===1?{}:{opacity:T(i.opacity)}}}return t.length>1&&t.some(c=>c.fillRule==="even-odd"||c.operation!==void 0&&c.operation!=="combine")&&g(e,"approximate","its path's subpaths subtract, intersect or exclude, or fill even-odd: drawn as one path, non-zero",n),{shape:"path",path:ne(ee(t),[1,0,0,1,-e.frame.left,-e.frame.top]),fill:a,...d?{stroke:d}:{}}}function ce(e){return e.children?"group":e.text?"type":e.placedLayer?"smartObject":e.adjustment?"adjustment":e.vectorFill&&(e.vectorStroke||e.vectorOrigination||e.vectorMask)?"shape":e.vectorFill?"fill":"pixel"}function le(e,s,n){const t=Ie(e,s,n),i=(s.name??"").replace(/\s+/gu," ").trim();return t&&i!==""&&i!==t.key?{...t,name:i}:t}function Ie(e,s,n){const t=ce(s),i=s.name??"",o=keyOf(i,`${t==="unknown"?"layer":t}-${String(n+1)}`,e.taken),a=l=>{e.kinds[l]=(e.kinds[l]??0)+1},d=ke(s,e),c=l=>{if(l!==void 0&&g(e,"pixels",l,o),!d){g(e,"omitted",l===void 0?"a layer with no pixels on the board: it draws nothing":"it has no pixels on the board to keep",o);return}a("pixel");const u=R(e,s,"pixel",o),f=H(e,s,o,{box:d.box});return{fn:"picture",key:o,kind:"pixel",pixels:d.img,opts:{key:o,src:new U(ae(e,o,"",d.img)),box:$e(d.img,d.box,e),fit:"fill",...u,...f?{mask:f}:{}}}},m={box:[0,0,e.frame.width,e.frame.height]};switch(t){case"group":{a("group");const l=(s.children??[]).map((p,x)=>le(e,p,x)).filter(p=>p!==void 0);let u=R(e,s,"group",o);const f=H(e,s,o,m),b=(u.opacity??100)<100||(u.fillOpacity??100)<100||u.effects!==void 0||f!==void 0,$=l.some(p=>p.kind==="adjustment"||p.opts.blendMode!==void 0&&p.opts.blendMode!=="normal");return(u.blendMode??"passThrough")==="passThrough"&&b&&$&&(g(e,"approximate","a pass-through group that fades, is masked or has effects over layers that blend through it: drawn as a normal group",o),u={...u,blendMode:"normal"}),{fn:"group",key:o,kind:"group",opts:{key:o,...u,...f?{mask:f}:{}},layers:ue(e,l)}}case"type":{const l=je(e,s,o);if(!l)return c("a type layer whose text could not be read");a("type");const u=R(e,s,"type",o),f=H(e,s,o,m);return{fn:"textLayer",key:o,kind:"type",...d?{pixels:d.img}:{},opts:{key:o,...l,...u,...f?{mask:f}:{}}}}case"smartObject":return c("a smart object: kept as its pixels; its embedded or linked file is not");case"adjustment":{const l=Se(e,s,o);if(!l)return;const u=ge(l);if(u){g(e,"omitted",`the adjustment: ${u}`,o);return}a("adjustment");const f=R(e,s,"adjustment",o),b=H(e,s,o,m);return{fn:"adjustment",key:o,kind:"adjustment",opts:{key:o,...l,...f,...b?{mask:b}:{}}}}case"shape":{const l=ze(e,s,o);if(!l)return c("a shape whose fill AllyHub's shape does not draw (a pattern, a noise, angle or diamond gradient): kept as its pixels");a("shape");const u=R(e,s,"shape",o),f=s.mask?.imageData?H(e,Object.fromEntries(Object.entries(s).filter(([b])=>b!=="vectorMask")),o,m):void 0;return{fn:"shape",key:o,kind:"shape",...d?{pixels:d.img}:{},opts:{key:o,...l,...u,...f?{mask:f}:{}}}}case"fill":{const l=de(e,s.vectorFill,o);if(!l||"gradient"in l&&l.gradient.style==="diamond")return c("a fill layer of a pattern, a noise or diamond gradient: kept as its pixels");a("fill");const u=R(e,s,"fill",o),f=H(e,s,o,m);return{fn:"fill",key:o,kind:"fill",...d?{pixels:d.img}:{},opts:{key:o,fill:l,...u,...f?{mask:f}:{}}}}default:return c()}}function ue(e,s){const n=[];let t;for(const i of s){if(!(i.opts.clipping===!0)){t=i,n.push(i);continue}if(t!==void 0&&(t.kind==="pixel"||t.kind==="shape"||t.kind==="fill")&&t.opts.mask===void 0&&t.opts.transform===void 0){n.push(i);continue}const d={...i.opts};if(delete d.clipping,i.fn==="picture"&&t?.pixels&&i.pixels){const c=d.src,m=d.box,l=e.frame.width,u=e.frame.height,f=Math.round((m[0]??0)*l),b=Math.round((m[1]??0)*u),$=t.pixels,p=t.opts.box,x=Math.round((p?.[0]??0)*l),w=Math.round((p?.[1]??0)*u),S=new Uint8Array(i.pixels.data);for(let r=0;r<i.pixels.height;r++)for(let y=0;y<i.pixels.width;y++){const O=y+f-x,h=r+b-w,k=O>=0&&h>=0&&O<$.width&&h<$.height?$.data[(h*$.width+O)*4+3]??0:0,v=(r*i.pixels.width+y)*4+3;S[v]=Math.round((S[v]??0)*k/255)}const M=e.imports.find(r=>r.name===c.name)?.path.replace(/^\.\//u,"");M&&e.files.set(M,new Uint8Array(Q({...i.pixels,data:S}))),g(e,"pixels",`clipped to ${t.key}, which AllyHub cannot clip to (${t.kind==="type"?"a type layer's glyphs":"a masked, turned or component base"}): its pixels cut by the base's own`,i.key),n.push({...i,opts:d});continue}g(e,"approximate",`clipped to ${t?.key??"nothing"}, which AllyHub cannot clip to: drawn unclipped`,i.key),n.push({...i,opts:d})}return n}const fe=/^[A-Za-z_$][\w$]*$/u;function W(e,s){if(e instanceof U)return e.name;if(e===null||typeof e!="object")return JSON.stringify(e);const n=s+" ",t=Array.isArray(e)?e.map(d=>W(d,n)):Object.entries(e).filter(([,d])=>d!==void 0).map(([d,c])=>`${fe.test(d)?d:JSON.stringify(d)}: ${W(c,n)}`),[i,o]=Array.isArray(e)?["[","]"]:["{","}"];if(t.length===0)return`${i}${o}`;const a=`${i}${Array.isArray(e)?"":" "}${t.join(", ")}${Array.isArray(e)?"":" "}${o}`;return a.length+s.length<=80&&!a.includes(`
5
- `)?a:`${i}
6
- ${t.map(d=>`${n}${d},`).join(`
4
+ `),m=`${e.o.id.replace(/\//gu,".")}.${e.board}.${s}`;(e.script[e.board]??={})[s]=B,g(e,"approximate","type: Chrome draws its words in the font of its name where the project has it, by CSS's line breaking: Photoshop's composer and its fallback fonts may set them otherwise",s);const w=(S,D)=>[o*S+c*D+h-e.frame.left,d*S+p*D+u-e.frame.top],M=e.frame.width,I=e.frame.height,A={};if(t.shapeType==="box"&&t.boxBounds&&t.boxBounds.length>=4){const[S=0,D=0,P=0,q=0]=t.boxBounds,[H,N]=w(S,D),K=(P-S)*l,Y=(q-D)*l,E=Math.max(0,H),J=Math.max(0,N),Z=Math.min(M,H+K),_=Math.min(I,N+Y);(E!==H||J!==N||Z!==H+K||_!==N+Y)&&g(e,"approximate","its text box reaches past the board: cut to it",s),Z>E&&_>J&&(A.box=[L(E,M),L(J,I),L(Z-E,M),L(_-J,I)])}else{const[S,D]=w(0,0),P=D-(k??12)*.9;g(e,"approximate","point text: its first baseline put 0.9 of its size under the top AllyHub places it from",s),A.position=[L(Math.max(0,Math.min(M,S)),M),L(Math.max(0,Math.min(I,P)),I)]}return Math.abs(b)>.001&&(A.transform={rotation:z(b)}),{textItem:{contents:new U(`ctx.s(${JSON.stringify(m)})`),...Object.keys(j).length>0?{characterStyle:j}:{},...Object.keys(O).length>0?{paragraphStyle:O}:{}},...A}}function Oe(e,i,s){const t=i.vectorMask?.paths??[];if(t.length===0)return;const a=i.vectorStroke,o=a?.fillEnabled!==!1?re(e,i.vectorFill,s):null;if(o===void 0||o&&"gradient"in o&&(o.gradient.style==="angle"||o.gradient.style==="diamond"))return;let d=null;if(a?.strokeEnabled===!0){const c=a.content?.type==="color"?C(e,a.content.color,s):void 0;a.content&&a.content.type!=="color"&&g(e,"approximate","its stroke's gradient or pattern: drawn black",s);const p=ne(a.lineWidth,e.ppi);d={...c===void 0?{}:{color:c},...p===void 0?{}:{width:Math.min(1e3,z(p))},...a.lineAlignment?{alignment:a.lineAlignment}:{},...a.lineDashSet&&a.lineDashSet.length>0?{dashes:a.lineDashSet.slice(0,8).map(h=>Math.min(1e3,z(h.value)))}:{},...a.lineCapType?{cap:a.lineCapType}:{},...a.lineJoinType?{join:a.lineJoinType}:{},...a.opacity===void 0||a.opacity===1?{}:{opacity:T(a.opacity)}}}return t.length>1&&t.some(c=>c.fillRule==="even-odd"||c.operation!==void 0&&c.operation!=="combine")&&g(e,"approximate","its path's subpaths subtract, intersect or exclude, or fill even-odd: drawn as one path, non-zero",s),{shape:"path",path:ie(te(t),[1,0,0,1,-e.frame.left,-e.frame.top]),fill:o,...d?{stroke:d}:{}}}function de(e){return e.children?"group":e.text?"type":e.placedLayer?"smartObject":e.adjustment?"adjustment":e.vectorFill&&(e.vectorStroke||e.vectorOrigination||e.vectorMask)?"shape":e.vectorFill?"fill":"pixel"}function ce(e,i,s){const t=Se(e,i,s),a=(i.name??"").replace(/\s+/gu," ").trim();return t&&a!==""&&a!==t.key?{...t,name:a}:t}function Se(e,i,s){const t=de(i),a=i.name??"",n=keyOf(a,`${t==="unknown"?"layer":t}-${String(s+1)}`,e.taken),o=h=>{e.kinds[h]=(e.kinds[h]??0)+1},d=ye(i,e),c=h=>{if(h!==void 0&&g(e,"pixels",h,n),!d){g(e,"omitted",h===void 0?"a layer with no pixels on the board: it draws nothing":"it has no pixels on the board to keep",n);return}o("pixel");const u=G(e,i,"pixel",n),l=F(e,i,n,{box:d.box});return{fn:"picture",key:n,kind:"pixel",pixels:d.img,opts:{key:n,src:new U(oe(e,n,"",d.img)),box:we(d.img,d.box,e),fit:"fill",...u,...l?{mask:l}:{}}}},p={box:[0,0,e.frame.width,e.frame.height]};switch(t){case"group":{o("group");const h=(i.children??[]).map((f,x)=>ce(e,f,x)).filter(f=>f!==void 0);let u=G(e,i,"group",n);const l=F(e,i,n,p),b=(u.opacity??100)<100||(u.fillOpacity??100)<100||u.effects!==void 0||l!==void 0,v=h.some(f=>f.kind==="adjustment"||f.opts.blendMode!==void 0&&f.opts.blendMode!=="normal");return(u.blendMode??"passThrough")==="passThrough"&&b&&v&&(g(e,"approximate","a pass-through group that fades, is masked or has effects over layers that blend through it: drawn as a normal group",n),u={...u,blendMode:"normal"}),{fn:"group",key:n,kind:"group",opts:{key:n,...u,...l?{mask:l}:{}},layers:le(e,h)}}case"type":{const h=ve(e,i,n);if(!h)return c("a type layer whose text could not be read");o("type");const u=G(e,i,"type",n),l=F(e,i,n,p);return{fn:"textLayer",key:n,kind:"type",...d?{pixels:d.img}:{},opts:{key:n,...h,...u,...l?{mask:l}:{}}}}case"smartObject":return c("a smart object: kept as its pixels; its embedded or linked file is not");case"adjustment":{const h=Me(e,i,n);if(!h)return;const u=fe(h);if(u){g(e,"omitted",`the adjustment: ${u}`,n);return}o("adjustment");const l=G(e,i,"adjustment",n),b=F(e,i,n,p);return{fn:"adjustment",key:n,kind:"adjustment",opts:{key:n,...h,...l,...b?{mask:b}:{}}}}case"shape":{const h=Oe(e,i,n);if(!h)return c("a shape whose fill AllyHub's shape does not draw (a pattern, a noise, angle or diamond gradient): kept as its pixels");o("shape");const u=G(e,i,"shape",n),l=i.mask?.imageData?F(e,Object.fromEntries(Object.entries(i).filter(([b])=>b!=="vectorMask")),n,p):void 0;return{fn:"shape",key:n,kind:"shape",...d?{pixels:d.img}:{},opts:{key:n,...h,...u,...l?{mask:l}:{}}}}case"fill":{const h=re(e,i.vectorFill,n);if(!h||"gradient"in h&&h.gradient.style==="diamond")return c("a fill layer of a pattern, a noise or diamond gradient: kept as its pixels");o("fill");const u=G(e,i,"fill",n),l=F(e,i,n,p);return{fn:"fill",key:n,kind:"fill",...d?{pixels:d.img}:{},opts:{key:n,fill:h,...u,...l?{mask:l}:{}}}}default:return c()}}function le(e,i){const s=[];let t;for(const a of i){if(!(a.opts.clipping===!0)){t=a,s.push(a);continue}if(t!==void 0&&(t.kind==="pixel"||t.kind==="shape"||t.kind==="fill")&&t.opts.mask===void 0&&t.opts.transform===void 0){s.push(a);continue}const d={...a.opts};if(delete d.clipping,a.fn==="picture"&&t?.pixels&&a.pixels){const c=d.src,p=d.box,h=e.frame.width,u=e.frame.height,l=Math.round((p[0]??0)*h),b=Math.round((p[1]??0)*u),v=t.pixels,f=t.opts.box,x=Math.round((f?.[0]??0)*h),k=Math.round((f?.[1]??0)*u),j=new Uint8Array(a.pixels.data);for(let r=0;r<a.pixels.height;r++)for(let y=0;y<a.pixels.width;y++){const O=y+l-x,B=r+b-k,m=O>=0&&B>=0&&O<v.width&&B<v.height?v.data[(B*v.width+O)*4+3]??0:0,w=(r*a.pixels.width+y)*4+3;j[w]=Math.round((j[w]??0)*m/255)}const $=e.imports.find(r=>r.name===c.name)?.path.replace(/^\.\//u,"");$&&e.files.set($,new Uint8Array(Q({...a.pixels,data:j}))),g(e,"pixels",`clipped to ${t.key}, which AllyHub cannot clip to (${t.kind==="type"?"a type layer's glyphs":"a masked, turned or component base"}): its pixels cut by the base's own`,a.key),s.push({...a,opts:d});continue}g(e,"approximate",`clipped to ${t?.key??"nothing"}, which AllyHub cannot clip to: drawn unclipped`,a.key),s.push({...a,opts:d})}return s}const ue=/^[A-Za-z_$][\w$]*$/u;function W(e,i){if(e instanceof U)return e.name;if(e===null||typeof e!="object")return JSON.stringify(e);const s=i+" ",t=Array.isArray(e)?e.map(d=>W(d,s)):Object.entries(e).filter(([,d])=>d!==void 0).map(([d,c])=>`${ue.test(d)?d:JSON.stringify(d)}: ${W(c,s)}`),[a,n]=Array.isArray(e)?["[","]"]:["{","}"];if(t.length===0)return`${a}${n}`;const o=`${a}${Array.isArray(e)?"":" "}${t.join(", ")}${Array.isArray(e)?"":" "}${n}`;return o.length+i.length<=80&&!o.includes(`
5
+ `)?o:`${a}
6
+ ${t.map(d=>`${s}${d},`).join(`
7
7
  `)}
8
- ${s}${o}`}function he(e,s){return(e.name===void 0?"":`// ${JSON.stringify(e.name).slice(1,-1)}
9
- ${s}`)+Ae(e,s)}function Ae(e,s){if(e.fn==="group"){const n=s+" ",t=Object.entries(e.opts).filter(([,o])=>o!==void 0).map(([o,a])=>`${n}${fe.test(o)?o:JSON.stringify(o)}: ${W(a,n)},`),i=(e.layers??[]).map(o=>`${n} ${he(o,n+" ")},`);return`group({
8
+ ${i}${n}`}function he(e,i){return(e.name===void 0?"":`// ${JSON.stringify(e.name).slice(1,-1)}
9
+ ${i}`)+je(e,i)}function je(e,i){if(e.fn==="group"){const s=i+" ",t=Object.entries(e.opts).filter(([,n])=>n!==void 0).map(([n,o])=>`${s}${ue.test(n)?n:JSON.stringify(n)}: ${W(o,s)},`),a=(e.layers??[]).map(n=>`${s} ${he(n,s+" ")},`);return`group({
10
10
  ${t.join(`
11
11
  `)}
12
- ${n}layers: [
13
- ${i.join(`
12
+ ${s}layers: [
13
+ ${a.join(`
14
14
  `)}
15
- ${n}],
16
- ${s}})`}return`${e.fn}(${W(e.opts,s)})`}export function importPsd(e,s){oe();const n=Y(e,{useImageData:!0,skipThumbnail:!0,skipLinkedFilesData:!0}),t=[],i=new Map,o={psd:n,ppi:n.imageResources?.resolutionInfo?.horizontalResolution??72,notes:t,files:i,script:{},imports:[],o:s,board:"",frame:{left:0,top:0,width:n.width,height:n.height},taken:new Set,kinds:{}};(n.bitsPerChannel??8)!==8&&t.push({how:"approximate",what:`its ${String(n.bitsPerChannel)} bits a channel: read as 8`});const a=n.colorMode??3;a!==3&&t.push({how:"approximate",what:`its colour mode (${["bitmap","grayscale","indexed","RGB","CMYK","","","multichannel","duotone","Lab"][a]??String(a)}): read as RGB without its profile`});const d=n.children??[],c=d.filter(h=>h.artboard),m=new Set,l=[],u=n.imageData?{width:n.imageData.width,height:n.imageData.height,data:new Uint8Array(n.imageData.data.buffer,n.imageData.data.byteOffset,n.imageData.data.byteLength)}:void 0;u||t.push({how:"omitted",what:"the file has no merged composite (saved without Maximize Compatibility): nothing to compare a render with"});const f=h=>{if(!u)return;const k=new Uint8Array(h.width*h.height*4);for(let v=0;v<h.height;v++)for(let z=0;z<h.width;z++){const A=z+h.left,D=v+h.top;A<0||D<0||A>=u.width||D>=u.height||k.set(u.data.subarray((D*u.width+A)*4,(D*u.width+A)*4+4),(v*h.width+z)*4)}return{width:h.width,height:h.height,data:k}},b=(h,k,v,z)=>{const A=keyOf(h,`board-${String(l.length+1)}`,m);o.board=A,o.frame=v,o.taken=new Set,o.kinds={};const D=ue(o,k.map((B,E)=>le(o,B,E)).filter(B=>B!==void 0)),I=f(v);l.push({key:A,name:h,width:v.width,height:v.height,background:z,layers:D,...I?{composite:I}:{},kinds:o.kinds})};if(c.length>0){for(const k of c){const v=k.artboard?.rect??{left:0,top:0,right:n.width,bottom:n.height},z=k.artboard?.backgroundType??1,A=z===3?"transparent":z===2?"#000000":z===4?X(k.artboard?.color).hex:"#ffffff";b(k.name??"artboard",k.children??[],{left:Math.round(v.left),top:Math.round(v.top),width:Math.max(1,Math.round(v.right-v.left)),height:Math.max(1,Math.round(v.bottom-v.top))},A)}const h=d.filter(k=>!k.artboard);for(const k of h)t.push({how:"omitted",what:`${k.name??"a layer"} lies outside every artboard`,layer:k.name??""})}else b(s.source.replace(/\.(psd|psb)$/iu,"")||"canvas",d,{left:0,top:0,width:n.width,height:n.height},"transparent");for(const h of l)(h.width>16384||h.height>16384)&&t.push({how:"omitted",what:`board ${h.key} is ${String(h.width)}×${String(h.height)}: a board is at most 16384 a side`,board:h.key});const $=xe(s.id),p=`${$}.ts`,x=/\.ps[db]$/iu.exec(s.source)?.[0]??"",w=ie(o,s.source.slice(0,s.source.length-x.length),x);i.set(w,e);const S=new Set(["board","image"]),M=h=>{for(const k of h)S.add(k.fn),k.layers&&M(k.layers)};for(const h of l)M(h.layers);const r=o.ppi,y=[`import { ${[...S].sort().join(", ")} } from "@allyhub/sdk/image";`,"",...o.imports.map(h=>`import ${h.name} from ${JSON.stringify(h.path)};`),"",`// Imported from ${s.source} (kept beside it${w===s.source?"":` as ${w}`}): its layers by their names, a pixel`,"// layer's pixels beside it, a type layer's words in its script.","export default image({",` script: ${JSON.stringify(`./${$}.{locale}.yaml`)},`," transparent: true,"," boards: (ctx) => [",...l.map(h=>[" board({",...[` key: ${JSON.stringify(h.key)},`,...h.name!==h.key?[` title: ${JSON.stringify(h.name)},`]:[],` size: "${String(Math.min(16384,h.width))}x${String(Math.min(16384,h.height))}",`,` background: ${JSON.stringify(h.background)},`,...r!==72?[` resolution: ${String(j(r))},`]:[]]," layers: [",...h.layers.map(v=>` ${he(v," ")},`)," ],"," }),"].join(`
17
- `))," ],","});",""],O=Object.keys(o.script).length>0;return i.set(p,y.join(`
18
- `).replace("boards: (ctx) =>",O?"boards: (ctx) =>":"boards: () =>")),i.set(`${$}.${s.lang}.yaml`,ye({title:s.source.replace(/\.(psd|psb)$/iu,""),...O?{boards:Object.entries(o.script).map(([h,k])=>({id:h,text:k}))}:{}})),{files:i,module:p,source:w,boards:l.map(h=>({key:h.key,name:h.name,width:h.width,height:h.height,...h.composite?{composite:h.composite}:{},kinds:h.kinds})),report:t}}export function layerTree(e){oe();const s=Y(e,{useImageData:!0,skipThumbnail:!0,skipLinkedFilesData:!0,skipCompositeImageData:!0,skipLayerImageData:!0}),n=t=>t.map(i=>{const o=i.effects?Object.entries(i.effects).filter(([d,c])=>d!=="scale"&&d!=="disabled"&&c!==void 0).map(([d])=>d):[],a=[...i.mask&&(i.mask.right??0)>(i.mask.left??0)?["mask"]:[],...i.vectorMask?["vectorMask"]:[],...o.map(d=>`effect:${d}`),...i.adjustment?[`adjustment:${i.adjustment.type}`]:[],...i.text?[`text:${i.text.text}`]:[],...i.vectorFill?[`fill:${i.vectorFill.type}`]:[],...i.vectorStroke?.strokeEnabled===!0?["stroke"]:[],...i.placedLayer?["placed"]:[],...i.artboard?["artboard"]:[]];return{name:i.name??"",kind:ce(i),blendMode:i.blendMode??"normal",opacity:Math.round((i.opacity??1)*100),...i.fillOpacity===void 0?{}:{fillOpacity:Math.round(i.fillOpacity*100)},hidden:i.hidden===!0,clipping:i.clipping===!0,has:a,...i.children?{children:n(i.children)}:{}}});return n(s.children??[])}export function treeLines(e,s=""){return[...e].reverse().flatMap(n=>[`${s}${n.name} [${n.kind}] ${n.blendMode} ${String(n.opacity)}%${n.fillOpacity===void 0||n.fillOpacity===100?"":` fill ${String(n.fillOpacity)}%`}${n.hidden?" hidden":""}${n.clipping?" clipped":""}${n.has.length>0?` {${n.has.join(", ")}}`:""}`,...treeLines(n.children??[],`${s} `)])}
15
+ ${s}],
16
+ ${i}})`}return`${e.fn}(${W(e.opts,i)})`}export async function importPsd(e,i){const{readPsd:s}=await V(),t=s(e,{useImageData:!0,skipThumbnail:!0,skipLinkedFilesData:!0}),a=[],n=new Map,o={psd:t,ppi:t.imageResources?.resolutionInfo?.horizontalResolution??72,notes:a,files:n,script:{},imports:[],o:i,board:"",frame:{left:0,top:0,width:t.width,height:t.height},taken:new Set,kinds:{}};(t.bitsPerChannel??8)!==8&&a.push({how:"approximate",what:`its ${String(t.bitsPerChannel)} bits a channel: read as 8`});const d=t.colorMode??3;d!==3&&a.push({how:"approximate",what:`its colour mode (${["bitmap","grayscale","indexed","RGB","CMYK","","","multichannel","duotone","Lab"][d]??String(d)}): read as RGB without its profile`});const c=t.children??[],p=c.filter(m=>m.artboard),h=new Set,u=[],l=t.imageData?{width:t.imageData.width,height:t.imageData.height,data:new Uint8Array(t.imageData.data.buffer,t.imageData.data.byteOffset,t.imageData.data.byteLength)}:void 0;l||a.push({how:"omitted",what:"the file has no merged composite (saved without Maximize Compatibility): nothing to compare a render with"});const b=m=>{if(!l)return;const w=new Uint8Array(m.width*m.height*4);for(let M=0;M<m.height;M++)for(let I=0;I<m.width;I++){const A=I+m.left,S=M+m.top;A<0||S<0||A>=l.width||S>=l.height||w.set(l.data.subarray((S*l.width+A)*4,(S*l.width+A)*4+4),(M*m.width+I)*4)}return{width:m.width,height:m.height,data:w}},v=(m,w,M,I)=>{const A=keyOf(m,`board-${String(u.length+1)}`,h);o.board=A,o.frame=M,o.taken=new Set,o.kinds={};const S=le(o,w.map((P,q)=>ce(o,P,q)).filter(P=>P!==void 0)),D=b(M);u.push({key:A,name:m,width:M.width,height:M.height,background:I,layers:S,...D?{composite:D}:{},kinds:o.kinds})};if(p.length>0){for(const w of p){const M=w.artboard?.rect??{left:0,top:0,right:t.width,bottom:t.height},I=w.artboard?.backgroundType??1,A=I===3?"transparent":I===2?"#000000":I===4?ee(w.artboard?.color).hex:"#ffffff";v(w.name??"artboard",w.children??[],{left:Math.round(M.left),top:Math.round(M.top),width:Math.max(1,Math.round(M.right-M.left)),height:Math.max(1,Math.round(M.bottom-M.top))},A)}const m=c.filter(w=>!w.artboard);for(const w of m)a.push({how:"omitted",what:`${w.name??"a layer"} lies outside every artboard`,layer:w.name??""})}else v(i.source.replace(/\.(psd|psb)$/iu,"")||"canvas",c,{left:0,top:0,width:t.width,height:t.height},"transparent");for(const m of u)(m.width>16384||m.height>16384)&&a.push({how:"omitted",what:`board ${m.key} is ${String(m.width)}×${String(m.height)}: a board is at most 16384 a side`,board:m.key});const f=be(i.id),x=`${f}.ts`,k=/\.ps[db]$/iu.exec(i.source)?.[0]??"",j=se(o,i.source.slice(0,i.source.length-k.length),k);n.set(j,e);const $=new Set(["board","image"]),r=m=>{for(const w of m)$.add(w.fn),w.layers&&r(w.layers)};for(const m of u)r(m.layers);const y=o.ppi,O=[`import { ${[...$].sort().join(", ")} } from "@allyhub/sdk/image";`,"",...o.imports.map(m=>`import ${m.name} from ${JSON.stringify(m.path)};`),"",`// Imported from ${i.source} (kept beside it${j===i.source?"":` as ${j}`}): its layers by their names, a pixel`,"// layer's pixels beside it, a type layer's words in its script.","export default image({",` script: ${JSON.stringify(`./${f}.{locale}.yaml`)},`," transparent: true,"," boards: (ctx) => [",...u.map(m=>[" board({",...[` key: ${JSON.stringify(m.key)},`,...m.name!==m.key?[` title: ${JSON.stringify(m.name)},`]:[],` size: "${String(Math.min(16384,m.width))}x${String(Math.min(16384,m.height))}",`,` background: ${JSON.stringify(m.background)},`,...y!==72?[` resolution: ${String(z(y))},`]:[]]," layers: [",...m.layers.map(M=>` ${he(M," ")},`)," ],"," }),"].join(`
17
+ `))," ],","});",""],B=Object.keys(o.script).length>0;return n.set(x,O.join(`
18
+ `).replace("boards: (ctx) =>",B?"boards: (ctx) =>":"boards: () =>")),n.set(`${f}.${i.lang}.yaml`,me({title:i.source.replace(/\.(psd|psb)$/iu,""),...B?{boards:Object.entries(o.script).map(([m,w])=>({id:m,text:w}))}:{}})),{files:n,module:x,source:j,boards:u.map(m=>({key:m.key,name:m.name,width:m.width,height:m.height,...m.composite?{composite:m.composite}:{},kinds:m.kinds})),report:a}}export async function layerTree(e){const{readPsd:i}=await V(),s=i(e,{useImageData:!0,skipThumbnail:!0,skipLinkedFilesData:!0,skipCompositeImageData:!0,skipLayerImageData:!0}),t=a=>a.map(n=>{const o=n.effects?Object.entries(n.effects).filter(([c,p])=>c!=="scale"&&c!=="disabled"&&p!==void 0).map(([c])=>c):[],d=[...n.mask&&(n.mask.right??0)>(n.mask.left??0)?["mask"]:[],...n.vectorMask?["vectorMask"]:[],...o.map(c=>`effect:${c}`),...n.adjustment?[`adjustment:${n.adjustment.type}`]:[],...n.text?[`text:${n.text.text}`]:[],...n.vectorFill?[`fill:${n.vectorFill.type}`]:[],...n.vectorStroke?.strokeEnabled===!0?["stroke"]:[],...n.placedLayer?["placed"]:[],...n.artboard?["artboard"]:[]];return{name:n.name??"",kind:de(n),blendMode:n.blendMode??"normal",opacity:Math.round((n.opacity??1)*100),...n.fillOpacity===void 0?{}:{fillOpacity:Math.round(n.fillOpacity*100)},hidden:n.hidden===!0,clipping:n.clipping===!0,has:d,...n.children?{children:t(n.children)}:{}}});return t(s.children??[])}export function treeLines(e,i=""){return[...e].reverse().flatMap(s=>[`${i}${s.name} [${s.kind}] ${s.blendMode} ${String(s.opacity)}%${s.fillOpacity===void 0||s.fillOpacity===100?"":` fill ${String(s.fillOpacity)}%`}${s.hidden?" hidden":""}${s.clipping?" clipped":""}${s.has.length>0?` {${s.has.join(", ")}}`:""}`,...treeLines(s.children??[],`${i} `)])}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{createHash as F}from"node:crypto";import{initializeCanvas as U,writePsdUint8Array as $}from"ag-psd";import{writePng as R}from"@allyhub/measure";import{ADJUSTMENT_DEFAULTS as m,EFFECT_DEFAULTS as j,TEXT_DEFAULTS as S}from"@allyhub/piece";import{BLENDS as O,JUSTIFY as W,knotsOf as M,psdGradient as D,pxUnits as d,rgbOf as k}from"./map.js";export const PSD_DEFAULTS={format:"psd"};let G=!1;function N(){if(G)return;U(()=>{throw new Error("ag-psd asked for a canvas: AllyHub gives it pixels as data.")},(t,s)=>({width:t,height:s,data:new Uint8ClampedArray(t*s*4),colorSpace:"srgb"})),G=!0}const L=e=>({width:e.width,height:e.height,data:new Uint8ClampedArray(e.data.buffer,e.data.byteOffset,e.data.byteLength)}),u=e=>{const{r:t,g:s,b:i}=k(e);return{r:t,g:s,b:i}};function E(...e){const t=F("sha256");for(const i of e)t.update(i);const s=t.digest("hex");return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20,32)}`}const H={100:"Thin",200:"ExtraLight",300:"Light",400:"Regular",500:"Medium",600:"SemiBold",700:"Bold",800:"ExtraBold",900:"Black"};export function postScriptName(e,t,s){const i=H[Math.round(t/100)*100]??"Regular",r=s?i==="Regular"?"Italic":`${i}Italic`:i;return`${e.replace(/\s*Variable$/u,"").replace(/[^A-Za-z0-9]/gu,"")}-${r}`}const p=(e,t,s,i)=>{e.notes.push({how:t,what:s,...i===void 0?{}:{layer:i}})};function I(e){if("color"in e)return{type:"color",color:u(e.color)};if("gradient"in e){const t=e.gradient;return{...D(t),style:t.style??"linear",angle:t.angle??90,scale:(t.scale??100)/100,reverse:t.reverse===!0,align:!0}}}function q(e,t,s){const i={scale:1},r=o=>o.enabled!==!1,c=(o,a)=>({present:!0,showInDialog:!0,enabled:r(o),blendMode:O[o.blendMode??a.blendMode],opacity:(o.opacity??a.opacity??100)/100}),n=j;if(e.dropShadow){const o=e.dropShadow;i.dropShadow=[{...c(o,n.dropShadow),color:u(o.color??n.dropShadow.color),angle:o.angle??n.dropShadow.angle,useGlobalLight:!1,distance:d(o.distance??n.dropShadow.distance),choke:d(o.spread??n.dropShadow.spread),size:d(o.size??n.dropShadow.size),layerConceals:!0}]}if(e.innerShadow){const o=e.innerShadow;i.innerShadow=[{...c(o,n.innerShadow),color:u(o.color??n.innerShadow.color),angle:o.angle??n.innerShadow.angle,useGlobalLight:!1,distance:d(o.distance??n.innerShadow.distance),choke:d(o.choke??n.innerShadow.choke),size:d(o.size??n.innerShadow.size)}]}if(e.outerGlow){const o=e.outerGlow;i.outerGlow={...c(o,n.outerGlow),color:u(o.color??n.outerGlow.color),technique:"softer",choke:d(o.spread??n.outerGlow.spread),size:d(o.size??n.outerGlow.size),range:.5}}if(e.innerGlow){const o=e.innerGlow;i.innerGlow={...c(o,n.innerGlow),color:u(o.color??n.innerGlow.color),technique:"softer",source:o.source??n.innerGlow.source,choke:d(o.choke??n.innerGlow.choke),size:d(o.size??n.innerGlow.size),range:.5}}if(e.stroke){const o=e.stroke;i.stroke=[{...c(o,n.stroke),size:d(o.size??n.stroke.size),position:o.position??n.stroke.position,fillType:"color",color:u(o.color??n.stroke.color)}]}if(e.colorOverlay){const o=e.colorOverlay;i.solidFill=[{...c(o,n.colorOverlay),color:u(o.color??n.colorOverlay.color)}]}if(e.gradientOverlay){const o=e.gradientOverlay,a=o.gradient??n.gradientOverlay.gradient;i.gradientOverlay=[{...c(o,n.gradientOverlay),gradient:D({...a,stops:[...a.stops]}),type:a.style??"linear",angle:a.angle??90,scale:(a.scale??100)/100,reverse:a.reverse===!0,align:!0,offset:{x:0,y:0}}]}if(e.patternOverlay&&p(t,"omitted","the pattern overlay: ag-psd writes no pattern's pixels into the file",s),e.satin){const o=e.satin;i.satin={...c(o,n.satin),color:u(o.color??n.satin.color),angle:o.angle??n.satin.angle,distance:d(o.distance??n.satin.distance),size:d(o.size??n.satin.size),invert:o.invert??n.satin.invert}}if(e.bevelEmboss){const o=e.bevelEmboss,a=n.bevelEmboss;i.bevel={present:!0,showInDialog:!0,enabled:r(o),style:"inner bevel",technique:"smooth",strength:(o.depth??a.depth)/100,direction:o.direction??a.direction,size:d(o.size??a.size),soften:d(o.soften??a.soften),angle:o.angle??a.angle,altitude:o.altitude??a.altitude,useGlobalLight:!1,highlightBlendMode:O[o.highlightMode??a.highlightMode],highlightColor:u(o.highlightColor??a.highlightColor),highlightOpacity:(o.highlightOpacity??a.highlightOpacity)/100,shadowBlendMode:O[o.shadowMode??a.shadowMode],shadowColor:u(o.shadowColor??a.shadowColor),shadowOpacity:(o.shadowOpacity??a.shadowOpacity)/100}}const l=Object.keys(i).length>1;return l&&p(t,"approximate","layer styles: Photoshop draws its effects by its own engine (its blurs, its bevel's lighting), which AllyHub's SVG filters follow by its published dialog's numbers",s),l?i:void 0}const _=e=>{const t=m.levels;return{shadowInput:e?.inputBlack??t.inputBlack,highlightInput:e?.inputWhite??t.inputWhite,shadowOutput:e?.outputBlack??t.outputBlack,highlightOutput:e?.outputWhite??t.outputWhite,midtoneInput:e?.gamma??t.gamma}},V={reds:[315,345,15,45],yellows:[15,45,75,105],greens:[75,105,135,165],cyans:[135,165,195,225],blues:[195,225,255,285],magentas:[255,285,315,345]},J=new Set(["brightnessContrast","hueSaturation","vibrance","colorBalance","blackAndWhite","photoFilter"]);function X(e){switch(e.kind){case"levels":return{type:"levels",channels:[e.rgb,e.red,e.green,e.blue].map(_)};case"curves":{const t=s=>(s??[]).map(([i,r])=>({input:i,output:r}));return{type:"curves",channels:[t(e.rgb??m.curves.rgb),t(e.red),t(e.green),t(e.blue)]}}case"brightnessContrast":return{type:"brightness/contrast",brightness:e.brightness??0,contrast:e.contrast??0,meanValue:127,useLegacy:e.useLegacy??!0,labColorOnly:!1};case"hueSaturation":return{type:"hue/saturation",colorize:e.colorize===!0,colorization:{hue:0,saturation:25,lightness:0},master:{hue:e.hue??0,saturation:e.saturation??0,lightness:e.lightness??0},...Object.fromEntries(Object.entries(V).map(([t,[s,i,r,c]])=>[t,{a:s,b:i,c:r,d:c,hue:0,saturation:0,lightness:0}]))};case"vibrance":return{type:"vibrance",vibrance:e.vibrance??0,saturation:e.saturation??0};case"colorBalance":{const t=s=>({cyanRed:s?.[0]??0,magentaGreen:s?.[1]??0,yellowBlue:s?.[2]??0});return{type:"color balance",shadows:t(e.shadows),midtones:t(e.midtones),highlights:t(e.highlights),preserveLuminosity:e.preserveLuminosity??!0}}case"blackAndWhite":{const t=m.blackAndWhite;return{type:"black & white",reds:e.reds??t.reds,yellows:e.yellows??t.yellows,greens:e.greens??t.greens,cyans:e.cyans??t.cyans,blues:e.blues??t.blues,magentas:e.magentas??t.magentas,useTint:!1,tintColor:{r:225,g:211,b:179}}}case"photoFilter":{const t=m.photoFilter;return{type:"photo filter",color:u(e.color??t.color),density:(e.density??t.density)/100,preserveLuminosity:e.preserveLuminosity??t.preserveLuminosity}}case"invert":return{type:"invert"};case"threshold":return{type:"threshold",level:e.level??m.threshold.level};case"gradientMap":{const t=D({...e.gradient??m.gradientMap.gradient,stops:[...(e.gradient??m.gradientMap.gradient).stops]});return{type:"gradient map",name:"Custom",gradientType:"solid",reverse:e.reverse===!0,dither:!1,smoothness:1,colorStops:t.colorStops.map(s=>({...s,location:Math.round(s.location*4096)})),opacityStops:t.opacityStops.map(s=>({...s,location:Math.round(s.location*4096)}))}}case"exposure":return{type:"exposure",exposure:e.exposure??0,offset:e.offset??0,gamma:e.gammaCorrection??1}}}function Y(e,t){const s=e.text;if(!s)return;const i=t.board.resolution,r=b=>b*72/i,c=s.characterStyle,n=c.size??S.size,l=c.font??s.family??"Arial",o=postScriptName(l,c.weight??S.weight,c.italic===!0),a=k(c.color??S.color);a.a<1&&p(t,"approximate","a type layer's colour has an alpha, which Photoshop's text colour does not: written opaque",e.key),p(t,"approximate","type: Photoshop redraws the words (it asks to update the text layers when the file opens) by its own composer, so line breaks and baselines may move",e.key),p(t,"approximate",`the font is named ${o}: a PostScript name made from its family and weight by the usual convention; Photoshop shows another where it has none of that name`,e.key);const[h,g,f,w,z,T]=e.matrix,A=(b,x)=>[h*b+f*x+z,g*b+w*x+T],y=s.paragraphStyle;let v;if(s.box)v=A(s.box[0],s.box[1]);else{const[b,x]=s.position??[0,0];let C=s.baseline;C===void 0&&(C=x+n*.9,p(t,"approximate","a type layer's baseline was not drawn (it is hidden), so it is put 0.9 of its size under its top",e.key)),v=A(b,C)}const B={font:{name:o},fontSize:r(n),fillColor:{r:a.r,g:a.g,b:a.b},tracking:c.tracking??0,...c.leading===void 0||c.leading==="auto"?{autoLeading:!0}:{autoLeading:!1,leading:r(c.leading)},fontCaps:c.capitalization==="allCaps"?2:c.capitalization==="smallCaps"?1:0,underline:c.underline===!0,strikethrough:c.strikeThrough===!0};return{text:s.contents,transform:[h,g,f,w,v[0],v[1]],antiAlias:"smooth",style:B,paragraphStyle:{justification:W[y.justification??"left"],firstLineIndent:r(y.firstLineIndent??0),startIndent:r(y.leftIndent??0),endIndent:r(y.rightIndent??0),spaceBefore:r(y.spaceBefore??0),spaceAfter:r(y.spaceAfter??0),autoLeading:S.autoLeading},...s.box?{shapeType:"box",boxBounds:[0,0,s.box[2],s.box[3]]}:{shapeType:"point"}}}function P(e,t){const s=e.kind==="group",i={name:e.key,id:t.id++,blendMode:O[e.blendMode??(s?"passThrough":"normal")],opacity:(e.opacity??100)/100,hidden:e.hidden,blendClippendElements:!0,...e.clipping===!0?{clipping:!0}:{},...e.fillOpacity===void 0?{}:{fillOpacity:e.fillOpacity/100}},r=t.px.layers.get(e.key),c=()=>{r&&(i.left=r.left,i.top=r.top,i.right=r.left+r.img.width,i.bottom=r.top+r.img.height,i.imageData=L(r.img))};if(e.effects){const l=q(e.effects,t,e.key);l&&(i.effects=l)}const n=e.mask;if(n?.kind==="vector"){const[l,o]=n.at,[a,h,g,f,w,z]=e.matrix;i.vectorMask={paths:M(n.path,[a,h,g,f,a*l+g*o+w,h*l+f*o+z]),...n.invert?{invert:!0}:{},...n.enabled?{}:{disable:!0}},(n.density!==100||n.feather!==0)&&(i.mask={...n.density===100?{}:{vectorMaskDensity:n.density/100},...n.feather===0?{}:{vectorMaskFeather:n.feather},fromVectorData:!0})}else if(n?.kind==="raster"){const l=t.px.masks.get(e.key);l?i.mask={left:l.left,top:l.top,right:l.left+l.img.width,bottom:l.top+l.img.height,defaultColor:0,...n.enabled?{}:{disabled:!0},...n.density===100?{}:{userMaskDensity:n.density/100},...n.feather===0?{}:{userMaskFeather:n.feather},imageData:L(l.img)}:i.mask={left:0,top:0,right:1,bottom:1,defaultColor:0,...n.enabled?{}:{disabled:!0},imageData:{width:1,height:1,data:new Uint8ClampedArray([0,0,0,255])}}}switch(n&&n.feather>0&&p(t,"approximate","a mask's feather: AllyHub's is a Gaussian's standard deviation, Photoshop's its own blur of that radius",e.key),e.kind){case"group":i.children=(e.layers??[]).map(l=>P(l,t)),i.opened=!0;break;case"adjustment":e.adjustment&&(i.adjustment=X(e.adjustment),J.has(e.adjustment.kind)&&p(t,"approximate",`${e.adjustment.kind}: Photoshop publishes no formula for it, so it draws its own way the numbers AllyHub draws by its stated one`,e.key));break;case"type":{const l=Y(e,t);l&&(i.text=l),c();break}case"shape":{const l=e.shape,o=l?.fill?I(l.fill):{type:"color",color:u("#000000")};if(!l||!o){p(t,"pixels","a shape filled with a pattern: written as a pixel layer, its path as its vector mask (ag-psd writes no pattern's pixels)",e.key),c(),l&&(i.vectorMask={paths:M(l.path,e.matrix)});break}const a=l.stroke,h=a?k(a.color??"#000000"):void 0;i.vectorFill=o,i.vectorStroke={strokeEnabled:a!==null,fillEnabled:l.fill!==null,lineWidth:d(a?.width??1),lineDashOffset:d(0),miterLimit:100,lineCapType:a?.cap??"butt",lineJoinType:a?.join??"miter",lineAlignment:a?.alignment??"center",scaleLock:!1,strokeAdjust:!1,lineDashSet:(a?.dashes??[]).map(g=>({units:"None",value:g})),blendMode:"normal",opacity:(a?.opacity??100)/100*(h?.a??1),content:{type:"color",color:h?{r:h.r,g:h.g,b:h.b}:{r:0,g:0,b:0}},resolution:t.board.resolution},i.vectorMask={paths:M(l.path,e.matrix)},c();break}case"fill":{const l=e.fill?I(e.fill):void 0;l?i.vectorFill=l:p(t,"pixels","a pattern fill: written as a pixel layer (ag-psd writes no pattern's pixels)",e.key),c();break}case"smartObject":{if(c(),r){const l=new Uint8Array(R(r.img)),o=E("linked",t.board.key,e.key,l);t.linked.push({id:o,name:`${e.key}.png`,type:"png ",creator:"8BIM",data:l});const[a,h,g,f]=[r.left,r.top,r.left+r.img.width,r.top+r.img.height];i.placedLayer={id:o,placed:E("placed",t.board.key,e.key,l),type:"raster",transform:[a,h,g,h,g,f,a,f],width:r.img.width,height:r.img.height,resolution:{units:"Density",value:t.board.resolution}},p(t,"pixels","a component: a smart object holding its pixels as drawn (an embedded PNG); its code and props are not in the file",e.key)}break}default:c()}return i}function Z(e){const t=i=>i.replace(/&/gu,"&amp;").replace(/"/gu,"&quot;").replace(/</gu,"&lt;"),s=`${String(Math.round(e.resolution*1e4))}/10000`;return`<?xpacket begin="\uFEFF" id="W5M0MpCehiHzreSzNTczkc9d"?><x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" photoshop:ColorMode="3" photoshop:ICCProfile="${t(e.colorProfile)}" tiff:XResolution="${s}" tiff:YResolution="${s}" tiff:ResolutionUnit="2"><dc:title><rdf:Alt><rdf:li xml:lang="x-default">${t(e.title??e.key)}</rdf:li></rdf:Alt></dc:title></rdf:Description></rdf:RDF></x:xmpmeta><?xpacket end="w"?>`}export function psdOf(e,t){const s={board:e,px:t,notes:[],linked:[],id:1},i=e.layers.map(h=>P(h,s)),r=e.background,c=r==="transparent"||k(r).a===0,n=c?void 0:k(r),l=c?3:n?.r===255&&n.g===255&&n.b===255?1:n?.r===0&&n.g===0&&n.b===0?2:4;n&&n.a<1&&p(s,"approximate",`the board's background ${r} has an alpha, which an artboard's colour does not: written opaque`);const o={name:e.title??e.key,id:s.id++,blendMode:"pass through",opacity:1,children:i,opened:!0,artboard:{rect:{top:0,left:0,bottom:e.height,right:e.width},presetName:"",...n?{color:{r:n.r,g:n.g,b:n.b}}:{},backgroundType:l}};return e.colorProfile!=="sRGB IEC61966-2.1"&&p(s,"approximate",`the board's colour profile ${e.colorProfile} is named in the file's metadata; its pixels are sRGB, as Chrome draws them`),p(s,"omitted","the colour profile's bytes: it is named in the file's metadata (XMP's photoshop:ICCProfile), and Photoshop gives an untagged file its working space"),{psd:{width:e.width,height:e.height,channels:4,bitsPerChannel:8,children:[o],imageData:L(t.composite),...s.linked.length>0?{linkedFiles:s.linked}:{},artboards:{count:1},imageResources:{resolutionInfo:{horizontalResolution:e.resolution,horizontalResolutionUnit:"PPI",widthUnit:"Inches",verticalResolution:e.resolution,verticalResolutionUnit:"PPI",heightUnit:"Inches"},xmpMetadata:Z(e)}},fidelity:s.notes}}export function writeBoardPsd(e,t,s={}){N();const{psd:i,fidelity:r}=psdOf(e,t);return{bytes:$(i,{invalidateTextLayers:!0,noBackground:!0,...(s.format??PSD_DEFAULTS.format)==="psb"?{psb:!0}:{}}),fidelity:r}}
2
+ import{createHash as E}from"node:crypto";import{writePng as F}from"@allyhub/measure";import{ADJUSTMENT_DEFAULTS as m,EFFECT_DEFAULTS as $,TEXT_DEFAULTS as S}from"@allyhub/piece";import{psdLib as R}from"./ag-psd.js";import{BLENDS as O,JUSTIFY as U,knotsOf as C,psdGradient as L,pxUnits as d,rgbOf as k}from"./map.js";export const PSD_DEFAULTS={format:"psd"};const D=e=>({width:e.width,height:e.height,data:new Uint8ClampedArray(e.data.buffer,e.data.byteOffset,e.data.byteLength)}),u=e=>{const{r:t,g:s,b:i}=k(e);return{r:t,g:s,b:i}};function A(...e){const t=E("sha256");for(const i of e)t.update(i);const s=t.digest("hex");return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20,32)}`}const j={100:"Thin",200:"ExtraLight",300:"Light",400:"Regular",500:"Medium",600:"SemiBold",700:"Bold",800:"ExtraBold",900:"Black"};export function postScriptName(e,t,s){const i=j[Math.round(t/100)*100]??"Regular",a=s?i==="Regular"?"Italic":`${i}Italic`:i;return`${e.replace(/\s*Variable$/u,"").replace(/[^A-Za-z0-9]/gu,"")}-${a}`}const p=(e,t,s,i)=>{e.notes.push({how:t,what:s,...i===void 0?{}:{layer:i}})};function I(e){if("color"in e)return{type:"color",color:u(e.color)};if("gradient"in e){const t=e.gradient;return{...L(t),style:t.style??"linear",angle:t.angle??90,scale:(t.scale??100)/100,reverse:t.reverse===!0,align:!0}}}function W(e,t,s){const i={scale:1},a=o=>o.enabled!==!1,c=(o,r)=>({present:!0,showInDialog:!0,enabled:a(o),blendMode:O[o.blendMode??r.blendMode],opacity:(o.opacity??r.opacity??100)/100}),n=$;if(e.dropShadow){const o=e.dropShadow;i.dropShadow=[{...c(o,n.dropShadow),color:u(o.color??n.dropShadow.color),angle:o.angle??n.dropShadow.angle,useGlobalLight:!1,distance:d(o.distance??n.dropShadow.distance),choke:d(o.spread??n.dropShadow.spread),size:d(o.size??n.dropShadow.size),layerConceals:!0}]}if(e.innerShadow){const o=e.innerShadow;i.innerShadow=[{...c(o,n.innerShadow),color:u(o.color??n.innerShadow.color),angle:o.angle??n.innerShadow.angle,useGlobalLight:!1,distance:d(o.distance??n.innerShadow.distance),choke:d(o.choke??n.innerShadow.choke),size:d(o.size??n.innerShadow.size)}]}if(e.outerGlow){const o=e.outerGlow;i.outerGlow={...c(o,n.outerGlow),color:u(o.color??n.outerGlow.color),technique:"softer",choke:d(o.spread??n.outerGlow.spread),size:d(o.size??n.outerGlow.size),range:.5}}if(e.innerGlow){const o=e.innerGlow;i.innerGlow={...c(o,n.innerGlow),color:u(o.color??n.innerGlow.color),technique:"softer",source:o.source??n.innerGlow.source,choke:d(o.choke??n.innerGlow.choke),size:d(o.size??n.innerGlow.size),range:.5}}if(e.stroke){const o=e.stroke;i.stroke=[{...c(o,n.stroke),size:d(o.size??n.stroke.size),position:o.position??n.stroke.position,fillType:"color",color:u(o.color??n.stroke.color)}]}if(e.colorOverlay){const o=e.colorOverlay;i.solidFill=[{...c(o,n.colorOverlay),color:u(o.color??n.colorOverlay.color)}]}if(e.gradientOverlay){const o=e.gradientOverlay,r=o.gradient??n.gradientOverlay.gradient;i.gradientOverlay=[{...c(o,n.gradientOverlay),gradient:L({...r,stops:[...r.stops]}),type:r.style??"linear",angle:r.angle??90,scale:(r.scale??100)/100,reverse:r.reverse===!0,align:!0,offset:{x:0,y:0}}]}if(e.patternOverlay&&p(t,"omitted","the pattern overlay: ag-psd writes no pattern's pixels into the file",s),e.satin){const o=e.satin;i.satin={...c(o,n.satin),color:u(o.color??n.satin.color),angle:o.angle??n.satin.angle,distance:d(o.distance??n.satin.distance),size:d(o.size??n.satin.size),invert:o.invert??n.satin.invert}}if(e.bevelEmboss){const o=e.bevelEmboss,r=n.bevelEmboss;i.bevel={present:!0,showInDialog:!0,enabled:a(o),style:"inner bevel",technique:"smooth",strength:(o.depth??r.depth)/100,direction:o.direction??r.direction,size:d(o.size??r.size),soften:d(o.soften??r.soften),angle:o.angle??r.angle,altitude:o.altitude??r.altitude,useGlobalLight:!1,highlightBlendMode:O[o.highlightMode??r.highlightMode],highlightColor:u(o.highlightColor??r.highlightColor),highlightOpacity:(o.highlightOpacity??r.highlightOpacity)/100,shadowBlendMode:O[o.shadowMode??r.shadowMode],shadowColor:u(o.shadowColor??r.shadowColor),shadowOpacity:(o.shadowOpacity??r.shadowOpacity)/100}}const l=Object.keys(i).length>1;return l&&p(t,"approximate","layer styles: Photoshop draws its effects by its own engine (its blurs, its bevel's lighting), which AllyHub's SVG filters follow by its published dialog's numbers",s),l?i:void 0}const N=e=>{const t=m.levels;return{shadowInput:e?.inputBlack??t.inputBlack,highlightInput:e?.inputWhite??t.inputWhite,shadowOutput:e?.outputBlack??t.outputBlack,highlightOutput:e?.outputWhite??t.outputWhite,midtoneInput:e?.gamma??t.gamma}},H={reds:[315,345,15,45],yellows:[15,45,75,105],greens:[75,105,135,165],cyans:[135,165,195,225],blues:[195,225,255,285],magentas:[255,285,315,345]},q=new Set(["brightnessContrast","hueSaturation","vibrance","colorBalance","blackAndWhite","photoFilter"]);function _(e){switch(e.kind){case"levels":return{type:"levels",channels:[e.rgb,e.red,e.green,e.blue].map(N)};case"curves":{const t=s=>(s??[]).map(([i,a])=>({input:i,output:a}));return{type:"curves",channels:[t(e.rgb??m.curves.rgb),t(e.red),t(e.green),t(e.blue)]}}case"brightnessContrast":return{type:"brightness/contrast",brightness:e.brightness??0,contrast:e.contrast??0,meanValue:127,useLegacy:e.useLegacy??!0,labColorOnly:!1};case"hueSaturation":return{type:"hue/saturation",colorize:e.colorize===!0,colorization:{hue:0,saturation:25,lightness:0},master:{hue:e.hue??0,saturation:e.saturation??0,lightness:e.lightness??0},...Object.fromEntries(Object.entries(H).map(([t,[s,i,a,c]])=>[t,{a:s,b:i,c:a,d:c,hue:0,saturation:0,lightness:0}]))};case"vibrance":return{type:"vibrance",vibrance:e.vibrance??0,saturation:e.saturation??0};case"colorBalance":{const t=s=>({cyanRed:s?.[0]??0,magentaGreen:s?.[1]??0,yellowBlue:s?.[2]??0});return{type:"color balance",shadows:t(e.shadows),midtones:t(e.midtones),highlights:t(e.highlights),preserveLuminosity:e.preserveLuminosity??!0}}case"blackAndWhite":{const t=m.blackAndWhite;return{type:"black & white",reds:e.reds??t.reds,yellows:e.yellows??t.yellows,greens:e.greens??t.greens,cyans:e.cyans??t.cyans,blues:e.blues??t.blues,magentas:e.magentas??t.magentas,useTint:!1,tintColor:{r:225,g:211,b:179}}}case"photoFilter":{const t=m.photoFilter;return{type:"photo filter",color:u(e.color??t.color),density:(e.density??t.density)/100,preserveLuminosity:e.preserveLuminosity??t.preserveLuminosity}}case"invert":return{type:"invert"};case"threshold":return{type:"threshold",level:e.level??m.threshold.level};case"gradientMap":{const t=L({...e.gradient??m.gradientMap.gradient,stops:[...(e.gradient??m.gradientMap.gradient).stops]});return{type:"gradient map",name:"Custom",gradientType:"solid",reverse:e.reverse===!0,dither:!1,smoothness:1,colorStops:t.colorStops.map(s=>({...s,location:Math.round(s.location*4096)})),opacityStops:t.opacityStops.map(s=>({...s,location:Math.round(s.location*4096)}))}}case"exposure":return{type:"exposure",exposure:e.exposure??0,offset:e.offset??0,gamma:e.gammaCorrection??1}}}function V(e,t){const s=e.text;if(!s)return;const i=t.board.resolution,a=b=>b*72/i,c=s.characterStyle,n=c.size??S.size,l=c.font??s.family??"Arial",o=postScriptName(l,c.weight??S.weight,c.italic===!0),r=k(c.color??S.color);r.a<1&&p(t,"approximate","a type layer's colour has an alpha, which Photoshop's text colour does not: written opaque",e.key),p(t,"approximate","type: Photoshop redraws the words (it asks to update the text layers when the file opens) by its own composer, so line breaks and baselines may move",e.key),p(t,"approximate",`the font is named ${o}: a PostScript name made from its family and weight by the usual convention; Photoshop shows another where it has none of that name`,e.key);const[h,g,f,w,z,T]=e.matrix,G=(b,x)=>[h*b+f*x+z,g*b+w*x+T],y=s.paragraphStyle;let v;if(s.box)v=G(s.box[0],s.box[1]);else{const[b,x]=s.position??[0,0];let M=s.baseline;M===void 0&&(M=x+n*.9,p(t,"approximate","a type layer's baseline was not drawn (it is hidden), so it is put 0.9 of its size under its top",e.key)),v=G(b,M)}const B={font:{name:o},fontSize:a(n),fillColor:{r:r.r,g:r.g,b:r.b},tracking:c.tracking??0,...c.leading===void 0||c.leading==="auto"?{autoLeading:!0}:{autoLeading:!1,leading:a(c.leading)},fontCaps:c.capitalization==="allCaps"?2:c.capitalization==="smallCaps"?1:0,underline:c.underline===!0,strikethrough:c.strikeThrough===!0};return{text:s.contents,transform:[h,g,f,w,v[0],v[1]],antiAlias:"smooth",style:B,paragraphStyle:{justification:U[y.justification??"left"],firstLineIndent:a(y.firstLineIndent??0),startIndent:a(y.leftIndent??0),endIndent:a(y.rightIndent??0),spaceBefore:a(y.spaceBefore??0),spaceAfter:a(y.spaceAfter??0),autoLeading:S.autoLeading},...s.box?{shapeType:"box",boxBounds:[0,0,s.box[2],s.box[3]]}:{shapeType:"point"}}}function P(e,t){const s=e.kind==="group",i={name:e.key,id:t.id++,blendMode:O[e.blendMode??(s?"passThrough":"normal")],opacity:(e.opacity??100)/100,hidden:e.hidden,blendClippendElements:!0,...e.clipping===!0?{clipping:!0}:{},...e.fillOpacity===void 0?{}:{fillOpacity:e.fillOpacity/100}},a=t.px.layers.get(e.key),c=()=>{a&&(i.left=a.left,i.top=a.top,i.right=a.left+a.img.width,i.bottom=a.top+a.img.height,i.imageData=D(a.img))};if(e.effects){const l=W(e.effects,t,e.key);l&&(i.effects=l)}const n=e.mask;if(n?.kind==="vector"){const[l,o]=n.at,[r,h,g,f,w,z]=e.matrix;i.vectorMask={paths:C(n.path,[r,h,g,f,r*l+g*o+w,h*l+f*o+z]),...n.invert?{invert:!0}:{},...n.enabled?{}:{disable:!0}},(n.density!==100||n.feather!==0)&&(i.mask={...n.density===100?{}:{vectorMaskDensity:n.density/100},...n.feather===0?{}:{vectorMaskFeather:n.feather},fromVectorData:!0})}else if(n?.kind==="raster"){const l=t.px.masks.get(e.key);l?i.mask={left:l.left,top:l.top,right:l.left+l.img.width,bottom:l.top+l.img.height,defaultColor:0,...n.enabled?{}:{disabled:!0},...n.density===100?{}:{userMaskDensity:n.density/100},...n.feather===0?{}:{userMaskFeather:n.feather},imageData:D(l.img)}:i.mask={left:0,top:0,right:1,bottom:1,defaultColor:0,...n.enabled?{}:{disabled:!0},imageData:{width:1,height:1,data:new Uint8ClampedArray([0,0,0,255])}}}switch(n&&n.feather>0&&p(t,"approximate","a mask's feather: AllyHub's is a Gaussian's standard deviation, Photoshop's its own blur of that radius",e.key),e.kind){case"group":i.children=(e.layers??[]).map(l=>P(l,t)),i.opened=!0;break;case"adjustment":e.adjustment&&(i.adjustment=_(e.adjustment),q.has(e.adjustment.kind)&&p(t,"approximate",`${e.adjustment.kind}: Photoshop publishes no formula for it, so it draws its own way the numbers AllyHub draws by its stated one`,e.key));break;case"type":{const l=V(e,t);l&&(i.text=l),c();break}case"shape":{const l=e.shape,o=l?.fill?I(l.fill):{type:"color",color:u("#000000")};if(!l||!o){p(t,"pixels","a shape filled with a pattern: written as a pixel layer, its path as its vector mask (ag-psd writes no pattern's pixels)",e.key),c(),l&&(i.vectorMask={paths:C(l.path,e.matrix)});break}const r=l.stroke,h=r?k(r.color??"#000000"):void 0;i.vectorFill=o,i.vectorStroke={strokeEnabled:r!==null,fillEnabled:l.fill!==null,lineWidth:d(r?.width??1),lineDashOffset:d(0),miterLimit:100,lineCapType:r?.cap??"butt",lineJoinType:r?.join??"miter",lineAlignment:r?.alignment??"center",scaleLock:!1,strokeAdjust:!1,lineDashSet:(r?.dashes??[]).map(g=>({units:"None",value:g})),blendMode:"normal",opacity:(r?.opacity??100)/100*(h?.a??1),content:{type:"color",color:h?{r:h.r,g:h.g,b:h.b}:{r:0,g:0,b:0}},resolution:t.board.resolution},i.vectorMask={paths:C(l.path,e.matrix)},c();break}case"fill":{const l=e.fill?I(e.fill):void 0;l?i.vectorFill=l:p(t,"pixels","a pattern fill: written as a pixel layer (ag-psd writes no pattern's pixels)",e.key),c();break}case"smartObject":{if(c(),a){const l=new Uint8Array(F(a.img)),o=A("linked",t.board.key,e.key,l);t.linked.push({id:o,name:`${e.key}.png`,type:"png ",creator:"8BIM",data:l});const[r,h,g,f]=[a.left,a.top,a.left+a.img.width,a.top+a.img.height];i.placedLayer={id:o,placed:A("placed",t.board.key,e.key,l),type:"raster",transform:[r,h,g,h,g,f,r,f],width:a.img.width,height:a.img.height,resolution:{units:"Density",value:t.board.resolution}},p(t,"pixels","a component: a smart object holding its pixels as drawn (an embedded PNG); its code and props are not in the file",e.key)}break}default:c()}return i}function J(e){const t=i=>i.replace(/&/gu,"&amp;").replace(/"/gu,"&quot;").replace(/</gu,"&lt;"),s=`${String(Math.round(e.resolution*1e4))}/10000`;return`<?xpacket begin="\uFEFF" id="W5M0MpCehiHzreSzNTczkc9d"?><x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" photoshop:ColorMode="3" photoshop:ICCProfile="${t(e.colorProfile)}" tiff:XResolution="${s}" tiff:YResolution="${s}" tiff:ResolutionUnit="2"><dc:title><rdf:Alt><rdf:li xml:lang="x-default">${t(e.title??e.key)}</rdf:li></rdf:Alt></dc:title></rdf:Description></rdf:RDF></x:xmpmeta><?xpacket end="w"?>`}export function psdOf(e,t){const s={board:e,px:t,notes:[],linked:[],id:1},i=e.layers.map(h=>P(h,s)),a=e.background,c=a==="transparent"||k(a).a===0,n=c?void 0:k(a),l=c?3:n?.r===255&&n.g===255&&n.b===255?1:n?.r===0&&n.g===0&&n.b===0?2:4;n&&n.a<1&&p(s,"approximate",`the board's background ${a} has an alpha, which an artboard's colour does not: written opaque`);const o={name:e.title??e.key,id:s.id++,blendMode:"pass through",opacity:1,children:i,opened:!0,artboard:{rect:{top:0,left:0,bottom:e.height,right:e.width},presetName:"",...n?{color:{r:n.r,g:n.g,b:n.b}}:{},backgroundType:l}};return e.colorProfile!=="sRGB IEC61966-2.1"&&p(s,"approximate",`the board's colour profile ${e.colorProfile} is named in the file's metadata; its pixels are sRGB, as Chrome draws them`),p(s,"omitted","the colour profile's bytes: it is named in the file's metadata (XMP's photoshop:ICCProfile), and Photoshop gives an untagged file its working space"),{psd:{width:e.width,height:e.height,channels:4,bitsPerChannel:8,children:[o],imageData:D(t.composite),...s.linked.length>0?{linkedFiles:s.linked}:{},artboards:{count:1},imageResources:{resolutionInfo:{horizontalResolution:e.resolution,horizontalResolutionUnit:"PPI",widthUnit:"Inches",verticalResolution:e.resolution,verticalResolutionUnit:"PPI",heightUnit:"Inches"},xmpMetadata:J(e)}},fidelity:s.notes}}export async function writeBoardPsd(e,t,s={}){const{writePsdUint8Array:i}=await R(),{psd:a,fidelity:c}=psdOf(e,t);return{bytes:i(a,{invalidateTextLayers:!0,noBackground:!0,...(s.format??PSD_DEFAULTS.format)==="psb"?{psb:!0}:{}}),fidelity:c}}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/image-psd",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{PDFDict as b,PDFDocument as w,PDFHexString as h,PDFName as e,PDFNull as P,PDFNumber as C,PDFString as N}from"pdf-lib";const O=o=>/^[\x20-\x7e]*$/u.test(o)&&!/[()\\]/u.test(o)?N.of(o):h.fromText(o);function j(){const o=process.env.SOURCE_DATE_EPOCH;if(!(o===void 0||!/^\d+$/u.test(o)))return new Date(Number(o)*1e3)}export async function finishPdf(o,c){const t=await w.load(o,{updateMetadata:!1}),i=t.context.lookup(t.context.trailerInfo.Info),r=j();r?(t.setCreationDate(r),t.setModificationDate(r)):i instanceof b&&(i.delete(e.of("CreationDate")),i.delete(e.of("ModDate"))),c.title!==void 0&&c.title!==""&&t.setTitle(c.title,{showInWindowTitleBar:!0});const d=t.getPages(),l=(c.outline??[]).slice(0,d.length);if(l.length>0){const u=t.context.nextRef(),n=l.map(()=>t.context.nextRef());l.forEach((T,a)=>{const D=d[a],x=n[a];if(!D||!x)return;const s=t.context.obj({});s.set(e.of("Title"),O(T)),s.set(e.of("Parent"),u),s.set(e.of("Dest"),t.context.obj([D.ref,e.of("Fit")]));const g=n[a-1],p=n[a+1];g&&s.set(e.of("Prev"),g),p&&s.set(e.of("Next"),p),t.context.assign(x,s)});const f=t.context.obj({});f.set(e.of("Type"),e.of("Outlines"));const m=n[0],F=n.at(-1);f.set(e.of("First"),m??P),f.set(e.of("Last"),F??P),f.set(e.of("Count"),C.of(n.length)),t.context.assign(u,f),t.catalog.set(e.of("Outlines"),u)}return Buffer.from(await t.save({useObjectStreams:!1}))}
2
+ import{firstUse as N}from"@allyhub/runtimes";export const pdfLib=N("pdf-lib",()=>import("pdf-lib"));const O=(n,o)=>/^[\x20-\x7e]*$/u.test(o)&&!/[()\\]/u.test(o)?n.PDFString.of(o):n.PDFHexString.fromText(o);function j(){const n=process.env.SOURCE_DATE_EPOCH;if(!(n===void 0||!/^\d+$/u.test(n)))return new Date(Number(n)*1e3)}export async function finishPdf(n,o){const d=await pdfLib(),{PDFDict:F,PDFDocument:b,PDFName:e,PDFNull:x,PDFNumber:w}=d,t=await b.load(n,{updateMetadata:!1}),a=t.context.lookup(t.context.trailerInfo.Info),r=j();r?(t.setCreationDate(r),t.setModificationDate(r)):a instanceof F&&(a.delete(e.of("CreationDate")),a.delete(e.of("ModDate"))),o.title!==void 0&&o.title!==""&&t.setTitle(o.title,{showInWindowTitleBar:!0});const D=t.getPages(),l=(o.outline??[]).slice(0,D.length);if(l.length>0){const u=t.context.nextRef(),s=l.map(()=>t.context.nextRef());l.forEach((C,i)=>{const p=D[i],g=s[i];if(!p||!g)return;const f=t.context.obj({});f.set(e.of("Title"),O(d,C)),f.set(e.of("Parent"),u),f.set(e.of("Dest"),t.context.obj([p.ref,e.of("Fit")]));const m=s[i-1],P=s[i+1];m&&f.set(e.of("Prev"),m),P&&f.set(e.of("Next"),P),t.context.assign(g,f)});const c=t.context.obj({});c.set(e.of("Type"),e.of("Outlines"));const T=s[0],h=s.at(-1);c.set(e.of("First"),T??x),c.set(e.of("Last"),h??x),c.set(e.of("Count"),w.of(s.length)),t.context.assign(u,c),t.catalog.set(e.of("Outlines"),u)}return Buffer.from(await t.save({useObjectStreams:!1}))}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/image-render",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./*": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/image-runtime",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/image-sdk",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/jobs",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/linkedin-extension",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/linkedin-model",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +1,3 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export{ARTICLE_WIDTH,ArticleBlockView,ArticleBody,ArticleView,Byline,EmbedCard,RunsView}from"./article.js";export{WORDS_FONT,foldMeasured}from"./fold.js";export{Actions,Author,Content,FEED_WIDTH,FOLD_LINES,PHONE_WIDTH,wordsWidth,PLACEHOLDER,PictureGrid,Post,PostWords,VideoElement,clock}from"./post.js";export{Words,runsOf}from"./text.js";
2
+ import{jsx as n,Fragment as Z,jsxs as v}from"react/jsx-runtime";import{useContext as G}from"react";import{forwardRef as J,createElement as Q}from"react";var A=(...e)=>e.filter((a,t,i)=>!!a&&a.trim()!==""&&i.indexOf(a)===t).join(" ").trim(),X=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ee=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,t,i)=>i?i.toUpperCase():t.toLowerCase()),b=e=>{const a=ee(e);return a.charAt(0).toUpperCase()+a.slice(1)};import{forwardRef as ae,createElement as H}from"react";var te={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},ie=e=>{for(const a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1},re=ae(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:i,className:l="",children:o,iconNode:c,...s},u)=>H("svg",{ref:u,...te,width:a,height:a,stroke:e,strokeWidth:i?Number(t)*24/Number(a):t,className:A("lucide",l),...!o&&!ie(s)&&{"aria-hidden":"true"},...s},[...c.map(([m,h])=>H(m,h)),...Array.isArray(o)?o:[o]])),p=(e,a)=>{const t=J(({className:i,...l},o)=>Q(re,{ref:o,iconNode:a,className:A(`lucide-${X(b(e))}`,`lucide-${e}`,i),...l}));return t.displayName=b(e),t},ne=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],le=p("bookmark",ne),se=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],oe=p("ellipsis",se),ce=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],de=p("external-link",ce),he=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ue=p("file-text",he),me=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],pe=p("globe",me),fe=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],ve=p("message-square-text",fe),ke=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ye=p("play",ke),Ne=[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]],ge=p("repeat-2",Ne),we=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],xe=p("send",we),_e=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],Me=p("thumbs-up",_e),Se=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Ce=p("users",Se);import{jsx as r,jsxs as d}from"react/jsx-runtime";import{createContext as Ee,useContext as Ae,useEffect as j,useMemo as be,useState as He}from"react";import{entitySpans as je}from"@allyhub/linkedin-model";var Le=new Intl.Segmenter(void 0,{granularity:"grapheme"}),L=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,$e="… more";function Ie(e,a,t){const i=[];let l=0;for(const o of e.split(`
3
+ `)){let c=l,s="",u=-1;for(const{segment:m}of Le.segment(o)){const h=/\s/u.test(m);L.test(m)&&(u=s.length);const f=s+m;if(h||t(f.trimEnd(),c)<=a){s=f,h&&(u=s.length);continue}const k=u>0?u:s.length;i.push({start:c,text:s.slice(0,k)}),c+=k,s=s.slice(k)+m,u=L.test(m)?s.length-m.length:-1}i.push({start:c,text:s}),l+=o.length+1}return i}function Re(e,a,t,i){const l=Ie(e,t,i);if(l.length<=a)return{folded:!1,shown:e,lines:l.length};const o=t-i($e,-1);let c;if(l.slice(0,a).forEach((s,u)=>{for(const m of s.text.matchAll(/\S+/gu)){const h=m.index+m[0].length;i(s.text.slice(0,h),s.start)<o&&(c={line:u,end:s.start+h})}}),c===void 0){const s=l[a-1];return{folded:!0,shown:e.slice(0,(s?.start??0)+(s?.text.length??0)).trimEnd(),lines:a}}return{folded:!0,shown:e.slice(0,c.end),lines:c.line+1}}var $='14px "Inter Variable", Inter, -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans SC", "Noto Color Emoji", sans-serif';function I(e,a,t,i=$){const l=new OffscreenCanvas(1,1).getContext("2d");if(l===null)return{folded:!1,shown:e,lines:0};const o=i,c=`600 ${i}`,s=je(e),u=(h,f)=>(l.font=f,l.measureText(h).width);return Re(e,a,t,(h,f)=>{if(f<0)return u(h,o);let k=0,y=0;for(const E of s){const w=Math.max(E.from-f,0),x=Math.min(E.to-f,h.length);x<=y||w>=h.length||(w>y&&(k+=u(h.slice(y,w),o)),k+=u(h.slice(Math.max(w,y),x),c),y=x)}return k+(y<h.length?u(h.slice(y),o):0)})}import{jsx as R,Fragment as Ve}from"react/jsx-runtime";import{entitySpans as Te}from"@allyhub/linkedin-model";function V(e){const a=[];let t=0;for(const i of Te(e))i.from<t||(i.from>t&&a.push({text:e.slice(t,i.from)}),a.push({text:e.slice(i.from,i.to),link:!0}),t=i.to);return t<e.length&&a.push({text:e.slice(t)}),a}function T({text:e}){return R(Ve,{children:V(e).map((a,t)=>a.link===!0?R("span",{className:"ak-li-link",children:a.text},t):a.text)})}var _=552,De=390,M=e=>e-2-24,Oe=3,N={name:"AllyHub",headline:"The content creation system for people and AI"},S=Ee(e=>r("video",{...e}));function qe(e){return{ONE_DAY:"1d left",THREE_DAYS:"3d left",SEVEN_DAYS:"1w left",FOURTEEN_DAYS:"2w left"}[e??"SEVEN_DAYS"]??"1w left"}function D(e){const a=Math.round(e),t=Math.floor(a/3600),i=Math.floor(a%3600/60),l=o=>String(o).padStart(2,"0");return t>0?`${String(t)}:${l(i)}:${l(a%60)}`:`${String(i)}:${l(a%60)}`}function O({visibility:e,avatar:a=48}){return d("header",{className:"ak-li-author",children:[r("div",{className:"ak-li-avatar",style:{width:a,height:a},"aria-hidden":"true",children:N.name.slice(0,1)}),d("div",{className:"ak-li-who",children:[r("span",{className:"ak-li-name",children:N.name}),r("span",{className:"ak-li-headline",children:N.headline}),d("span",{className:"ak-li-when",children:["Now •"," ",e==="CONNECTIONS"?r(Ce,{"aria-label":"Connections only"}):r(pe,{"aria-label":"Anyone"})]})]})]})}function q({text:e,lines:a,onFolded:t,width:i=M(_)}){const[l,o]=He(0);j(()=>{let s=!0;return document.fonts.ready.then(()=>{s&&o(u=>u+1)}),()=>{s=!1}},[]);const c=be(()=>{if(a===void 0||l<0)return;const s=I(e,a,i);return s.folded?s.shown:void 0},[e,a,i,l]);return j(()=>{t?.(c!==void 0)},[c,t]),d("div",{className:"ak-li-words",dir:"auto","data-fold":a,"data-text":e,children:[r(T,{text:c??e}),c===void 0?null:r("span",{className:"ak-li-more",children:"… more"})]})}function ze({label:e}){return r("div",{className:"ak-li-made",children:e})}function C({m:e}){return e.kind==="made"||e.src===void 0?r(ze,{label:e.label??e.file}):r("img",{src:e.src,alt:e.alt??""})}function Pe({m:e}){const a=Ae(S),t=e.width!==void 0&&e.height!==void 0&&e.height>0?{aspectRatio:`${String(e.width)} / ${String(e.height)}`}:void 0;return d("div",{className:"ak-li-video",style:t,children:[e.src===void 0?null:a({src:`${e.src}#t=0.1`,muted:!0,playsInline:!0,preload:"auto"},e.file),r("span",{className:"ak-li-play","aria-hidden":"true"}),e.seconds===void 0?null:r("span",{className:"ak-li-clock",children:D(e.seconds)})]})}function We({m:e,title:a}){return d("div",{className:"ak-li-document",children:[r("div",{className:"ak-li-doc-bar",children:r("span",{className:"ak-li-doc-title",children:a??e.label??e.file??""})}),e.src===void 0?d("div",{className:"ak-li-doc-page",children:[r(ue,{"aria-hidden":"true"}),r("span",{children:e.label??e.file})]}):r("img",{src:e.src,alt:e.alt??""})]})}var Fe=e=>e?.width!==void 0&&e.height!==void 0&&e.width>e.height;function z({images:e,onMedium:a}){if(e.length===0)return null;const t=e.length>4?4:e.length,i=e.length-t;return r("div",{className:"ak-li-grid","data-count":t,"data-wide":Fe(e[0])?"":void 0,children:e.slice(0,t).map((l,o)=>d("div",{className:"ak-li-cell",children:[r(C,{m:l}),o===t-1&&i>0?d("span",{className:"ak-li-hidden",children:["+",i]}):null,a?.(o)]},o))})}function Ue({c:e}){let a=e.source;try{a=new URL(e.source).hostname.replace(/^www\./u,"")}catch{}return d("div",{className:"ak-li-card",children:[e.thumbnail?r("div",{className:"ak-li-card-picture",children:r(C,{m:e.thumbnail})}):null,d("div",{className:"ak-li-card-text",children:[r("span",{className:"ak-li-card-title",children:e.title??e.source}),d("span",{className:"ak-li-card-site",children:[a,r(de,{"aria-hidden":"true"})]})]})]})}function Be({c:e}){return d("div",{className:"ak-li-poll",children:[r("div",{className:"ak-li-poll-question",dir:"auto",children:e.question}),r("div",{className:"ak-li-poll-hint",children:"The author can see how you vote."}),e.options.map((a,t)=>r("div",{className:"ak-li-option",dir:"auto",children:a},t)),d("div",{className:"ak-li-poll-foot",children:["0 votes • ",qe(e.duration)]})]})}function P({content:e,onMedium:a}){if(e===void 0)return null;switch(e.type){case"media":{const t=e.medium;return d("div",{className:"ak-li-content",children:[t.kind==="video"?r(Pe,{m:t}):t.kind==="document"||t.kind==="made"&&e.title!==void 0?r(We,{m:t,title:e.title}):r("div",{className:"ak-li-single",children:r(C,{m:t})}),a?.(0)]})}case"multiImage":return r("div",{className:"ak-li-content",children:r(z,{images:e.images,onMedium:a})});case"poll":return r(Be,{c:e});case"article":return d("div",{className:"ak-li-content",children:[r(Ue,{c:e}),a?.(0)]})}}function W(){return d("div",{className:"ak-li-actions","aria-hidden":"true",children:[r(Me,{}),r(ve,{}),r(ge,{}),r(xe,{})]})}function Ye({post:e,lines:a,slots:t={},onFolded:i,width:l=_}){return d("article",{className:"ak-li-post",children:[r(O,{visibility:e.visibility}),t.words??(e.commentary===""?null:r(q,{text:e.commentary,lines:a,onFolded:i,width:M(l)})),t.content??r(P,{content:e.content,onMedium:t.onMedium}),t.after,r(W,{})]})}var Ke=632;function g({runs:e}){return n(Z,{children:e.map((a,t)=>{let i=a.text;return a.italic===!0&&(i=n("em",{children:i})),a.bold===!0&&(i=n("strong",{children:i})),a.link!==void 0&&(i=n("span",{className:"ak-li-a-link",children:i})),n("span",{children:i},t)})})}function F({url:e}){let a=e;try{a=new URL(e).hostname.replace(/^www\./u,"")}catch{}return v("div",{className:"ak-li-embed",children:[n(ye,{"aria-hidden":"true"}),v("div",{className:"ak-li-embed-text",children:[n("span",{className:"ak-li-embed-site",children:a}),n("span",{className:"ak-li-embed-url",children:e})]})]})}function U({file:e,alt:a,src:t,measure:i}){const l=G(S);if(t===void 0)return n("div",{className:"ak-li-made",children:e});if(/\.mp4$/iu.test(e)){const o=i?.width!==void 0&&i.height!==void 0?{aspectRatio:`${String(i.width)} / ${String(i.height)}`}:void 0;return v("div",{className:"ak-li-video",style:o,children:[l({src:`${t}#t=0.1`,muted:!0,playsInline:!0},e),n("span",{className:"ak-li-play","aria-hidden":"true"})]})}return n("img",{src:t,alt:a??""})}function B({block:e,source:a,measure:t}){switch(e.type){case"paragraph":return n("p",{dir:"auto",children:e.runs.length===0?n("br",{}):n(g,{runs:e.runs})});case"h1":return n("h2",{dir:"auto",children:n(g,{runs:e.runs})});case"h2":return n("h3",{dir:"auto",children:n(g,{runs:e.runs})});case"quote":return n("blockquote",{dir:"auto",children:n(g,{runs:e.runs})});case"ul":case"ol":{const i=e.type;return n(i,{children:e.items.map((l,o)=>n("li",{dir:"auto",children:n(g,{runs:l})},o))})}case"code":return n("pre",{children:n("code",{children:e.code})});case"divider":return n("hr",{});case"embed":return n(F,{url:e.url});case"image":return v("figure",{children:[n(U,{file:e.file,alt:e.alt,src:a(e.file),measure:t?.(e.file)}),e.caption===void 0?null:n("figcaption",{children:e.caption})]})}}function Y({article:e,source:a,measure:t}){return n("div",{className:"ak-li-a-body",children:e.blocks.map((i,l)=>n(B,{block:i,source:a,measure:t},l))})}function K(){return v("div",{className:"ak-li-a-by",children:[n("div",{className:"ak-li-avatar",style:{width:48,height:48},"aria-hidden":"true",children:N.name.slice(0,1)}),v("div",{className:"ak-li-who",children:[n("span",{className:"ak-li-name",children:N.name}),n("span",{className:"ak-li-headline",children:N.headline})]}),v("span",{className:"ak-li-a-tools","aria-hidden":"true",children:[n(le,{}),n(oe,{})]})]})}function Ze({article:e,source:a,measure:t}){return v("article",{className:"ak-li-article",children:[e.cover?n("div",{className:"ak-li-a-cover",children:n(U,{file:e.cover.file,alt:e.cover.alt,src:a(e.cover.file),measure:t?.(e.cover.file)})}):null,n("h1",{className:"ak-li-a-title",dir:"auto",children:e.title}),n(K,{}),n(Y,{article:e,source:a,measure:t})]})}export{Ke as ARTICLE_WIDTH,W as Actions,B as ArticleBlockView,Y as ArticleBody,Ze as ArticleView,O as Author,K as Byline,P as Content,F as EmbedCard,_ as FEED_WIDTH,Oe as FOLD_LINES,De as PHONE_WIDTH,N as PLACEHOLDER,z as PictureGrid,Ye as Post,q as PostWords,g as RunsView,S as VideoElement,$ as WORDS_FONT,T as Words,D as clock,I as foldMeasured,V as runsOf,M as wordsWidth};