decocms 2.302.7 → 2.304.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/dist/client/assets/{AlertCircle-CG9syR30.js → AlertCircle-BeiDn4Fp.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-BoVSDn9e.js → ArrowNarrowLeft-hulNygQd.js} +1 -1
  3. package/dist/client/assets/{ArrowUpRight-BdaniATT.js → ArrowUpRight-lTwxwkJA.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-DenMuCVF.js → CheckCircle-3TB25Bcb.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-C3Ygm425.js → ChevronDown-_b59faTm.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-ZWCM92t_.js → ChevronRight-DEybByBs.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-D2rVf06n.js → ChevronUp-B_td_jK6.js} +1 -1
  8. package/dist/client/assets/{Container-D7Azh5xu.js → Container-d8d36LPk.js} +1 -1
  9. package/dist/client/assets/{DotsVertical-CLHEpDSq.js → DotsVertical-9AuPT8gf.js} +1 -1
  10. package/dist/client/assets/{LinkExternal01-DxXEJ52C.js → LinkExternal01-BMrJcbl6.js} +1 -1
  11. package/dist/client/assets/{Lock01-BguDy0uh.js → Lock01-C5rgxGgu.js} +1 -1
  12. package/dist/client/assets/{Palette-BYEIR3m2.js → Palette-DfnmIo6d.js} +1 -1
  13. package/dist/client/assets/{Play-Bwjd77ev.js → Play-BGW505UY.js} +1 -1
  14. package/dist/client/assets/{Plus-DTn86Odk.js → Plus-DlISHBLe.js} +1 -1
  15. package/dist/client/assets/{RefreshCcw01-BHf_tfWd.js → RefreshCcw01-Dbq2QLAC.js} +1 -1
  16. package/dist/client/assets/{SearchMd-a6724p0Y.js → SearchMd-C8WDOhfc.js} +1 -1
  17. package/dist/client/assets/{Settings02-CrnanDsL.js → Settings02-BIpL5e3f.js} +1 -1
  18. package/dist/client/assets/{Shield01-DtxRf8Qj.js → Shield01-DCoI7_zY.js} +1 -1
  19. package/dist/client/assets/{Star01-BFmiet3n.js → Star01-Chns_B29.js} +1 -1
  20. package/dist/client/assets/{Sun-CRJFmy5s.js → Sun-CgSsJ8OX.js} +1 -1
  21. package/dist/client/assets/{Tool01-9otovhMh.js → Tool01-B8RjIhe4.js} +1 -1
  22. package/dist/client/assets/{Trash01-re7YiF5g.js → Trash01-CFncShuD.js} +1 -1
  23. package/dist/client/assets/{User01-BgnyFNdJ.js → User01-Bq8r53VC.js} +1 -1
  24. package/dist/client/assets/{Users03-BPGIuPOi.js → Users03-qD8JWxak.js} +1 -1
  25. package/dist/client/assets/{X-DlTdh5jK.js → X-BNOerUAB.js} +1 -1
  26. package/dist/client/assets/{XCircle-BE4LAsf8.js → XCircle-B-JS14_e.js} +1 -1
  27. package/dist/client/assets/{XClose-CDyDeDuF.js → XClose-vOlmnMjZ.js} +1 -1
  28. package/dist/client/assets/{Zap-DE6pD70D.js → Zap-BPHOFmqu.js} +1 -1
  29. package/dist/client/assets/{ZapSquare-FWH2wtfn.js → ZapSquare-CX9zqrxv.js} +1 -1
  30. package/dist/client/assets/{accordion-BubDFUkM.js → accordion-DIyksd99.js} +1 -1
  31. package/dist/client/assets/{agent-icon-DzVM2Y3D.js → agent-icon-CLQAOsUE.js} +1 -1
  32. package/dist/client/assets/{agents-list-ClVNGy3h.js → agents-list-D0BQglaf.js} +1 -1
  33. package/dist/client/assets/ai-providers-BnclkXxt.js +1 -0
  34. package/dist/client/assets/{alert-dialog-Cp4KelsS.js → alert-dialog-BWduFhy-.js} +1 -1
  35. package/dist/client/assets/{auth-catchall-DAjGP-X3.js → auth-catchall-D-v4q1Qx.js} +1 -1
  36. package/dist/client/assets/{automation-list-row-DP5TESrt.js → automation-list-row-DPkrb87t.js} +1 -1
  37. package/dist/client/assets/{automations-BKKclzI8.js → automations-BCzY9gmM.js} +1 -1
  38. package/dist/client/assets/{avatar-D56WFjQj.js → avatar-C6HNjGDg.js} +1 -1
  39. package/dist/client/assets/{badge-Brrebgj_.js → badge-CZCn9Wwi.js} +1 -1
  40. package/dist/client/assets/{brand-context-B9KleYrA.js → brand-context-DcqBJ41j.js} +1 -1
  41. package/dist/client/assets/{card-CbtqsNyF.js → card-oNblR0HO.js} +1 -1
  42. package/dist/client/assets/{chat-context-D8pNmIoM.js → chat-context-RcvBJBC7.js} +1 -1
  43. package/dist/client/assets/{checkbox-A-1sOL7a.js → checkbox-JSEUVCMB.js} +1 -1
  44. package/dist/client/assets/{collection-detail-BiV7gm_U.js → collection-detail-C5pV1mWu.js} +1 -1
  45. package/dist/client/assets/{collection-display-button-hDD2VNh1.js → collection-display-button-DQSPcJBz.js} +1 -1
  46. package/dist/client/assets/{collection-search-TTX5BBhb.js → collection-search-CLoorkFj.js} +1 -1
  47. package/dist/client/assets/{collection-search-BtNt6NZG.js → collection-search-DGO6_1o7.js} +1 -1
  48. package/dist/client/assets/{collection-table-wrapper-RDfR0u8g.js → collection-table-wrapper-P7sXgSq0.js} +1 -1
  49. package/dist/client/assets/{collection-tabs-BYirFRax.js → collection-tabs-6c5Oz0MD.js} +1 -1
  50. package/dist/client/assets/{collections-DY4I1w_a.js → collections-CcBlrCx6.js} +1 -1
  51. package/dist/client/assets/{command-DzkZTofz.js → command-C666DFpg.js} +1 -1
  52. package/dist/client/assets/{connection-card-iSBKdQg9.js → connection-card-DbGlMaON.js} +1 -1
  53. package/dist/client/assets/{connection-detail-DeALevd5.js → connection-detail-DOFWK_LZ.js} +1 -1
  54. package/dist/client/assets/{connection-form-helpers-Cad-A9NK.js → connection-form-helpers-S9iwzj4v.js} +1 -1
  55. package/dist/client/assets/{connections-BhCBByIk.js → connections-DZgnlfnc.js} +1 -1
  56. package/dist/client/assets/{constants-BXUJyD1c.js → constants-B22iOAkD.js} +1 -1
  57. package/dist/client/assets/{constants-9TBj0Gaa.js → constants-DRQ2x-Dp.js} +1 -1
  58. package/dist/client/assets/{dialog-DpgNnjBX.js → dialog-ReVTOuxu.js} +1 -1
  59. package/dist/client/assets/{domain-settings-CfEXVZxs.js → domain-settings-_aY4XST2.js} +1 -1
  60. package/dist/client/assets/{drawer-LAm5-sL1.js → drawer-BYHJ-8Om.js} +1 -1
  61. package/dist/client/assets/{dropdown-menu-CSBZWMuU.js → dropdown-menu-y8iKrNsS.js} +1 -1
  62. package/dist/client/assets/{dynamic-plugin-layout-YqPG32No.js → dynamic-plugin-layout-BxzD5223.js} +1 -1
  63. package/dist/client/assets/{empty-state-D8Ji8JRa.js → empty-state-B4rhh1dc.js} +1 -1
  64. package/dist/client/assets/{empty-state-C3GO5RSf.js → empty-state-ByRM_QUo.js} +1 -1
  65. package/dist/client/assets/{extract-connection-data-cbAHcCfh.js → extract-connection-data-CbVt8VgN.js} +1 -1
  66. package/dist/client/assets/{features-D_II3j_j.js → features-BMKDqpeL.js} +1 -1
  67. package/dist/client/assets/{form-DFO_5Fzm.js → form-D8QDPjk9.js} +1 -1
  68. package/dist/client/assets/{general-By1woa8E.js → general-WpQ82n-X.js} +1 -1
  69. package/dist/client/assets/index-BB2bR64l.js +1 -0
  70. package/dist/client/assets/{index-B2vPEOVc.js → index-BET8kMZe.js} +1 -1
  71. package/dist/client/assets/{index-ImhE7zFL.js → index-Bi-e-UKp.js} +1 -1
  72. package/dist/client/assets/{index-DSoRyzSx.js → index-Bpod-O0_.js} +1 -1
  73. package/dist/client/assets/{index-D2mitOSe.js → index-BuLwXk3-.js} +4 -4
  74. package/dist/client/assets/{index-CHNVhIMp.js → index-CPmmcxsi.js} +1 -1
  75. package/dist/client/assets/{index-DF5x0d60.js → index-CTWz6nN8.js} +1 -1
  76. package/dist/client/assets/{index-XLC4yiSV.js → index-CeC26NPv.js} +1 -1
  77. package/dist/client/assets/{index-tSJy2IW6.js → index-Cf5saV1q.js} +1 -1
  78. package/dist/client/assets/{index-Br3d5-Cj.js → index-CgURykwj.js} +1 -1
  79. package/dist/client/assets/{index-CQ4D5GAP.js → index-D4IWA9IU.js} +2 -2
  80. package/dist/client/assets/{index-DYIl7M2a.js → index-D8dvMQZl.js} +1 -1
  81. package/dist/client/assets/{index-swcvm5Z1.js → index-D9Q6YnJH.js} +1 -1
  82. package/dist/client/assets/{index-2dOrl4x0.js → index-DBj2qw-o.js} +1 -1
  83. package/dist/client/assets/{index-C4QwSWi9.js → index-DXXI9MyH.js} +1 -1
  84. package/dist/client/assets/{index-r9i7ABND.js → index-U5YmU8lc.js} +1 -1
  85. package/dist/client/assets/{infiniteQueryObserver-CxkHF-jm.js → infiniteQueryObserver-ClYEJj89.js} +1 -1
  86. package/dist/client/assets/{input-6Sf2hB_F.js → input-DhXllgVP.js} +1 -1
  87. package/dist/client/assets/{integration-icon-8lhkAaq5.js → integration-icon-CNQIPioy.js} +1 -1
  88. package/dist/client/assets/{label-DoJDMV6i.js → label-BDcPRk17.js} +1 -1
  89. package/dist/client/assets/{layout-BHQ_c4RM.js → layout-DBK70FJ7.js} +1 -1
  90. package/dist/client/assets/{lean-canvas-recruit-modal-CDcr9qCt.js → lean-canvas-recruit-modal-Cosr7uB6.js} +1 -1
  91. package/dist/client/assets/{login-Am3HfZgi.js → login-uRApKgz7.js} +1 -1
  92. package/dist/client/assets/{members-yGwdGYMP.js → members-CgYS1Zxe.js} +1 -1
  93. package/dist/client/assets/{monaco-editor-CglgsbP6.js → monaco-editor-D34bkcWL.js} +1 -1
  94. package/dist/client/assets/{monitoring-stats-row-C64ix0dR.js → monitoring-stats-row-Rw8mxMr8.js} +1 -1
  95. package/dist/client/assets/{oauth-callback-YaQtgy3B.js → oauth-callback-DLWU7IjL.js} +1 -1
  96. package/dist/client/assets/{oauth-callback-ai-provider-DXuTlaTS.js → oauth-callback-ai-provider-5FDIcGBj.js} +1 -1
  97. package/dist/client/assets/{onboarding-WnwwsOhD.js → onboarding-jyaCV8uq.js} +1 -1
  98. package/dist/client/assets/{org-layout-DCXUX3EB.js → org-layout-DxW3YApR.js} +1 -1
  99. package/dist/client/assets/{org-plugin-layout-Dsb_WQsm.js → org-plugin-layout-B-uqLn5y.js} +1 -1
  100. package/dist/client/assets/{pair-B01JdgFS.js → pair-CM7Z5dgt.js} +1 -1
  101. package/dist/client/assets/{plugin-empty-state-D3CO3AdB.js → plugin-empty-state-C-o1hhqY.js} +1 -1
  102. package/dist/client/assets/{plugin-header-aeJUAm2h.js → plugin-header-BTFD2Tcj.js} +1 -1
  103. package/dist/client/assets/{plugin-layout-CP1Bb1gU.js → plugin-layout-BiJEtvKW.js} +1 -1
  104. package/dist/client/assets/{popover-BajibMdr.js → popover-DQq9bf6V.js} +1 -1
  105. package/dist/client/assets/{profile-DDe57pOS.js → profile-PICkTEdT.js} +1 -1
  106. package/dist/client/assets/{project-app-view-AKSh-WqN.js → project-app-view-B1QcPr4W.js} +1 -1
  107. package/dist/client/assets/registry-Dr9Q687k.js +2 -0
  108. package/dist/client/assets/{registry-layout-QiSXnsNM.js → registry-layout-DGmSzwah.js} +1 -1
  109. package/dist/client/assets/{required-auth-layout-jdQgts2c.js → required-auth-layout-CfAoaltR.js} +1 -1
  110. package/dist/client/assets/{reset-password-BN5V7l8r.js → reset-password-NMO08kVP.js} +1 -1
  111. package/dist/client/assets/{roles-HeW5UUYX.js → roles-CCaqodZQ.js} +1 -1
  112. package/dist/client/assets/{scroll-area-SGeY9dE-.js → scroll-area-AhoYMTSF.js} +1 -1
  113. package/dist/client/assets/{search-input-D6oau9hI.js → search-input-BSmmjMtR.js} +1 -1
  114. package/dist/client/assets/{select-DeRvPFq1.js → select-dTphD0ES.js} +1 -1
  115. package/dist/client/assets/{select-model-Di1os-Ub.js → select-model-D2H_jWcd.js} +1 -1
  116. package/dist/client/assets/{settings-layout-Ds_Ffodp.js → settings-layout-Bn3d6rRU.js} +1 -1
  117. package/dist/client/assets/{settings-section-RBLHL8gf.js → settings-section-DkPpouMA.js} +1 -1
  118. package/dist/client/assets/{shell-layout-BBGXUnLn.js → shell-layout-DLX5f9iI.js} +1 -1
  119. package/dist/client/assets/{skeleton-BAo1ij7j.js → skeleton-DCMX-VkN.js} +1 -1
  120. package/dist/client/assets/{sso-CKN-2e5M.js → sso-BeQadTWm.js} +1 -1
  121. package/dist/client/assets/{store-hnD4E6ii.js → store-D-lrayyv.js} +1 -1
  122. package/dist/client/assets/store-registry-dKQp57q_.js +2 -0
  123. package/dist/client/assets/{switch-BGrAKUyr.js → switch-D9uEYoPa.js} +1 -1
  124. package/dist/client/assets/{table-0gEoBFzX.js → table-BIcJswmk.js} +1 -1
  125. package/dist/client/assets/{tabs-ChLvcDIf.js → tabs-Bbs5xG17.js} +1 -1
  126. package/dist/client/assets/{task-status-B0G255I6.js → task-status-1zFON5T4.js} +1 -1
  127. package/dist/client/assets/{textarea-CDageIb2.js → textarea-BMU9fnHG.js} +1 -1
  128. package/dist/client/assets/{toggle-group-BUN1pnfF.js → toggle-group-juphd3c4.js} +1 -1
  129. package/dist/client/assets/{tools-list-DIvrgoIa.js → tools-list-BP78dRI3.js} +1 -1
  130. package/dist/client/assets/{tooltip-pBgOajzM.js → tooltip-B5FrLY14.js} +1 -1
  131. package/dist/client/assets/{types-wSZC8rz7.js → types-DmM_J5U9.js} +1 -1
  132. package/dist/client/assets/{use-ai-providers-DVEz2NmK.js → use-ai-providers-CVAGId9e.js} +1 -1
  133. package/dist/client/assets/{use-collections-DV5bwdGb.js → use-collections-DKWG5Tun.js} +1 -1
  134. package/dist/client/assets/{use-connection-fs-HjrZ7.js → use-connection-Dy5vq_5j.js} +1 -1
  135. package/dist/client/assets/{use-copy-lIGig9yc.js → use-copy-BSYEct5q.js} +1 -1
  136. package/dist/client/assets/{use-create-virtual-mcp-Bz4IDcO1.js → use-create-virtual-mcp-ifW0Pllw.js} +1 -1
  137. package/dist/client/assets/{use-decopilot-events-B38OLSFm.js → use-decopilot-events-DVXCv4R8.js} +1 -1
  138. package/dist/client/assets/{use-delete-connection-CORGK4Oi.js → use-delete-connection-CRe3MUPe.js} +1 -1
  139. package/dist/client/assets/{use-infinite-scroll-C0wp7W5X.js → use-infinite-scroll-4DQHfv5o.js} +1 -1
  140. package/dist/client/assets/{use-list-state-DWVI_yIs.js → use-list-state-CihFBhY3.js} +1 -1
  141. package/dist/client/assets/{use-mcp-tools-C-hABbHm.js → use-mcp-tools-Bog3rGRX.js} +1 -1
  142. package/dist/client/assets/{use-members-DbWcRqMH.js → use-members-eWVl2b1I.js} +1 -1
  143. package/dist/client/assets/{use-navigate-to-agent-37f-6W2B.js → use-navigate-to-agent--7ajKHhy.js} +1 -1
  144. package/dist/client/assets/{use-org-auth-client-5_rgl0KN.js → use-org-auth-client-C-BGwXKo.js} +1 -1
  145. package/dist/client/assets/{use-org-sso-CFxSE_n9.js → use-org-sso-2mlDJ8c4.js} +1 -1
  146. package/dist/client/assets/{use-organization-roles-Cy74Gv9v.js → use-organization-roles-PByiiFjp.js} +1 -1
  147. package/dist/client/assets/{use-organization-settings-B3AsJEWq.js → use-organization-settings-DngIHmBy.js} +1 -1
  148. package/dist/client/assets/{use-registry-connections-C9X2yrii.js → use-registry-connections-CDM-gpri.js} +1 -1
  149. package/dist/client/assets/{use-status-sounds-DuT0KslZ.js → use-status-sounds-BzXaoVC8.js} +1 -1
  150. package/dist/client/assets/{use-tasks-Bg4m_k7S.js → use-tasks-M1RmMNT7.js} +1 -1
  151. package/dist/client/assets/{use-view-mode-_U7GAKYn.js → use-view-mode-DRDlksJe.js} +1 -1
  152. package/dist/client/assets/{use-virtual-mcp-CwGnYHPH.js → use-virtual-mcp-CDCK02Yj.js} +1 -1
  153. package/dist/client/assets/useInfiniteQuery-DtJBa4_2.js +1 -0
  154. package/dist/client/assets/useSuspenseInfiniteQuery-G-zitmER.js +1 -0
  155. package/dist/client/assets/{user-CpC285Qu.js → user-WYGHhGxH.js} +1 -1
  156. package/dist/client/assets/{view-mode-toggle-zrlQPSP1.js → view-mode-toggle-CK1VLDTo.js} +1 -1
  157. package/dist/client/assets/{workflow-D77PbtT7.js → workflow-DkcKupEW.js} +1 -1
  158. package/dist/client/assets/workflow-detail-BtHvU2Pd.js +1 -0
  159. package/dist/client/index.html +1 -1
  160. package/dist/server/cli.js +544 -489
  161. package/dist/server/node_modules/slice-ansi/index.d.ts +19 -0
  162. package/dist/server/node_modules/slice-ansi/index.js +260 -0
  163. package/dist/server/node_modules/{environment → slice-ansi}/license +1 -0
  164. package/dist/server/node_modules/slice-ansi/package.json +59 -0
  165. package/dist/server/node_modules/slice-ansi/readme.md +54 -0
  166. package/dist/server/node_modules/slice-ansi/tokenize-ansi.js +752 -0
  167. package/dist/server/server.js +87 -44
  168. package/package.json +2 -1
  169. package/dist/client/assets/ai-providers-CCNzjFxx.js +0 -1
  170. package/dist/client/assets/index-B13jh3-s.js +0 -1
  171. package/dist/client/assets/registry-BEeKP9Pe.js +0 -2
  172. package/dist/client/assets/store-registry-s8CHypuf.js +0 -2
  173. package/dist/client/assets/useInfiniteQuery-DGrk4ASG.js +0 -1
  174. package/dist/client/assets/useSuspenseInfiniteQuery-cV09mkra.js +0 -1
  175. package/dist/client/assets/workflow-detail-DAtCF7t1.js +0 -1
  176. package/dist/server/node_modules/environment/index.d.ts +0 -74
  177. package/dist/server/node_modules/environment/index.js +0 -47
  178. package/dist/server/node_modules/environment/package.json +0 -74
  179. package/dist/server/node_modules/environment/readme.md +0 -94
  180. package/dist/server/node_modules/escape-string-regexp/index.d.ts +0 -18
  181. package/dist/server/node_modules/escape-string-regexp/index.js +0 -11
  182. package/dist/server/node_modules/escape-string-regexp/license +0 -9
  183. package/dist/server/node_modules/escape-string-regexp/package.json +0 -43
  184. package/dist/server/node_modules/escape-string-regexp/readme.md +0 -29
  185. package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
  186. package/dist/server/node_modules/is-fullwidth-code-point/index.js +0 -12
  187. package/dist/server/node_modules/is-fullwidth-code-point/license +0 -9
  188. package/dist/server/node_modules/is-fullwidth-code-point/package.json +0 -53
  189. package/dist/server/node_modules/is-fullwidth-code-point/readme.md +0 -31
  190. package/dist/server/node_modules/is-unicode-supported/index.d.ts +0 -12
  191. package/dist/server/node_modules/is-unicode-supported/index.js +0 -21
  192. package/dist/server/node_modules/is-unicode-supported/license +0 -9
  193. package/dist/server/node_modules/is-unicode-supported/package.json +0 -47
  194. package/dist/server/node_modules/is-unicode-supported/readme.md +0 -35
  195. package/dist/server/node_modules/pg-pool/LICENSE +0 -21
  196. package/dist/server/node_modules/pg-pool/README.md +0 -357
  197. package/dist/server/node_modules/pg-pool/esm/index.mjs +0 -5
  198. package/dist/server/node_modules/pg-pool/index.js +0 -517
  199. package/dist/server/node_modules/pg-pool/package.json +0 -51
  200. package/dist/server/node_modules/restore-cursor/index.d.ts +0 -11
  201. package/dist/server/node_modules/restore-cursor/index.js +0 -11
  202. package/dist/server/node_modules/restore-cursor/license +0 -9
  203. package/dist/server/node_modules/restore-cursor/package.json +0 -55
  204. package/dist/server/node_modules/restore-cursor/readme.md +0 -31
  205. package/dist/server/node_modules/string-width/index.d.ts +0 -39
  206. package/dist/server/node_modules/string-width/index.js +0 -82
  207. package/dist/server/node_modules/string-width/license +0 -9
  208. package/dist/server/node_modules/string-width/package.json +0 -64
  209. package/dist/server/node_modules/string-width/readme.md +0 -66
@@ -0,0 +1,19 @@
1
+ /**
2
+ Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
3
+
4
+ @param string - A string with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk).
5
+ @param startSlice - Zero-based visible-column index at which to start the slice. Grapheme clusters are kept intact.
6
+ @param endSlice - Zero-based visible-column index at which to end the slice.
7
+
8
+ @example
9
+ ```
10
+ import chalk from 'chalk';
11
+ import sliceAnsi from 'slice-ansi';
12
+
13
+ const string = 'The quick brown ' + chalk.red('fox jumped over ') +
14
+ 'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
15
+
16
+ console.log(sliceAnsi(string, 20, 30));
17
+ ```
18
+ */
19
+ export default function sliceAnsi(string: string, startSlice: number, endSlice?: number): string;
@@ -0,0 +1,260 @@
1
+ import tokenizeAnsi from './tokenize-ansi.js';
2
+
3
+ function applySgrFragments(activeStyles, fragments) {
4
+ for (const fragment of fragments) {
5
+ switch (fragment.type) {
6
+ case 'reset': {
7
+ activeStyles.clear();
8
+ break;
9
+ }
10
+
11
+ case 'end': {
12
+ activeStyles.delete(fragment.endCode);
13
+ break;
14
+ }
15
+
16
+ case 'start': {
17
+ activeStyles.delete(fragment.endCode);
18
+ activeStyles.set(fragment.endCode, fragment.code);
19
+ break;
20
+ }
21
+
22
+ default: {
23
+ break;
24
+ }
25
+ }
26
+ }
27
+
28
+ return activeStyles;
29
+ }
30
+
31
+ function undoAnsiCodes(activeStyles) {
32
+ return [...activeStyles.keys()].reverse().join('');
33
+ }
34
+
35
+ function closeHyperlink(hyperlinkToken) {
36
+ return `${hyperlinkToken.closePrefix}${hyperlinkToken.terminator}`;
37
+ }
38
+
39
+ function shouldIncludeSgrAfterEnd(token, activeStyles) {
40
+ let hasStartFragment = false;
41
+ let hasClosingEffect = false;
42
+
43
+ for (const fragment of token.fragments) {
44
+ if (fragment.type === 'start') {
45
+ hasStartFragment = true;
46
+ continue;
47
+ }
48
+
49
+ if (fragment.type === 'reset' && activeStyles.size > 0) {
50
+ hasClosingEffect = true;
51
+ continue;
52
+ }
53
+
54
+ if (fragment.type === 'end' && activeStyles.has(fragment.endCode)) {
55
+ hasClosingEffect = true;
56
+ }
57
+ }
58
+
59
+ return hasClosingEffect && !hasStartFragment;
60
+ }
61
+
62
+ function applySgrToken({token, isPastEnd, activeStyles, returnValue, include, activeHyperlink, position}) {
63
+ if (isPastEnd && !shouldIncludeSgrAfterEnd(token, activeStyles)) {
64
+ return {
65
+ activeStyles,
66
+ activeHyperlink,
67
+ position,
68
+ returnValue,
69
+ include,
70
+ };
71
+ }
72
+
73
+ activeStyles = applySgrFragments(activeStyles, token.fragments);
74
+ if (include) {
75
+ returnValue += token.code;
76
+ }
77
+
78
+ return {
79
+ activeStyles,
80
+ activeHyperlink,
81
+ position,
82
+ returnValue,
83
+ include,
84
+ };
85
+ }
86
+
87
+ function applyHyperlinkToken({token, isPastEnd, activeStyles, activeHyperlink, position, returnValue, include}) {
88
+ if (
89
+ isPastEnd
90
+ && (
91
+ token.action !== 'close'
92
+ || !activeHyperlink
93
+ )
94
+ ) {
95
+ return {
96
+ activeStyles,
97
+ activeHyperlink,
98
+ position,
99
+ returnValue,
100
+ include,
101
+ };
102
+ }
103
+
104
+ if (token.action === 'open') {
105
+ activeHyperlink = token;
106
+ } else if (token.action === 'close') {
107
+ activeHyperlink = undefined;
108
+ }
109
+
110
+ if (include) {
111
+ returnValue += token.code;
112
+ }
113
+
114
+ return {
115
+ activeStyles,
116
+ activeHyperlink,
117
+ position,
118
+ returnValue,
119
+ include,
120
+ };
121
+ }
122
+
123
+ function applyControlToken({token, isPastEnd, activeStyles, activeHyperlink, position, returnValue, include}) {
124
+ if (!isPastEnd && include) {
125
+ returnValue += token.code;
126
+ }
127
+
128
+ return {
129
+ activeStyles,
130
+ activeHyperlink,
131
+ position,
132
+ returnValue,
133
+ include,
134
+ };
135
+ }
136
+
137
+ function applyCharacterToken({token, start, activeStyles, activeHyperlink, position, returnValue, include}) {
138
+ if (
139
+ !include
140
+ && position >= start
141
+ && !token.isGraphemeContinuation
142
+ ) {
143
+ include = true;
144
+ returnValue = [...activeStyles.values()].join('');
145
+ if (activeHyperlink) {
146
+ returnValue += activeHyperlink.code;
147
+ }
148
+ }
149
+
150
+ if (include) {
151
+ returnValue += token.value;
152
+ }
153
+
154
+ position += token.visibleWidth;
155
+ return {
156
+ activeStyles,
157
+ activeHyperlink,
158
+ position,
159
+ returnValue,
160
+ include,
161
+ };
162
+ }
163
+
164
+ const tokenHandlers = {
165
+ sgr: applySgrToken,
166
+ hyperlink: applyHyperlinkToken,
167
+ control: applyControlToken,
168
+ character: applyCharacterToken,
169
+ };
170
+
171
+ function applyToken(parameters) {
172
+ const tokenHandler = tokenHandlers[parameters.token.type];
173
+ if (!tokenHandler) {
174
+ const {
175
+ activeStyles,
176
+ activeHyperlink,
177
+ position,
178
+ returnValue,
179
+ include,
180
+ } = parameters;
181
+
182
+ return {
183
+ activeStyles,
184
+ activeHyperlink,
185
+ position,
186
+ returnValue,
187
+ include,
188
+ };
189
+ }
190
+
191
+ return tokenHandler(parameters);
192
+ }
193
+
194
+ function createHasContinuationAheadMap(tokens) {
195
+ const hasContinuationAhead = Array.from({length: tokens.length}, () => false);
196
+ let nextCharacterIsContinuation = false;
197
+
198
+ for (let tokenIndex = tokens.length - 1; tokenIndex >= 0; tokenIndex--) {
199
+ const token = tokens[tokenIndex];
200
+ hasContinuationAhead[tokenIndex] = nextCharacterIsContinuation;
201
+ if (token.type === 'character') {
202
+ nextCharacterIsContinuation = Boolean(token.isGraphemeContinuation);
203
+ }
204
+ }
205
+
206
+ return hasContinuationAhead;
207
+ }
208
+
209
+ export default function sliceAnsi(string, start, end) {
210
+ const tokens = tokenizeAnsi(string, {endCharacter: end});
211
+ const hasContinuationAhead = createHasContinuationAheadMap(tokens);
212
+ let activeStyles = new Map();
213
+ let activeHyperlink;
214
+ let position = 0;
215
+ let returnValue = '';
216
+ let include = false;
217
+
218
+ for (const [tokenIndex, token] of tokens.entries()) {
219
+ let isPastEnd = end !== undefined && position >= end;
220
+ if (
221
+ isPastEnd
222
+ && token.type !== 'character'
223
+ && hasContinuationAhead[tokenIndex]
224
+ ) {
225
+ isPastEnd = false;
226
+ }
227
+
228
+ if (
229
+ isPastEnd
230
+ && token.type === 'character'
231
+ && !token.isGraphemeContinuation
232
+ ) {
233
+ break;
234
+ }
235
+
236
+ ({activeStyles, activeHyperlink, position, returnValue, include} = applyToken({
237
+ token,
238
+ isPastEnd,
239
+ start,
240
+ activeStyles,
241
+ activeHyperlink,
242
+ position,
243
+ returnValue,
244
+ include,
245
+ }));
246
+ }
247
+
248
+ if (!include) {
249
+ return '';
250
+ }
251
+
252
+ if (activeHyperlink) {
253
+ returnValue += closeHyperlink(activeHyperlink);
254
+ }
255
+
256
+ // Disable active codes at the end
257
+ returnValue += undoAnsiCodes(activeStyles);
258
+
259
+ return returnValue;
260
+ }
@@ -1,5 +1,6 @@
1
1
  MIT License
2
2
 
3
+ Copyright (c) DC <threedeecee@gmail.com>
3
4
  Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "slice-ansi",
3
+ "version": "8.0.0",
4
+ "description": "Slice a string with ANSI escape codes",
5
+ "license": "MIT",
6
+ "repository": "chalk/slice-ansi",
7
+ "funding": "https://github.com/chalk/slice-ansi?sponsor=1",
8
+ "type": "module",
9
+ "exports": {
10
+ "types": "./index.d.ts",
11
+ "default": "./index.js"
12
+ },
13
+ "sideEffects": false,
14
+ "engines": {
15
+ "node": ">=20"
16
+ },
17
+ "scripts": {
18
+ "test": "xo && ava && tsc --lib esnext index.d.ts"
19
+ },
20
+ "files": [
21
+ "index.js",
22
+ "tokenize-ansi.js",
23
+ "index.d.ts"
24
+ ],
25
+ "keywords": [
26
+ "slice",
27
+ "string",
28
+ "ansi",
29
+ "styles",
30
+ "color",
31
+ "colour",
32
+ "colors",
33
+ "terminal",
34
+ "console",
35
+ "cli",
36
+ "tty",
37
+ "escape",
38
+ "formatting",
39
+ "rgb",
40
+ "256",
41
+ "shell",
42
+ "xterm",
43
+ "log",
44
+ "logging",
45
+ "command-line",
46
+ "text"
47
+ ],
48
+ "dependencies": {
49
+ "ansi-styles": "^6.2.3",
50
+ "is-fullwidth-code-point": "^5.1.0"
51
+ },
52
+ "devDependencies": {
53
+ "ava": "^6.4.1",
54
+ "chalk": "^5.6.2",
55
+ "random-item": "^4.0.1",
56
+ "strip-ansi": "^7.1.2",
57
+ "xo": "^1.2.3"
58
+ }
59
+ }
@@ -0,0 +1,54 @@
1
+ # slice-ansi [![XO: Linted](https://img.shields.io/badge/xo-linted-blue.svg)](https://github.com/xojs/xo)
2
+
3
+ > Slice a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install slice-ansi
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import chalk from 'chalk';
15
+ import sliceAnsi from 'slice-ansi';
16
+
17
+ const string = 'The quick brown ' + chalk.red('fox jumped over ') +
18
+ 'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
19
+
20
+ console.log(sliceAnsi(string, 20, 30));
21
+ ```
22
+
23
+ ## API
24
+
25
+ ### sliceAnsi(string, startSlice, endSlice?)
26
+
27
+ #### string
28
+
29
+ Type: `string`
30
+
31
+ String with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk).
32
+
33
+ #### startSlice
34
+
35
+ Type: `number`
36
+
37
+ Zero-based visible-column index at which to start the slice. Grapheme clusters (for example, emoji sequences and combining marks) are kept intact.
38
+
39
+ #### endSlice
40
+
41
+ Type: `number`
42
+
43
+ Zero-based visible-column index at which to end the slice.
44
+
45
+ ## Related
46
+
47
+ - [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
48
+ - [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal
49
+ - [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
50
+
51
+ ## Maintainers
52
+
53
+ - [Sindre Sorhus](https://github.com/sindresorhus)
54
+ - [Josh Junon](https://github.com/qix-)