@sunub/obsidian-mcp-server 0.3.19 → 0.3.21

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 (527) hide show
  1. package/README.md +1 -24
  2. package/build/cli/App.d.ts +1 -0
  3. package/build/cli/App.js +273 -0
  4. package/build/cli/App.js.map +1 -0
  5. package/build/cli/AppContainer.d.ts +1 -0
  6. package/build/cli/AppContainer.js +19 -0
  7. package/build/cli/AppContainer.js.map +1 -0
  8. package/build/cli/colors.d.ts +15 -0
  9. package/build/cli/colors.js +15 -0
  10. package/build/cli/colors.js.map +1 -0
  11. package/build/cli/commands/types.d.ts +19 -0
  12. package/build/cli/commands/types.js +11 -0
  13. package/build/cli/commands/types.js.map +1 -0
  14. package/build/cli/config/SettingContext.d.ts +1 -0
  15. package/build/cli/config/SettingContext.js +2 -0
  16. package/build/cli/config/SettingContext.js.map +1 -0
  17. package/build/cli/config/mcpServersConfig.d.ts +30 -0
  18. package/build/cli/config/mcpServersConfig.js +119 -0
  19. package/build/cli/config/mcpServersConfig.js.map +1 -0
  20. package/build/cli/config/settingSchema.d.ts +162 -0
  21. package/build/cli/config/settingSchema.js +110 -0
  22. package/build/cli/config/settingSchema.js.map +1 -0
  23. package/build/cli/constants.d.ts +47 -0
  24. package/build/cli/constants.js +101 -0
  25. package/build/cli/constants.js.map +1 -0
  26. package/build/cli/context/InputContext.d.ts +12 -0
  27. package/build/cli/context/InputContext.js +10 -0
  28. package/build/cli/context/InputContext.js.map +1 -0
  29. package/build/cli/context/KeypressContext.d.ts +30 -0
  30. package/build/cli/context/KeypressContext.js +200 -0
  31. package/build/cli/context/KeypressContext.js.map +1 -0
  32. package/build/cli/context/KeypressContext.util.d.ts +7 -0
  33. package/build/cli/context/KeypressContext.util.js +476 -0
  34. package/build/cli/context/KeypressContext.util.js.map +1 -0
  35. package/build/cli/errors/index.d.ts +3 -0
  36. package/build/cli/errors/index.js +7 -0
  37. package/build/cli/errors/index.js.map +1 -0
  38. package/build/cli/hooks/useAtCompletion.d.ts +12 -0
  39. package/build/cli/hooks/useAtCompletion.js +5 -0
  40. package/build/cli/hooks/useAtCompletion.js.map +1 -0
  41. package/build/cli/hooks/useCommandCompletion.d.ts +59 -0
  42. package/build/cli/hooks/useCommandCompletion.js +344 -0
  43. package/build/cli/hooks/useCommandCompletion.js.map +1 -0
  44. package/build/cli/hooks/useCompletion.d.ts +22 -0
  45. package/build/cli/hooks/useCompletion.js +84 -0
  46. package/build/cli/hooks/useCompletion.js.map +1 -0
  47. package/build/cli/hooks/useDispatcher.d.ts +6 -0
  48. package/build/cli/hooks/useDispatcher.js +286 -0
  49. package/build/cli/hooks/useDispatcher.js.map +1 -0
  50. package/build/cli/hooks/useFocus.d.ts +2 -0
  51. package/build/cli/hooks/useFocus.js +3 -0
  52. package/build/cli/hooks/useFocus.js.map +1 -0
  53. package/build/cli/hooks/useHistoryManager.d.ts +32 -0
  54. package/build/cli/hooks/useHistoryManager.js +78 -0
  55. package/build/cli/hooks/useHistoryManager.js.map +1 -0
  56. package/build/cli/hooks/useInputHistory.d.ts +24 -0
  57. package/build/cli/hooks/useInputHistory.js +159 -0
  58. package/build/cli/hooks/useInputHistory.js.map +1 -0
  59. package/build/cli/hooks/useKeyMatchers.d.ts +17 -0
  60. package/build/cli/hooks/useKeyMatchers.js +18 -0
  61. package/build/cli/hooks/useKeyMatchers.js.map +1 -0
  62. package/build/cli/hooks/useKeypress.d.ts +19 -0
  63. package/build/cli/hooks/useKeypress.js +28 -0
  64. package/build/cli/hooks/useKeypress.js.map +1 -0
  65. package/build/cli/hooks/useLlmStream/constants.d.ts +4 -0
  66. package/build/cli/hooks/useLlmStream/constants.js +5 -0
  67. package/build/cli/hooks/useLlmStream/constants.js.map +1 -0
  68. package/build/cli/hooks/useLlmStream/index.d.ts +2 -0
  69. package/build/cli/hooks/useLlmStream/index.js +2 -0
  70. package/build/cli/hooks/useLlmStream/index.js.map +1 -0
  71. package/build/cli/hooks/useLlmStream/llmService.d.ts +2 -0
  72. package/build/cli/hooks/useLlmStream/llmService.js +111 -0
  73. package/build/cli/hooks/useLlmStream/llmService.js.map +1 -0
  74. package/build/cli/hooks/useLlmStream/types.d.ts +38 -0
  75. package/build/cli/hooks/useLlmStream/types.js.map +1 -0
  76. package/build/cli/hooks/useLlmStream/useLlmStream.d.ts +12 -0
  77. package/build/cli/hooks/useLlmStream/useLlmStream.js +176 -0
  78. package/build/cli/hooks/useLlmStream/useLlmStream.js.map +1 -0
  79. package/build/cli/hooks/useLlmStream/utils.d.ts +17 -0
  80. package/build/cli/hooks/useLlmStream/utils.js +142 -0
  81. package/build/cli/hooks/useLlmStream/utils.js.map +1 -0
  82. package/build/cli/hooks/useMcpClient.d.ts +10 -0
  83. package/build/cli/hooks/useMcpClient.js +98 -0
  84. package/build/cli/hooks/useMcpClient.js.map +1 -0
  85. package/build/cli/hooks/useMcpManager.d.ts +26 -0
  86. package/build/cli/hooks/useMcpManager.js +89 -0
  87. package/build/cli/hooks/useMcpManager.js.map +1 -0
  88. package/build/cli/hooks/usePromptCompletion.d.ts +19 -0
  89. package/build/cli/hooks/usePromptCompletion.js +13 -0
  90. package/build/cli/hooks/usePromptCompletion.js.map +1 -0
  91. package/build/cli/hooks/useRagContext.d.ts +6 -0
  92. package/build/cli/hooks/useRagContext.js +84 -0
  93. package/build/cli/hooks/useRagContext.js.map +1 -0
  94. package/build/cli/hooks/useShellCompletion.d.ts +18 -0
  95. package/build/cli/hooks/useShellCompletion.js +10 -0
  96. package/build/cli/hooks/useShellCompletion.js.map +1 -0
  97. package/build/cli/hooks/useSlashCompletion.d.ts +21 -0
  98. package/build/cli/hooks/useSlashCompletion.js +11 -0
  99. package/build/cli/hooks/useSlashCompletion.js.map +1 -0
  100. package/build/cli/hooks/useTerminalSize.d.ts +4 -0
  101. package/build/cli/hooks/useTerminalSize.js +21 -0
  102. package/build/cli/hooks/useTerminalSize.js.map +1 -0
  103. package/build/cli/index.d.ts +1 -0
  104. package/build/cli/index.js +27 -0
  105. package/build/cli/index.js.map +1 -0
  106. package/build/cli/key/input.d.ts +5 -0
  107. package/build/cli/key/input.js +9 -0
  108. package/build/cli/key/input.js.map +1 -0
  109. package/build/cli/key/keyBindings.d.ts +152 -0
  110. package/build/cli/key/keyBindings.js +630 -0
  111. package/build/cli/key/keyBindings.js.map +1 -0
  112. package/build/cli/key/keyMatchers.d.ts +19 -0
  113. package/build/cli/key/keyMatchers.js +25 -0
  114. package/build/cli/key/keyMatchers.js.map +1 -0
  115. package/build/cli/key/mouse.d.ts +23 -0
  116. package/build/cli/key/mouse.js +155 -0
  117. package/build/cli/key/mouse.js.map +1 -0
  118. package/build/cli/key/text-buffer.d.ts +156 -0
  119. package/build/cli/key/text-buffer.js +937 -0
  120. package/build/cli/key/text-buffer.js.map +1 -0
  121. package/build/cli/main.d.ts +1 -0
  122. package/build/cli/main.js +20 -0
  123. package/build/cli/main.js.map +1 -0
  124. package/build/cli/services/McpClientService.d.ts +32 -0
  125. package/build/cli/services/McpClientService.js +123 -0
  126. package/build/cli/services/McpClientService.js.map +1 -0
  127. package/build/cli/services/McpManager.d.ts +28 -0
  128. package/build/cli/services/McpManager.js +146 -0
  129. package/build/cli/services/McpManager.js.map +1 -0
  130. package/build/cli/theme/builtin/default-dark.d.ts +7 -0
  131. package/build/cli/theme/builtin/default-dark.js +143 -0
  132. package/build/cli/theme/builtin/default-dark.js.map +1 -0
  133. package/build/cli/theme/builtin/no-color.d.ts +7 -0
  134. package/build/cli/theme/builtin/no-color.js +125 -0
  135. package/build/cli/theme/builtin/no-color.js.map +1 -0
  136. package/build/cli/theme/builtin/tokyonight-dark.d.ts +7 -0
  137. package/build/cli/theme/builtin/tokyonight-dark.js +146 -0
  138. package/build/cli/theme/builtin/tokyonight-dark.js.map +1 -0
  139. package/build/cli/theme/semantic-colors.d.ts +2 -0
  140. package/build/cli/theme/semantic-colors.js +19 -0
  141. package/build/cli/theme/semantic-colors.js.map +1 -0
  142. package/build/cli/theme/semantic-tokens.d.ts +42 -0
  143. package/build/cli/theme/semantic-tokens.js +77 -0
  144. package/build/cli/theme/semantic-tokens.js.map +1 -0
  145. package/build/cli/theme/theme-manager.d.ts +32 -0
  146. package/build/cli/theme/theme-manager.js +150 -0
  147. package/build/cli/theme/theme-manager.js.map +1 -0
  148. package/build/cli/theme/theme.d.ts +107 -0
  149. package/build/cli/theme/theme.js +333 -0
  150. package/build/cli/theme/theme.js.map +1 -0
  151. package/build/cli/tmp.d.ts +1 -0
  152. package/build/cli/tmp.js +27 -0
  153. package/build/cli/tmp.js.map +1 -0
  154. package/build/cli/types.d.ts +97 -0
  155. package/build/cli/types.js +2 -0
  156. package/build/cli/types.js.map +1 -0
  157. package/build/cli/ui/ConnectionStatus.d.ts +13 -0
  158. package/build/cli/ui/ConnectionStatus.js +19 -0
  159. package/build/cli/ui/ConnectionStatus.js.map +1 -0
  160. package/build/cli/ui/HalfPaddingBox.d.ts +13 -0
  161. package/build/cli/ui/HalfPaddingBox.js +11 -0
  162. package/build/cli/ui/HalfPaddingBox.js.map +1 -0
  163. package/build/cli/ui/HelpCommands.d.ts +5 -0
  164. package/build/cli/ui/HelpCommands.js +11 -0
  165. package/build/cli/ui/HelpCommands.js.map +1 -0
  166. package/build/cli/ui/HistoryItemDisplay.d.ts +9 -0
  167. package/build/cli/ui/HistoryItemDisplay.js +34 -0
  168. package/build/cli/ui/HistoryItemDisplay.js.map +1 -0
  169. package/build/cli/ui/InputPrompt.d.ts +13 -0
  170. package/build/cli/ui/InputPrompt.js +138 -0
  171. package/build/cli/ui/InputPrompt.js.map +1 -0
  172. package/build/cli/ui/LLMErrorComponent.d.ts +6 -0
  173. package/build/cli/ui/LLMErrorComponent.js +18 -0
  174. package/build/cli/ui/LLMErrorComponent.js.map +1 -0
  175. package/build/cli/ui/LLMHealthChecker.d.ts +8 -0
  176. package/build/cli/ui/LLMHealthChecker.js +22 -0
  177. package/build/cli/ui/LLMHealthChecker.js.map +1 -0
  178. package/build/cli/ui/MCPServers.d.ts +11 -0
  179. package/build/cli/ui/MCPServers.js +15 -0
  180. package/build/cli/ui/MCPServers.js.map +1 -0
  181. package/build/cli/ui/MainContent.d.ts +12 -0
  182. package/build/cli/ui/MainContent.js +28 -0
  183. package/build/cli/ui/MainContent.js.map +1 -0
  184. package/build/cli/ui/MarkdownDisplay.d.ts +8 -0
  185. package/build/cli/ui/MarkdownDisplay.js +6 -0
  186. package/build/cli/ui/MarkdownDisplay.js.map +1 -0
  187. package/build/cli/ui/MouseContext.d.ts +1 -0
  188. package/build/cli/ui/MouseContext.js +2 -0
  189. package/build/cli/ui/MouseContext.js.map +1 -0
  190. package/build/cli/ui/SuggestionsDisplay.d.ts +25 -0
  191. package/build/cli/ui/SuggestionsDisplay.js +45 -0
  192. package/build/cli/ui/SuggestionsDisplay.js.map +1 -0
  193. package/build/cli/ui/SystemInfoSummaryBox.d.ts +6 -0
  194. package/build/cli/ui/SystemInfoSummaryBox.js +6 -0
  195. package/build/cli/ui/SystemInfoSummaryBox.js.map +1 -0
  196. package/build/cli/ui/ThinkingIndicator.d.ts +2 -0
  197. package/build/cli/ui/ThinkingIndicator.js +16 -0
  198. package/build/cli/ui/ThinkingIndicator.js.map +1 -0
  199. package/build/cli/ui/layout/DefaultAppLayout.d.ts +2 -0
  200. package/build/cli/ui/layout/DefaultAppLayout.js +6 -0
  201. package/build/cli/ui/layout/DefaultAppLayout.js.map +1 -0
  202. package/build/cli/ui/shared/ExpandableText.d.ts +14 -0
  203. package/build/cli/ui/shared/ExpandableText.js +19 -0
  204. package/build/cli/ui/shared/ExpandableText.js.map +1 -0
  205. package/build/cli/utils/cache.d.ts +21 -0
  206. package/build/cli/utils/cache.js +56 -0
  207. package/build/cli/utils/cache.js.map +1 -0
  208. package/build/cli/utils/cleanup.d.ts +1 -0
  209. package/build/cli/utils/cleanup.js +5 -0
  210. package/build/cli/utils/cleanup.js.map +1 -0
  211. package/build/cli/utils/commandUtils.d.ts +11 -0
  212. package/build/cli/utils/commandUtils.js +16 -0
  213. package/build/cli/utils/commandUtils.js.map +1 -0
  214. package/build/cli/utils/historyStorage.d.ts +13 -0
  215. package/build/cli/utils/historyStorage.js +64 -0
  216. package/build/cli/utils/historyStorage.js.map +1 -0
  217. package/build/cli/utils/stdio.d.ts +18 -0
  218. package/build/cli/utils/stdio.js +58 -0
  219. package/build/cli/utils/stdio.js.map +1 -0
  220. package/build/cli/utils/terminal.d.ts +15 -0
  221. package/build/cli/utils/terminal.js +51 -0
  222. package/build/cli/utils/terminal.js.map +1 -0
  223. package/build/cli/utils/textUtil.d.ts +63 -0
  224. package/build/cli/utils/textUtil.js +231 -0
  225. package/build/cli/utils/textUtil.js.map +1 -0
  226. package/build/config.d.ts +25 -0
  227. package/{dist/src → build}/config.js +29 -8
  228. package/build/config.js.map +1 -0
  229. package/build/index.d.ts +2 -0
  230. package/{dist/src → build}/index.js +0 -3
  231. package/build/index.js.map +1 -0
  232. package/{dist/src → build}/server.d.ts +0 -1
  233. package/{dist/src → build}/server.js +1 -2
  234. package/build/server.js.map +1 -0
  235. package/{dist/src → build}/setup.d.ts +0 -2
  236. package/{dist/src → build}/setup.js +2 -4
  237. package/build/setup.js.map +1 -0
  238. package/build/shared/configSchema.d.ts +27 -0
  239. package/build/shared/configSchema.js +31 -0
  240. package/build/shared/configSchema.js.map +1 -0
  241. package/build/shared/index.d.ts +3 -0
  242. package/build/shared/index.js +4 -0
  243. package/build/shared/index.js.map +1 -0
  244. package/build/shared/types.d.ts +20 -0
  245. package/build/shared/types.js +2 -0
  246. package/build/shared/types.js.map +1 -0
  247. package/build/shared/utils/debugLogger.d.ts +12 -0
  248. package/build/shared/utils/debugLogger.js +54 -0
  249. package/build/shared/utils/debugLogger.js.map +1 -0
  250. package/{dist/src → build}/tools/create_document_with_properties/index.d.ts +22 -5
  251. package/{dist/src → build}/tools/create_document_with_properties/index.js +2 -2
  252. package/build/tools/create_document_with_properties/index.js.map +1 -0
  253. package/build/tools/create_document_with_properties/params.d.ts +66 -0
  254. package/{dist/src → build}/tools/create_document_with_properties/params.js +1 -1
  255. package/build/tools/create_document_with_properties/params.js.map +1 -0
  256. package/{dist/src → build}/tools/generate_property/index.d.ts +1 -2
  257. package/{dist/src → build}/tools/generate_property/index.js +1 -1
  258. package/build/tools/generate_property/index.js.map +1 -0
  259. package/{dist/src → build}/tools/generate_property/params.d.ts +30 -7
  260. package/build/tools/generate_property/params.js.map +1 -0
  261. package/{dist/src → build}/tools/index.d.ts +51 -36
  262. package/build/tools/index.js +13 -0
  263. package/build/tools/index.js.map +1 -0
  264. package/{dist/src → build}/tools/organize_attachments/index.d.ts +1 -2
  265. package/{dist/src → build}/tools/organize_attachments/index.js +2 -2
  266. package/build/tools/organize_attachments/index.js.map +1 -0
  267. package/build/tools/organize_attachments/params.d.ts +122 -0
  268. package/{dist/src → build}/tools/organize_attachments/params.js +3 -3
  269. package/build/tools/organize_attachments/params.js.map +1 -0
  270. package/{dist/src → build}/tools/organize_attachments/utils.d.ts +0 -1
  271. package/build/tools/organize_attachments/utils.js.map +1 -0
  272. package/{dist/src → build}/tools/vault/index.d.ts +5 -26
  273. package/{dist/src → build}/tools/vault/index.js +3 -3
  274. package/build/tools/vault/index.js.map +1 -0
  275. package/{dist/src → build}/tools/vault/metrics.d.ts +0 -1
  276. package/build/tools/vault/metrics.js.map +1 -0
  277. package/build/tools/vault/params.d.ts +115 -0
  278. package/{dist/src → build}/tools/vault/params.js +0 -1
  279. package/build/tools/vault/params.js.map +1 -0
  280. package/build/tools/vault/types/collect_context.d.ts +1340 -0
  281. package/{dist/src → build}/tools/vault/types/collect_context.js +1 -1
  282. package/build/tools/vault/types/collect_context.js.map +1 -0
  283. package/build/tools/vault/types/list_all.d.ts +387 -0
  284. package/{dist/src → build}/tools/vault/types/list_all.js +4 -9
  285. package/build/tools/vault/types/list_all.js.map +1 -0
  286. package/build/tools/vault/types/read_specific.d.ts +297 -0
  287. package/{dist/src → build}/tools/vault/types/read_specific.js +1 -3
  288. package/build/tools/vault/types/read_specific.js.map +1 -0
  289. package/build/tools/vault/types/search.d.ts +598 -0
  290. package/{dist/src → build}/tools/vault/types/search.js +8 -16
  291. package/build/tools/vault/types/search.js.map +1 -0
  292. package/{dist/src → build}/tools/vault/utils/actions/collect_context.d.ts +1 -2
  293. package/{dist/src → build}/tools/vault/utils/actions/collect_context.js +4 -4
  294. package/build/tools/vault/utils/actions/collect_context.js.map +1 -0
  295. package/{dist/src → build}/tools/vault/utils/actions/index_rag.d.ts +0 -1
  296. package/build/tools/vault/utils/actions/index_rag.js.map +1 -0
  297. package/{dist/src → build}/tools/vault/utils/actions/list_all.d.ts +1 -2
  298. package/{dist/src → build}/tools/vault/utils/actions/list_all.js +1 -1
  299. package/build/tools/vault/utils/actions/list_all.js.map +1 -0
  300. package/{dist/src → build}/tools/vault/utils/actions/load_memory.d.ts +1 -2
  301. package/{dist/src → build}/tools/vault/utils/actions/load_memory.js +3 -3
  302. package/build/tools/vault/utils/actions/load_memory.js.map +1 -0
  303. package/{dist/src → build}/tools/vault/utils/actions/read.d.ts +1 -2
  304. package/{dist/src → build}/tools/vault/utils/actions/read.js +1 -1
  305. package/build/tools/vault/utils/actions/read.js.map +1 -0
  306. package/{dist/src → build}/tools/vault/utils/actions/search.d.ts +1 -2
  307. package/{dist/src → build}/tools/vault/utils/actions/search.js +2 -2
  308. package/build/tools/vault/utils/actions/search.js.map +1 -0
  309. package/{dist/src → build}/tools/vault/utils/actions/stats.d.ts +0 -1
  310. package/build/tools/vault/utils/actions/stats.js.map +1 -0
  311. package/{dist/src → build}/tools/vault/utils/constants.d.ts +0 -1
  312. package/build/tools/vault/utils/constants.js.map +1 -0
  313. package/{dist/src → build}/tools/vault/utils/document.d.ts +0 -6
  314. package/{dist/src → build}/tools/vault/utils/document.js +0 -1
  315. package/build/tools/vault/utils/document.js.map +1 -0
  316. package/{dist/src → build}/tools/vault/utils/shared.d.ts +1 -2
  317. package/build/tools/vault/utils/shared.js.map +1 -0
  318. package/build/tools/vault/utils.d.ts +7 -0
  319. package/build/tools/vault/utils.js +8 -0
  320. package/build/tools/vault/utils.js.map +1 -0
  321. package/{dist/src → build}/tools/write_property/index.d.ts +22 -5
  322. package/{dist/src → build}/tools/write_property/index.js +1 -1
  323. package/build/tools/write_property/index.js.map +1 -0
  324. package/build/tools/write_property/params.d.ts +60 -0
  325. package/build/tools/write_property/params.js.map +1 -0
  326. package/{dist/src → build}/utils/DirectoryWalker.d.ts +1 -2
  327. package/build/utils/DirectoryWalker.js.map +1 -0
  328. package/{dist/src → build}/utils/Embedder.d.ts +0 -1
  329. package/{dist/src → build}/utils/Embedder.js +1 -1
  330. package/build/utils/Embedder.js.map +1 -0
  331. package/{dist/src → build}/utils/Indexer.d.ts +2 -3
  332. package/{dist/src → build}/utils/Indexer.js +2 -2
  333. package/build/utils/Indexer.js.map +1 -0
  334. package/{dist/src → build}/utils/LLMClient.d.ts +0 -5
  335. package/build/utils/LLMClient.js +53 -0
  336. package/build/utils/LLMClient.js.map +1 -0
  337. package/{dist/src → build}/utils/LocalReranker.d.ts +0 -1
  338. package/{dist/src → build}/utils/LocalReranker.js +1 -1
  339. package/build/utils/LocalReranker.js.map +1 -0
  340. package/{dist/src → build}/utils/RAGIndexer.d.ts +1 -2
  341. package/{dist/src → build}/utils/RAGIndexer.js +8 -11
  342. package/build/utils/RAGIndexer.js.map +1 -0
  343. package/build/utils/RerankerClient.d.ts +61 -0
  344. package/{dist/src → build}/utils/RerankerClient.js +1 -20
  345. package/build/utils/RerankerClient.js.map +1 -0
  346. package/{dist/src → build}/utils/VaultManger/VaultManager.d.ts +3 -7
  347. package/{dist/src → build}/utils/VaultManger/VaultManager.js +17 -20
  348. package/build/utils/VaultManger/VaultManager.js.map +1 -0
  349. package/{dist/src → build}/utils/VaultManger/VaultPathError.d.ts +0 -1
  350. package/build/utils/VaultManger/VaultPathError.js.map +1 -0
  351. package/build/utils/VaultManger/index.d.ts +3 -0
  352. package/build/utils/VaultManger/index.js +3 -0
  353. package/build/utils/VaultManger/index.js.map +1 -0
  354. package/{dist/src → build}/utils/VaultManger/types.d.ts +1 -2
  355. package/build/utils/VaultManger/types.js +2 -0
  356. package/build/utils/VaultManger/types.js.map +1 -0
  357. package/{dist/src → build}/utils/VaultWatcher.d.ts +0 -1
  358. package/{dist/src → build}/utils/VaultWatcher.js +1 -1
  359. package/build/utils/VaultWatcher.js.map +1 -0
  360. package/{dist/src → build}/utils/VectorDB.d.ts +0 -1
  361. package/build/utils/VectorDB.js +241 -0
  362. package/build/utils/VectorDB.js.map +1 -0
  363. package/{dist/src → build}/utils/constants.d.ts +0 -1
  364. package/build/utils/constants.js.map +1 -0
  365. package/{dist/src → build}/utils/createToolError.d.ts +0 -1
  366. package/build/utils/createToolError.js.map +1 -0
  367. package/build/utils/getVaultManager.d.ts +2 -0
  368. package/{dist/src → build}/utils/getVaultManager.js +1 -7
  369. package/build/utils/getVaultManager.js.map +1 -0
  370. package/{dist/src → build}/utils/processor/LinkExtractor.d.ts +0 -1
  371. package/build/utils/processor/LinkExtractor.js.map +1 -0
  372. package/build/utils/processor/MatterParser.d.ts +2 -0
  373. package/build/utils/processor/MatterParser.js +28 -0
  374. package/build/utils/processor/MatterParser.js.map +1 -0
  375. package/build/utils/processor/types.d.ts +104 -0
  376. package/{dist/src → build}/utils/processor/types.js +2 -10
  377. package/build/utils/processor/types.js.map +1 -0
  378. package/{dist/src → build}/utils/semaphore.d.ts +0 -1
  379. package/build/utils/semaphore.js.map +1 -0
  380. package/package.json +84 -72
  381. package/dist/package.json +0 -74
  382. package/dist/src/config.d.ts +0 -6
  383. package/dist/src/config.d.ts.map +0 -1
  384. package/dist/src/config.js.map +0 -1
  385. package/dist/src/db.d.ts +0 -2
  386. package/dist/src/db.d.ts.map +0 -1
  387. package/dist/src/db.js +0 -58
  388. package/dist/src/db.js.map +0 -1
  389. package/dist/src/index.d.ts +0 -3
  390. package/dist/src/index.d.ts.map +0 -1
  391. package/dist/src/index.js.map +0 -1
  392. package/dist/src/server.d.ts.map +0 -1
  393. package/dist/src/server.js.map +0 -1
  394. package/dist/src/setup.d.ts.map +0 -1
  395. package/dist/src/setup.js.map +0 -1
  396. package/dist/src/tools/create_document_with_properties/index.d.ts.map +0 -1
  397. package/dist/src/tools/create_document_with_properties/index.js.map +0 -1
  398. package/dist/src/tools/create_document_with_properties/params.d.ts +0 -19
  399. package/dist/src/tools/create_document_with_properties/params.d.ts.map +0 -1
  400. package/dist/src/tools/create_document_with_properties/params.js.map +0 -1
  401. package/dist/src/tools/generate_property/index.d.ts.map +0 -1
  402. package/dist/src/tools/generate_property/index.js.map +0 -1
  403. package/dist/src/tools/generate_property/params.d.ts.map +0 -1
  404. package/dist/src/tools/generate_property/params.js.map +0 -1
  405. package/dist/src/tools/index.d.ts.map +0 -1
  406. package/dist/src/tools/index.js +0 -13
  407. package/dist/src/tools/index.js.map +0 -1
  408. package/dist/src/tools/organize_attachments/index.d.ts.map +0 -1
  409. package/dist/src/tools/organize_attachments/index.js.map +0 -1
  410. package/dist/src/tools/organize_attachments/params.d.ts +0 -47
  411. package/dist/src/tools/organize_attachments/params.d.ts.map +0 -1
  412. package/dist/src/tools/organize_attachments/params.js.map +0 -1
  413. package/dist/src/tools/organize_attachments/utils.d.ts.map +0 -1
  414. package/dist/src/tools/organize_attachments/utils.js.map +0 -1
  415. package/dist/src/tools/vault/index.d.ts.map +0 -1
  416. package/dist/src/tools/vault/index.js.map +0 -1
  417. package/dist/src/tools/vault/metrics.d.ts.map +0 -1
  418. package/dist/src/tools/vault/metrics.js.map +0 -1
  419. package/dist/src/tools/vault/params.d.ts +0 -100
  420. package/dist/src/tools/vault/params.d.ts.map +0 -1
  421. package/dist/src/tools/vault/params.js.map +0 -1
  422. package/dist/src/tools/vault/types/collect_context.d.ts +0 -388
  423. package/dist/src/tools/vault/types/collect_context.d.ts.map +0 -1
  424. package/dist/src/tools/vault/types/collect_context.js.map +0 -1
  425. package/dist/src/tools/vault/types/list_all.d.ts +0 -89
  426. package/dist/src/tools/vault/types/list_all.d.ts.map +0 -1
  427. package/dist/src/tools/vault/types/list_all.js.map +0 -1
  428. package/dist/src/tools/vault/types/read_specific.d.ts +0 -68
  429. package/dist/src/tools/vault/types/read_specific.d.ts.map +0 -1
  430. package/dist/src/tools/vault/types/read_specific.js.map +0 -1
  431. package/dist/src/tools/vault/types/search.d.ts +0 -151
  432. package/dist/src/tools/vault/types/search.d.ts.map +0 -1
  433. package/dist/src/tools/vault/types/search.js.map +0 -1
  434. package/dist/src/tools/vault/utils/actions/collect_context.d.ts.map +0 -1
  435. package/dist/src/tools/vault/utils/actions/collect_context.js.map +0 -1
  436. package/dist/src/tools/vault/utils/actions/index_rag.d.ts.map +0 -1
  437. package/dist/src/tools/vault/utils/actions/index_rag.js.map +0 -1
  438. package/dist/src/tools/vault/utils/actions/list_all.d.ts.map +0 -1
  439. package/dist/src/tools/vault/utils/actions/list_all.js.map +0 -1
  440. package/dist/src/tools/vault/utils/actions/load_memory.d.ts.map +0 -1
  441. package/dist/src/tools/vault/utils/actions/load_memory.js.map +0 -1
  442. package/dist/src/tools/vault/utils/actions/read.d.ts.map +0 -1
  443. package/dist/src/tools/vault/utils/actions/read.js.map +0 -1
  444. package/dist/src/tools/vault/utils/actions/search.d.ts.map +0 -1
  445. package/dist/src/tools/vault/utils/actions/search.js.map +0 -1
  446. package/dist/src/tools/vault/utils/actions/stats.d.ts.map +0 -1
  447. package/dist/src/tools/vault/utils/actions/stats.js.map +0 -1
  448. package/dist/src/tools/vault/utils/constants.d.ts.map +0 -1
  449. package/dist/src/tools/vault/utils/constants.js.map +0 -1
  450. package/dist/src/tools/vault/utils/document.d.ts.map +0 -1
  451. package/dist/src/tools/vault/utils/document.js.map +0 -1
  452. package/dist/src/tools/vault/utils/shared.d.ts.map +0 -1
  453. package/dist/src/tools/vault/utils/shared.js.map +0 -1
  454. package/dist/src/tools/vault/utils.d.ts +0 -8
  455. package/dist/src/tools/vault/utils.d.ts.map +0 -1
  456. package/dist/src/tools/vault/utils.js +0 -8
  457. package/dist/src/tools/vault/utils.js.map +0 -1
  458. package/dist/src/tools/write_property/index.d.ts.map +0 -1
  459. package/dist/src/tools/write_property/index.js.map +0 -1
  460. package/dist/src/tools/write_property/params.d.ts +0 -17
  461. package/dist/src/tools/write_property/params.d.ts.map +0 -1
  462. package/dist/src/tools/write_property/params.js.map +0 -1
  463. package/dist/src/utils/DirectoryWalker.d.ts.map +0 -1
  464. package/dist/src/utils/DirectoryWalker.js.map +0 -1
  465. package/dist/src/utils/Embedder.d.ts.map +0 -1
  466. package/dist/src/utils/Embedder.js.map +0 -1
  467. package/dist/src/utils/Indexer.d.ts.map +0 -1
  468. package/dist/src/utils/Indexer.js.map +0 -1
  469. package/dist/src/utils/LLMClient.d.ts.map +0 -1
  470. package/dist/src/utils/LLMClient.js +0 -112
  471. package/dist/src/utils/LLMClient.js.map +0 -1
  472. package/dist/src/utils/LocalReranker.d.ts.map +0 -1
  473. package/dist/src/utils/LocalReranker.js.map +0 -1
  474. package/dist/src/utils/RAGIndexer.d.ts.map +0 -1
  475. package/dist/src/utils/RAGIndexer.js.map +0 -1
  476. package/dist/src/utils/RerankerClient.d.ts +0 -28
  477. package/dist/src/utils/RerankerClient.d.ts.map +0 -1
  478. package/dist/src/utils/RerankerClient.js.map +0 -1
  479. package/dist/src/utils/VaultManger/VaultManager.d.ts.map +0 -1
  480. package/dist/src/utils/VaultManger/VaultManager.js.map +0 -1
  481. package/dist/src/utils/VaultManger/VaultPathError.d.ts.map +0 -1
  482. package/dist/src/utils/VaultManger/VaultPathError.js.map +0 -1
  483. package/dist/src/utils/VaultManger/index.d.ts +0 -4
  484. package/dist/src/utils/VaultManger/index.d.ts.map +0 -1
  485. package/dist/src/utils/VaultManger/index.js +0 -3
  486. package/dist/src/utils/VaultManger/index.js.map +0 -1
  487. package/dist/src/utils/VaultManger/types.d.ts.map +0 -1
  488. package/dist/src/utils/VaultManger/types.js.map +0 -1
  489. package/dist/src/utils/VaultWatcher.d.ts.map +0 -1
  490. package/dist/src/utils/VaultWatcher.js.map +0 -1
  491. package/dist/src/utils/VectorDB.d.ts.map +0 -1
  492. package/dist/src/utils/VectorDB.js +0 -305
  493. package/dist/src/utils/VectorDB.js.map +0 -1
  494. package/dist/src/utils/constants.d.ts.map +0 -1
  495. package/dist/src/utils/constants.js.map +0 -1
  496. package/dist/src/utils/createToolError.d.ts.map +0 -1
  497. package/dist/src/utils/createToolError.js.map +0 -1
  498. package/dist/src/utils/getVaultManager.d.ts +0 -7
  499. package/dist/src/utils/getVaultManager.d.ts.map +0 -1
  500. package/dist/src/utils/getVaultManager.js.map +0 -1
  501. package/dist/src/utils/processor/LinkExtractor.d.ts.map +0 -1
  502. package/dist/src/utils/processor/LinkExtractor.js.map +0 -1
  503. package/dist/src/utils/processor/MatterParser.d.ts +0 -3
  504. package/dist/src/utils/processor/MatterParser.d.ts.map +0 -1
  505. package/dist/src/utils/processor/MatterParser.js +0 -27
  506. package/dist/src/utils/processor/MatterParser.js.map +0 -1
  507. package/dist/src/utils/processor/types.d.ts +0 -53
  508. package/dist/src/utils/processor/types.d.ts.map +0 -1
  509. package/dist/src/utils/processor/types.js.map +0 -1
  510. package/dist/src/utils/semaphore.d.ts.map +0 -1
  511. package/dist/src/utils/semaphore.js.map +0 -1
  512. package/dist/tsconfig.build.tsbuildinfo +0 -1
  513. /package/{dist/src/utils/VaultManger → build/cli/hooks/useLlmStream}/types.js +0 -0
  514. /package/{dist/src → build}/tools/generate_property/params.js +0 -0
  515. /package/{dist/src → build}/tools/organize_attachments/utils.js +0 -0
  516. /package/{dist/src → build}/tools/vault/metrics.js +0 -0
  517. /package/{dist/src → build}/tools/vault/utils/actions/index_rag.js +0 -0
  518. /package/{dist/src → build}/tools/vault/utils/actions/stats.js +0 -0
  519. /package/{dist/src → build}/tools/vault/utils/constants.js +0 -0
  520. /package/{dist/src → build}/tools/vault/utils/shared.js +0 -0
  521. /package/{dist/src → build}/tools/write_property/params.js +0 -0
  522. /package/{dist/src → build}/utils/DirectoryWalker.js +0 -0
  523. /package/{dist/src → build}/utils/VaultManger/VaultPathError.js +0 -0
  524. /package/{dist/src → build}/utils/constants.js +0 -0
  525. /package/{dist/src → build}/utils/createToolError.js +0 -0
  526. /package/{dist/src → build}/utils/processor/LinkExtractor.js +0 -0
  527. /package/{dist/src → build}/utils/semaphore.js +0 -0
@@ -0,0 +1,937 @@
1
+ import { LRU_BUFFER_PERF_CACHE_LIMIT } from "../constants.js";
2
+ import { cpLen, cpSlice, getCachedStringWidth, toCodePoints, } from "../utils/textUtil.js";
3
+ import { LRUCache } from "mnemonist";
4
+ import { useCallback, useEffect, useMemo, useReducer } from "react";
5
+ export const PASTED_TEXT_PLACEHOLDER_REGEX = /\[Pasted Text: \d+ (?:lines|chars)(?: #\d+)?\]/g;
6
+ const lineLayoutCache = new LRUCache(LRU_BUFFER_PERF_CACHE_LIMIT);
7
+ function getLineLayoutCacheKey(line, viewportWidth, isCursorOnLine, cursorCol) {
8
+ // Most lines (99.9% in a large buffer) are not cursor lines.
9
+ // We use a simpler key for them to reduce string allocation overhead.
10
+ if (!isCursorOnLine) {
11
+ return `${viewportWidth}:N:${line}`;
12
+ }
13
+ return `${viewportWidth}:C:${cursorCol}:${line}`;
14
+ }
15
+ function calculateVisualCursorFromLayout(layout, logicalCursor) {
16
+ const { logicalToVisualMap, visualLines, transformedToLogicalMaps } = layout;
17
+ const [logicalRow, logicalCol] = logicalCursor;
18
+ const segmentsForLogicalLine = logicalToVisualMap[logicalRow];
19
+ if (!segmentsForLogicalLine || segmentsForLogicalLine.length === 0) {
20
+ // This can happen for an empty document.
21
+ return [0, 0, 0];
22
+ }
23
+ // Find the segment where the logical column fits.
24
+ // The segments are sorted by startColInLogical.
25
+ let targetSegmentIndex = segmentsForLogicalLine.findIndex(([, startColInLogical], index) => {
26
+ const nextStartColInLogical = index + 1 < segmentsForLogicalLine.length
27
+ ? segmentsForLogicalLine[index + 1][1]
28
+ : Infinity;
29
+ return (logicalCol >= startColInLogical && logicalCol < nextStartColInLogical);
30
+ });
31
+ // If not found, it means the cursor is at the end of the logical line.
32
+ if (targetSegmentIndex === -1) {
33
+ if (logicalCol === 0) {
34
+ targetSegmentIndex = 0;
35
+ }
36
+ else {
37
+ targetSegmentIndex = segmentsForLogicalLine.length - 1;
38
+ }
39
+ }
40
+ const [visualRow, startColInLogical] = segmentsForLogicalLine[targetSegmentIndex];
41
+ // Find the coordinates in transformed space in order to conver to visual
42
+ const transformedToLogicalMap = transformedToLogicalMaps[logicalRow] ?? [];
43
+ let transformedCol = 0;
44
+ for (let i = 0; i < transformedToLogicalMap.length; i++) {
45
+ if (transformedToLogicalMap[i] > logicalCol) {
46
+ transformedCol = Math.max(0, i - 1);
47
+ break;
48
+ }
49
+ if (i === transformedToLogicalMap.length - 1) {
50
+ transformedCol = transformedToLogicalMap.length - 1;
51
+ }
52
+ }
53
+ let startColInTransformed = 0;
54
+ while (startColInTransformed < transformedToLogicalMap.length &&
55
+ transformedToLogicalMap[startColInTransformed] < startColInLogical) {
56
+ startColInTransformed++;
57
+ }
58
+ const clampedTransformedCol = Math.min(transformedCol, Math.max(0, transformedToLogicalMap.length - 1));
59
+ const visualColIndex = clampedTransformedCol - startColInTransformed;
60
+ const currentVisualLineText = visualLines[visualRow] ?? "";
61
+ let visualColWidth = 0;
62
+ const codePoints = toCodePoints(currentVisualLineText);
63
+ for (let i = 0; i < Math.min(visualColIndex, codePoints.length); i++) {
64
+ visualColWidth += getCachedStringWidth(codePoints[i]);
65
+ }
66
+ const clampedVisualColIndex = Math.min(Math.max(visualColIndex, 0), codePoints.length);
67
+ return [visualRow, clampedVisualColIndex, visualColWidth];
68
+ }
69
+ /**
70
+ * Helper: Converts logical row/col position to absolute text offset
71
+ */
72
+ export function logicalPosToOffset(lines, row, col) {
73
+ let offset = 0;
74
+ const actualRow = Math.min(row, lines.length - 1);
75
+ for (let i = 0; i < actualRow; i++) {
76
+ offset += cpLen(lines[i]) + 1; // +1 for newline
77
+ }
78
+ if (actualRow >= 0 && actualRow < lines.length) {
79
+ offset += Math.min(col, cpLen(lines[actualRow]));
80
+ }
81
+ return offset;
82
+ }
83
+ /**
84
+ * Helper: Converts absolute text offset to logical row/col position
85
+ */
86
+ export function offsetToLogicalPos(text, offset) {
87
+ const lines = text.split("\n");
88
+ let currentOffset = 0;
89
+ for (let i = 0; i < lines.length; i++) {
90
+ const lineLen = cpLen(lines[i]);
91
+ const lineLenWithNewline = lineLen + (i < lines.length - 1 ? 1 : 0);
92
+ if (offset <= currentOffset + lineLen) {
93
+ return [i, offset - currentOffset];
94
+ }
95
+ if (offset < currentOffset + lineLenWithNewline) {
96
+ return [i, lineLen];
97
+ }
98
+ currentOffset += lineLenWithNewline;
99
+ }
100
+ const lastRow = Math.max(0, lines.length - 1);
101
+ return [lastRow, cpLen(lines[lastRow] || "")];
102
+ }
103
+ function bufferReducerLogic(state, action) {
104
+ const { lines, cursorRow, cursorCol } = state;
105
+ const currentLineText = lines[cursorRow] || "";
106
+ const lineCount = lines.length;
107
+ const pushUndo = (_newLines) => {
108
+ return [...state.undoStack, lines].slice(-100);
109
+ };
110
+ switch (action.type) {
111
+ case "SET_VIEWPORT":
112
+ return {
113
+ ...state,
114
+ viewportWidth: action.payload.width,
115
+ viewportHeight: action.payload.height,
116
+ };
117
+ case "SET_TEXT": {
118
+ const newLines = action.payload.replace(/\r\n/g, "\n").split("\n");
119
+ const safeLines = newLines.length > 0 ? newLines : [""];
120
+ let r = 0;
121
+ let c = 0;
122
+ if (action.cursorPosition === "end") {
123
+ r = safeLines.length - 1;
124
+ c = cpLen(safeLines[r]);
125
+ }
126
+ else if (typeof action.cursorPosition === "number") {
127
+ [r, c] = offsetToLogicalPos(action.payload, action.cursorPosition);
128
+ }
129
+ return {
130
+ ...state,
131
+ lines: safeLines,
132
+ cursorRow: r,
133
+ cursorCol: c,
134
+ preferredCol: null,
135
+ undoStack: pushUndo(safeLines),
136
+ redoStack: [],
137
+ };
138
+ }
139
+ case "INSERT": {
140
+ const payload = action.payload
141
+ .replace(/\r\n/g, "\n")
142
+ .replace(/\r/g, "\n");
143
+ const parts = payload.split("\n");
144
+ const newLines = [...lines];
145
+ const before = cpSlice(currentLineText, 0, cursorCol);
146
+ const after = cpSlice(currentLineText, cursorCol);
147
+ let nextRow = cursorRow;
148
+ let nextCol = cursorCol;
149
+ if (parts.length === 1) {
150
+ newLines[cursorRow] = before + parts[0] + after;
151
+ nextCol = cursorCol + cpLen(parts[0]);
152
+ }
153
+ else {
154
+ const firstLine = before + parts[0];
155
+ const lastPart = parts[parts.length - 1];
156
+ const lastLine = lastPart + after;
157
+ const middle = parts.slice(1, -1);
158
+ newLines.splice(cursorRow, 1, firstLine, ...middle, lastLine);
159
+ nextRow = cursorRow + parts.length - 1;
160
+ nextCol = cpLen(lastPart);
161
+ }
162
+ return {
163
+ ...state,
164
+ lines: newLines,
165
+ cursorRow: nextRow,
166
+ cursorCol: nextCol,
167
+ preferredCol: null,
168
+ undoStack: pushUndo(newLines),
169
+ redoStack: [],
170
+ };
171
+ }
172
+ case "NEWLINE": {
173
+ const newLines = [...lines];
174
+ const before = cpSlice(currentLineText, 0, cursorCol);
175
+ const after = cpSlice(currentLineText, cursorCol);
176
+ newLines[cursorRow] = before;
177
+ newLines.splice(cursorRow + 1, 0, after);
178
+ return {
179
+ ...state,
180
+ lines: newLines,
181
+ cursorRow: cursorRow + 1,
182
+ cursorCol: 0,
183
+ preferredCol: null,
184
+ undoStack: pushUndo(newLines),
185
+ redoStack: [],
186
+ };
187
+ }
188
+ case "BACKSPACE": {
189
+ if (cursorCol === 0 && cursorRow === 0)
190
+ return state;
191
+ const newLines = [...lines];
192
+ if (cursorCol > 0) {
193
+ newLines[cursorRow] =
194
+ cpSlice(currentLineText, 0, cursorCol - 1) +
195
+ cpSlice(currentLineText, cursorCol);
196
+ return {
197
+ ...state,
198
+ lines: newLines,
199
+ cursorCol: cursorCol - 1,
200
+ preferredCol: null,
201
+ undoStack: pushUndo(newLines),
202
+ redoStack: [],
203
+ };
204
+ }
205
+ else {
206
+ const prevLine = lines[cursorRow - 1];
207
+ const prevLen = cpLen(prevLine);
208
+ newLines[cursorRow - 1] = prevLine + currentLineText;
209
+ newLines.splice(cursorRow, 1);
210
+ return {
211
+ ...state,
212
+ lines: newLines,
213
+ cursorRow: cursorRow - 1,
214
+ cursorCol: prevLen,
215
+ preferredCol: null,
216
+ undoStack: pushUndo(newLines),
217
+ redoStack: [],
218
+ };
219
+ }
220
+ }
221
+ case "DELETE": {
222
+ if (cursorCol === cpLen(currentLineText) && cursorRow === lineCount - 1)
223
+ return state;
224
+ const newLines = [...lines];
225
+ if (cursorCol < cpLen(currentLineText)) {
226
+ newLines[cursorRow] =
227
+ cpSlice(currentLineText, 0, cursorCol) +
228
+ cpSlice(currentLineText, cursorCol + 1);
229
+ }
230
+ else {
231
+ newLines[cursorRow] = currentLineText + lines[cursorRow + 1];
232
+ newLines.splice(cursorRow + 1, 1);
233
+ }
234
+ return {
235
+ ...state,
236
+ lines: newLines,
237
+ preferredCol: null,
238
+ undoStack: pushUndo(newLines),
239
+ redoStack: [],
240
+ };
241
+ }
242
+ case "KILL_LINE_RIGHT": {
243
+ const newLines = [...lines];
244
+ newLines[cursorRow] = cpSlice(currentLineText, 0, cursorCol);
245
+ return {
246
+ ...state,
247
+ lines: newLines,
248
+ preferredCol: null,
249
+ undoStack: pushUndo(newLines),
250
+ redoStack: [],
251
+ };
252
+ }
253
+ case "KILL_LINE_LEFT": {
254
+ const newLines = [...lines];
255
+ newLines[cursorRow] = cpSlice(currentLineText, cursorCol);
256
+ return {
257
+ ...state,
258
+ lines: newLines,
259
+ cursorCol: 0,
260
+ preferredCol: null,
261
+ undoStack: pushUndo(newLines),
262
+ redoStack: [],
263
+ };
264
+ }
265
+ case "DELETE_WORD_LEFT": {
266
+ if (cursorCol === 0)
267
+ return state;
268
+ const before = cpSlice(currentLineText, 0, cursorCol);
269
+ const after = cpSlice(currentLineText, cursorCol);
270
+ // Simple word boundary: skip whitespace then skip non-whitespace
271
+ let i = before.length - 1;
272
+ while (i >= 0 && before[i] === " ")
273
+ i--;
274
+ while (i >= 0 && before[i] !== " ")
275
+ i--;
276
+ const newBefore = before.slice(0, i + 1);
277
+ const newLines = [...lines];
278
+ newLines[cursorRow] = newBefore + after;
279
+ return {
280
+ ...state,
281
+ lines: newLines,
282
+ cursorCol: cpLen(newBefore),
283
+ preferredCol: null,
284
+ undoStack: pushUndo(newLines),
285
+ redoStack: [],
286
+ };
287
+ }
288
+ case "DELETE_WORD_RIGHT": {
289
+ const before = cpSlice(currentLineText, 0, cursorCol);
290
+ const after = cpSlice(currentLineText, cursorCol);
291
+ if (after.length === 0)
292
+ return state;
293
+ let i = 0;
294
+ while (i < after.length && after[i] === " ")
295
+ i++;
296
+ while (i < after.length && after[i] !== " ")
297
+ i++;
298
+ const newAfter = after.slice(i);
299
+ const newLines = [...lines];
300
+ newLines[cursorRow] = before + newAfter;
301
+ return {
302
+ ...state,
303
+ lines: newLines,
304
+ preferredCol: null,
305
+ undoStack: pushUndo(newLines),
306
+ redoStack: [],
307
+ };
308
+ }
309
+ case "MOVE": {
310
+ const { dir } = action;
311
+ const { visualLayout, preferredCol } = state;
312
+ const [vRow, , vWidth] = calculateVisualCursorFromLayout(visualLayout, [
313
+ cursorRow,
314
+ cursorCol,
315
+ ]);
316
+ if (dir === "left" ||
317
+ dir === "right" ||
318
+ dir === "home" ||
319
+ dir === "end") {
320
+ let r = cursorRow;
321
+ let c = cursorCol;
322
+ if (dir === "left") {
323
+ if (c > 0)
324
+ c--;
325
+ else if (r > 0) {
326
+ r--;
327
+ c = cpLen(lines[r]);
328
+ }
329
+ }
330
+ else if (dir === "right") {
331
+ if (c < cpLen(currentLineText))
332
+ c++;
333
+ else if (r < lineCount - 1) {
334
+ r++;
335
+ c = 0;
336
+ }
337
+ }
338
+ else if (dir === "home")
339
+ c = 0;
340
+ else if (dir === "end")
341
+ c = cpLen(currentLineText);
342
+ return { ...state, cursorRow: r, cursorCol: c, preferredCol: null };
343
+ }
344
+ // Up/Down movement (width-based)
345
+ let newVisRow = vRow;
346
+ const targetWidth = preferredCol !== null ? preferredCol : vWidth;
347
+ if (dir === "up" && newVisRow > 0) {
348
+ newVisRow--;
349
+ }
350
+ else if (dir === "down" &&
351
+ newVisRow < visualLayout.visualLines.length - 1) {
352
+ newVisRow++;
353
+ }
354
+ else {
355
+ return state;
356
+ }
357
+ // Find the logical index in the new visual line that best matches the targetWidth
358
+ const newLineText = visualLayout.visualLines[newVisRow] ?? "";
359
+ const codePoints = toCodePoints(newLineText);
360
+ let currentWidth = 0;
361
+ let newVisColIdx = 0;
362
+ for (let i = 0; i < codePoints.length; i++) {
363
+ const charWidth = getCachedStringWidth(codePoints[i]);
364
+ if (currentWidth + charWidth > targetWidth) {
365
+ break;
366
+ }
367
+ currentWidth += charWidth;
368
+ newVisColIdx = i + 1;
369
+ }
370
+ const mapping = visualLayout.visualToLogicalMap[newVisRow];
371
+ if (mapping) {
372
+ return {
373
+ ...state,
374
+ cursorRow: mapping[0],
375
+ cursorCol: mapping[1] + newVisColIdx,
376
+ preferredCol: targetWidth,
377
+ };
378
+ }
379
+ return state;
380
+ }
381
+ case "REPLACE_RANGE": {
382
+ const { startRow, startCol, endRow, endCol, text } = action.payload;
383
+ const newLines = [...lines];
384
+ const prefix = cpSlice(lines[startRow] || "", 0, startCol);
385
+ const suffix = cpSlice(lines[endRow] || "", endCol);
386
+ const replacementParts = text.replace(/\r\n/g, "\n").split("\n");
387
+ const firstPart = prefix + replacementParts[0];
388
+ const lastPart = replacementParts[replacementParts.length - 1] + suffix;
389
+ if (replacementParts.length === 1) {
390
+ newLines.splice(startRow, endRow - startRow + 1, firstPart + suffix);
391
+ }
392
+ else {
393
+ const middleParts = replacementParts.slice(1, -1);
394
+ newLines.splice(startRow, endRow - startRow + 1, firstPart, ...middleParts, lastPart);
395
+ }
396
+ return {
397
+ ...state,
398
+ lines: newLines,
399
+ cursorRow: startRow + replacementParts.length - 1,
400
+ cursorCol: cpLen(replacementParts[replacementParts.length - 1]),
401
+ preferredCol: null,
402
+ undoStack: pushUndo(newLines),
403
+ redoStack: [],
404
+ };
405
+ }
406
+ case "UNDO": {
407
+ if (state.undoStack.length === 0)
408
+ return state;
409
+ const prevLines = state.undoStack[state.undoStack.length - 1];
410
+ return {
411
+ ...state,
412
+ lines: prevLines,
413
+ undoStack: state.undoStack.slice(0, -1),
414
+ redoStack: [...state.redoStack, lines],
415
+ cursorRow: Math.max(0, prevLines.length - 1),
416
+ cursorCol: cpLen(prevLines[prevLines.length - 1] || ""),
417
+ preferredCol: null,
418
+ };
419
+ }
420
+ case "REDO": {
421
+ if (state.redoStack.length === 0)
422
+ return state;
423
+ const nextLines = state.redoStack[state.redoStack.length - 1];
424
+ return {
425
+ ...state,
426
+ lines: nextLines,
427
+ redoStack: state.redoStack.slice(0, -1),
428
+ undoStack: [...state.undoStack, lines],
429
+ cursorRow: Math.max(0, nextLines.length - 1),
430
+ cursorCol: cpLen(nextLines[nextLines.length - 1] || ""),
431
+ preferredCol: null,
432
+ };
433
+ }
434
+ default:
435
+ return state;
436
+ }
437
+ }
438
+ const transformationsCache = new LRUCache(LRU_BUFFER_PERF_CACHE_LIMIT);
439
+ export function calculateTransformationsForLine(line) {
440
+ const cached = transformationsCache.get(line);
441
+ if (cached) {
442
+ return cached;
443
+ }
444
+ const transformations = [];
445
+ // 2. Detect paste placeholders
446
+ const pasteRegex = new RegExp(PASTED_TEXT_PLACEHOLDER_REGEX.source, "g");
447
+ const match = pasteRegex.exec(line);
448
+ while (match !== null) {
449
+ const logicalText = match[0];
450
+ const logStart = cpLen(line.substring(0, match.index));
451
+ const logEnd = logStart + cpLen(logicalText);
452
+ transformations.push({
453
+ logStart,
454
+ logEnd,
455
+ logicalText,
456
+ collapsedText: logicalText,
457
+ type: "paste",
458
+ id: logicalText,
459
+ });
460
+ }
461
+ // Sort transformations by logStart to maintain consistency
462
+ transformations.sort((a, b) => a.logStart - b.logStart);
463
+ transformationsCache.set(line, transformations);
464
+ return transformations;
465
+ }
466
+ export function calculateTransformedLine(logLine, logIndex, logicalCursor, transformations) {
467
+ let transformedLine = "";
468
+ const transformedToLogMap = [];
469
+ let lastLogPos = 0;
470
+ const cursorIsOnThisLine = logIndex === logicalCursor[0];
471
+ const cursorCol = logicalCursor[1];
472
+ for (const transform of transformations) {
473
+ const textBeforeTransformation = cpSlice(logLine, lastLogPos, transform.logStart);
474
+ transformedLine += textBeforeTransformation;
475
+ for (let i = 0; i < cpLen(textBeforeTransformation); i++) {
476
+ transformedToLogMap.push(lastLogPos + i);
477
+ }
478
+ const isExpanded = transform.type === "image" &&
479
+ cursorIsOnThisLine &&
480
+ cursorCol >= transform.logStart &&
481
+ cursorCol <= transform.logEnd;
482
+ const transformedText = isExpanded
483
+ ? transform.logicalText
484
+ : transform.collapsedText;
485
+ transformedLine += transformedText;
486
+ // Map transformed characters back to logical characters
487
+ const transformedLen = cpLen(transformedText);
488
+ if (isExpanded) {
489
+ for (let i = 0; i < transformedLen; i++) {
490
+ transformedToLogMap.push(transform.logStart + i);
491
+ }
492
+ }
493
+ else {
494
+ // Collapsed: distribute transformed positions monotonically across the raw span.
495
+ // This preserves ordering across wrapped slices so logicalToVisualMap has
496
+ // increasing startColInLogical and visual cursor mapping remains consistent.
497
+ const logicalLength = Math.max(0, transform.logEnd - transform.logStart);
498
+ for (let i = 0; i < transformedLen; i++) {
499
+ // Map the i-th transformed code point into [logStart, logEnd)
500
+ const transformationToLogicalOffset = logicalLength === 0
501
+ ? 0
502
+ : Math.floor((i * logicalLength) / transformedLen);
503
+ const transformationToLogicalIndex = transform.logStart +
504
+ Math.min(transformationToLogicalOffset, Math.max(logicalLength - 1, 0));
505
+ transformedToLogMap.push(transformationToLogicalIndex);
506
+ }
507
+ }
508
+ lastLogPos = transform.logEnd;
509
+ }
510
+ // Append text after last transform
511
+ const remainingUntransformedText = cpSlice(logLine, lastLogPos);
512
+ transformedLine += remainingUntransformedText;
513
+ for (let i = 0; i < cpLen(remainingUntransformedText); i++) {
514
+ transformedToLogMap.push(lastLogPos + i);
515
+ }
516
+ // For a cursor at the very end of the transformed line
517
+ transformedToLogMap.push(cpLen(logLine));
518
+ return { transformedLine, transformedToLogMap };
519
+ }
520
+ function calculateLayout(logicalLines, viewportWidth, logicalCursor) {
521
+ const visualLines = [];
522
+ const logicalToVisualMap = [];
523
+ const visualToLogicalMap = [];
524
+ const transformedToLogicalMaps = [];
525
+ const visualToTransformedMap = [];
526
+ logicalLines.forEach((logLine, logIndex) => {
527
+ logicalToVisualMap[logIndex] = [];
528
+ const isCursorOnLine = logIndex === logicalCursor[0];
529
+ const cacheKey = getLineLayoutCacheKey(logLine, viewportWidth, isCursorOnLine, logicalCursor[1]);
530
+ const cached = lineLayoutCache.get(cacheKey);
531
+ if (cached) {
532
+ const visualLineOffset = visualLines.length;
533
+ visualLines.push(...cached.visualLines);
534
+ cached.logicalToVisualMap.forEach(([relVisualIdx, logCol]) => {
535
+ logicalToVisualMap[logIndex].push([
536
+ visualLineOffset + relVisualIdx,
537
+ logCol,
538
+ ]);
539
+ });
540
+ cached.visualToLogicalMap.forEach(([, logCol]) => {
541
+ visualToLogicalMap.push([logIndex, logCol]);
542
+ });
543
+ transformedToLogicalMaps[logIndex] = cached.transformedToLogMap;
544
+ visualToTransformedMap.push(...cached.visualToTransformedMap);
545
+ return;
546
+ }
547
+ // Not in cache, calculate
548
+ const transformations = calculateTransformationsForLine(logLine);
549
+ const { transformedLine, transformedToLogMap } = calculateTransformedLine(logLine, logIndex, logicalCursor, transformations);
550
+ const lineVisualLines = [];
551
+ const lineLogicalToVisualMap = [];
552
+ const lineVisualToLogicalMap = [];
553
+ const lineVisualToTransformedMap = [];
554
+ if (transformedLine.length === 0) {
555
+ // Handle empty logical line
556
+ lineLogicalToVisualMap.push([0, 0]);
557
+ lineVisualToLogicalMap.push([logIndex, 0]);
558
+ lineVisualToTransformedMap.push(0);
559
+ lineVisualLines.push("");
560
+ }
561
+ else {
562
+ // Non-empty logical line
563
+ let currentPosInLogLine = 0; // Tracks position within the current logical line (code point index)
564
+ const codePointsInLogLine = toCodePoints(transformedLine);
565
+ while (currentPosInLogLine < codePointsInLogLine.length) {
566
+ let currentChunk = "";
567
+ let currentChunkVisualWidth = 0;
568
+ let numCodePointsInChunk = 0;
569
+ let lastWordBreakPoint = -1; // Index in codePointsInLogLine for word break
570
+ let numCodePointsAtLastWordBreak = 0;
571
+ // Iterate through code points to build the current visual line (chunk)
572
+ for (let i = currentPosInLogLine; i < codePointsInLogLine.length; i++) {
573
+ const char = codePointsInLogLine[i];
574
+ const charVisualWidth = getCachedStringWidth(char);
575
+ if (currentChunkVisualWidth + charVisualWidth > viewportWidth) {
576
+ // Character would exceed viewport width
577
+ if (lastWordBreakPoint !== -1 &&
578
+ numCodePointsAtLastWordBreak > 0 &&
579
+ currentPosInLogLine + numCodePointsAtLastWordBreak < i) {
580
+ // We have a valid word break point to use, and it's not the start of the current segment
581
+ currentChunk = codePointsInLogLine
582
+ .slice(currentPosInLogLine, currentPosInLogLine + numCodePointsAtLastWordBreak)
583
+ .join("");
584
+ numCodePointsInChunk = numCodePointsAtLastWordBreak;
585
+ }
586
+ else {
587
+ // No word break, or word break is at the start of this potential chunk, or word break leads to empty chunk.
588
+ // Hard break: take characters up to viewportWidth, or just the current char if it alone is too wide.
589
+ if (numCodePointsInChunk === 0 &&
590
+ charVisualWidth > viewportWidth) {
591
+ // Single character is wider than viewport, take it anyway
592
+ currentChunk = char;
593
+ numCodePointsInChunk = 1;
594
+ }
595
+ }
596
+ break; // Break from inner loop to finalize this chunk
597
+ }
598
+ currentChunk += char;
599
+ currentChunkVisualWidth += charVisualWidth;
600
+ numCodePointsInChunk++;
601
+ // Check for word break opportunity (space)
602
+ if (char === " ") {
603
+ lastWordBreakPoint = i; // Store code point index of the space
604
+ // Store the state *before* adding the space, if we decide to break here.
605
+ numCodePointsAtLastWordBreak = numCodePointsInChunk - 1; // Chars *before* the space
606
+ }
607
+ }
608
+ if (numCodePointsInChunk === 0 &&
609
+ currentPosInLogLine < codePointsInLogLine.length) {
610
+ const firstChar = codePointsInLogLine[currentPosInLogLine];
611
+ currentChunk = firstChar;
612
+ numCodePointsInChunk = 1;
613
+ }
614
+ const logicalStartCol = transformedToLogMap[currentPosInLogLine] ?? 0;
615
+ lineLogicalToVisualMap.push([lineVisualLines.length, logicalStartCol]);
616
+ lineVisualToLogicalMap.push([logIndex, logicalStartCol]);
617
+ lineVisualToTransformedMap.push(currentPosInLogLine);
618
+ lineVisualLines.push(currentChunk);
619
+ const logicalStartOfThisChunk = currentPosInLogLine;
620
+ currentPosInLogLine += numCodePointsInChunk;
621
+ if (logicalStartOfThisChunk + numCodePointsInChunk <
622
+ codePointsInLogLine.length &&
623
+ currentPosInLogLine < codePointsInLogLine.length &&
624
+ codePointsInLogLine[currentPosInLogLine] === " ") {
625
+ currentPosInLogLine++;
626
+ }
627
+ }
628
+ }
629
+ // Cache the result for this line
630
+ lineLayoutCache.set(cacheKey, {
631
+ visualLines: lineVisualLines,
632
+ logicalToVisualMap: lineLogicalToVisualMap,
633
+ visualToLogicalMap: lineVisualToLogicalMap,
634
+ transformedToLogMap,
635
+ visualToTransformedMap: lineVisualToTransformedMap,
636
+ });
637
+ const visualLineOffset = visualLines.length;
638
+ visualLines.push(...lineVisualLines);
639
+ lineLogicalToVisualMap.forEach(([relVisualIdx, logCol]) => {
640
+ logicalToVisualMap[logIndex].push([
641
+ visualLineOffset + relVisualIdx,
642
+ logCol,
643
+ ]);
644
+ });
645
+ lineVisualToLogicalMap.forEach(([, logCol]) => {
646
+ visualToLogicalMap.push([logIndex, logCol]);
647
+ });
648
+ transformedToLogicalMaps[logIndex] = transformedToLogMap;
649
+ visualToTransformedMap.push(...lineVisualToTransformedMap);
650
+ });
651
+ // If the entire logical text was empty, ensure there's one empty visual line.
652
+ if (logicalLines.length === 0 ||
653
+ (logicalLines.length === 1 && logicalLines[0] === "")) {
654
+ if (visualLines.length === 0) {
655
+ visualLines.push("");
656
+ if (!logicalToVisualMap[0])
657
+ logicalToVisualMap[0] = [];
658
+ logicalToVisualMap[0].push([0, 0]);
659
+ visualToLogicalMap.push([0, 0]);
660
+ visualToTransformedMap.push(0);
661
+ }
662
+ }
663
+ return {
664
+ visualLines,
665
+ logicalToVisualMap,
666
+ visualToLogicalMap,
667
+ transformedToLogicalMaps,
668
+ visualToTransformedMap,
669
+ };
670
+ }
671
+ function textBufferReducer(state, action) {
672
+ let newState = bufferReducerLogic(state, action);
673
+ // Recalculate layout if lines or width changed
674
+ if (newState.lines !== state.lines ||
675
+ newState.viewportWidth !== state.viewportWidth) {
676
+ newState = {
677
+ ...newState,
678
+ visualLayout: calculateLayout(newState.lines, newState.viewportWidth, [
679
+ newState.cursorRow,
680
+ newState.cursorCol,
681
+ ]),
682
+ };
683
+ }
684
+ // Handle scrolling (Vertical scroll-into-view)
685
+ const visualCursor = calculateVisualCursorFromLayout(newState.visualLayout, [
686
+ newState.cursorRow,
687
+ newState.cursorCol,
688
+ ]);
689
+ const cursorVisRow = visualCursor[0];
690
+ let newScrollRow = newState.visualScrollRow;
691
+ if (cursorVisRow < newScrollRow) {
692
+ newScrollRow = cursorVisRow;
693
+ }
694
+ else if (cursorVisRow >= newScrollRow + newState.viewportHeight) {
695
+ newScrollRow = cursorVisRow - newState.viewportHeight + 1;
696
+ }
697
+ // Clamp scroll row
698
+ const maxScroll = Math.max(0, newState.visualLayout.visualLines.length - newState.viewportHeight);
699
+ newScrollRow = Math.min(Math.max(newScrollRow, 0), maxScroll);
700
+ if (newScrollRow !== newState.visualScrollRow) {
701
+ newState = { ...newState, visualScrollRow: newScrollRow };
702
+ }
703
+ return newState;
704
+ }
705
+ export function useTextBuffer({ initialText = "", viewportWidth = 80, viewportHeight = 10, }) {
706
+ const initialState = useMemo(() => {
707
+ const lines = initialText.replace(/\r\n/g, "\n").split("\n");
708
+ const safeLines = lines.length === 0 ? [""] : lines;
709
+ const layout = calculateLayout(safeLines, viewportWidth, [0, 0]);
710
+ return {
711
+ lines: safeLines,
712
+ cursorRow: 0,
713
+ cursorCol: 0,
714
+ preferredCol: null,
715
+ undoStack: [],
716
+ redoStack: [],
717
+ viewportWidth,
718
+ viewportHeight,
719
+ visualScrollRow: 0,
720
+ visualLayout: layout,
721
+ };
722
+ }, [initialText, viewportWidth, viewportHeight]);
723
+ const [state, dispatch] = useReducer(textBufferReducer, initialState);
724
+ useEffect(() => {
725
+ dispatch({
726
+ type: "SET_VIEWPORT",
727
+ payload: { width: viewportWidth, height: viewportHeight },
728
+ });
729
+ }, [viewportWidth, viewportHeight]);
730
+ const insert = useCallback((text, opts) => dispatch({ type: "INSERT", payload: text, isPaste: opts?.paste }), []);
731
+ const setText = useCallback((text, cursorPosition) => dispatch({ type: "SET_TEXT", payload: text, cursorPosition }), []);
732
+ const backspace = useCallback(() => dispatch({ type: "BACKSPACE" }), []);
733
+ const deleteChar = useCallback(() => dispatch({ type: "DELETE" }), []);
734
+ const newline = useCallback(() => dispatch({ type: "NEWLINE" }), []);
735
+ const killLineRight = useCallback(() => dispatch({ type: "KILL_LINE_RIGHT" }), []);
736
+ const killLineLeft = useCallback(() => dispatch({ type: "KILL_LINE_LEFT" }), []);
737
+ const deleteWordLeft = useCallback(() => dispatch({ type: "DELETE_WORD_LEFT" }), []);
738
+ const deleteWordRight = useCallback(() => dispatch({ type: "DELETE_WORD_RIGHT" }), []);
739
+ const move = useCallback((dir) => dispatch({ type: "MOVE", dir }), []);
740
+ const undo = useCallback(() => dispatch({ type: "UNDO" }), []);
741
+ const redo = useCallback(() => dispatch({ type: "REDO" }), []);
742
+ const replaceRange = useCallback((startRow, startCol, endRow, endCol, text) => dispatch({
743
+ type: "REPLACE_RANGE",
744
+ payload: { startRow, startCol, endRow, endCol, text },
745
+ }), []);
746
+ const getOffset = useCallback(() => logicalPosToOffset(state.lines, state.cursorRow, state.cursorCol), [state.lines, state.cursorRow, state.cursorCol]);
747
+ const handleInput = useCallback((key) => {
748
+ if (key.name === "backspace") {
749
+ backspace();
750
+ return true;
751
+ }
752
+ if (key.name === "delete") {
753
+ deleteChar();
754
+ return true;
755
+ }
756
+ if (key.name === "left") {
757
+ move("left");
758
+ return true;
759
+ }
760
+ if (key.name === "right") {
761
+ move("right");
762
+ return true;
763
+ }
764
+ if (key.name === "up") {
765
+ move("up");
766
+ return true;
767
+ }
768
+ if (key.name === "down") {
769
+ move("down");
770
+ return true;
771
+ }
772
+ if (key.name === "home") {
773
+ move("home");
774
+ return true;
775
+ }
776
+ if (key.name === "end") {
777
+ move("end");
778
+ return true;
779
+ }
780
+ if (key.name === "enter" && key.shift) {
781
+ newline();
782
+ return true;
783
+ }
784
+ // Handle character input (only insertable printable characters)
785
+ if (key.insertable && key.sequence) {
786
+ insert(key.sequence);
787
+ return true;
788
+ }
789
+ return false;
790
+ }, [backspace, deleteChar, move, insert, newline]);
791
+ const [vRow, vColIdx, vWidth] = useMemo(() => calculateVisualCursorFromLayout(state.visualLayout, [
792
+ state.cursorRow,
793
+ state.cursorCol,
794
+ ]), [state.visualLayout, state.cursorRow, state.cursorCol]);
795
+ const visualCursor = useMemo(() => [vRow, vWidth], [vRow, vWidth]);
796
+ const visualCursorColIndex = vColIdx;
797
+ const viewportVisualLines = useMemo(() => state.visualLayout.visualLines.slice(state.visualScrollRow, state.visualScrollRow + state.viewportHeight), [
798
+ state.visualLayout.visualLines,
799
+ state.visualScrollRow,
800
+ state.viewportHeight,
801
+ ]);
802
+ const noop = useCallback(() => { }, []);
803
+ const noopCount = useCallback((_count) => { }, []);
804
+ const noopAsync = useCallback(async () => { }, []);
805
+ return useMemo(() => ({
806
+ lines: state.lines,
807
+ text: state.lines.join("\n"),
808
+ cursor: [state.cursorRow, state.cursorCol],
809
+ preferredCol: state.preferredCol,
810
+ selectionAnchor: null,
811
+ pastedContent: {},
812
+ // Visual / Viewport properties
813
+ allVisualLines: state.visualLayout.visualLines,
814
+ viewportVisualLines,
815
+ visualCursor,
816
+ visualCursorColIndex,
817
+ visualCursorColWidth: vWidth,
818
+ visualScrollRow: state.visualScrollRow,
819
+ viewportHeight: state.viewportHeight,
820
+ visualToLogicalMap: state.visualLayout.visualToLogicalMap,
821
+ transformedToLogicalMaps: state.visualLayout.transformedToLogicalMaps,
822
+ visualToTransformedMap: state.visualLayout.visualToTransformedMap,
823
+ visualLayout: state.visualLayout,
824
+ // Core actions
825
+ insert,
826
+ setText,
827
+ newline,
828
+ backspace,
829
+ del: deleteChar,
830
+ move,
831
+ undo,
832
+ redo,
833
+ replaceRange,
834
+ deleteWordLeft,
835
+ deleteWordRight,
836
+ killLineRight,
837
+ killLineLeft,
838
+ handleInput,
839
+ getOffset,
840
+ // Advanced actions (stubs — not yet implemented in this buffer)
841
+ openInExternalEditor: noopAsync,
842
+ replaceRangeByOffset: (_s, _e, _t) => { },
843
+ moveToOffset: (_offset) => { },
844
+ moveToVisualPosition: (_vr, _vc) => { },
845
+ getLogicalPositionFromVisual: (_vr, _vc) => null,
846
+ getExpandedPasteAtLine: (_lineIndex) => null,
847
+ togglePasteExpansion: (_id, _row, _col) => { },
848
+ // Vim stubs
849
+ vimDeleteWordForward: noopCount,
850
+ vimDeleteWordBackward: noopCount,
851
+ vimDeleteWordEnd: noopCount,
852
+ vimDeleteBigWordForward: noopCount,
853
+ vimDeleteBigWordBackward: noopCount,
854
+ vimDeleteBigWordEnd: noopCount,
855
+ vimChangeWordForward: noopCount,
856
+ vimChangeWordBackward: noopCount,
857
+ vimChangeWordEnd: noopCount,
858
+ vimChangeBigWordForward: noopCount,
859
+ vimChangeBigWordBackward: noopCount,
860
+ vimChangeBigWordEnd: noopCount,
861
+ vimDeleteLine: noopCount,
862
+ vimChangeLine: noopCount,
863
+ vimDeleteToEndOfLine: (_count) => { },
864
+ vimDeleteToStartOfLine: noop,
865
+ vimChangeToEndOfLine: (_count) => { },
866
+ vimDeleteToFirstNonWhitespace: noop,
867
+ vimChangeToStartOfLine: noop,
868
+ vimChangeToFirstNonWhitespace: noop,
869
+ vimDeleteToFirstLine: noopCount,
870
+ vimDeleteToLastLine: noopCount,
871
+ vimChangeMovement: (_m, _count) => { },
872
+ vimMoveLeft: noopCount,
873
+ vimMoveRight: noopCount,
874
+ vimMoveUp: noopCount,
875
+ vimMoveDown: noopCount,
876
+ vimMoveWordForward: noopCount,
877
+ vimMoveWordBackward: noopCount,
878
+ vimMoveWordEnd: noopCount,
879
+ vimMoveBigWordForward: noopCount,
880
+ vimMoveBigWordBackward: noopCount,
881
+ vimMoveBigWordEnd: noopCount,
882
+ vimDeleteChar: noopCount,
883
+ vimDeleteCharBefore: noopCount,
884
+ vimToggleCase: noopCount,
885
+ vimReplaceChar: (_char, _count) => { },
886
+ vimFindCharForward: (_char, _count, _till) => { },
887
+ vimFindCharBackward: (_char, _count, _till) => { },
888
+ vimDeleteToCharForward: (_char, _count, _till) => { },
889
+ vimDeleteToCharBackward: (_char, _count, _till) => { },
890
+ vimInsertAtCursor: noop,
891
+ vimAppendAtCursor: noop,
892
+ vimOpenLineBelow: noop,
893
+ vimOpenLineAbove: noop,
894
+ vimAppendAtLineEnd: noop,
895
+ vimInsertAtLineStart: noop,
896
+ vimMoveToLineStart: noop,
897
+ vimMoveToLineEnd: noop,
898
+ vimMoveToFirstNonWhitespace: noop,
899
+ vimMoveToFirstLine: noop,
900
+ vimMoveToLastLine: noop,
901
+ vimMoveToLine: noopCount,
902
+ vimEscapeInsertMode: noop,
903
+ vimYankLine: noopCount,
904
+ vimYankWordForward: noopCount,
905
+ vimYankBigWordForward: noopCount,
906
+ vimYankWordEnd: noopCount,
907
+ vimYankBigWordEnd: noopCount,
908
+ vimYankToEndOfLine: noopCount,
909
+ vimPasteAfter: noopCount,
910
+ vimPasteBefore: noopCount,
911
+ }), [
912
+ state,
913
+ viewportVisualLines,
914
+ visualCursor,
915
+ visualCursorColIndex,
916
+ vWidth,
917
+ insert,
918
+ setText,
919
+ newline,
920
+ backspace,
921
+ deleteChar,
922
+ move,
923
+ undo,
924
+ redo,
925
+ replaceRange,
926
+ deleteWordLeft,
927
+ deleteWordRight,
928
+ killLineRight,
929
+ killLineLeft,
930
+ handleInput,
931
+ getOffset,
932
+ noop,
933
+ noopCount,
934
+ noopAsync,
935
+ ]);
936
+ }
937
+ //# sourceMappingURL=text-buffer.js.map